Skip to content

Commit 10297b3

Browse files
committed
Merge pull request #172 from bcostm/master
[NUCLEO_xxx] Fix us_ticker and analog_out issues when -O3/-Otime options are used
2 parents 3c8f1c0 + c482ad7 commit 10297b3

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/us_ticker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ void set_compare(uint16_t count) {
4949

5050
// Used to increment the slave counter
5151
static void tim_update_irq_handler(void) {
52-
SlaveCounter++;
5352
if (TIM_GetITStatus(TIM_MST, TIM_IT_Update) == SET) {
5453
TIM_ClearITPendingBit(TIM_MST, TIM_IT_Update);
54+
SlaveCounter++;
5555
}
5656
}
5757

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/us_ticker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ void set_compare(uint16_t count) {
4949

5050
// Used to increment the slave counter
5151
static void tim_update_irq_handler(void) {
52-
SlaveCounter++;
5352
if (TIM_GetITStatus(TIM_MST, TIM_IT_Update) == SET) {
5453
TIM_ClearITPendingBit(TIM_MST, TIM_IT_Update);
54+
SlaveCounter++;
5555
}
5656
}
5757

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/us_ticker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ void set_compare(uint16_t count) {
5252

5353
// Used to increment the slave counter
5454
static void tim_update_irq_handler(void) {
55-
SlaveCounter++;
5655
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_UPDATE) == SET) {
5756
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE);
5857
__HAL_TIM_SetCounter(&TimMasterHandle, 0); // Reset counter !!!
58+
SlaveCounter++;
5959
}
6060
}
6161

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ void analogout_init(dac_t *obj, PinName pin) {
6565
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
6666
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
6767

68-
if (pin == PA_4) {
68+
if (obj->channel == PA_4) {
6969
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
7070
DAC_Cmd(DAC_Channel_1, ENABLE);
7171
}
72-
else { // PA_5
73-
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
74-
DAC_Cmd(DAC_Channel_2, ENABLE);
75-
}
72+
//if (obj->channel == PA_5) {
73+
// DAC_Init(DAC_Channel_2, &DAC_InitStructure);
74+
// DAC_Cmd(DAC_Channel_2, ENABLE);
75+
//}
7676

7777
analogout_write_u16(obj, 0);
7878
}
@@ -84,18 +84,19 @@ static inline void dac_write(dac_t *obj, uint16_t value) {
8484
if (obj->channel == PA_4) {
8585
DAC_SetChannel1Data(DAC_Align_12b_R, value);
8686
}
87-
else { // PA_5
88-
DAC_SetChannel2Data(DAC_Align_12b_R, value);
89-
}
87+
//if (obj->channel == PA_5) {
88+
// DAC_SetChannel2Data(DAC_Align_12b_R, value);
89+
//}
9090
}
9191

9292
static inline int dac_read(dac_t *obj) {
9393
if (obj->channel == PA_4) {
9494
return (int)DAC_GetDataOutputValue(DAC_Channel_1);
9595
}
96-
else { // PA_5
97-
return (int)DAC_GetDataOutputValue(DAC_Channel_2);
98-
}
96+
//if (obj->channel == PA_5) {
97+
// return (int)DAC_GetDataOutputValue(DAC_Channel_2);
98+
//}
99+
return 0;
99100
}
100101

101102
void analogout_write(dac_t *obj, float value) {

0 commit comments

Comments
 (0)