This is where the framing/deframing and transmission happens for UART frames. More...
Data Structures | |
struct | UART_MSG_RX_OBJ |
UART msg receive object. More... | |
struct | UART_MSG_TX_OBJ |
UART msg Transmit object. More... | |
Macros | |
#define | PBV_CRC_POLYNOM 0x8005 |
Standard PBV CRC Polynomial. For documentation, as it is not used in calculation in this file. | |
#define | PBV_CRC_POLYNOM_REV 0xA001 |
Reversed polynomial. needed for odd byte in the data stream. | |
#define | PBV_ReadyToSend UART1_IsTxReady |
linking functions with UART mcc driver functions | |
#define | PBV_Write UART1_Write |
linking functions with UART mcc driver functions | |
#define | PBV_IsRxReady UART1_IsRxReady |
linking functions with UART mcc driver functions | |
#define | PBV_Read UART1_Read |
linking functions with UART mcc driver functions | |
#define | PBV_START_OF_FRAME 0x55 |
Standard Start of frame for PBV UART frames. | |
#define | PBV_END_OF_FRAME 0x0d |
Standard End of frame for PBV UART frames. | |
#define | PBV_RCV_DATABUFFER_SIZE 64 |
Maximum UART buffer. The max data that could be received is 64 bytes. | |
#define | PBV_HEADER_SIZE 5 |
Maximum UART buffer. The max data that could be received is 64 bytes. | |
Typedefs | |
typedef struct UART_MSG_RX_OBJ | UART_MSG_RX_OBJ_t |
UART msg receive object. | |
typedef struct UART_MSG_TX_OBJ | UART_MSG_TX_OBJ_t |
UART msg Transmit object. | |
Functions | |
void | PBV_UART_Init (PBV_Datatype_TX_t *boardToPbv, PBV_Datatype_TX_t *boardToPbvAscii, PBV_Datatype_RX_t *pbvToBoard) |
initializes UART objects | |
uint8_t | PBV_UART_Receive_from_GUI () |
implements the state machine for UART Frame receiving from PBV. | |
uint8_t | PBV_UART_Transmit_Ascii_to_GUI () |
implements the state machine for UART ascii TX | |
uint8_t | PBV_UART_Transmit_to_GUI () |
implements the state machine for UART numerical TX | |
void | PBV_UART_Reinit (PBV_Datatype_TX_t *ptr) |
reinitializes the UART object with new protocol id. | |
void | PBV_UART_Link_Data_TX (PBV_Datatype_TX_t *ptr) |
links the data from the calling application to the UART TX object | |
int | PBV_UART_Link_Data_RX (PBV_Datatype_RX_t *ptr) |
Links the data from received frame to the calling application | |
uint16_t | PBV_Calculate_CRC (uint8_t *message, uint16_t length) |
Calculates the CRC on 16 bit stream of data. | |
Variables | |
UART_MSG_TX_OBJ_t | pbvUartObjectTx |
UART object for numeric tx. | |
UART_MSG_RX_OBJ_t | pbvUartObjectRx |
UART object for numeric rx. | |
UART_MSG_TX_OBJ_t | pbvUartObjectAscii |
UART object for ascii tx. | |
#define | RCV_WAIT_FOR_STARTBYTE 0 |
Internal STATES for RX State machine for PBV UART Frames. | |
#define | RCV_READ_ID_HIGHBYTE 1 |
#define | RCV_READ_ID_LOWBYTE 2 |
#define | RCV_READ_LENGTH_HIGHBYTE 3 |
#define | RCV_READ_LENGTH_LOWBYTE 4 |
#define | RCV_READ_DATA 5 |
#define | RCV_READ_CRC_HIGHBYTE 6 |
#define | RCV_READ_CRC_LOWBYTE 7 |
#define | RCV_READ_EOF 8 |
#define | RCV_MESSAGE_RECEIVED 9 |
This is where the framing/deframing and transmission happens for UART frames. The fundamental difference between this and CAN-FD frames is that CAN-FD defines a strategy for framing and deframing data, and PBV follows that strategy. UART is a point to point byte by byte transfer of data. To build a frame on top of it, another layer is needed where the data is framed/deframed and trasnmitted. It defines an additional statemachine
#define PBV_CRC_POLYNOM 0x8005 |
Definition at line 24 of file PBV_UART.c.
#define PBV_CRC_POLYNOM_REV 0xA001 |
Definition at line 30 of file PBV_UART.c.
#define PBV_END_OF_FRAME 0x0d |
Definition at line 66 of file PBV_UART.c.
#define PBV_HEADER_SIZE 5 |
Receive Data lenght excluding header (5 bytes) and footer (3 bytes, but not needed in memory allocation for UART arrays.) in bytes 0x55 + protocol ID (2 bytes) + length (2 bytes)?
Definition at line 98 of file PBV_UART.c.
#define PBV_IsRxReady UART1_IsRxReady |
Definition at line 48 of file PBV_UART.c.
#define PBV_RCV_DATABUFFER_SIZE 64 |
Receive Data lenght excluding header (5 bytes) and footer (3 bytes, but not needed in memory allocation for UART arrays.)
Definition at line 91 of file PBV_UART.c.
#define PBV_Read UART1_Read |
Definition at line 54 of file PBV_UART.c.
#define PBV_ReadyToSend UART1_IsTxReady |
Definition at line 36 of file PBV_UART.c.
#define PBV_START_OF_FRAME 0x55 |
Definition at line 60 of file PBV_UART.c.
#define PBV_Write UART1_Write |
Definition at line 42 of file PBV_UART.c.
#define RCV_MESSAGE_RECEIVED 9 |
Definition at line 83 of file PBV_UART.c.
#define RCV_READ_CRC_HIGHBYTE 6 |
Definition at line 80 of file PBV_UART.c.
#define RCV_READ_CRC_LOWBYTE 7 |
Definition at line 81 of file PBV_UART.c.
#define RCV_READ_DATA 5 |
Definition at line 79 of file PBV_UART.c.
#define RCV_READ_EOF 8 |
Definition at line 82 of file PBV_UART.c.
#define RCV_READ_ID_HIGHBYTE 1 |
Definition at line 75 of file PBV_UART.c.
#define RCV_READ_ID_LOWBYTE 2 |
Definition at line 76 of file PBV_UART.c.
#define RCV_READ_LENGTH_HIGHBYTE 3 |
Definition at line 77 of file PBV_UART.c.
#define RCV_READ_LENGTH_LOWBYTE 4 |
Definition at line 78 of file PBV_UART.c.
#define RCV_WAIT_FOR_STARTBYTE 0 |
< STATES for RX State machine for PBV UART Frames
Definition at line 74 of file PBV_UART.c.
typedef struct UART_MSG_RX_OBJ UART_MSG_RX_OBJ_t |
UART RX Object data type
typedef struct UART_MSG_TX_OBJ UART_MSG_TX_OBJ_t |
UART TX Object data type
uint16_t PBV_Calculate_CRC | ( | uint8_t * | message, |
uint16_t | length | ||
) |
uint8_t | * pointer to data. |
uint16_t | length of data in bytes |
calculates the 16 bit CRC on an incoming stream of bytes. the data for CRC is [header][data]. odd byte processed seperately. Manually cleared shift registers in the end. Ticket has been raised to fix this. uses the CRC peripheral
Definition at line 583 of file PBV_UART.c.
void PBV_UART_Init | ( | PBV_Datatype_TX_t * | boardToPbv, |
PBV_Datatype_TX_t * | boardToPbvAscii, | ||
PBV_Datatype_RX_t * | pbvToBoard | ||
) |
PBV_Datatype_TX_t | * - ptr to numerical data |
PBV_Datatype_TX_t | * - ptr to ascii data |
PBV_Datatype_TX_t | * - ptr to received data ( for completeness, not used now) |
initializes UART objects with application objects. Also initializes uartActiveTx and uartActiveTxAscii
Definition at line 165 of file PBV_UART.c.
int PBV_UART_Link_Data_RX | ( | PBV_Datatype_RX_t * | ptr | ) |
PBV_Datatype_RX_t | * |
Links the data from received frame to the calling application
Definition at line 562 of file PBV_UART.c.
void PBV_UART_Link_Data_TX | ( | PBV_Datatype_TX_t * | ptr | ) |
PBV_Datatype_TX_t | * |
links the data from the calling application to the UART TX object.
Definition at line 541 of file PBV_UART.c.
uint8_t PBV_UART_Receive_from_GUI | ( | ) |
implements the state machine for message RX. maintains internal state machine states as defined in RCV_<STATES>
< local copy created to pass to CRC function.
< calculating CRC. data for CRC [header][data]
Definition at line 189 of file PBV_UART.c.
void PBV_UART_Reinit | ( | PBV_Datatype_TX_t * | ptr | ) |
PBV_Datatype_TX_t |
reinitializes the UART object with new protocol id.
Definition at line 526 of file PBV_UART.c.
uint8_t PBV_UART_Transmit_Ascii_to_GUI | ( | ) |
implements the state machine for UART ascii TX
Definition at line 320 of file PBV_UART.c.
uint8_t PBV_UART_Transmit_to_GUI | ( | ) |
implements the state machine for UART numerical TX
Definition at line 423 of file PBV_UART.c.
UART_MSG_TX_OBJ_t pbvUartObjectAscii |
Definition at line 154 of file PBV_UART.c.
UART_MSG_RX_OBJ_t pbvUartObjectRx |
Definition at line 148 of file PBV_UART.c.
UART_MSG_TX_OBJ_t pbvUartObjectTx |
Definition at line 142 of file PBV_UART.c.