Void USBnoPD_IncrementDebounceCount(void) * Increment debounce counter, used in timer IRQHandler USBnoPD_TCPP0203_ConvertADCDataToCurrent(USBnoPD_adc_buffer_filtered, USBnoPD_TCPP0203_ConvertADCDataToVoltage(USBnoPD_adc_buffer_filtered, * Update the voltage buffer by converting the filtered values */ Static uint16_t USBnoPD_adc_buffer_filtered * Local buffer for filtered RAW ADC values */ * Process the ADC values and update USBnoPD_adc_converted_buffer with measured values. Static int32_t USBnoPD_TCPP0203_ConvertADCDataToCurrent(uint32_t ADCData, uint32_t Ga, uint32_t Rs)Ĭurrent = (int32_t)((vadc * 1000u) / (Ga * Rs)) * ADC measurement provides measurement on IANA pin. * Calculate the VBUS current level corresponding to ADC raw converted data. * If no Ra or Rb are defined, return vadc directly */ Vadc = (ADCData * VDD_VALUE) / ADC_FULL_SCALE Static uint32_t USBnoPD_TCPP0203_ConvertADCDataToVoltage(uint32_t ADCData, uint32_t Ra, uint32_t Rb) * ADCData ADC raw converted data (resolution 12 bits) * vadc = raw_data * (ADC_FULL_SCALE / VDD) * Voltage level is measured though a voltage divider * Calculate the VBUS voltage level corresponding to ADC raw converted data. * USER CODE BEGIN EC */ #define USBNOPD_ADC_USED_CHANNELS 5u /* Number of used ADC channels */ #define USBNOPD_CC_VOLTAGE_MAXRA 800u /* CC line Max voltage when Ra is connected (in mV) */ #define USBNOPD_CC_VOLTAGE_MINRD 850u /* CC line Min voltage when connected to Rd (in mV) */ #define USBNOPD_CC_VOLTAGE_MAXRD 2450u /* CC line Max voltage when connected to Rd (in mV) */ #define USBNOPD_CC_VOLTAGE_MINOPEN 2750u /* CC line Minimum voltage when not connected (in mV) */ #define USBNOPD_VBUS_VOLTAGE_MAX 5500u /* Vbus Maximum allowed voltage (in mV) */ #define USBNOPD_VPROV_VOLTAGE_MIN 4500u /* Vprov Minimum voltage (in mV) */ #define USBNOPD_VSAFE_VOLTAGE_MAX 100u /* Vbus safe voltage to end vbus discharge (in mV) */ #define USBNOPD_SRC1M1_NORA 0u /* No voltage divider on CC lines */ #define USBNOPD_SRC1M1_NORB 0u /* No voltage divider on CC lines */ #define USBNOPD_DEBOUNCE_ATTACH_TICKS 120u /* Number of ticks needed to complete attaching state debouncing */ #define USBNOPD_DEBOUNCE_DETACH_TICKS 10u /* Number of ticks needed to complete detaching state debouncing */ #define ADC_FULL_SCALE 0x0FFFu /* Maximum digital value of the ADC output (12 Bits) */ /* USER CODE END EC */Īdd the following code between the /* USER CODE BEGIN EFP-END EFP*/ tags:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |