mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c
- Revision:
- 226:b062af740e40
- Parent:
- 172:2f4f8c56b261
- Child:
- 304:89b9c3a9a045
diff -r 2af4c5d0160c -r b062af740e40 targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c --- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c Wed Jun 11 09:30:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c Wed Jun 11 09:45:09 2014 +0100 @@ -29,10 +29,7 @@ #include "us_ticker_api.h" #include "PeripheralNames.h" -// 32-bit timer selection -#define TIM_MST TIM5 -#define TIM_MST_IRQ TIM5_IRQn -#define TIM_MST_RCC __TIM5_CLK_ENABLE() +#define TIM_MST TIM5 static TIM_HandleTypeDef TimMasterHandle; static int us_ticker_inited = 0; @@ -41,23 +38,9 @@ if (us_ticker_inited) return; us_ticker_inited = 1; - // Enable timer clock - TIM_MST_RCC; + TimMasterHandle.Instance = TIM_MST; - // Configure time base - TimMasterHandle.Instance = TIM_MST; - TimMasterHandle.Init.Period = 0xFFFFFFFF; - TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick - TimMasterHandle.Init.ClockDivision = 0; - TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP; - TimMasterHandle.Init.RepetitionCounter = 0; - HAL_TIM_OC_Init(&TimMasterHandle); - - NVIC_SetVector(TIM_MST_IRQ, (uint32_t)us_ticker_irq_handler); - NVIC_EnableIRQ(TIM_MST_IRQ); - - // Enable timer - HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1); + HAL_InitTick(0); // The passed value is not used } uint32_t us_ticker_read() {