This commit is contained in:
rusefillc 2023-05-24 10:12:16 -04:00
parent c4aaf4e41c
commit 34f280e4b8
3 changed files with 36 additions and 0 deletions

View File

@ -9,3 +9,5 @@ typedef enum {
BOR_Level_2 = 2,
BOR_Level_3 = 3
} BOR_Level_t;
#define PORT_SIZE 16

View File

@ -2,3 +2,5 @@ DDEFS += -DFIRMWARE_ID=\"AT32F435\"
DDEFS += -DSHORT_BOARD_NAME=AT32F435
DDEFS += -DAT32F435VGT7
HW_LAYER_EMS_CPP += $(ARTERY_CONTRIB)/../mpu_util.cpp

32
mpu_util.cpp Normal file
View File

@ -0,0 +1,32 @@
/**
* @file mpu_util.cpp
*/
#include "pch.h"
void baseMCUInit(void) {
}
#define PORT_SIZE 16
// copy-paste of stm32 method? reuse code?
brain_pin_e parseBrainPin(const char *str) {
if (strEqual(str, "none"))
return Gpio::Unassigned;
// todo: create method toLowerCase?
if (str[0] != 'p' && str[0] != 'P') {
return Gpio::Invalid;
}
char port = str[1];
brain_pin_e basePin;
if (port >= 'a' && port <= 'z') {
basePin = Gpio::A0 + PORT_SIZE * (port - 'a');
} else if (port >= 'A' && port <= 'Z') {
basePin = Gpio::A0 + PORT_SIZE * (port - 'A');
} else {
return Gpio::Invalid;
}
const char *pinStr = str + 2;
int pin = atoi(pinStr);
return (brain_pin_e)(basePin + pin);
}