SLAAEK3A January 2024 – September 2024 MSPM0G3507
Some users want to change the specific
values that are used by the UART packet header, or the maximum packet size. This
change is done by modifying the #define values found in the beginning of the
uart_to_spi_bridge.c
file, as shown in the following code.
/* Define UART Header and Start Byte*/
#define UART_HEADER_LENGTH 0x02
#define UART_START_BYTE 0xF8
#define UART_READ_SPI_BYTE 0xFA
#define UART_WRITE_SPI_BYTE 0xFB
#define RW_INDEX 0x00
#define LENGTH_INDEX 0x01
/*Define max packet sizes*/
#define SPI_MAX_PACKET_SIZE (16)
#define UART_MAX_PACKET_SIZE (SPI_MAX_PACKET_SIZE + UART_HEADER_LENGTH)
Many portions of the code are intended to be used for error detection and handling. At these points in the code, the user can use additional error handling or reporting for a more robust application. For example, the following code segment demonstrates a way to check for errors in SPI transmissions, and sets an error flag in the event of an error. The user can quit sending and change the UART Bridge Status here to reflect the error. This and many other areas in the code have options for error consideration.
for(int i = 0; i < gMsgLength; i++){
if(!DL_SPI_transmitDataCheck8(SPI_0_INST, gSPIData[i])){
gError = ERROR_SPI_WRITE_FAILED;
}
}