Bar Logo 4kW dsPIC33C PSFB DC-DC DA (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
app_PBV_interface.c
1
2#include "config/comms_config.h"
3#include "app_PBV_interface.h"
4#include "app_PBV_config.h"
5
6
15
16
25
26
27
36
37
45
46
57void PBV_Change_from_Sixteen_to_Eight(uint16_t * sixteenPtr, uint8_t * eightPtr, uint16_t length)
58{
59 for (uint16_t i = 0, j = 0; i < (length * 2); i = i + 2, j++)
60 {
61 eightPtr[i] = (uint8_t) (sixteenPtr[j] >> 8);
62 eightPtr[i + 1] = (uint8_t) (sixteenPtr[j] & 0x00FF);
63 }
64}
65
66
76void PBV_Change_from_Eight_to_Sixteen(uint8_t * eightPtr, uint16_t * sixteenPtr, uint16_t length)
77{
78 uint8_t length_odd = (uint8_t) (length & 0x01);
79 uint16_t length_t;
80
81 uint16_t i, j;
82
83 if (length_odd)
84 length_t = (length & 0xFFFE);
85 else
86 length_t = length;
87
88 for (i = 0, j = 0; i < length_t; i = i + 2, j++)
89 {
90 sixteenPtr[j] = ((uint16_t) (eightPtr[i] << 8)) + eightPtr[i + 1];
91 }
92 if (length_odd)
93 sixteenPtr[++j] = ((uint16_t) (eightPtr[length-1] << 8));
94
95}
96
97
110void app_PBV_Init(PBV_Datatype_TX_t * Board_To_PBV, PBV_Datatype_TX_t * Board_To_PBVAscii, PBV_Datatype_RX_t *PBV_To_Board)
111{
112 App_System_To_PBV_Ptr = Board_To_PBV;
113 App_System_To_PBV_ASCII_Ptr = Board_To_PBVAscii;
114 App_PBV_To_System_Ptr = PBV_To_Board;
115
117}
118
119
129void app_PBV_Re_Init(PBV_Datatype_TX_t * ptr)
130{
131 // experiment with reassigning the protocol IDs in runtime to CAN objects.
132 // or changing DLCs...
134}
135
136
146void app_Receive_From_PBV(PBV_Datatype_RX_t * ptr)
147{
150}
151
152
165{
167 ||
169 ||
170 ptr->PBV_Message_State == PBV_MESSAGE_TX_ERROR // TODO: for CAN. If the tx fails in arbitration. Introduce a RETRY mechanism.
171 )
172 {
175 }
176}
177
178
188int app_Read_Received_From_PBV(PBV_Datatype_RX_t * ptr)
189{
190 return APP_PBV_FUNCS.linkDataRX(ptr);
191}
192
193
229
230
241{
242#if PBV_CANFD
243 app_PBV_Task();
244#endif
245}
246
247
258{
259#if PBV_UART
260 app_PBV_Task();
261#endif
262}
static PBV_Datatype_RX_t * App_PBV_To_System_Ptr
void app_PBV_Task_10ms()
task to be executed every 10ms
void app_PBV_Task_100us()
Task to be executed every 100 us.
const APP_PBV_INTF_API_t APP_PBV_FUNCS
< Includes
static PBV_Datatype_TX_t * App_System_To_PBV_Ptr
static PBV_Datatype_TX_t * App_System_To_PBV_ASCII_Ptr
void app_Send_To_PBV(PBV_Datatype_TX_t *ptr)
static void app_PBV_Task(void)
@ 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.
PBV_Intf_Init_t init
PBV_Intf_Link_Data_TX_t linkDataTX
PBV_Intf_Transmit_Ascii_to_GUI_t txGuiAscii
PBV_Intf_Reinit_t reinit
PBV_Intf_Link_Data_RX_t linkDataRX
PBV_Intf_Transmit_to_GUI_t txGui
PBV_Intf_Receive_from_GUI_t rxGui
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.