104 #define SPS_RESET_WAIT_TIME_TICKS (5u)
196 const uint16_t address,
198 uint16_t *pSpiTxBuffer);
233 const uint16_t address,
236 uint16_t *pSpiTxBuffer);
257 const uint16_t address,
259 uint16_t *pSpiTxBuffer) {
288 const uint16_t address,
291 uint16_t *pSpiTxBuffer) {
300 uint8_t preceedingWriteData = (pSpiTxBuffer[(
SPS_SPI_BUFFERSIZE - 1u - device)]) & 0xFFu;
400 spsDevicePositionInDaisyChain,
408 spsDevicePositionInDaisyChain,
497 if (
STD_OK == transmitRetval) {
511 if (
STD_OK == transmitRetval) {
522 if (
STD_OK == transmitRetval) {
533 if (
STD_OK == transmitRetval) {
545 if (
STD_OK == transmitRetval) {
557 if (
STD_OK == transmitRetval) {
569 if (
STD_OK == transmitRetval) {
606 if (channelCurrent_mA >
sps_channelStatus[channelIndex].thresholdFeedbackOn_mA) {
610 return channelFeedback;
619 #ifdef UNITY_UNIT_TEST
626 extern void TEST_SPS_SetSpsState(
const SPS_STATE_e newState) {
629 extern uint8_t TEST_SPS_GetSpsTimer(
void) {
632 extern void TEST_SPS_SetSpsTimer(
const uint8_t newTimer) {
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define NULL_PTR
Null pointer.
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
void IO_PinReset(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Header for the driver for the IO module.
void MCU_delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
Headers for the driver for the MCU module.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Implementation of the tasks used by the system, headers.
STD_RETURN_TYPE_e SPI_TransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA.
Headers for the driver for the SPI module.
void SPI_SpsInterfaceSwitchToLowSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
Switch the SPS spi handle to low speed.
void SPI_SpsInterfaceSwitchToHighSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
Switch the SPS spi handle to high speed.
SPI_INTERFACE_CONFIG_s spi_spsInterface
#define SPS_SPI_CS_GIOPORT_DIR
#define SPS_RESET_WAIT_TIME_TICKS
SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex)
Returns the channel affiliation.
void SPS_Initialize(void)
Initialize IOs for the SPS driver.
static void SPS_InitializeIo(void)
static STD_RETURN_TYPE_e SPS_Transmit(void)
Transmit all assembled messages for one timeframe.
static void SPS_GlobalReadCurrent(const uint8_t outputAllDevices)
Read the current measurements for a specific output for all SPS ICs of the daisy-chain.
static void SPS_GlobalRegisterRead(const uint16_t address, const SPS_READ_TYPE_e controlOrDiagnostic, uint16_t *pSpiTxBuffer)
Sets the SPI Tx buffer for a register read access for all SPS ICs of the daisy-chain.
static uint16_t sps_spiRxRegisterBuffer[SPS_SPI_BUFFERSIZE]
void SPS_Ctrl(void)
Control function for the CONT driver state machine.
static void SPS_SingleDeviceRegisterWrite(uint8_t device, const uint16_t address, uint8_t writeData, SPS_WRITE_TYPE_e writeType, uint16_t *pSpiTxBuffer)
Sets the SPI Tx buffer for a register write access for a specific single SPS ICs in the daisy-chain.
static void SPS_InitializeBuffers(void)
static void SPS_GlobalRegisterWrite(const uint16_t address, uint8_t writeData, uint16_t *pSpiTxBuffer)
Sets the SPI Tx buffer for a register write access for all SPS ICs of the daisy-chain.
void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
static void SPS_SetContactorsTxBuffer(void)
Assemble an update to the channel state of the SPS ICs.
void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a contactor.
static uint16_t sps_spiTxRegisterBuffer[SPS_SPI_BUFFERSIZE]
static SPS_STATE_e sps_state
static uint16_t sps_spiTxWriteToChannelChannelControlRegister[SPS_SPI_BUFFERSIZE]
static uint16_t sps_spiRxReadAnswerDuringChannelControl[SPS_SPI_BUFFERSIZE]
static void SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request the functional state of a channel.
static void SPS_SetCommandTxBuffer(const SPS_ACTION_e action)
Assemble a general command to the SPS ICs.
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelFeedback(SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
Headers for the driver for the smart power switches.
SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
#define SPS_OUTPUT_CONTROL_REGISTER_ADDRESS
#define SPS_GLOBAL_CONTROL_REGISTER_ADDRESS
#define SPS_NR_OF_AVAILABLE_SPS_CHANNELS
#define SPS_SPI_BUFFERSIZE
#define SPS_OD_IOUT1_DIAG_REGISTER_ADDRESS
@ SPS_TRIGGER_CURRENT_MEASUREMENT
@ SPS_CONFIGURE_CONTROL_REGISTER
@ SPS_READ_MEASURED_CURRENT2
@ SPS_READ_MEASURED_CURRENT1
@ SPS_READ_MEASURED_CURRENT3
@ SPS_READ_MEASURED_CURRENT4
enum SPS_WRITE_TYPE SPS_WRITE_TYPE_e
enum SPS_ACTION SPS_ACTION_e
#define SPS_RESET_GIOPORT
enum SPS_STATE SPS_STATE_e
#define SPS_DRIVE_STRENGTH_BIT_START
@ SPS_andWithCurrentValue
@ SPS_replaceCurrentValue
#define SPS_MODE_BIT_START
#define SPS_OD_IOUT2_DIAG_REGISTER_ADDRESS
#define SPS_RESET_GIOPORT_DIR
#define SPS_NR_CONTACTOR_PER_IC
@ SPS_READ_DIAGNOSTIC_REGISTER
@ SPS_READ_CONTROL_REGISTER
enum SPS_CHANNEL_FUNCTION SPS_CHANNEL_FUNCTION_e
#define SPS_RW_BIT_POSITION
#define SPS_OD_IOUT4_DIAG_REGISTER_ADDRESS
#define SPS_OD_IOUT3_DIAG_REGISTER_ADDRESS
enum SPS_READ_TYPE SPS_READ_TYPE_e
#define SPS_ADDRESS_BIT_START
#define SPS_EN_IRQ_PIN_DIAG_REGISTER_ADDRESS
#define SPS_DIAG_CTRL_BIT_POSITION
@ SPS_ACTION_READ_CURRENT_MEASUREMENT2
@ SPS_ACTION_READ_CURRENT_MEASUREMENT1
@ SPS_ACTION_TRIGGER_CURRENT_MEASUREMENT
@ SPS_ACTION_READ_EN_IRQ_PIN
@ SPS_ACTION_READ_CURRENT_MEASUREMENT4
@ SPS_ACTION_CONFIGURE_CONTROL_REGISTER
@ SPS_ACTION_READ_CURRENT_MEASUREMENT3
#define SPS_I_MEASUREMENT_LSB_mA
#define SPS_BITMASK_DIAGNOSTIC_ONDEMAND_OUTPUT_CURRENT
#define SPS_C_CONTROL_REGISTER_ADDRESS
uint8_t SPS_CHANNEL_INDEX
enum SPS_CHANNEL_AFFILIATION SPS_CHANNEL_AFFILIATION_e
affiliation type of a sps channel
SPS_CHANNEL_FUNCTION_e channelRequested
const SPS_CHANNEL_AFFILIATION_e affiliation
SPS_CHANNEL_FUNCTION_e channel