Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: targets/TARGET_STM/hal_tick_32b.c
- Revision:
- 186:707f6e361f3e
- Parent:
- 180:96ed750bd169
--- a/targets/TARGET_STM/hal_tick_32b.c Thu Apr 19 17:12:19 2018 +0100
+++ b/targets/TARGET_STM/hal_tick_32b.c Fri Jun 22 16:45:37 2018 +0100
@@ -18,12 +18,8 @@
// A 32-bit timer is used
#if !TIM_MST_16BIT
-#define DEBUG_TICK 0 // Set to 1 to toggle a pin (see below which pin) at each tick
-
extern TIM_HandleTypeDef TimMasterHandle;
-extern void HAL_IncTick(void);
-
volatile uint32_t PreviousVal = 0;
void us_ticker_irq_handler(void);
@@ -37,24 +33,6 @@
us_ticker_irq_handler();
}
}
-
- // Channel 2 for HAL tick
- if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
- if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
- __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
- uint32_t val = __HAL_TIM_GET_COUNTER(&TimMasterHandle);
- if ((val - PreviousVal) >= HAL_TICK_DELAY) {
- // Increment HAL variable
- HAL_IncTick();
- // Prepare next interrupt
- __HAL_TIM_SET_COMPARE(&TimMasterHandle, TIM_CHANNEL_2, val + HAL_TICK_DELAY);
- PreviousVal = val;
-#if DEBUG_TICK > 0
- HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_6);
-#endif
- }
- }
- }
}
// Reconfigure the HAL tick using a standard timer instead of systick.
@@ -112,41 +90,13 @@
// Channel 1 for mbed timeout
HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1);
- // Channel 2 for HAL tick
- HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_2);
- PreviousVal = __HAL_TIM_GET_COUNTER(&TimMasterHandle);
- __HAL_TIM_SET_COMPARE(&TimMasterHandle, TIM_CHANNEL_2, PreviousVal + HAL_TICK_DELAY);
- __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
-
// Freeze timer on stop/breakpoint
// Define the FREEZE_TIMER_ON_DEBUG macro in mbed_app.json for example
#if !defined(NDEBUG) && defined(FREEZE_TIMER_ON_DEBUG) && defined(TIM_MST_DBGMCU_FREEZE)
TIM_MST_DBGMCU_FREEZE;
#endif
-#if DEBUG_TICK > 0
- __HAL_RCC_GPIOB_CLK_ENABLE();
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.Pin = GPIO_PIN_6;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-#endif
-
return HAL_OK;
}
-/* NOTE: must be called with interrupts disabled! */
-void HAL_SuspendTick(void)
-{
- __HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
-}
-
-/* NOTE: must be called with interrupts disabled! */
-void HAL_ResumeTick(void)
-{
- __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
-}
-
#endif // !TIM_MST_16BIT
