STM32 timer hack

This commit is contained in:
Pascal Langer 2017-12-17 01:13:43 +01:00
parent 4171d2f93b
commit dc9f738f30
2 changed files with 21 additions and 13 deletions

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 1
#define VERSION_REVISION 6
#define VERSION_PATCH_LEVEL 43
#define VERSION_PATCH_LEVEL 44
//******************
// Protocols
//******************
@ -238,16 +238,17 @@ struct PPM_Parameters
// Telemetry
enum MultiPacketTypes {
MULTI_TELEMETRY_STATUS = 1,
MULTI_TELEMETRY_SPORT = 2,
MULTI_TELEMETRY_HUB = 3,
MULTI_TELEMETRY_DSM = 4,
MULTI_TELEMETRY_DSMBIND = 5,
MULTI_TELEMETRY_AFHDS2A = 6,
MULTI_TELEMETRY_CONFIG = 7,
MULTI_TELEMETRY_SYNC = 8,
MULTI_TELEMETRY_SPORT_POLLING = 9,
enum MultiPacketTypes
{
MULTI_TELEMETRY_STATUS = 1,
MULTI_TELEMETRY_SPORT = 2,
MULTI_TELEMETRY_HUB = 3,
MULTI_TELEMETRY_DSM = 4,
MULTI_TELEMETRY_DSMBIND = 5,
MULTI_TELEMETRY_AFHDS2A = 6,
MULTI_TELEMETRY_CONFIG = 7,
MULTI_TELEMETRY_SYNC = 8,
MULTI_TELEMETRY_SPORT_POLLING = 9,
};
// Macros

View File

@ -1537,7 +1537,12 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
if(discard_frame==1)
{
#ifdef STM32_BOARD
timer.detachInterrupt(TIMER_CH2); // Disable interrupt on ch2
//For whatever reason the line below does not stop the interrupt to be called
//timer.detachInterrupt(TIMER_CH2); // Disable interrupt on ch2
//So I'm pushing the comparator out (32ms from now) so it does not come to interfer
uint16_t OCR1B;
OCR1B=TCNT1;
timer.setCompare(TIMER_CH2,OCR1B);
#else
CLR_TIMSK1_OCIE1B; // Disable interrupt on compare B match
#endif
@ -1561,7 +1566,9 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
{ // Timer1 compare B interrupt
discard_frame=1;
#ifdef STM32_BOARD
timer.detachInterrupt(TIMER_CH2); // Disable interrupt on ch2
//For whatever reason the line below does not stop the interrupt to be called
//timer.detachInterrupt(TIMER_CH2); // Disable interrupt on ch2
//So I leave the comparator as it is (32ms from now) so it does not come to interfer
debugln("Bad frame timer");
#else
CLR_TIMSK1_OCIE1B; // Disable interrupt on compare B match