Bar Logo 4kW dsPIC33C PSFB DC-DC DA (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
app_PBV_CAN.c
1/*
2 * @file app_PBV_CAN.c
3 * @author M70027
4 * @ingroup PBV_CAN
5 * @brief Power Board Visualizer CAN interface
6 */
7
8// includes
9#include "app_PBV_CAN.h"
10// MCC header files
11#include "../mcc_generated_files/can/can1.h"
12
14typedef struct CAN_MSG_OBJ CAN_MSG_OBJ_t;
15
16
21
22
27
28
33
34
45void PBV_CAN_Init(PBV_Datatype_TX_t* Board_To_PBV, PBV_Datatype_TX_t* Board_To_PBVAscii, PBV_Datatype_RX_t *PBV_To_Board)
46{
53
54 PBV_CAN_Object_ASCII.msgId = Board_To_PBVAscii->PBV_Protcol_ID;
60}
61
62
70{
72 {
73 if (CAN1_Receive(&PBV_CAN_Object_RX) == true)
74 return 0;
75 }
76 return 1;
77}
78
79
93
94
109
119 {
121 switch (ptr->Length)
122 {
123 case 0:
125 break;
126 case 1:
128 break;
129 case 2:
131 break;
132 case 3:
134 break;
135 case 4:
137 break;
138 case 5:
140 break;
141 case 6:
143 break;
144 case 7:
146 break;
147 case 8:
149 break;
150 case 9 ... 12:
152 break;
153 case 13 ... 16:
155 break;
156 case 17 ... 20:
158 break;
159 case 21 ... 24:
161 break;
162 case 25 ... 32:
164 break;
165 case 33 ... 48:
167 break;
168 case 49 ... 64:
170 break;
171 default:
173 break;
174 }
175 }
176 else
177 {
179 switch (ptr->Length)
180 {
181 case 0:
183 break;
184 case 1:
186 break;
187 case 2:
189 break;
190 case 3:
192 break;
193 case 4:
195 break;
196 case 5:
198 break;
199 case 6:
201 break;
202 case 7:
204 break;
205 case 8:
207 break;
208 case 9 ... 12:
210 break;
211 case 13 ... 16:
213 break;
214 case 17 ... 20:
216 break;
217 case 21 ... 24:
219 break;
220 case 25 ... 32:
222 break;
223 case 33 ... 48:
225 break;
226 case 49 ... 64:
228 break;
229 default:
231 break;
232 }
233 }
234}
235
236
249
250
259 if (ptr->PBV_Message_State == 0){
263 {
264 case DLC_0:
265 ptr->Length = 0;
266 break;
267 case DLC_1:
268 ptr->Length = 1;
269 break;
270 case DLC_2:
271 ptr->Length = 2;
272 break;
273 case DLC_3:
274 ptr->Length = 3;
275 break;
276 case DLC_4:
277 ptr->Length = 4;
278 break;
279 case DLC_5:
280 ptr->Length = 5;
281 break;
282 case DLC_6:
283 ptr->Length = 6;
284 break;
285 case DLC_7:
286 ptr->Length = 7;
287 break;
288 case DLC_8:
289 ptr->Length = 8;
290 break;
291 case DLC_12:
292 ptr->Length = 12;
293 break;
294 case DLC_16:
295 ptr->Length = 16;
296 break;
297 case DLC_20:
298 ptr->Length = 20;
299 break;
300 case DLC_24:
301 ptr->Length = 24;
302 break;
303 case DLC_32:
304 ptr->Length = 32;
305 break;
306 case DLC_48:
307 ptr->Length = 48;
308 break;
309 case DLC_64:
310 ptr->Length = 64;
311 break;
312 default:
313 ptr->Length = 64;
314 break;
315 }
316 }
317}
@ CAN1_TXQ
Definition can1.h:217
@ DLC_24
Definition can_types.h:194
@ DLC_0
Definition can_types.h:179
@ DLC_5
Definition can_types.h:184
@ DLC_20
Definition can_types.h:193
@ DLC_2
Definition can_types.h:181
@ DLC_12
Definition can_types.h:191
@ DLC_8
Definition can_types.h:187
@ DLC_16
Definition can_types.h:192
@ DLC_1
Definition can_types.h:180
@ DLC_48
Definition can_types.h:196
@ DLC_3
Definition can_types.h:182
@ DLC_4
Definition can_types.h:183
@ DLC_64
Definition can_types.h:197
@ DLC_6
Definition can_types.h:185
@ DLC_32
Definition can_types.h:195
@ DLC_7
Definition can_types.h:186
@ CAN_FRAME_STD
Definition can_types.h:92
@ CAN_FRAME_EXT
Definition can_types.h:93
@ CAN_FRAME_DATA
Definition can_types.h:103
@ CAN_FD_FORMAT
Definition can_types.h:115
@ CAN_BRS_MODE
Definition can_types.h:82
@ CAN_TX_MSG_REQUEST_SUCCESS
Definition can_types.h:125
void PBV_CAN_Link_Data_TX(PBV_Datatype_TX_t *ptr)
Links the data from TX PBV datatype to CAN TX object.
CAN_MSG_OBJ_t PBV_CAN_Object_TX
CAN object for Numeric TX. Initialized by PBV_CAN_Init()
Definition app_PBV_CAN.c:20
uint8_t PBV_CAN_Receive_from_GUI()
Definition app_PBV_CAN.c:69
void PBV_CAN_Link_Data_RX(PBV_Datatype_RX_t *ptr)
links the received data to the application data structure
CAN_MSG_OBJ_t PBV_CAN_Object_ASCII
CAN object for ascii TX. Initialized by PBV_CAN_Init()
Definition app_PBV_CAN.c:32
void PBV_CAN_Reinit(PBV_Datatype_TX_t *ptr)
reinitializes the can object with new can id.
uint8_t PBV_CAN_Transmit_Ascii_to_GUI()
Definition app_PBV_CAN.c:86
CAN_MSG_OBJ_t PBV_CAN_Object_RX
CAN object for numeric RX. Does not have to be initialized.
Definition app_PBV_CAN.c:26
uint8_t PBV_CAN_Transmit_to_GUI()
transmits the numerical msg to PBV
@ PBV_SIGNAL_MODE
Object will transmit/receive signals.
@ PBV_MESSAGE_TRANSMITTED
Message transmitted. successful transmit.
@ PBV_MESSAGE_TX_ERROR
if some error happens. unsuccessful transmit
bool CAN1_Receive(struct CAN_MSG_OBJ *rxCanMsg)
Reads the received single message object.
Definition can1.c:703
uint8_t CAN1_ReceivedMessageCountGet(void)
Returns the number of CAN messages received in all the FIFO.
Definition can1.c:854
enum CAN_TX_MSG_REQUEST_STATUS CAN1_Transmit(const enum CAN1_TX_FIFO_CHANNELS fifoChannel, struct CAN_MSG_OBJ *txCanMsg)
Writes the CAN message object to specified transmit FIFO channel.
Definition can1.c:788
unsigned int frameType
Definition can_types.h:55
unsigned int formatType
Definition can_types.h:57
unsigned int dlc
Definition can_types.h:56
unsigned int idType
Definition can_types.h:54
unsigned int brs
Definition can_types.h:58
This data structure used to configure the CAN FD message object.
Definition can_types.h:68
struct CAN_MSG_FIELD field
Definition can_types.h:70
uint32_t msgId
Definition can_types.h:69
uint8_t * data
Definition can_types.h:71
uint32_t PBV_Protcol_ID
Protocol ID.
uint8_t * Data_Buffer
Pointer to the data to be transmitted.
enum PBV_SIGNAL_ASCII_MODE PBV_Signal_Ascii
Object will transmit Signals or ASCII.
uint16_t Length
Length of transmitted message in Bytes.
uint32_t PBV_Protcol_ID
Protocol ID of the received message.
PBV_MESSAGE_RX_STATE_t PBV_Message_State
State of the received message.
uint8_t * Data_Buffer
Received Data pointer.
uint16_t Length
Length of received message in Bytes.