44 float UTIL_supplyVoltage;
46 uint8_t UTIL_supplyType;
83 initSingle.
posSel = adcPosSelAVDD;
84 initSingle.
negSel = adcNegSelVSS;
150 for( i = 0; i < avg; i++ ) {
152 supplyVoltage += (float) adcData * 5.0 / 4095.0;
157 supplyVoltage = supplyVoltage / (float) avg;
159 return supplyVoltage;
179 float supplyVoltageLoad;
206 i = 0.006074 * loadSetting + 0.00309;
207 r = ( supplyVoltage - supplyVoltageLoad ) / i;
209 printf(
" sv = %.3f svl = %.3f i = %.3f r = %.3f\r\n",
210 supplyVoltage, supplyVoltageLoad, i, r );
240 else if( ( v < 3.20 ) || ( r > 0.5 ) ) {
247 UTIL_supplyVoltage = v;
249 UTIL_supplyType = type;
276 *type = UTIL_supplyType;
277 *voltage = UTIL_supplyVoltage;
294 return UTIL_supplyType;
Driver for the Si7021 I2C Humidity and Temperature Sensor.
Clock management unit (CMU) API.
ADC_PosSel_TypeDef posSel
uint8_t UTIL_supplyGetType(void)
Returns the type of the power supply.
bool UTIL_isLowPower(void)
Checks if the current power supply has low power capability.
static void adcInit(void)
Initializes the A/D converter.
void UTIL_delay(uint32_t ms)
Delays number of msTick Systicks (1 ms)
ADC_AcqTime_TypeDef acqTime
#define ADC_INITSINGLE_DEFAULT
ADC_NegSel_TypeDef negSel
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
__STATIC_INLINE uint32_t ADC_DataSingleGet(ADC_TypeDef *adc)
Get single conversion result.
static void adcDeInit(void)
De-initializes the A/D converter.
ADC_PRSSEL_TypeDef prsSel
#define UTIL_SUPPLY_TYPE_AAA
static uint16_t getAdcSample(void)
Initiates an A/D conversion and reads the sample when done.
void ADC_Init(ADC_TypeDef *adc, const ADC_Init_TypeDef *init)
Initialize ADC.
static float measureSupplyVoltage(unsigned int avg)
Measures the supply voltage by averaging multiple readings.
General Purpose IO (GPIO) peripheral API.
#define UTIL_SUPPLY_TYPE_USB
#define _ADC_CTRL_RESETVALUE
uint8_t ADC_TimebaseCalc(uint32_t hfperFreq)
Calculate timebase value in order to get a timebase providing at least 1us.
uint32_t SI7021_cmdWrite(uint8_t *cmd, size_t cmdLen, uint8_t *data, size_t dataLen)
Sends a command and data to the chip over the I2C bus.
Utility Functions for the Thunderboard Sense.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
#define _CMU_CTRL_CLKOUTSEL1_MASK
void ADC_InitSingle(ADC_TypeDef *adc, const ADC_InitSingle_TypeDef *init)
Initialize single ADC sample conversion.
#define UTIL_SUPPLY_TYPE_UNKNOWN
void UTIL_supplyGetCharacteristics(uint8_t *type, float *voltage, float *ir)
Retrieves the supply characteristic variables.
#define UTIL_SUPPLY_TYPE_CR2032
#define SI7021_CMD_WRITE_HEATER_CTRL
Energy management unit (EMU) peripheral API.
uint32_t SI7021_init(void)
Initializes the Si7021 chip.
uint8_t ADC_PrescaleCalc(uint32_t adcFreq, uint32_t hfperFreq)
Calculate prescaler value used to determine ADC clock.
__STATIC_INLINE void ADC_Start(ADC_TypeDef *adc, ADC_Start_TypeDef cmd)
Start scan sequence and/or single conversion.
Analog to Digital Converter (ADC) peripheral API.
ADC_Ref_TypeDef reference
#define SI7021_CMD_WRITE_USER_REG1
void UTIL_supplyProbe(void)
Probes the connected supply and determines its type. The results are stored in global variables...
static float measureSupplyIR(uint8_t loadSetting)
Measures the unladed and loaded supply voltage and calculates the intermal resistance of the connecte...
void PRS_SourceAsyncSignalSet(unsigned int ch, uint32_t source, uint32_t signal)
Set source and asynchronous signal to be used for a channel.
__STATIC_INLINE uint32_t ADC_IntGet(ADC_TypeDef *adc)
Get pending ADC interrupt flags.
BOARD module header file.
Peripheral Reflex System (PRS) peripheral API.
void SI7021_deInit(void)
De-initializes the Si7021 chip. Disables the sensor power domain, this also disables other sensors...