File tree Expand file tree Collapse file tree 4 files changed +19
-20
lines changed
libraries/mbed/targets/hal/TARGET_STM Expand file tree Collapse file tree 4 files changed +19
-20
lines changed Original file line number Diff line number Diff line change 37
37
38
38
static int us_ticker_inited = 0 ;
39
39
static volatile uint32_t SlaveCounter = 0 ;
40
- static uint32_t oc_int_part = 0 ;
41
- static uint16_t oc_rem_part = 0 ;
40
+ static volatile uint32_t oc_int_part = 0 ;
41
+ static volatile uint16_t oc_rem_part = 0 ;
42
42
43
43
void set_compare (uint16_t count ) {
44
44
// Set new output compare value
Original file line number Diff line number Diff line change 37
37
38
38
static int us_ticker_inited = 0 ;
39
39
static volatile uint32_t SlaveCounter = 0 ;
40
- static uint32_t oc_int_part = 0 ;
41
- static uint16_t oc_rem_part = 0 ;
40
+ static volatile uint32_t oc_int_part = 0 ;
41
+ static volatile uint16_t oc_rem_part = 0 ;
42
42
43
43
void set_compare (uint16_t count ) {
44
44
// Set new output compare value
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ static TIM_HandleTypeDef TimMasterHandle;
40
40
41
41
static int us_ticker_inited = 0 ;
42
42
static volatile uint32_t SlaveCounter = 0 ;
43
- static uint32_t oc_int_part = 0 ;
44
- static uint16_t oc_rem_part = 0 ;
43
+ static volatile uint32_t oc_int_part = 0 ;
44
+ static volatile uint16_t oc_rem_part = 0 ;
45
45
46
46
void set_compare (uint16_t count ) {
47
47
// Set new output compare value
Original file line number Diff line number Diff line change 36
36
37
37
static int us_ticker_inited = 0 ;
38
38
static volatile uint32_t SlaveCounter = 0 ;
39
- static uint32_t oc_int_part = 0 ;
40
- static uint16_t oc_rem_part = 0 ;
39
+ static volatile uint32_t oc_int_part = 0 ;
40
+ static volatile uint16_t oc_rem_part = 0 ;
41
41
42
42
void set_compare (uint16_t count ) {
43
43
// Set new output compare value
@@ -58,20 +58,19 @@ static void tim_update_oc_irq_handler(void) {
58
58
// Output compare interrupt: used by interrupt system
59
59
if (TIM_GetITStatus (TIM_MST , TIM_IT_CC1 ) == SET ) {
60
60
TIM_ClearITPendingBit (TIM_MST , TIM_IT_CC1 );
61
- }
62
-
63
- if (oc_rem_part > 0 ) {
64
- set_compare (oc_rem_part ); // Finish the remaining time left
65
- oc_rem_part = 0 ;
66
- }
67
- else {
68
- if (oc_int_part > 0 ) {
69
- set_compare (0xFFFF );
70
- oc_rem_part = cval ; // To finish the counter loop the next time
71
- oc_int_part -- ;
61
+ if (oc_rem_part > 0 ) {
62
+ set_compare (oc_rem_part ); // Finish the remaining time left
63
+ oc_rem_part = 0 ;
72
64
}
73
65
else {
74
- us_ticker_irq_handler ();
66
+ if (oc_int_part > 0 ) {
67
+ set_compare (0xFFFF );
68
+ oc_rem_part = cval ; // To finish the counter loop the next time
69
+ oc_int_part -- ;
70
+ }
71
+ else {
72
+ us_ticker_irq_handler ();
73
+ }
75
74
}
76
75
}
77
76
}
You can’t perform that action at this time.
0 commit comments