Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches

This is where the framing/deframing and transmission happens for UART frames. More...

+ Collaboration diagram for UART Communication:

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
 

Detailed Description

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

Macro Definition Documentation

◆ PBV_CRC_POLYNOM

#define PBV_CRC_POLYNOM   0x8005

Definition at line 24 of file PBV_UART.c.

◆ PBV_CRC_POLYNOM_REV

#define PBV_CRC_POLYNOM_REV   0xA001

Definition at line 30 of file PBV_UART.c.

◆ PBV_END_OF_FRAME

#define PBV_END_OF_FRAME   0x0d

Definition at line 66 of file PBV_UART.c.

◆ PBV_HEADER_SIZE

#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.

◆ PBV_IsRxReady

#define PBV_IsRxReady   UART1_IsRxReady

Definition at line 48 of file PBV_UART.c.

◆ PBV_RCV_DATABUFFER_SIZE

#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.

◆ PBV_Read

#define PBV_Read   UART1_Read

Definition at line 54 of file PBV_UART.c.

◆ PBV_ReadyToSend

#define PBV_ReadyToSend   UART1_IsTxReady

Definition at line 36 of file PBV_UART.c.

◆ PBV_START_OF_FRAME

#define PBV_START_OF_FRAME   0x55

Definition at line 60 of file PBV_UART.c.

◆ PBV_Write

#define PBV_Write   UART1_Write

Definition at line 42 of file PBV_UART.c.

◆ RCV_MESSAGE_RECEIVED

#define RCV_MESSAGE_RECEIVED   9

Definition at line 83 of file PBV_UART.c.

◆ RCV_READ_CRC_HIGHBYTE

#define RCV_READ_CRC_HIGHBYTE   6

Definition at line 80 of file PBV_UART.c.

◆ RCV_READ_CRC_LOWBYTE

#define RCV_READ_CRC_LOWBYTE   7

Definition at line 81 of file PBV_UART.c.

◆ RCV_READ_DATA

#define RCV_READ_DATA   5

Definition at line 79 of file PBV_UART.c.

◆ RCV_READ_EOF

#define RCV_READ_EOF   8

Definition at line 82 of file PBV_UART.c.

◆ RCV_READ_ID_HIGHBYTE

#define RCV_READ_ID_HIGHBYTE   1

Definition at line 75 of file PBV_UART.c.

◆ RCV_READ_ID_LOWBYTE

#define RCV_READ_ID_LOWBYTE   2

Definition at line 76 of file PBV_UART.c.

◆ RCV_READ_LENGTH_HIGHBYTE

#define RCV_READ_LENGTH_HIGHBYTE   3

Definition at line 77 of file PBV_UART.c.

◆ RCV_READ_LENGTH_LOWBYTE

#define RCV_READ_LENGTH_LOWBYTE   4

Definition at line 78 of file PBV_UART.c.

◆ RCV_WAIT_FOR_STARTBYTE

#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 Documentation

◆ UART_MSG_RX_OBJ_t

UART RX Object data type

◆ UART_MSG_TX_OBJ_t

UART TX Object data type

Function Documentation

◆ PBV_Calculate_CRC()

uint16_t PBV_Calculate_CRC ( uint8_t *  message,
uint16_t  length 
)
Parameters
uint8_t* pointer to data.
uint16_tlength of data in bytes
Returns
calculated CRC

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PBV_UART_Init()

void PBV_UART_Init ( PBV_Datatype_TX_t boardToPbv,
PBV_Datatype_TX_t boardToPbvAscii,
PBV_Datatype_RX_t pbvToBoard 
)
Parameters
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)
Returns
void

initializes UART objects with application objects. Also initializes uartActiveTx and uartActiveTxAscii

Definition at line 165 of file PBV_UART.c.

◆ PBV_UART_Link_Data_RX()

int PBV_UART_Link_Data_RX ( PBV_Datatype_RX_t ptr)
Parameters
PBV_Datatype_RX_t*
Returns
void

Links the data from received frame to the calling application

Definition at line 562 of file PBV_UART.c.

◆ PBV_UART_Link_Data_TX()

void PBV_UART_Link_Data_TX ( PBV_Datatype_TX_t ptr)
Parameters
PBV_Datatype_TX_t*
Returns
void

links the data from the calling application to the UART TX object.

Definition at line 541 of file PBV_UART.c.

◆ PBV_UART_Receive_from_GUI()

uint8_t PBV_UART_Receive_from_GUI ( )
Returns
int (1: ready to receive, 2: Receiving, 0: Received successfully, -1: CRC error)

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.

+ Here is the call graph for this function:

◆ PBV_UART_Reinit()

void PBV_UART_Reinit ( PBV_Datatype_TX_t ptr)
Parameters
PBV_Datatype_TX_t
Returns

reinitializes the UART object with new protocol id.

Definition at line 526 of file PBV_UART.c.

◆ PBV_UART_Transmit_Ascii_to_GUI()

uint8_t PBV_UART_Transmit_Ascii_to_GUI ( )
Returns
int

implements the state machine for UART ascii TX

Definition at line 320 of file PBV_UART.c.

◆ PBV_UART_Transmit_to_GUI()

uint8_t PBV_UART_Transmit_to_GUI ( )
Returns
int

implements the state machine for UART numerical TX

Definition at line 423 of file PBV_UART.c.

Variable Documentation

◆ pbvUartObjectAscii

UART_MSG_TX_OBJ_t pbvUartObjectAscii

Definition at line 154 of file PBV_UART.c.

◆ pbvUartObjectRx

UART_MSG_RX_OBJ_t pbvUartObjectRx

Definition at line 148 of file PBV_UART.c.

◆ pbvUartObjectTx

UART_MSG_TX_OBJ_t pbvUartObjectTx

Definition at line 142 of file PBV_UART.c.