17 extern uint64_t
ahRaw;
18 extern uint32_t
ahCnt;
141 bool isHigh=(PORTD & 0b00000100)!=0;
void SetHighCurrentMode(void)
Sets High Current Mode.
Definition: spi.c:120
void DACSetAmps(double i)
Sets the DAC to a certain Current.
Definition: spi.c:185
void SPIInit(void)
Initializes the SPI Interface.
Definition: spi.c:366
static void SPIDeselectADC(void)
Revoke ADC CS.
Definition: spi.h:127
double ADCGetAs(void)
Gets the Ampere Seconds consumed.
Definition: spi.c:255
SPIADCData_t SPIADCData
Definition: spi.h:57
#define DACPORT
Definition: spi.h:12
Raw values for ADC, DAC and LEDs.
Definition: spi.h:77
static bool IsHighCurrentMode(void)
Returns True if High Current Mode is active.
Definition: spi.h:139
#define DACCSPIN
Definition: spi.h:13
void CalcIMaxLookupTable(void)
Calculates the Lookup Table for IMax.
Definition: spi.c:75
Raw values for ADC, DAC and LEDs.
Definition: spi.h:53
uint16_t soaIMaxLUT[128]
Lookup Table for maximum DAC-Value versus ADC-Voltage.
Definition: spi.c:71
uint16_t derating
Temperature Derating factor *65535. Maximum Power has to be derated by multiplication with derating.
Definition: spi.c:57
#define ADCPORT
Definition: spi.h:14
uint8_t LED
Bitmask for LED shift register.
Definition: spi.h:82
uint16_t ADCGetIHighAvgRaw()
Returns the averaged Value for the Current.
Definition: spi.c:335
uint8_t DAC_CMD
Command Byte for DAC.
Definition: spi.h:84
double ADCGetIByVal(uint16_t iRaw, bool isHigh)
Returns the Current for a given Value.
Definition: spi.c:269
uint16_t ADCGetVLifeRaw()
Returns the Life Value for the Sink Voltage.
Definition: spi.c:323
uint16_t DAC
Raw value for the DAC.
Definition: spi.h:60
#define ADCCSPIN
Definition: spi.h:15
uint8_t SpiSendAndReceiveByte(uint8_t b)
Sends and receives a Byte over the SPI Bus.
Definition: spi.c:138
void CalcRChannel(void)
Definition: spi.c:411
volatile SPIADCData_t SPIADCAvg
Averaged Values over 16 measurements. These values may get up to 14 bits of precision.
Definition: spi.c:55
void SpiGetADC2(void)
Faster Alternative.
uint16_t Ihigh
The Current measured over the 100mR Shunt. Always valid but inaccurate if in low current mode.
Definition: spi.h:40
uint16_t V
The Voltage.
Definition: spi.h:38
void DACSetAmpsByStr(char *str)
Sets the sink to the value of a string.
Definition: spi.c:226
static void SpiSelectDAC(void)
Asserts DAC CS.
Definition: spi.h:106
volatile ADC_RcvStruct_t ADC_RcvStruct
Definition: spi.c:54
uint16_t DAC
Raw value for the DAC.
Definition: spi.h:83
uint16_t Ilow
The Current measured over both Shunts. Invalid if in high Current Range since the 3R3 is shorted by t...
Definition: spi.h:39
uint16_t ADCGetVAvgRaw()
Returns the averaged Value for the Sink Voltage.
Definition: spi.c:359
uint16_t ADCGetIlowLifeRaw()
Returns the Life Value for the Current.
Definition: spi.c:313
uint64_t ahRaw
The sum of current values.
Definition: Eload.c:72
static bool SPIADCBusy(void)
Returns True if SPI is occupied by ADC.
Definition: spi.h:99
uint32_t ahTickCnt
The number of 100Hz interrupts since ahRaw is counting.
Definition: Eload.c:74
static void SPIDeselectDAC(void)
Revoke DAC CS.
Definition: spi.h:113
uint16_t ADCGetILowAvgRaw()
Returns the averaged Value for the Current.
Definition: spi.c:349
void DACSetRaw(uint16_t value)
Sets the raw Value of the DAC.
Definition: spi.c:162
static void SpiSelectADC(void)
Asserts ADC CS.
Definition: spi.h:120
double ADCGetIavg(void)
Returns the averaged Value for Load Current.
Definition: spi.c:240
uint16_t ADCGetIhighLifeRaw()
Returns the Life Value for the Current.
Definition: spi.c:299
uint8_t LED
Bitmask for LED shift register.
Definition: spi.h:59
void SetLowCurrentMode(void)
Sets Low Current Mode.
Definition: spi.c:110
uint32_t ahCnt
Number of average values added to ahRaw;.
Definition: Eload.c:73
void SPISetLEDs(uint8_t mask)
Sets the State of the 8 LEDs on the SPI-Shift-Register.
Definition: spi.c:103
uint8_t DAC_CMD
Definition: spi.h:61
double ADCGetVavg(void)
Returns the averaged Value for the Sink Voltage.
Definition: spi.c:287
uint8_t dummy
Dummy byte.
Definition: spi.h:58