From cbb9ac96d560777d66ddf19508781822a1ca3852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 1 Apr 2017 14:13:55 +0200 Subject: [PATCH] add core board definition --- Makefile | 6 ++++-- global.c | 11 ++++++++--- global.h | 12 ++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index a3a6d04..929b04c 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,8 @@ endif BINARY = firmware # which development board is used -# supported are: SYSTEM_BOARD, MAPLE_MINI, BLUE_PILL -BOARD = BLUE_PILL +# supported are: SYSTEM_BOARD, MAPLE_MINI, BLUE_PILL, CORE_BOARD +BOARD = CORE_BOARD # source files CSRC = $(wildcard *.c) @@ -71,6 +71,8 @@ ifeq ($(BOARD),SYSTEM_BOARD) LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f1/stm32f103x8.ld else ifeq ($(BOARD),BLUE_PILL) LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f1/stm32f103x8.ld +else ifeq ($(BOARD),CORE_BOARD) +LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f1/stm32f103x8.ld else ifeq ($(BOARD),MAPLE_MINI) LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f1/stm32f103xb.ld endif diff --git a/global.c b/global.c index a3f646e..6e03c56 100644 --- a/global.c +++ b/global.c @@ -58,7 +58,7 @@ char* b2s(uint64_t binary, uint8_t rjust) /** switch on board LED */ void led_on(void) { -#if defined(SYSTEM_BOARD) || defined(BLUE_PILL) +#if defined(SYSTEM_BOARD) || defined(BLUE_PILL) || defined(CORE_BOARD) gpio_clear(GPIO(LED_PORT), GPIO(LED_PIN)); #elif defined(MAPLE_MINI) gpio_set(GPIO(LED_PORT), GPIO(LED_PIN)); @@ -67,7 +67,7 @@ void led_on(void) /** switch off board LED */ void led_off(void) { -#if defined(SYSTEM_BOARD) || defined(BLUE_PILL) +#if defined(SYSTEM_BOARD) || defined(BLUE_PILL) || defined(CORE_BOARD) gpio_set(GPIO(LED_PORT), GPIO(LED_PIN)); #elif defined(MAPLE_MINI) gpio_clear(GPIO(LED_PORT), GPIO(LED_PIN)); @@ -90,10 +90,15 @@ void board_setup(void) #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 - gpio_clear(GPIO(BUTTON_PORT), GPIO(BUTTON_PIN)); // pull down to be able to detect button push (go high) 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 +#if defined(MAPLE_MINI) + 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 +#elif defined(CORE_BOARD) + 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 +#endif exti_enable_request(EXTI(BUTTON_PIN)); // enable external interrupt nvic_enable_irq(NVIC_EXTI_IRQ(BUTTON_PIN)); // enable interrupt #endif diff --git a/global.h b/global.h index 123d71d..bf35164 100644 --- a/global.h +++ b/global.h @@ -258,10 +258,10 @@ /** @defgroup board_led board LED GPIO * @{ */ -#if defined(SYSTEM_BOARD) -/* on system board LED is on pin 11/PA1 */ -#define LED_PORT A /**< GPIO port (port A on system board) */ -#define LED_PIN 1 /**< GPIO pin (pin PA1 on system board) */ +#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) */ #elif defined(BLUE_PILL) /* on minimum system LED is on pin 2/PC13 */ #define LED_PORT C /**< GPIO port (port C on blue pill) */ @@ -280,6 +280,10 @@ /* 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) */ +#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) */ #endif /** @} */