global: update pin definitions
This commit is contained in:
parent
28ddcc8f6a
commit
fda7619e9f
18
bootloader.c
18
bootloader.c
|
@ -46,28 +46,28 @@ void main(void)
|
|||
__dfu_magic[3] = 0;
|
||||
} else { // check if the force DFU mode input is set
|
||||
// disable SWJ pin to use as GPIO
|
||||
#if (GPIO(B) == GPIO(DFU_FORCE_PORT)) && (GPIO(4) == GPIO(DFU_FORCE_PIN))
|
||||
#if (GPIO(B) == GPIO_PORT(DFU_FORCE_PIN)) && (GPIO(4) == GPIO_PIN(DFU_FORCE_PIN))
|
||||
// JNTRST pin is used as DFU pin
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable clock for alternate function domain
|
||||
gpio_primary_remap(AFIO_MAPR_SWJ_CFG_FULL_SWJ_NO_JNTRST, 0); // keep SWJ enable bit don't use JNTRST
|
||||
#elif ((GPIO(B) == GPIO(DFU_FORCE_PORT)) && (GPIO(3) == GPIO(DFU_FORCE_PIN))) || ((GPIO(A) == GPIO(DFU_FORCE_PORT)) && (GPIO(15) == GPIO(DFU_FORCE_PIN)))
|
||||
#elif ((GPIO(B) == GPIO_PORT(DFU_FORCE_PIN)) && (GPIO(3) == GPIO_PIN(DFU_FORCE_PIN))) || ((GPIO(A) == GPIO_PORT(DFU_FORCE_PIN)) && (GPIO(15) == GPIO_PIN(DFU_FORCE_PIN)))
|
||||
// JTAG but not SWD pin used as DFU pin
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable clock for alternate function domain
|
||||
gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON, 0); // disable JTAG but keep SWD
|
||||
#elif ((GPIO(A) == GPIO(DFU_FORCE_PORT)) && (GPIO(14) == GPIO(DFU_FORCE_PIN))) || ((GPIO(A) == GPIO(DFU_FORCE_PORT)) && (GPIO(13) == GPIO(DFU_FORCE_PIN)))
|
||||
#elif ((GPIO(A) == GPIO_PORT(DFU_FORCE_PIN)) && (GPIO(14) == GPIO_PIN(DFU_FORCE_PIN))) || ((GPIO(A) == GPIO_PORT(DFU_FORCE_PIN)) && (GPIO(13) == GPIO_PIN(DFU_FORCE_PIN)))
|
||||
// JTAG and SWD pin used as DFU pin
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable clock for alternate function domain
|
||||
gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF, 0); // disable JTAG and SWD
|
||||
#endif
|
||||
rcc_periph_clock_enable(RCC_GPIO(DFU_FORCE_PORT)); // enable clock for GPIO domain
|
||||
gpio_set_mode(GPIO(DFU_FORCE_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO(DFU_FORCE_PIN)); // set GPIO to input
|
||||
rcc_periph_clock_enable(GPIO_RCC(DFU_FORCE_PIN)); // enable clock for GPIO domain
|
||||
gpio_set_mode(GPIO_PORT(DFU_FORCE_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO_PIN(DFU_FORCE_PIN)); // set GPIO to input
|
||||
// pull on the opposite of the expected value
|
||||
#if (DFU_FORCE_VALUE == 1)
|
||||
gpio_clear(GPIO(DFU_FORCE_PORT), GPIO(DFU_FORCE_PIN)); // pull down to be able to detect when tied to high
|
||||
if (gpio_get(GPIO(DFU_FORCE_PORT), GPIO(DFU_FORCE_PIN))) { // check if output is set to the value to force DFU mode
|
||||
gpio_clear(GPIO_PORT(DFU_FORCE_PIN), GPIO_PIN(DFU_FORCE_PIN)); // pull down to be able to detect when tied to high
|
||||
if (gpio_get(GPIO_PORT(DFU_FORCE_PIN), GPIO_PIN(DFU_FORCE_PIN))) { // check if output is set to the value to force DFU mode
|
||||
#else
|
||||
gpio_set(GPIO(DFU_FORCE_PORT), GPIO(DFU_FORCE_PIN)); // pull up to be able to detect when tied to low
|
||||
if (0 == gpio_get(GPIO(DFU_FORCE_PORT), GPIO(DFU_FORCE_PIN))) { // check if output is set to the value to force DFU mode
|
||||
gpio_set(GPIO_PORT(DFU_FORCE_PIN), GPIO_PIN(DFU_FORCE_PIN)); // pull up to be able to detect when tied to low
|
||||
if (0 == gpio_get(GPIO_PORT(DFU_FORCE_PIN), GPIO_PIN(DFU_FORCE_PIN))) { // check if output is set to the value to force DFU mode
|
||||
#endif
|
||||
dfu_force = true; // DFU mode forced
|
||||
}
|
||||
|
|
42
global.c
42
global.c
|
@ -68,12 +68,12 @@ inline void led_on(void)
|
|||
{
|
||||
#if defined(LED_PIN)
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO(LED_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(LED_PIN)); // set LED pin push-pull
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(LED_PIN)); // set LED pin push-pull
|
||||
#endif // BUSVOODOO
|
||||
#if defined(LED_ON) && LED_ON
|
||||
gpio_set(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
gpio_set(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#else
|
||||
gpio_clear(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
gpio_clear(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#endif // LED_ON
|
||||
#endif // LED_PIN
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ inline void led_off(void)
|
|||
{
|
||||
#if defined(LED_PIN)
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO(LED_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(LED_PIN)); // set LED pin to floating to disable LEDs
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LED_PIN)); // set LED pin to floating to disable LEDs
|
||||
#else
|
||||
#if defined(LED_ON) && LED_ON
|
||||
gpio_clear(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
gpio_clear(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#else
|
||||
gpio_set(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
gpio_set(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#endif // BUSVOODOO
|
||||
#endif // LED_ON
|
||||
#endif // LED_PIN
|
||||
|
@ -99,9 +99,9 @@ inline void led_toggle(void)
|
|||
{
|
||||
#if defined(LED_PIN)
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO(LED_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(LED_PIN)); // set LED pin to push-pull
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(LED_PIN)); // set LED pin to push-pull
|
||||
#endif // BUSVOODOO
|
||||
gpio_toggle(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
gpio_toggle(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#endif // LED_PIN
|
||||
}
|
||||
|
||||
|
@ -186,29 +186,29 @@ void board_setup(void)
|
|||
{
|
||||
#if defined(LED_PIN)
|
||||
// setup LED
|
||||
rcc_periph_clock_enable(RCC_GPIO(LED_PORT)); // enable clock for LED
|
||||
rcc_periph_clock_enable(GPIO_RCC(LED_PIN)); // enable clock for LED
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO(LED_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(LED_PIN)); // set LED pin to floating to disable LEDs
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LED_PIN)); // set LED pin to floating to disable LEDs
|
||||
#else
|
||||
gpio_set_mode(GPIO(LED_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(LED_PIN)); // set LED pin to output push-pull do drive LED
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(LED_PIN)); // set LED pin to output push-pull do drive LED
|
||||
#endif
|
||||
led_off(); // switch off LED per default
|
||||
#endif // LED_PIN
|
||||
|
||||
// setup button
|
||||
#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
|
||||
rcc_periph_clock_enable(RCC_GPIO(BUTTON_PORT)); // enable clock for button
|
||||
gpio_set_mode(GPIO(BUTTON_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO(BUTTON_PIN)); // set button pin to input
|
||||
rcc_periph_clock_enable(GPIO_RCC(BUTTON_PIN)); // enable clock for button
|
||||
gpio_set_mode(GPIO_PORT(BUTTON_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO(BUTTON_PIN)); // set button pin to input
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable alternate function clock for external interrupt
|
||||
exti_select_source(EXTI(BUTTON_PIN), GPIO(BUTTON_PORT)); // mask external interrupt of this pin only for this port
|
||||
exti_select_source(GPIO_EXTI(BUTTON_PIN), GPIO_PORT(BUTTON_PIN)); // mask external interrupt of this pin only for this port
|
||||
#if defined(BUTTON_PRESSED) && BUTTON_PRESSED
|
||||
gpio_clear(GPIO(BUTTON_PORT), GPIO(BUTTON_PIN)); // pull down to be able to detect button push (go high)
|
||||
exti_set_trigger(EXTI(BUTTON_PIN), EXTI_TRIGGER_RISING); // trigger when button is pressed
|
||||
gpio_clear(GPIO_PORT(BUTTON_PIN), GPIO(BUTTON_PIN)); // pull down to be able to detect button push (go high)
|
||||
exti_set_trigger(GPIO_EXTI(BUTTON_PIN), EXTI_TRIGGER_RISING); // trigger when button is pressed
|
||||
#else
|
||||
gpio_set(GPIO(BUTTON_PORT), GPIO(BUTTON_PIN)); // pull up to be able to detect button push (go low)
|
||||
exti_set_trigger(EXTI(BUTTON_PIN), EXTI_TRIGGER_FALLING); // trigger when button is pressed
|
||||
gpio_set(GPIO_PORT(BUTTON_PIN), GPIO(BUTTON_PIN)); // pull up to be able to detect button push (go low)
|
||||
exti_set_trigger(GPIO_EXTI(BUTTON_PIN), EXTI_TRIGGER_FALLING); // trigger when button is pressed
|
||||
#endif
|
||||
exti_enable_request(EXTI(BUTTON_PIN)); // enable external interrupt
|
||||
exti_enable_request(GPIO_EXTI(BUTTON_PIN)); // enable external interrupt
|
||||
nvic_enable_irq(NVIC_EXTI_IRQ(BUTTON_PIN)); // enable interrupt
|
||||
#endif
|
||||
|
||||
|
@ -220,9 +220,9 @@ void board_setup(void)
|
|||
|
||||
#if defined(BUTTON_PIN)
|
||||
/** interrupt service routine called when button is pressed */
|
||||
void EXTI_ISR(BUTTON_PIN)(void)
|
||||
void GPIO_EXTI_ISR(BUTTON_PIN)(void)
|
||||
{
|
||||
exti_reset_request(EXTI(BUTTON_PIN)); // reset interrupt
|
||||
exti_reset_request(GPIO_EXTI(BUTTON_PIN)); // reset interrupt
|
||||
button_flag = true; // perform button action
|
||||
}
|
||||
#endif
|
||||
|
|
32
global.h
32
global.h
|
@ -612,28 +612,23 @@
|
|||
*/
|
||||
#if defined(SYSTEM_BOARD) || defined(CORE_BOARD)
|
||||
/* on system and core board LED is on pin 11/PA1 */
|
||||
#define LED_PORT A /**< GPIO port (port A) */
|
||||
#define LED_PIN 1 /**< GPIO pin (pin PA1) */
|
||||
#define LED_PIN PA1 /**< GPIO pin (pin PA1) */
|
||||
#define LED_ON 0 /**< LED is on when pin is low */
|
||||
#elif defined(BLUE_PILL)
|
||||
/* on minimum system LED is on pin 2/PC13 */
|
||||
#define LED_PORT C /**< GPIO port (port C on blue pill) */
|
||||
#define LED_PIN 13 /**< GPIO pin (pin PC13 on system board) */
|
||||
#define LED_PIN PC13 /**< GPIO pin (pin PC13 on system board) */
|
||||
#define LED_ON 0 /**< LED is on when pin is low */
|
||||
#elif defined (MAPLE_MINI)
|
||||
/* on maple mini LED is on pin 19/PB1 */
|
||||
#define LED_PORT B /**< GPIO port (port B on maple mini) */
|
||||
#define LED_PIN 1 /**< GPIO pin (pin PB1 on maple mini) */
|
||||
#define LED_PIN PB1 /**< GPIO pin (pin PB1 on maple mini) */
|
||||
#define LED_ON 1 /**< LED is on when pin is high */
|
||||
#elif defined (STLINKV2) // it's actually a STM32F101, but it seems to have all STM32F103 features
|
||||
/* on ST-Link V2 clone dongle in aluminum case LED is on pin PA9 (remap USART1_TX if used) */
|
||||
#define LED_PORT A /**< GPIO port (port A) */
|
||||
#define LED_PIN 9 /**< GPIO pin (pin PA9) */
|
||||
#define LED_PIN PA9 /**< GPIO pin (pin PA9) */
|
||||
#define LED_ON 1 /**< the color and on level depends on the clone */
|
||||
#elif defined (BUSVOODOO)
|
||||
/* on BusVoodoo LED is on pin PA8 */
|
||||
#define LED_PORT A /**< GPIO port (port A) */
|
||||
#define LED_PIN 8 /**< GPIO pin (pin PA8) */
|
||||
#define LED_PIN PA8 /**< GPIO pin (pin PA8) */
|
||||
#define LED_ON 1 /**< blue LED is on when pin is high, red LED is on when pin is low, LED is off when LED is floating */
|
||||
#endif
|
||||
/** @} */
|
||||
|
@ -643,13 +638,11 @@
|
|||
*/
|
||||
#if defined(MAPLE_MINI)
|
||||
/* on maple mini user button is on 32/PB8 */
|
||||
#define BUTTON_PORT B /**< GPIO port (port B on maple mini) */
|
||||
#define BUTTON_PIN 8 /**< GPIO pin (pin PB8 on maple mini) */
|
||||
#define BUTTON_PIN PB8 /**< GPIO pin (pin PB8 on maple mini) */
|
||||
#define BUTTON_PRESSED 1 /**< pin is high when button is pressed */
|
||||
#elif defined(CORE_BOARD)
|
||||
/* on core board user button is on PA8 */
|
||||
#define BUTTON_PORT A /**< GPIO port (port A) */
|
||||
#define BUTTON_PIN 8 /**< GPIO pin (pin PA8) */
|
||||
#define BUTTON_PIN PA8 /**< GPIO pin (pin PA8) */
|
||||
#define BUTTON_PRESSED 0 /**< pin is low when button is pressed */
|
||||
#endif
|
||||
/** @} */
|
||||
|
@ -659,30 +652,25 @@
|
|||
*/
|
||||
#if defined(MAPLE_MINI)
|
||||
/* use button */
|
||||
#define DFU_FORCE_PORT BUTTON_PORT /**< button port */
|
||||
#define DFU_FORCE_PIN BUTTON_PIN /**< button pin */
|
||||
#define DFU_FORCE_VALUE 1 /**< button is pulled low unpressed, high pressed to force DFU mode */
|
||||
#elif defined(CORE_BOARD)
|
||||
/* use button */
|
||||
#define DFU_FORCE_PORT BUTTON_PORT /**< button port */
|
||||
#define DFU_FORCE_PIN BUTTON_PIN /**< button pin */
|
||||
#define DFU_FORCE_VALUE 0 /**< button floating unpressed, connected to ground pressed to force DFU mode */
|
||||
#elif defined(BUSVOODOO)
|
||||
#if BUSVOODOO_HARDWARE_VERSION==0
|
||||
/* on BusVoodoo v0 DFU input is on PC7 */
|
||||
#define DFU_FORCE_PORT C /**< GPIO port (port C) */
|
||||
#define DFU_FORCE_PIN 7 /**< GPIO pin (pin PC7) */
|
||||
#define DFU_FORCE_PIN PC7 /**< GPIO pin (pin PC7) */
|
||||
#define DFU_FORCE_VALUE 1 /**< pin is pulled low, and goes high when shorted with VUSB */
|
||||
#else
|
||||
/* on BusVoodoo vA DFU input is on PC4 */
|
||||
#define DFU_FORCE_PORT C /**< GPIO port (port C) */
|
||||
#define DFU_FORCE_PIN 4 /**< GPIO pin (pin PC4) */
|
||||
#define DFU_FORCE_PIN PC4 /**< GPIO pin (pin PC4) */
|
||||
#define DFU_FORCE_VALUE 1 /**< pin floating, set high when shorted with nearby VCC */
|
||||
#endif
|
||||
#else
|
||||
/* use the JNTRST pin as GPIO (SWJ will still be working, minus NTRST) */
|
||||
#define DFU_FORCE_PORT B /**< JNTRST port (needs to be remapped to become PB4) */
|
||||
#define DFU_FORCE_PIN 4 /**< JNTRST pin (needs to be remapped to become PB4) */
|
||||
#define DFU_FORCE_PIN PB4 /**< JNTRST pin (needs to be remapped to become PB4) */
|
||||
#define DFU_FORCE_VALUE 0 /**< must be low to force DFU mode (note: JNTRST is also pulled up after reset) */
|
||||
#endif
|
||||
/** @} */
|
||||
|
|
Loading…
Reference in New Issue