59 #include "Mockfassert.h"
60 #include "Mockmxm_cfg.h"
70 TEST_FILE(
"mxm_17841b.c")
74 #define MXM_41B_CONFIG_REGISTER_LENGTH (7u)
79 .extendMessageBytes = 0,
81 .regRXIntEnable = 0x00u,
82 .regTXIntEnable = 0x00u,
387 uint16_t
rxBuffer[10] = {0x13u, 0x00u};
389 MXM_ReceiveData_ReturnArrayThruPtr_rxBuffer(
rxBuffer, 2);
394 MXM_GetSPIStateReady_ExpectAndReturn(
STD_OK);
408 uint16_t
rxBuffer[10] = {0x13u, 0x01u};
410 MXM_ReceiveData_ReturnArrayThruPtr_rxBuffer(
rxBuffer, 2);
415 MXM_GetSPIStateReady_ExpectAndReturn(
STD_OK);
428 uint16_t
rxBuffer[10] = {0x15u, 0x84u, 0x12u};
430 MXM_ReceiveData_ReturnArrayThruPtr_rxBuffer(
rxBuffer, 3);
435 MXM_GetSPIStateReady_ExpectAndReturn(
STD_OK);
448 uint16_t tx_buffer[10] = {0xE0u};
449 MXM_SendData_ExpectAndReturn(tx_buffer, 1,
STD_OK);
464 uint16_t tx_buffer[10] = {0xE0u};
466 MXM_SendData_ExpectAndReturn(tx_buffer, 1,
STD_NOT_OK);
481 uint16_t tx_buffer[10] = {0x20u};
482 MXM_SendData_ExpectAndReturn(tx_buffer, 1,
STD_OK);
497 uint16_t tx_buffer[10] = {0x20u};
499 MXM_SendData_ExpectAndReturn(tx_buffer, 1,
STD_NOT_OK);
528 MXM_ReceiveData_IgnoreAndReturn(
STD_OK);
540 MXM_ReceiveData_IgnoreAndReturn(
STD_OK);
553 MXM_ShutDownBridgeIc_Expect();
555 const uint32_t shutdownTimestamp = 42u;
556 OS_GetTickCount_ExpectAndReturn(shutdownTimestamp);
560 OS_CheckTimeHasPassed_ExpectAndReturn(shutdownTimestamp, 0u,
false);
561 OS_CheckTimeHasPassed_IgnoreArg_timeToPass_ms();
565 OS_CheckTimeHasPassed_ExpectAndReturn(shutdownTimestamp, 0u,
true);
566 OS_CheckTimeHasPassed_IgnoreArg_timeToPass_ms();
568 MXM_EnableBridgeIc_Expect();
584 MXM_ReceiveData_ExpectAndReturn(
593 MXM_GetSPIStateReady_ExpectAndReturn(
STD_OK);
#define NULL_PTR
Null pointer.
void testReadRegisterFunctionWithIllegalValues(void)
void testReadRegisterFunctionWithLegalValues(void)
void testStateRequestInconsistentInputPayload(void)
void testSetStateRequestInvalidInstancePointer(void)
Test with an invalid pointer.
void testTransitionsOnlyAllowedInIdleAfterInit(void)
void testStateRequestConsistentInput(void)
void testStateRequestInconsistentInputRXBuffer(void)
void testOnlyAllowedTransitionFromUnitializedIsInit(void)
Test that the only transition from uninitialized is initialization.
void testStateRequestInconsistentInputProcessed(void)
void testStateGetVersion(void)
void testStateClearTransmitBuffer(void)
void testStateDefault(void)
void testStateInitNormalFlow(void)
void testStateClearTransmitBufferFailedSPIWrite(void)
void testStateCheckFmeaGNDLAlert(void)
void testStateClearReceiveBufferFailedSPIWrite(void)
void testStateStayInIdle(void)
void testStateUARTWaitForRXStatusChangeFail(void)
void testStateStayInUninitialized(void)
void testStateClearReceiveBuffer(void)
void testStateCheckFMEA(void)
void testStateUARTWaitForRXStatusChangeSuccess(void)
void testWriteRegisterFunctionWithLegalValues(void)
void testWriteRegisterFunctionWithIllegalValues(void)
STD_RETURN_TYPE_e MXM_41BSetStateRequest(MXM_41B_INSTANCE_s *pInstance, MXM_STATEMACH_41B_e state, uint16_t *pPayload, uint8_t payloadLength, uint8_t extendMessageBytes, uint16_t *pRxBuffer, uint16_t rxBufferLength, MXM_41B_STATE_REQUEST_STATUS_e *processed)
Set state transition for MAX17841B-state-machine.
void MXM_41BStateMachine(MXM_41B_INSTANCE_s *pInstance)
Execute state-machine for the MAX17841B.
STD_RETURN_TYPE_e MXM_41BWriteRegisterFunction(MXM_41B_INSTANCE_s *pInstance, MXM_41B_REG_FUNCTION_e registerFunction, MXM_41B_REG_BIT_VALUE value)
Write a register function.
void MXM_41BInitializeStateStruct(MXM_41B_INSTANCE_s *pInstance)
Initializes the state struct with default values.
STD_RETURN_TYPE_e MXM_41BReadRegisterFunction(const MXM_41B_INSTANCE_s *const kpkInstance, MXM_41B_REG_FUNCTION_e registerFunction, MXM_41B_REG_BIT_VALUE *pValue)
Read the value of a register function.
Headers for the driver for the MAX17841B ASCI and MAX1785x analog front-end.
@ MXM_STATEMACH_41B_MAXSTATE
@ MXM_STATEMACH_41B_GET_VERSION
@ MXM_STATEMACH_41B_CLEAR_RECEIVE_BUFFER
@ MXM_STATEMACH_41B_CLEAR_TRANSMIT_BUFFER
@ MXM_STATEMACH_41B_UNINITIALIZED
@ MXM_STATEMACH_41B_CHECK_FMEA
@ MXM_STATEMACH_41B_UART_TRANSACTION
@ MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_WRITE
@ MXM_41B_UART_READ_BACK_RECEIVE_BUFFER_SAVE
@ MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_READ_AND_READ_BACK_RCV_BUF
@ MXM_41B_REG_FUNCTION_RX_BUSY_STATUS
@ MXM_41B_REG_FUNCTION_RX_EMPTY_STATUS
@ MXM_41B_REG_FUNCTION_TX_PREAMBLES
@ MXM_41B_REG_FUNCTION_RX_ERROR_INT
@ MXM_41B_REG_FUNCTION_KEEP_ALIVE
@ MXM_41B_REG_FUNCTION_RX_OVERFLOW_INT
MXM_41B_STATE_REQUEST_STATUS_e
Request status of MAX17841B states.
@ MXM_41B_STATE_UNPROCESSED
@ MXM_41B_STATE_PROCESSED
#define MXM_41B_CONFIG_3_DEFAULT_VALUE
#define MXM_41B_CONFIG_1_DEFAULT_VALUE
#define MXM_41B_CONFIG_2_DEFAULT_VALUE
#define MXM_41B_RX_INT_ENABLE_DEFAULT_VALUE
#define MXM_41B_RX_INT_FLAG_DEFAULT_VALUE
#define MXM_41B_TX_INT_ENABLE_DEFAULT_VALUE
#define MXM_41B_TX_INT_FLAG_DEFAULT_VALUE
Struct for the state-variable of state-machine.
MXM_41B_STATE_REQUEST_STATUS_e * processed
uint16_t spiRXBuffer[MXM_SPI_RX_BUFFER_LENGTH]
uint16_t spiTXBuffer[MXM_SPI_TX_BUFFER_LENGTH]
MXM_41B_SUBSTATES_e substate
MXM_STATEMACH_41B_e state
#define TEST_ASSERT_FAIL_ASSERT(_code_under_test)
assert whether assert macro has failed
uint16_t commandBuffer[10]
#define MXM_41B_CONFIG_REGISTER_LENGTH
MXM_41B_STATE_REQUEST_STATUS_e status41b
static MXM_41B_INSTANCE_s mxm_41bState