NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
battery_unittest.cc File Reference
#include <stdint.h>
#include <limits.h>
#include "sensors/battery.h"
#include "io/beeper.h"
#include "unittest_macros.h"
#include "gtest/gtest.h"
#include "common/filter.h"
Include dependency graph for battery_unittest.cc:

Data Structures

struct  batteryAdcToVoltageExpectation_s
 
struct  batteryAdcToBatteryStateExpectation_s
 
struct  batteryAdcToCellCountExpectation_s
 

Macros

#define ELEVEN_TO_ONE_VOLTAGE_DIVIDER   110
 

Typedefs

typedef struct
batteryAdcToVoltageExpectation_s 
batteryAdcToVoltageExpectation_t
 
typedef struct
batteryAdcToBatteryStateExpectation_s 
batteryAdcToBatteryStateExpectation_t
 
typedef struct
batteryAdcToCellCountExpectation_s 
batteryAdcToCellCountExpectation_t
 

Functions

uint16_t batteryAdcToVoltage (uint16_t src)
 
uint16_t _battery_adc_to_voltage (struct battery *self, uint16_t src)
 
 TEST (BatteryTest, BatteryADCToVoltage)
 
 TEST (BatteryTest, BatteryState)
 
 TEST (BatteryTest, CellCount)
 
 TEST (BatteryTest, RollOverPattern1)
 
 TEST (BatteryTest, RollOverPattern2)
 
float applyBiQuadFilter (float sample, biquad_t *state)
 
void BiQuadNewLpf (float filterCutFreq, biquad_t *newState, uint32_t refreshRate)
 
bool feature (uint32_t mask)
 
uint16_t adcGetChannel (uint8_t channel)
 

Variables

uint16_t currentADCReading
 
uint8_t armingFlags = 0
 
int16_t rcCommand [4] = {0,0,0,0}
 

Macro Definition Documentation

#define ELEVEN_TO_ONE_VOLTAGE_DIVIDER   110

Typedef Documentation

Function Documentation

uint16_t _battery_adc_to_voltage ( struct battery self,
uint16_t  src 
)
uint16_t adcGetChannel ( uint8_t  channel)
float applyBiQuadFilter ( float  sample,
biquad_t state 
)
uint16_t batteryAdcToVoltage ( uint16_t  src)
void BiQuadNewLpf ( float  filterCutFreq,
biquad_t newState,
uint32_t  refreshRate 
)
bool feature ( uint32_t  mask)
TEST ( BatteryTest  ,
BatteryADCToVoltage   
)

Here is the call graph for this function:

TEST ( BatteryTest  ,
BatteryState   
)

Here is the call graph for this function:

TEST ( BatteryTest  ,
CellCount   
)

Here is the call graph for this function:

TEST ( BatteryTest  ,
RollOverPattern1   
)

These next two tests do not test any production code (!) but serves as an example of how to use a signed variable for timing purposes.

The 'signed diff timing' pattern is followed in a few places in the production codebase.

TEST ( BatteryTest  ,
RollOverPattern2   
)

Variable Documentation

uint8_t armingFlags = 0
uint16_t currentADCReading
int16_t rcCommand[4] = {0,0,0,0}