Skip to content

Commit

Permalink
Version 0.6.1
Browse files Browse the repository at this point in the history
TIM CC handler now swit case
  • Loading branch information
BeSeeTek committed Jul 28, 2021
1 parent c501a6b commit a9dc394
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Inc/freertos_cubemx.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extern "C" {
#include "tim64extender.h"
#define VERSION_MAJOR 0
#define VERSION_MINOR 6
#define VERSION_PATCH 0
#define VERSION_PATCH 1
const uint8_t UDP_TARGET_DEFAULT_IP_ADDRESS[4] = { 192, 168, 0, 200 };


Expand Down
2 changes: 1 addition & 1 deletion Src/tim.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)

/* TIM1 interrupt Init */
HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 4, 0);// tim1 higher prio than tim2 since its overflowing more often
HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); // DAMNED TIM1_UP_TIM10_IRQn is 25 TIM1_CC_IRQn is 27 so if both are pending UP is serverd first this needs to be cached since it generates a time glichs for the next CC interrupt if this has an old value https://stackoverflow.com/questions/48567316/two-external-interrupts-with-same-priority-at-the-same-time-cortex-m
HAL_NVIC_SetPriority(TIM1_CC_IRQn, 4, 0);// tim1 higher prio than tim2 since its overflowing more often
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspInit 1 */
Expand Down
24 changes: 13 additions & 11 deletions Src/tim64extender.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,30 +180,32 @@ uint64_t TIM_Get_64Bit_TimeStamp_IC(TIM_HandleTypeDef * htim){

if (htim->Instance == TIM1) {
// there can't be a race condition here since TIM1 has an an independent interupt for update, so the pending isr are in the right order in the NVIC
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
switch (htim->Channel) {
case HAL_TIM_ACTIVE_CHANNEL_1:
//this is the nromal case
timestamp = tim1_upper_bits_mask+ (uint64_t) HAL_TIM_ReadCapturedValue(&htim1,TIM_CHANNEL_1)+1;
}
break;

if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_2) {
case HAL_TIM_ACTIVE_CHANNEL_2 :
//this is the nromal case
timestamp = tim1_upper_bits_mask+ (uint64_t) HAL_TIM_ReadCapturedValue(&htim1,TIM_CHANNEL_2)+1;
}
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_3) {
break;
case HAL_TIM_ACTIVE_CHANNEL_3:
//this is the nromal case
timestamp = tim1_upper_bits_mask+ (uint64_t) HAL_TIM_ReadCapturedValue(&htim1,TIM_CHANNEL_3)+1;
}
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4) {
break;
case HAL_TIM_ACTIVE_CHANNEL_4:
//this is the nromal case
timestamp = tim1_upper_bits_mask+ (uint64_t) HAL_TIM_ReadCapturedValue(&htim1,TIM_CHANNEL_4)+1;
}
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_5) {
break;
case HAL_TIM_ACTIVE_CHANNEL_5:
//this is the nromal case
timestamp = tim1_upper_bits_mask+ (uint64_t) HAL_TIM_ReadCapturedValue(&htim1,TIM_CHANNEL_5)+1;
}
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_6) {
break;
case HAL_TIM_ACTIVE_CHANNEL_6:
//this is the nromal case
timestamp = tim1_upper_bits_mask+ (uint64_t) HAL_TIM_ReadCapturedValue(&htim1,TIM_CHANNEL_6)+1;
break;
}
}

Expand Down

0 comments on commit a9dc394

Please sign in to comment.