application: minor, get RCC from port
This commit is contained in:
parent
02e72a8bf9
commit
baaa435de8
|
@ -67,7 +67,6 @@ const uint8_t channels[] = {ADC_CHANNEL17, ADC_CHANNEL(TARGET_CHANNEL), ADC_CHAN
|
|||
|
||||
#define CHANNEL_NUMBERS 12 /**< number of target signals */
|
||||
static const char* channel_names[] = {"B12", "B13", "B14", "B15", "A8 ", "A9 ", "A10", "A15", "B3 ", "B4 ", "B5 ", "B6 "}; /**< names of pin connected to target signals */
|
||||
static const uint32_t channel_rccs[] = {GPIO_RCC(PB12), GPIO_RCC(PB13), GPIO_RCC(PB14), GPIO_RCC(PB15), GPIO_RCC(PA8), GPIO_RCC(PA9), GPIO_RCC(PA10), GPIO_RCC(PA15), GPIO_RCC(PB3), GPIO_RCC(PB4), GPIO_RCC(PB5), GPIO_RCC(PB6)}; /**< RCC for signal pin ports */
|
||||
static const uint32_t channel_ports[] = {GPIO_PORT(PB12), GPIO_PORT(PB13), GPIO_PORT(PB14), GPIO_PORT(PB15), GPIO_PORT(PA8), GPIO_PORT(PA9), GPIO_PORT(PA10), GPIO_PORT(PA15), GPIO_PORT(PB3), GPIO_PORT(PB4), GPIO_PORT(PB5), GPIO_PORT(PB6)}; /**< GPIO ports for signal pin */
|
||||
static const uint32_t channel_pins[] = {GPIO_PIN(PB12), GPIO_PIN(PB13), GPIO_PIN(PB14), GPIO_PIN(PB15), GPIO_PIN(PA8), GPIO_PIN(PA9), GPIO_PIN(PA10), GPIO_PIN(PA15), GPIO_PIN(PB3), GPIO_PIN(PB4), GPIO_PIN(PB5), GPIO_PIN(PB6)}; /**< GPIO pins for signal pin */
|
||||
|
||||
|
@ -111,6 +110,42 @@ static void print_fpu(double fpu, uint8_t precision)
|
|||
puts(decimal);
|
||||
}
|
||||
|
||||
/** get RCC from corresponding port
|
||||
* @param[in] port port address
|
||||
* @return RCC address corresponding to port
|
||||
*/
|
||||
static uint32_t port2rcc(uint32_t port)
|
||||
{
|
||||
uint32_t rcc = 0;
|
||||
switch (port) {
|
||||
case GPIOA:
|
||||
rcc = RCC_GPIOA;
|
||||
break;
|
||||
case GPIOB:
|
||||
rcc = RCC_GPIOB;
|
||||
break;
|
||||
case GPIOC:
|
||||
rcc = RCC_GPIOC;
|
||||
break;
|
||||
case GPIOD:
|
||||
rcc = RCC_GPIOD;
|
||||
break;
|
||||
case GPIOE:
|
||||
rcc = RCC_GPIOE;
|
||||
break;
|
||||
case GPIOF:
|
||||
rcc = RCC_GPIOF;
|
||||
break;
|
||||
case GPIOG:
|
||||
rcc = RCC_GPIOG;
|
||||
break;
|
||||
default: // unknown port
|
||||
while (true); // halt firmware
|
||||
break;
|
||||
}
|
||||
return rcc;
|
||||
}
|
||||
|
||||
/** measure target and signal voltages
|
||||
* @return voltages of channels
|
||||
*/
|
||||
|
@ -759,7 +794,7 @@ void main(void)
|
|||
|
||||
puts("setup signal pins: ");
|
||||
for (uint8_t i = 0; i < CHANNEL_NUMBERS; i++) {
|
||||
rcc_periph_clock_enable(channel_rccs[i]); // enable clock for port domain
|
||||
rcc_periph_clock_enable(port2rcc(channel_ports[i])); // enable clock for port domain
|
||||
gpio_mode_setup(channel_ports[i], GPIO_MODE_INPUT, GPIO_PUPD_NONE, channel_pins[i]); // ensure pin is floating input
|
||||
}
|
||||
puts("OK\n");
|
||||
|
|
Loading…
Reference in New Issue