Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
PBV_interface.c
1
3#include "config/comms_config.h"
4#include "PBV_interface.h"
5#include "PBV_config.h"
6
7
13
14
20
21
22
28
29
34static PBV_Datatype_TX_t * appSystemToPbvAsciiPtr;
35
36
46void PBV_Change_from_Sixteen_to_Eight(uint16_t * sixteenPtr, uint8_t * eightPtr, uint16_t length)
47{
48 for (uint16_t i = 0, j = 0; i < (length * 2); i = i + 2, j++)
49 {
50 eightPtr[i] = (uint8_t) (sixteenPtr[j] >> 8);
51 eightPtr[i + 1] = (uint8_t) (sixteenPtr[j] & 0x00FF);
52 }
53}
54
55
64void PBV_Change_from_Eight_to_Sixteen(uint8_t * eightPtr, uint16_t * sixteenPtr, uint16_t length)
65{
66 uint8_t length_odd = (uint8_t) (length & 0x01);
67 uint16_t length_t;
68
69 uint16_t i, j;
70
71 if (length_odd)
72 {
73 length_t = (length & 0xFFFE);
74 }
75 else
76 {
77 length_t = length;
78 }
79
80 for (i = 0, j = 0; i < length_t; i = i + 2, j++)
81 {
82 sixteenPtr[j] = ((uint16_t) (eightPtr[i] << 8)) + eightPtr[i + 1];
83 }
84 if (length_odd)
85 {
86 sixteenPtr[++j] = ((uint16_t) (eightPtr[length-1] << 8));
87 }
88
89}
90
91
103void App_PBV_Init(PBV_Datatype_TX_t * boardToPbv, PBV_Datatype_TX_t * boardToPpvAscii, PBV_Datatype_RX_t *pbvToBoard)
104{
105 appSystemToPbvPtr = boardToPbv;
106 appSystemToPbvAsciiPtr = boardToPpvAscii;
107 appPbvToSystemPtr = pbvToBoard;
108
109 appPbvFuncs.init(appSystemToPbvPtr, appSystemToPbvAsciiPtr, pbvToBoard);
110}
111
112
123{
124 // experiment with reassigning the protocol IDs in runtime to CAN objects.
125 // or changing DLCs...
126 appPbvFuncs.reinit(ptr);
127}
128
129
146
147
159{
161 ||
163 ||
164 ptr->PBV_Message_State == PBV_MESSAGE_TX_ERROR // TODO: for CAN. If the tx fails in arbitration. Introduce a RETRY mechanism.
165 )
166 {
169 }
170}
171
172
186
187
219
220
230{
231#if PBV_CANFD
232 App_PBV_Task();
233#endif
234}
235
236
245{
246#if PBV_UART
247 App_PBV_Task();
248#endif
249}
void App_PBV_Task_100us()
Task to be executed every 100 us.
void PBV_Change_from_Sixteen_to_Eight(uint16_t *sixteenPtr, uint8_t *eightPtr, uint16_t length)
This function changes 16 bit data to 8 bit data.
void App_PBV_Init(PBV_Datatype_TX_t *boardToPbv, PBV_Datatype_TX_t *boardToPpvAscii, PBV_Datatype_RX_t *pbvToBoard)
Initializes the PBV init, by linking the application object pointers from the application to CAN or U...
void App_PBV_Task_10ms()
task to be executed every 10ms
void App_Send_To_PBV(PBV_Datatype_TX_t *ptr)
This function links the data from application object to the CAN or UART object and This function ch...
const APP_PBV_INTF_API_t appPbvFuncs
< Includes
Definition PBV_config.c:26
static PBV_Datatype_RX_t * appPbvToSystemPtr
pointer to the PBV_Datatype_RX_t object that will be passed from the application.
static void App_PBV_Task(void)
Main application task for Power Board Visualizer.
int App_Read_Received_From_PBV(PBV_Datatype_RX_t *ptr)
This function links the data received by CAN or UART objects to the application object.
static PBV_Datatype_TX_t * appSystemToPbvPtr
pointer to the PBV_Datatype_TX_t object that will be passed from the application.
void App_PBV_Re_Init(PBV_Datatype_TX_t *ptr)
Reinitializes the objects if any parameters( ID, length, etc) are to be changed to the CAN or UART ob...
void App_Receive_From_PBV(PBV_Datatype_RX_t *ptr)
This function changes the state of the application object. this acts as a trigger for the periodic ta...
void PBV_Change_from_Eight_to_Sixteen(uint8_t *eightPtr, uint16_t *sixteenPtr, uint16_t length)
This function changes 8 bit data to sixteen bit data.
@ PBV_MESSAGE_READY_TO_RECEIVE
Message Reception triggered.
@ PBV_STATE_RECEIVING
Message beinf received.
@ PBV_MESSAGE_TRANSMITTED
Message transmitted. successful transmit.
@ PBV_MESSAGE_INIT
Init State. Only Send Messages in this State
@ PBV_MESSAGE_TX_ERROR
if some error happens. unsuccessful transmit
@ PBV_MESSAGE_TRANSMIT_START
Start Transmitting message.
@ PBV_MESSAGE_TRANSMITTING
Transmitting Message.
structure of API function pointers.
Definition PBV_config.h:89
PBV_Intf_Init_t init
Definition PBV_config.h:90
PBV_Intf_Link_Data_TX_t linkDataTX
Definition PBV_config.h:95
PBV_Intf_Transmit_Ascii_to_GUI_t txGuiAscii
Definition PBV_config.h:93
PBV_Intf_Reinit_t reinit
Definition PBV_config.h:94
PBV_Intf_Link_Data_RX_t linkDataRX
Definition PBV_config.h:96
PBV_Intf_Transmit_to_GUI_t txGui
Definition PBV_config.h:92
PBV_Intf_Receive_from_GUI_t rxGui
Definition PBV_config.h:91
PBV_MESSAGE_TX_STATE_t PBV_Message_State
State of the TX object.
PBV_MESSAGE_RX_STATE_t PBV_Message_State
State of the received message.