Subversion Repositories FuelGauge

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 6
Line 131... Line 131...
131
    /* Wait for calibration completion */
131
    /* Wait for calibration completion */
132
    while(HAL_IS_BIT_SET(hadc->Instance->CR, ADC_CR_ADCAL))
132
    while(HAL_IS_BIT_SET(hadc->Instance->CR, ADC_CR_ADCAL))
133
    {
133
    {
134
      if((HAL_GetTick() - tickstart) > ADC_CALIBRATION_TIMEOUT)
134
      if((HAL_GetTick() - tickstart) > ADC_CALIBRATION_TIMEOUT)
135
      {
135
      {
-
 
136
        /* New check to avoid false timeout detection in case of preemption */
-
 
137
        if(HAL_IS_BIT_SET(hadc->Instance->CR, ADC_CR_ADCAL))
-
 
138
        {
136
        /* Update ADC state machine to error */
139
          /* Update ADC state machine to error */
137
        ADC_STATE_CLR_SET(hadc->State,
140
          ADC_STATE_CLR_SET(hadc->State,
138
                          HAL_ADC_STATE_BUSY_INTERNAL,
141
                            HAL_ADC_STATE_BUSY_INTERNAL,
139
                          HAL_ADC_STATE_ERROR_INTERNAL);
142
                            HAL_ADC_STATE_ERROR_INTERNAL);
140
       
143
 
141
        /* Process unlocked */
144
          /* Process unlocked */
142
        __HAL_UNLOCK(hadc);
145
          __HAL_UNLOCK(hadc);
143
       
146
 
144
        return HAL_ERROR;
147
          return HAL_ERROR;
-
 
148
        }
145
      }
149
      }
146
    }
150
    }
147
   
151
   
148
    /* Restore ADC DMA transfer request after calibration */
152
    /* Restore ADC DMA transfer request after calibration */
149
    SET_BIT(hadc->Instance->CFGR1, backup_setting_adc_dma_transfer);
153
    SET_BIT(hadc->Instance->CFGR1, backup_setting_adc_dma_transfer);