105 #define SPS_RESET_WAIT_TIME_TICKS (5u)
197 const uint16_t address,
199 uint16_t *pSpiTxBuffer);
234 const uint16_t address,
237 uint16_t *pSpiTxBuffer);
263 const uint16_t address,
265 uint16_t *pSpiTxBuffer) {
294 const uint16_t address,
297 uint16_t *pSpiTxBuffer) {
306 uint8_t preceedingWriteData = (uint8_t)((pSpiTxBuffer[(
SPS_SPI_BUFFERSIZE - 1u - device)]) & 0xFFu);
318 ((uint16_t)preceedingWriteData | (uint16_t)writeData);
321 ((uint16_t)preceedingWriteData & (uint16_t)writeData);
409 spsDevicePositionInDaisyChain,
417 spsDevicePositionInDaisyChain,
506 if (
STD_OK == transmitRetval) {
520 if (
STD_OK == transmitRetval) {
531 if (
STD_OK == transmitRetval) {
542 if (
STD_OK == transmitRetval) {
554 if (
STD_OK == transmitRetval) {
566 if (
STD_OK == transmitRetval) {
578 if (
STD_OK == transmitRetval) {
615 if (channelCurrent_mA >
sps_channelStatus[channelIndex].thresholdFeedbackOn_mA) {
619 return channelFeedback;
624 FAS_ASSERT((normallyOpen ==
true) || (normallyOpen ==
false));
630 if (normallyOpen ==
true) {
642 return channelFeedback;
651 #ifdef UNITY_UNIT_TEST
658 extern void TEST_SPS_SetSpsState(
const SPS_STATE_e newState) {
661 extern uint8_t TEST_SPS_GetSpsTimer(
void) {
664 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
#define SETBIT(register, bit)
sets a bit to 1u
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)
Reset 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.
Declaration of the OS wrapper interface.
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.
uint8_t PEX_GetPin(uint8_t portExpander, uint8_t pin)
get pin state of port expander pins.
Header for the driver for the NXP PCA9539 port expander module.
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
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelPexFeedback(const SPS_CHANNEL_INDEX channelIndex, bool normallyOpen)
Get the feedback state of a channel.
#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.
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelCurrentFeedback(const SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
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.
Headers for the driver for the smart power switches.
SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
#define SPS_FEEDBACK_GIO_PORT_DIR
#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_FEEDBACK_GIO_PORT
#define SPS_RESET_GIO_PORT_DIR
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_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_RESET_GIO_PORT
#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