111 #define SPS_RESET_WAIT_TIME_TICKS (5u)
203 const uint16_t address,
205 uint16_t *pSpiTxBuffer);
240 const uint16_t address,
243 uint16_t *pSpiTxBuffer);
269 const uint16_t address,
271 uint16_t *pSpiTxBuffer) {
300 const uint16_t address,
303 uint16_t *pSpiTxBuffer) {
312 uint8_t preceedingWriteData = (uint8_t)((pSpiTxBuffer[(
SPS_SPI_BUFFERSIZE - 1u - device)]) & 0xFFu);
324 ((uint16_t)preceedingWriteData | (uint16_t)writeData);
327 ((uint16_t)preceedingWriteData & (uint16_t)writeData);
415 spsDevicePositionInDaisyChain,
423 spsDevicePositionInDaisyChain,
512 if (transmitRetval ==
STD_OK) {
526 if (transmitRetval ==
STD_OK) {
537 if (transmitRetval ==
STD_OK) {
548 if (transmitRetval ==
STD_OK) {
560 if (transmitRetval ==
STD_OK) {
572 if (transmitRetval ==
STD_OK) {
584 if (transmitRetval ==
STD_OK) {
629 if (channelCurrent_mA >
sps_channelStatus[channelIndex].thresholdFeedbackOn_mA) {
633 return channelFeedback;
638 FAS_ASSERT((normallyOpen ==
true) || (normallyOpen ==
false));
644 if (normallyOpen ==
true) {
656 return channelFeedback;
665 #ifdef UNITY_UNIT_TEST
672 extern void TEST_SPS_SetSpsState(
const SPS_STATE_e newState) {
675 extern uint8_t TEST_SPS_GetSpsTimer(
void) {
678 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.
General macros and definitions for the whole platform.
#define GEN_SET_BIT(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 SPI_SPS_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.
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.
void SPS_RequestGeneralIoState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
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_ISR_IRQ_DIAG_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
#define SPS_FEEDBACK_GIO_PORT
#define SPS_RESET_GIO_PORT_DIR
#define SPS_DRIVE_STRENGTH_BIT_START
@ SPS_READ_DIAGNOSTIC_REGISTER
@ SPS_READ_CONTROL_REGISTER
#define SPS_MODE_BIT_START
#define SPS_OD_IOUT2_DIAG_REGISTER_ADDRESS
@ 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_NR_CONTACTOR_PER_IC
#define SPS_RW_BIT_POSITION
#define SPS_OD_IOUT4_DIAG_REGISTER_ADDRESS
#define SPS_OD_IOUT3_DIAG_REGISTER_ADDRESS
#define SPS_ADDRESS_BIT_START
@ SPS_andWithCurrentValue
@ SPS_replaceCurrentValue
#define SPS_RESET_GIO_PORT
#define SPS_DIAG_CTRL_BIT_POSITION
#define SPS_I_MEASUREMENT_LSB_mA
#define SPS_BITMASK_DIAGNOSTIC_ONDEMAND_OUTPUT_CURRENT
#define SPS_C_CONTROL_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
uint8_t SPS_CHANNEL_INDEX
SPS_CHANNEL_AFFILIATION_e
affiliation type of a sps channel
SPS_CHANNEL_FUNCTION_e channelRequested
SPS_CHANNEL_FUNCTION_e channel
const SPS_CHANNEL_AFFILIATION_e affiliation