Merge pull request #172 from bcostm/master

[NUCLEO_xxx] Fix us_ticker and analog_out issues when -O3/-Otime options are used
pull/173/head
Emilio Monti 2014-02-18 11:02:46 +00:00
commit 10297b352c
4 changed files with 15 additions and 14 deletions

View File

@ -49,9 +49,9 @@ void set_compare(uint16_t count) {
// Used to increment the slave counter // Used to increment the slave counter
static void tim_update_irq_handler(void) { static void tim_update_irq_handler(void) {
SlaveCounter++;
if (TIM_GetITStatus(TIM_MST, TIM_IT_Update) == SET) { if (TIM_GetITStatus(TIM_MST, TIM_IT_Update) == SET) {
TIM_ClearITPendingBit(TIM_MST, TIM_IT_Update); TIM_ClearITPendingBit(TIM_MST, TIM_IT_Update);
SlaveCounter++;
} }
} }

View File

@ -49,9 +49,9 @@ void set_compare(uint16_t count) {
// Used to increment the slave counter // Used to increment the slave counter
static void tim_update_irq_handler(void) { static void tim_update_irq_handler(void) {
SlaveCounter++;
if (TIM_GetITStatus(TIM_MST, TIM_IT_Update) == SET) { if (TIM_GetITStatus(TIM_MST, TIM_IT_Update) == SET) {
TIM_ClearITPendingBit(TIM_MST, TIM_IT_Update); TIM_ClearITPendingBit(TIM_MST, TIM_IT_Update);
SlaveCounter++;
} }
} }

View File

@ -52,10 +52,10 @@ void set_compare(uint16_t count) {
// Used to increment the slave counter // Used to increment the slave counter
static void tim_update_irq_handler(void) { static void tim_update_irq_handler(void) {
SlaveCounter++;
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_UPDATE) == SET) { if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_UPDATE) == SET) {
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE); __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE);
__HAL_TIM_SetCounter(&TimMasterHandle, 0); // Reset counter !!! __HAL_TIM_SetCounter(&TimMasterHandle, 0); // Reset counter !!!
SlaveCounter++;
} }
} }

View File

@ -65,14 +65,14 @@ void analogout_init(dac_t *obj, PinName pin) {
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable; DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
if (pin == PA_4) { if (obj->channel == PA_4) {
DAC_Init(DAC_Channel_1, &DAC_InitStructure); DAC_Init(DAC_Channel_1, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_1, ENABLE); DAC_Cmd(DAC_Channel_1, ENABLE);
} }
else { // PA_5 //if (obj->channel == PA_5) {
DAC_Init(DAC_Channel_2, &DAC_InitStructure); // DAC_Init(DAC_Channel_2, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_2, ENABLE); // DAC_Cmd(DAC_Channel_2, ENABLE);
} //}
analogout_write_u16(obj, 0); analogout_write_u16(obj, 0);
} }
@ -84,18 +84,19 @@ static inline void dac_write(dac_t *obj, uint16_t value) {
if (obj->channel == PA_4) { if (obj->channel == PA_4) {
DAC_SetChannel1Data(DAC_Align_12b_R, value); DAC_SetChannel1Data(DAC_Align_12b_R, value);
} }
else { // PA_5 //if (obj->channel == PA_5) {
DAC_SetChannel2Data(DAC_Align_12b_R, value); // DAC_SetChannel2Data(DAC_Align_12b_R, value);
} //}
} }
static inline int dac_read(dac_t *obj) { static inline int dac_read(dac_t *obj) {
if (obj->channel == PA_4) { if (obj->channel == PA_4) {
return (int)DAC_GetDataOutputValue(DAC_Channel_1); return (int)DAC_GetDataOutputValue(DAC_Channel_1);
} }
else { // PA_5 //if (obj->channel == PA_5) {
return (int)DAC_GetDataOutputValue(DAC_Channel_2); // return (int)DAC_GetDataOutputValue(DAC_Channel_2);
} //}
return 0;
} }
void analogout_write(dac_t *obj, float value) { void analogout_write(dac_t *obj, float value) {