![]() ![]() (USBnoPD_adc_converted_buffer USBNOPD_CC_VOLTAGE_MAXRD) || ((USBnoPD_adc_converted_buffer > USBNOPD_CC_VOLTAGE_MAXRD) || * If a glitch is detected, reset debounce counter and go to detached state*/ (USBnoPD_adc_converted_buffer USBNOPD_CC_VOLTAGE_MINOPEN))Įlse if ((USBnoPD_adc_converted_buffer > USBNOPD_CC_VOLTAGE_MINRD) &Ĭase USBnoPD_State_ATTACHING: /* Attachment ongoing - debouncing */ If ((USBnoPD_adc_converted_buffer > USBNOPD_CC_VOLTAGE_MINRD) & ![]() Static void USBnoPD_StateMachineRun(void)Ĭase USBnoPD_State_DETACHED: /* IDLE, nothing connected */ HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_RESET) * Turn off green LED to indicate source is OFF */ * Handle a fault raised by the TCPP (OCP), used by EXTI IRQHandlerīSP_USBPD_PWR_VBUSOff(USBPD_PWR_TYPE_C_PORT_1) īSP_USBPD_PWR_VBUSDischargeOn(USBPD_PWR_TYPE_C_PORT_1) 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |