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_16b.c
- Revision:
- 186:707f6e361f3e
- Parent:
- 184:08ed48f1de7f
--- a/targets/TARGET_STM/hal_tick_16b.c Thu Apr 19 17:12:19 2018 +0100
+++ b/targets/TARGET_STM/hal_tick_16b.c Fri Jun 22 16:45:37 2018 +0100
@@ -18,13 +18,8 @@
// A 16-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 volatile uint32_t SlaveCounter;
-extern volatile uint32_t oc_int_part;
-
volatile uint32_t PreviousVal = 0;
void us_ticker_irq_handler(void);
@@ -37,14 +32,6 @@
#endif
TimMasterHandle.Instance = TIM_MST;
- // Clear Update interrupt flag
- if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_UPDATE) == SET) {
- if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_UPDATE) == SET) {
- __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE);
- SlaveCounter++;
- }
- }
-
#if defined(TARGET_STM32F0)
} // end timer_update_irq_handler function
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
@@ -57,31 +44,7 @@
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
-
- if (oc_int_part > 0) {
- oc_int_part--;
- } else {
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
- }
}
}
}
@@ -113,22 +76,10 @@
#endif
HAL_TIM_Base_Init(&TimMasterHandle);
- //LL_TIM_EnableUpdateEvent(TimMasterHandle.Instance);
-
// Configure output compare channel 1 for mbed timeout (enabled later when used)
HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1);
- // Configure output compare 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);
-
-
-
- // Configure interrupts
- // Update interrupt used for 32-bit counter
// Output compare channel 1 interrupt for mbed timeout
- // Output compare channel 2 interrupt for HAL tick
#if defined(TARGET_STM32F0)
NVIC_SetVector(TIM_MST_UP_IRQ, (uint32_t)timer_update_irq_handler);
NVIC_EnableIRQ(TIM_MST_UP_IRQ);
@@ -141,10 +92,6 @@
NVIC_EnableIRQ(TIM_MST_IRQ);
#endif
- // Enable interrupts
- __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_UPDATE); // For 32-bit counter
- __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2); // For HAL tick
-
// Enable timer
HAL_TIM_Base_Start(&TimMasterHandle);
@@ -154,29 +101,7 @@
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
