From ef39f2d9cac6fc50b1bbae9d16da371649dfa6e2 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Thu, 13 Mar 2014 14:40:49 -0700 Subject: [PATCH] Cleanup systick for stmhal --- stmhal/Makefile | 7 ------- stmhal/stm32f4xx_it.c | 2 -- stmhal/system_stm32f4xx.c | 5 +++++ stmhal/systick.c | 12 +++--------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/stmhal/Makefile b/stmhal/Makefile index f53887b746..5ec7728083 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -19,7 +19,6 @@ CROSS_COMPILE = arm-none-eabi- INC = -I. INC += -I$(PY_SRC) -INC += -I$(CMSIS_DIR) INC += -I$(CMSIS_DIR)/inc INC += -I$(CMSIS_DIR)/devinc INC += -I$(HAL_DIR)/inc @@ -32,7 +31,6 @@ INC += -I$(HAL_DIR)/inc CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT) -BOARD = STM32F4DISC BOARD ?= PYBOARD4 ifeq ($(wildcard boards/$(BOARD)/.),) $(error Invalid BOARD specified) @@ -226,11 +224,6 @@ GEN_PINS_HDR = $(BUILD)/pins.h # which source files might need it. $(OBJ): | $(BUILD)/pins.h -# temp hack -$(PY_BUILD): - mkdir -p $@ -$(OBJ): | $(PY_BUILD) $(PY_BUILD)/qstrdefs.generated.h - # Use a pattern rule here so that make will only call make-pins.py once to make # both pins_$(BOARD).c and pins.h $(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) diff --git a/stmhal/stm32f4xx_it.c b/stmhal/stm32f4xx_it.c index 61c4b7172e..96b12bfe4a 100644 --- a/stmhal/stm32f4xx_it.c +++ b/stmhal/stm32f4xx_it.c @@ -151,7 +151,6 @@ void PendSV_Handler(void) { } -#if 0 // defined in systick.c /** * @brief This function handles SysTick Handler. * @param None @@ -161,7 +160,6 @@ void SysTick_Handler(void) { HAL_IncTick(); } -#endif /******************************************************************************/ /* STM32F4xx Peripherals Interrupt Handlers */ diff --git a/stmhal/system_stm32f4xx.c b/stmhal/system_stm32f4xx.c index 8d806041c1..4e5490db56 100644 --- a/stmhal/system_stm32f4xx.c +++ b/stmhal/system_stm32f4xx.c @@ -316,6 +316,11 @@ void SystemClock_Config(void) { __fatal_error("HAL_RCC_ClockConfig"); } + + // SysTick_Config (called from HL_RCC_ClockConfig) sets the SysTick_IRQn to + // be the lowest priority, but we want it to be the highest priority, so fix + // things here. + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); } /** diff --git a/stmhal/systick.c b/stmhal/systick.c index 55c22dab01..eda39c7888 100644 --- a/stmhal/systick.c +++ b/stmhal/systick.c @@ -5,16 +5,10 @@ void sys_tick_init(void) { // SysTick_Config is now called from HAL_RCC_ClockConfig, which is called // from SystemClock_Config - HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); // make it highest priority -} -// called on SysTick interrupt -void SysTick_Handler(void) { - HAL_IncTick(); - HAL_SYSTICK_IRQHandler(); - // hack! - //void audio_drain(void); - //audio_drain(); + // SysTick_Config sets the SysTick_IRQn to be the lowest priority, but + // we want it to be the highest priority, so fix things here. + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); } void sys_tick_delay_ms(uint32_t delay_ms) {