Typo corrections (functions declaration)

pull/3213/head
bcostm 2016-11-14 09:56:54 +01:00
parent 777692cc16
commit 2006e458fd
4 changed files with 41 additions and 21 deletions

View File

@ -48,7 +48,8 @@ void set_compare(uint16_t count);
#if defined(TARGET_STM32F0)
void timer_update_irq_handler(void) {
#else
void timer_irq_handler(void) {
void timer_irq_handler(void)
{
#endif
uint16_t cnt_val = TIM_MST->CNT;
TimMasterHandle.Instance = TIM_MST;
@ -66,7 +67,8 @@ void timer_irq_handler(void) {
#if defined(TARGET_STM32F0)
} // end timer_update_irq_handler function
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
void timer_oc_irq_handler(void) {
void timer_oc_irq_handler(void)
{
uint16_t cnt_val = TIM_MST->CNT;
TimMasterHandle.Instance = TIM_MST;
#endif
@ -110,7 +112,8 @@ void timer_oc_irq_handler(void) {
}
// Reconfigure the HAL tick using a standard timer instead of systick.
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
// Enable timer clock
TIM_MST_RCC;
@ -173,13 +176,15 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
return HAL_OK;
}
void HAL_SuspendTick(void) {
void HAL_SuspendTick(void)
{
TimMasterHandle.Instance = TIM_MST;
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
__HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
}
void HAL_ResumeTick(void) {
void HAL_ResumeTick(void)
{
TimMasterHandle.Instance = TIM_MST;
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
__HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));

View File

@ -38,7 +38,8 @@ volatile uint32_t PreviousVal = 0;
void us_ticker_irq_handler(void);
void timer_irq_handler(void) {
void timer_irq_handler(void)
{
// Channel 1 for mbed timeout
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
@ -67,7 +68,8 @@ void timer_irq_handler(void) {
}
// Reconfigure the HAL tick using a standard timer instead of systick.
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
uint32_t PclkFreq;
@ -137,13 +139,15 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
return HAL_OK;
}
void HAL_SuspendTick(void) {
void HAL_SuspendTick(void)
{
TimMasterHandle.Instance = TIM_MST;
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
__HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
}
void HAL_ResumeTick(void) {
void HAL_ResumeTick(void)
{
TimMasterHandle.Instance = TIM_MST;
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
__HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));

View File

@ -43,7 +43,8 @@ volatile uint32_t tim_it_counter = 0; // Time stamp to be updated by timer_irq_h
static int us_ticker_inited = 0;
void set_compare(uint16_t count) {
void set_compare(uint16_t count)
{
TimMasterHandle.Instance = TIM_MST;
// Set new output compare value
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, count);
@ -51,7 +52,8 @@ void set_compare(uint16_t count) {
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
}
void us_ticker_init(void) {
void us_ticker_init(void)
{
if (us_ticker_inited) return;
us_ticker_inited = 1;
@ -60,7 +62,8 @@ void us_ticker_init(void) {
HAL_InitTick(0); // The passed value is not used
}
uint32_t us_ticker_read() {
uint32_t us_ticker_read()
{
uint32_t counter;
TimMasterHandle.Instance = TIM_MST;
@ -70,7 +73,7 @@ uint32_t us_ticker_read() {
#if defined(TARGET_STM32L0)
uint16_t cntH_old, cntH, cntL;
do {
// For some reason on L0xx series we need to read and clear the
// For some reason on L0xx series we need to read and clear the
// overflow flag which give extra time to propelry handle possible
// hiccup after ~60s
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1OF) == SET) {
@ -100,7 +103,8 @@ uint32_t us_ticker_read() {
#endif
}
void us_ticker_set_interrupt(timestamp_t timestamp) {
void us_ticker_set_interrupt(timestamp_t timestamp)
{
int delta = (int)((uint32_t)timestamp - us_ticker_read());
uint16_t cval = TIM_MST->CNT;
@ -120,12 +124,14 @@ void us_ticker_set_interrupt(timestamp_t timestamp) {
}
}
void us_ticker_disable_interrupt(void) {
void us_ticker_disable_interrupt(void)
{
TimMasterHandle.Instance = TIM_MST;
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC1);
}
void us_ticker_clear_interrupt(void) {
void us_ticker_clear_interrupt(void)
{
TimMasterHandle.Instance = TIM_MST;
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
__HAL_TIM_CLEAR_FLAG(&TimMasterHandle, TIM_FLAG_CC1);

View File

@ -37,7 +37,8 @@ TIM_HandleTypeDef TimMasterHandle;
static int us_ticker_inited = 0;
void us_ticker_init(void) {
void us_ticker_init(void)
{
if (us_ticker_inited) return;
us_ticker_inited = 1;
@ -46,12 +47,14 @@ void us_ticker_init(void) {
HAL_InitTick(0); // The passed value is not used
}
uint32_t us_ticker_read() {
uint32_t us_ticker_read()
{
if (!us_ticker_inited) us_ticker_init();
return TIM_MST->CNT;
}
void us_ticker_set_interrupt(timestamp_t timestamp) {
void us_ticker_set_interrupt(timestamp_t timestamp)
{
TimMasterHandle.Instance = TIM_MST;
// Set new output compare value
__HAL_TIM_SET_COMPARE(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
@ -59,12 +62,14 @@ void us_ticker_set_interrupt(timestamp_t timestamp) {
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
}
void us_ticker_disable_interrupt(void) {
void us_ticker_disable_interrupt(void)
{
TimMasterHandle.Instance = TIM_MST;
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC1);
}
void us_ticker_clear_interrupt(void) {
void us_ticker_clear_interrupt(void)
{
TimMasterHandle.Instance = TIM_MST;
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
}