ADC Driver (Not Implemented)
ADC Function
Initialization
-
void adc_init(uint8_t pin)
Initialize ADC on the specified pin and setup FVR (Fixed voltage reference).
- Parameters
pin (uint8_t) – pin/ADC number, if ADC is shared between pins, then the ADC mapping need to be configured in pin_init() function
Get single conversion
-
uint16_t adc_get_single_conversion(uint8_t pin)
Get single conversion from ADC
- Parameters
pin (uint8_t) – pin/ADC number
- Returns
ADC conversion result
- Return type
uint16_t
Current Sensing Function
Current sense Get Conversion
-
uint16_t curr_sense_single_conversion(uint8_t pin, uint16_t shunt_r, uint16_t amp_gain)
Get single conversion from a current sense amplifier(such as INA180) connected to an ADC
- Parameters
pin (uint8_t) – pin/ADC number
shunt_r (uint16_t) – shunt resistor value, in kilo-ohms
amp_gain (uint16_t) – gain of the current sense amplifier, in V/V
- Returns
Current sense conversion result
- Return type
uint16_t
Reference Implementation
An ADC driver for PIC18 exists in the Charging Board firmware repository, Link. The driver was generated by MPLab’s MCC Code Generator.