pins: STM32: extended debug information about on-chip pins
This commit is contained in:
parent
8d3b070818
commit
3b34f6b81e
|
@ -143,12 +143,14 @@ static void reportPins() {
|
|||
|
||||
/* show used pins */
|
||||
if (pin_user != NULL) {
|
||||
static char pin_state[64];
|
||||
brain_pin_e brainPin = index_to_brainPin(i);
|
||||
int pin = getBrainPinIndex(brainPin);
|
||||
ioportid_t port = getBrainPinPort(brainPin);
|
||||
debugBrainPin(pin_state, sizeof(pin_state), brainPin);
|
||||
|
||||
const char *boardPinName = getBoardSpecificPinName(brainPin);
|
||||
efiPrintf("pin %s%d (%s): %s", portname(port), pin, boardPinName, pin_user);
|
||||
efiPrintf("pin %s%d (%s): %s %s", portname(port), pin, boardPinName, pin_user, pin_state);
|
||||
totalPinsUsed++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,6 @@ const char *hwPhysicalPinName(Gpio brainPin);
|
|||
// the main usage for human-readable board-specific pin reference is convenience of error messages in case of pin conflict.
|
||||
const char * getBoardSpecificPinName(Gpio brainPin);
|
||||
|
||||
void debugBrainPin(char *buffer, size_t size, brain_pin_e brainPin);
|
||||
|
||||
const char* & getBrainUsedPin(size_t idx);
|
||||
|
|
|
@ -196,4 +196,9 @@ unsigned int getBrainPinOnchipNum(void) {
|
|||
return BRAIN_PIN_ONCHIP_PINS;
|
||||
}
|
||||
|
||||
void debugBrainPin(char *buffer, size_t, brain_pin_e)
|
||||
{
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
|
|
@ -177,4 +177,9 @@ unsigned int getBrainPinOnchipNum(void) {
|
|||
return BRAIN_PIN_ONCHIP_PINS;
|
||||
}
|
||||
|
||||
void debugBrainPin(char *buffer, size_t, brain_pin_e)
|
||||
{
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
|
|
@ -155,4 +155,31 @@ unsigned int getBrainPinOnchipNum(void) {
|
|||
return BRAIN_PIN_ONCHIP_PINS;
|
||||
}
|
||||
|
||||
static const char *mode_names[4] = { "Input", "GP out", "Alt", "Analog" };
|
||||
static const char *od_names[2] = { "Push-Pull", "Open-Drain" };
|
||||
static const char *speed_names[4] = { "Low", "Medium", "High", "Very High" };
|
||||
static const char *pull_names[4] = { "No pull", "Pull-up", "Pull-down", "Reserved" };
|
||||
|
||||
void debugBrainPin(char *buffer, size_t size, brain_pin_e brainPin) {
|
||||
ioportid_t port = getBrainPinPort(brainPin);
|
||||
int pin = getBrainPinIndex(brainPin);
|
||||
|
||||
if (port == nullptr) {
|
||||
buffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t af = (pin < 8) ? port->AFRL : port->AFRH;
|
||||
af = (af >> (4 * (pin & 0x07))) & 0x0f;
|
||||
|
||||
chsnprintf(buffer, size, "Mode %s AF%d %s %s Speed %s IN %d OUT %d",
|
||||
mode_names[(port->MODER >> (pin * 2)) & 0x03],
|
||||
af,
|
||||
od_names[(port->OTYPER >> pin) & 0x01],
|
||||
pull_names[(port->PUPDR >> (pin * 2)) & 0x03],
|
||||
speed_names[(port->OSPEEDR >> (pin * 2)) & 0x03],
|
||||
(port->IDR >> pin) & 0x01,
|
||||
(port->ODR >> pin) & 0x01);
|
||||
}
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
|
Loading…
Reference in New Issue