|  | Dual Active Bridge Development Board (Part-No. ) |
Content |  |  |  |  |  |

Loading...
Searching...
No Matches
PBV_UART.c
1
2
3/*
4 * @file app_PBV_UART.c
5 * @ingroup PBV_UART
6 * @brief Power Board Visualizer UART interface
7 */
8
9//includes
10#include <stdint.h>
11#include <stdbool.h>
12
13#include "PBV_UART.h"
14// MCC header files
15
16#include "uart/uart1.h"
17#include "crc/crc.h"
18
19
24#define PBV_CRC_POLYNOM 0x8005
25
26
30#define PBV_CRC_POLYNOM_REV 0xA001
31
32
36#define PBV_ReadyToSend UART1_IsTxReady
37
38
42#define PBV_Write UART1_Write
43
44
48#define PBV_IsRxReady UART1_IsRxReady
49
50
54#define PBV_Read UART1_Read
55
56
60#define PBV_START_OF_FRAME 0x55
61
62
66#define PBV_END_OF_FRAME 0x0d
67
68
74#define RCV_WAIT_FOR_STARTBYTE 0
75#define RCV_READ_ID_HIGHBYTE 1
76#define RCV_READ_ID_LOWBYTE 2
77#define RCV_READ_LENGTH_HIGHBYTE 3
78#define RCV_READ_LENGTH_LOWBYTE 4
79#define RCV_READ_DATA 5
80#define RCV_READ_CRC_HIGHBYTE 6
81#define RCV_READ_CRC_LOWBYTE 7
82#define RCV_READ_EOF 8
83#define RCV_MESSAGE_RECEIVED 9
86
91#define PBV_RCV_DATABUFFER_SIZE 64 // MAX..
92
93
98#define PBV_HEADER_SIZE 5
99
100
104 typedef struct UART_MSG_RX_OBJ
105{
106 uint8_t UART_Frame_State;
107 uint8_t Length_in_Bytes;
108 uint16_t Protocol_ID;
109 uint16_t Offset;
110 uint16_t CRC;
111 uint8_t PBV_Header[PBV_HEADER_SIZE];
112 uint8_t data[PBV_RCV_DATABUFFER_SIZE];
113} UART_MSG_RX_OBJ_t;
114
115
119 typedef struct UART_MSG_TX_OBJ
120{
121 uint8_t UART_Frame_State;
122 uint8_t Length_in_Bytes;
123 uint16_t Protocol_ID;
124 uint16_t Offset;
125 uint16_t CRC;
126 uint8_t PBV_Header[PBV_HEADER_SIZE];
127 uint8_t * data;
128} UART_MSG_TX_OBJ_t;
129
130uint32_t PBV_calculated_CRC = 0;
131
132static bool uartActiveTx;
133static bool uartActiveTxAscii;
134
135// private function declaration
136uint16_t PBV_Calculate_CRC(uint8_t *message, uint16_t length);
137
138
142 UART_MSG_TX_OBJ_t pbvUartObjectTx;
143
144
148 UART_MSG_RX_OBJ_t pbvUartObjectRx;
149
150
154 UART_MSG_TX_OBJ_t pbvUartObjectAscii;
155
156
165 void PBV_UART_Init(PBV_Datatype_TX_t * boardToPbv, PBV_Datatype_TX_t * boardToPbvAscii, PBV_Datatype_RX_t * pbvToBoard)
166{
167 pbvUartObjectTx.Protocol_ID = boardToPbv->PBV_Protcol_ID;
168 pbvUartObjectTx.Offset = 0;
169 pbvUartObjectTx.Length_in_Bytes = boardToPbv->Length;
170 pbvUartObjectTx.data = boardToPbv->Data_Buffer;
171
172 pbvUartObjectRx.Offset = 0;
173
174 pbvUartObjectAscii.Protocol_ID = boardToPbvAscii->PBV_Protcol_ID;
175 pbvUartObjectAscii.Offset = 0;
176 pbvUartObjectAscii.Length_in_Bytes = boardToPbvAscii->Length;
177 pbvUartObjectAscii.data = boardToPbvAscii->Data_Buffer;
178
179 uartActiveTx = false;
180 uartActiveTxAscii = false;
181}
182
183
189uint8_t PBV_UART_Receive_from_GUI()
190{
191 static uint16_t rcv_data_index = 0;
192 static uint16_t rcv_CRC = 0;
193 static uint16_t rcv_timeout = 0;
194 static uint8_t rcv_copy_for_CRC[PBV_RCV_DATABUFFER_SIZE + PBV_HEADER_SIZE];
195 uint8_t data;
196
197 while (1)
198 {
199 if (PBV_IsRxReady() == false)
200 {
201 if (++rcv_timeout >= 10000)
202 {
203 rcv_timeout = 0;
204 pbvUartObjectRx.UART_Frame_State = RCV_WAIT_FOR_STARTBYTE;
205 }
206 return PBV_MESSAGE_READY_TO_RECEIVE;
207 }
208 // ok, we have some data coming in, lets read and process
209 rcv_timeout = 0;
210 data = PBV_Read();
211 switch (pbvUartObjectRx.UART_Frame_State)
212 {
213 case RCV_WAIT_FOR_STARTBYTE:
214 if (data == PBV_START_OF_FRAME)
215 {
216 pbvUartObjectRx.UART_Frame_State = RCV_READ_ID_HIGHBYTE;
217 pbvUartObjectRx.Offset = 0;
218 pbvUartObjectRx.PBV_Header[pbvUartObjectRx.Offset] = data;
219 rcv_copy_for_CRC[rcv_data_index] = data; // for CRC
220 rcv_data_index++; // for CRC
221 pbvUartObjectRx.Offset++;
222 }
223 return PBV_STATE_RECEIVING;
224
225 case RCV_READ_ID_HIGHBYTE:
226 pbvUartObjectRx.Protocol_ID = data << 8;
227 pbvUartObjectRx.UART_Frame_State = RCV_READ_ID_LOWBYTE;
228 pbvUartObjectRx.PBV_Header[pbvUartObjectRx.Offset] = data;
229 rcv_copy_for_CRC[rcv_data_index] = data; // for CRC
230 rcv_data_index++; // for CRC
231 pbvUartObjectRx.Offset++;
232 return PBV_STATE_RECEIVING;
233
234 case RCV_READ_ID_LOWBYTE:
235 pbvUartObjectRx.Protocol_ID |= data;
236 pbvUartObjectRx.UART_Frame_State = RCV_READ_LENGTH_HIGHBYTE;
237 pbvUartObjectRx.PBV_Header[pbvUartObjectRx.Offset] = data;
238 rcv_copy_for_CRC[rcv_data_index] = data; // for CRC
239 rcv_data_index++; // for CRC
240 pbvUartObjectRx.Offset++;
241 return PBV_STATE_RECEIVING;
242
243 case RCV_READ_LENGTH_HIGHBYTE:
244 // clear CRC flag, for now, as the firmware doesn't support it
245 // With PBV version 2.0.0, dsPIC cannot receive
246 // messages from the GUI if this flag is not cleared
247 pbvUartObjectRx.PBV_Header[pbvUartObjectRx.Offset] = data;
248 rcv_copy_for_CRC[rcv_data_index] = data; // for CRC
249 rcv_data_index++; // for CRC
250 data = data & 0x7F; // clear bit 7 (CRC flag)
251 pbvUartObjectRx.Length_in_Bytes = data << 8;
252 pbvUartObjectRx.UART_Frame_State = RCV_READ_LENGTH_LOWBYTE;
253 pbvUartObjectRx.Offset++;
254 return PBV_STATE_RECEIVING;
255
256 case RCV_READ_LENGTH_LOWBYTE:
257 pbvUartObjectRx.PBV_Header[pbvUartObjectRx.Offset] = data;
258 pbvUartObjectRx.Length_in_Bytes |= data;
259 rcv_copy_for_CRC[rcv_data_index] = data; // for CRC
260 rcv_data_index++; // for CRC
261 pbvUartObjectRx.UART_Frame_State = RCV_READ_DATA;
262 pbvUartObjectRx.Offset = 0;
263 return PBV_STATE_RECEIVING;
264
265 case RCV_READ_DATA:
266 if (pbvUartObjectRx.Offset < (PBV_RCV_DATABUFFER_SIZE + PBV_HEADER_SIZE)) // MAX
267 {
268 pbvUartObjectRx.data[pbvUartObjectRx.Offset] = data;
269 pbvUartObjectRx.Offset++;
270
271 rcv_copy_for_CRC[rcv_data_index] = data; // for CRC
272 rcv_data_index++; // for CRC
273 }
274 if (pbvUartObjectRx.Offset >= pbvUartObjectRx.Length_in_Bytes) //are we finished receiving data???
275 {
276 pbvUartObjectRx.UART_Frame_State = RCV_READ_CRC_HIGHBYTE;
277 }
278 return PBV_STATE_RECEIVING;
279
280 case RCV_READ_CRC_HIGHBYTE:
281 rcv_CRC = data << 8;
282 pbvUartObjectRx.UART_Frame_State = RCV_READ_CRC_LOWBYTE;
283 return PBV_STATE_RECEIVING;
284
285 case RCV_READ_CRC_LOWBYTE:
286 rcv_CRC |= data;
287 pbvUartObjectRx.UART_Frame_State = RCV_READ_EOF;
288 return PBV_STATE_RECEIVING;
289
290 case RCV_READ_EOF:
291 if (data == 0x0d)
292 {
294 PBV_calculated_CRC = PBV_Calculate_CRC(rcv_copy_for_CRC, pbvUartObjectRx.Length_in_Bytes + PBV_HEADER_SIZE);
295 if (PBV_calculated_CRC == rcv_CRC)
296 {
297 rcv_data_index = 0;
298 rcv_CRC = 0;
299 PBV_calculated_CRC = 0;
300 pbvUartObjectRx.UART_Frame_State = RCV_MESSAGE_RECEIVED;
301 return PBV_MESSAGE_RECEIVED;
302 }
303 else {
304 rcv_data_index = 0; //for CRC
305 return PBV_MESSAGE_RX_ERROR;
306 }
307 }
308 default:
309 break;
310 }
311 }
312}
313
314
320uint8_t PBV_UART_Transmit_Ascii_to_GUI()
321{
322 uint8_t retval = PBV_MESSAGE_TX_ERROR;
323
324 if (uartActiveTx == true)
325 {
326 retval = PBV_MESSAGE_TX_ERROR;
327 }
328 else
329 {
330 switch (pbvUartObjectAscii.UART_Frame_State)
331 {
332 case 0:
333 pbvUartObjectAscii.PBV_Header[0] = PBV_START_OF_FRAME;
334 pbvUartObjectAscii.PBV_Header[1] = pbvUartObjectAscii.Protocol_ID >> 8;
335 pbvUartObjectAscii.PBV_Header[2] = pbvUartObjectAscii.Protocol_ID & 0xff;
336 pbvUartObjectAscii.PBV_Header[3] = pbvUartObjectAscii.Length_in_Bytes >> 8;
337 pbvUartObjectAscii.PBV_Header[4] = pbvUartObjectAscii.Length_in_Bytes & 0xff;
338 pbvUartObjectAscii.Offset = 0;
339 pbvUartObjectAscii.UART_Frame_State = 1;
340 uartActiveTxAscii = true;
341 retval = PBV_MESSAGE_TRANSMITTING;
342 break;
343
344 case 1: //transfer header
345 if (PBV_ReadyToSend())// && (MsCounter_++ > 1)) //@ftx
346 {
347 uint8_t temp = pbvUartObjectAscii.PBV_Header[pbvUartObjectAscii.Offset];
348 PBV_Write(temp);
349 pbvUartObjectAscii.Offset++;
350 if (pbvUartObjectAscii.Offset > 4)
351 {
352 pbvUartObjectAscii.Offset = 0;
353 pbvUartObjectAscii.UART_Frame_State = 2;
354 retval = PBV_MESSAGE_TRANSMITTING; // Why is this here?
355 }
356 }
357 else
358 {
359 retval = PBV_MESSAGE_TRANSMITTING;
360 }
361 break;
362
363 case 2: //transfer data
364 if (PBV_ReadyToSend())// && (MsCounter_++ > 1)) //@ftx
365 {
366 PBV_Write(pbvUartObjectAscii.data[pbvUartObjectAscii.Offset]);
367 pbvUartObjectAscii.Offset++;
368 if (pbvUartObjectAscii.Offset >= pbvUartObjectAscii.Length_in_Bytes)
369 {
370 pbvUartObjectAscii.UART_Frame_State = 3;
371 pbvUartObjectAscii.Offset = 0;
372 retval = PBV_MESSAGE_TRANSMITTING;
373 }
374 }
375 else
376 {
377 retval = PBV_MESSAGE_TRANSMITTING;
378 }
379 break;
380
381 case 3: //calculate CRC make end header
382 //IMPORTANT calculate crc before reusing PBV_HEADER
383 pbvUartObjectAscii.PBV_Header[0] = 0; //
384 pbvUartObjectAscii.PBV_Header[1] = 0; //add crc
385 pbvUartObjectAscii.PBV_Header[2] = PBV_END_OF_FRAME;
386 pbvUartObjectAscii.UART_Frame_State = 4;
387 retval = PBV_MESSAGE_TRANSMITTING;
388 break;
389
390 case 4: //transfer header
391 if (PBV_ReadyToSend())
392 {
393 PBV_Write(pbvUartObjectAscii.PBV_Header[pbvUartObjectAscii.Offset]);
394 pbvUartObjectAscii.Offset++;
395 if (pbvUartObjectAscii.Offset >= 3)
396 {
397 pbvUartObjectAscii.UART_Frame_State = 0;
398 pbvUartObjectAscii.Offset = 0;
399 uartActiveTxAscii = false;
400 retval = PBV_MESSAGE_TRANSMITTED;
401 }
402 }
403 else
404 {
405 retval = PBV_MESSAGE_TRANSMITTING;
406 }
407 break;
408
409 default:
410 retval = PBV_MESSAGE_TRANSMITTING;
411 break;
412 }
413 }
414 return retval;
415}
416
417
423uint8_t PBV_UART_Transmit_to_GUI()
424{
425 uint8_t retval = PBV_MESSAGE_TX_ERROR;
426 if (uartActiveTxAscii == true)
427 {
428 retval = PBV_MESSAGE_TX_ERROR;
429 }
430 else
431 {
432 switch (pbvUartObjectTx.UART_Frame_State)
433 {
434 case 0:
435 pbvUartObjectTx.PBV_Header[0] = PBV_START_OF_FRAME;
436 pbvUartObjectTx.PBV_Header[1] = pbvUartObjectTx.Protocol_ID >> 8;
437 pbvUartObjectTx.PBV_Header[2] = pbvUartObjectTx.Protocol_ID & 0xff;
438 pbvUartObjectTx.PBV_Header[3] = pbvUartObjectTx.Length_in_Bytes >> 8;
439 pbvUartObjectTx.PBV_Header[4] = pbvUartObjectTx.Length_in_Bytes & 0xff;
440 pbvUartObjectTx.Offset = 0;
441 pbvUartObjectTx.UART_Frame_State = 1;
442 uartActiveTx = true;
443 retval = PBV_MESSAGE_TRANSMITTING;
444 break;
445
446 case 1: //transfer header
447 if (PBV_ReadyToSend())// && (MsCounter_++ > 1)) //@ftx
448 {
449 uint16_t temp = pbvUartObjectTx.PBV_Header[pbvUartObjectTx.Offset];
450 PBV_Write(temp);
451 pbvUartObjectTx.Offset++;
452 if (pbvUartObjectTx.Offset > 4)
453 {
454 pbvUartObjectTx.Offset = 0;
455 pbvUartObjectTx.UART_Frame_State = 2;
456 retval = PBV_MESSAGE_TRANSMITTING;
457 }
458 }
459 else
460 {
461 retval = PBV_MESSAGE_TRANSMITTING;
462 }
463 break;
464
465 case 2: //transfer data
466 if (PBV_ReadyToSend())// && (MsCounter_++ > 1)) //@ftx
467 {
468 PBV_Write(pbvUartObjectTx.data[pbvUartObjectTx.Offset]);
469 pbvUartObjectTx.Offset++;
470 if (pbvUartObjectTx.Offset >= pbvUartObjectTx.Length_in_Bytes)
471 {
472 pbvUartObjectTx.UART_Frame_State = 3;
473 pbvUartObjectTx.Offset = 0;
474 retval = PBV_MESSAGE_TRANSMITTING;
475 }
476 }
477 else
478 {
479 retval = PBV_MESSAGE_TRANSMITTING;
480 }
481 break;
482
483 case 3: //calculate CRC make end header
484 //IMPORTANT calculate crc before reusing PBV_HEADER
485 pbvUartObjectTx.PBV_Header[0] = 0; //
486 pbvUartObjectTx.PBV_Header[1] = 0; //add crc
487 pbvUartObjectTx.PBV_Header[2] = PBV_END_OF_FRAME;
488 pbvUartObjectTx.UART_Frame_State = 4;
489 retval = PBV_MESSAGE_TRANSMITTING;
490 break;
491
492 case 4: //transfer header
493 if (PBV_ReadyToSend())
494 {
495 PBV_Write(pbvUartObjectTx.PBV_Header[pbvUartObjectTx.Offset]);
496 pbvUartObjectTx.Offset++;
497 if (pbvUartObjectTx.Offset >= 3)
498 {
499 pbvUartObjectTx.UART_Frame_State = 0;
500 pbvUartObjectTx.Offset = 0;
501 uartActiveTx = false;
502 retval = PBV_MESSAGE_TRANSMITTED;
503 }
504 }
505 else
506 {
507 retval = PBV_MESSAGE_TRANSMITTING;
508 }
509 break;
510
511 default:
512 retval = PBV_MESSAGE_TRANSMITTING;
513 break;
514 }
515 }
516 return (retval);
517}
518
519
526 void PBV_UART_Reinit(PBV_Datatype_TX_t * ptr)
527{
528 if (ptr->PBV_Signal_Ascii == PBV_SIGNAL_MODE)
529 pbvUartObjectTx.Protocol_ID = ptr->PBV_Protcol_ID;
530 else
531 pbvUartObjectAscii.Protocol_ID = ptr->PBV_Protcol_ID;
532}
533
534
541 void PBV_UART_Link_Data_TX(PBV_Datatype_TX_t * ptr)
542{
543 if (ptr->PBV_Signal_Ascii == PBV_SIGNAL_MODE)
544 {
545 pbvUartObjectTx.data = ptr->Data_Buffer;
546 pbvUartObjectTx.Length_in_Bytes = ptr->Length;
547 }
548 else
549 {
550 pbvUartObjectAscii.data = ptr->Data_Buffer;
551 pbvUartObjectTx.Length_in_Bytes = ptr->Length;
552 }
553}
554
555
562 void PBV_UART_Link_Data_RX(PBV_Datatype_RX_t * ptr)
563{
564 if (ptr->PBV_Message_State == PBV_MESSAGE_RECEIVED){
565 ptr->PBV_Protcol_ID = pbvUartObjectRx.Protocol_ID;
566 ptr->Data_Buffer = pbvUartObjectRx.data;
567 ptr->Length = pbvUartObjectRx.Length_in_Bytes;
568 }
569}
570
571
582uint16_t PBV_Calculate_CRC(uint8_t *message, uint16_t length)
583{
584 //CRC_Initialize();
585 uint8_t message_odd = (uint8_t) (length & 0x01);
586 uint16_t length_t = 0;
587 uint16_t i, j;
588 //uint16_t * message16bit;
589 uint32_t trycount = 0;
590 uint16_t resultCRC = 0;
591 uint16_t message16bit[PBV_RCV_DATABUFFER_SIZE];
592
593 //calCRCTEMP = 0; //
594
595 if (message_odd)
596 length_t = (length & 0xFFFE);
597 else
598 length_t = length;
599
600 for (i = 0, j = 0; i < length_t; i += 2, j++)
601 {
602 //*(message16bit + j) = (message[i + 1 ] << 8 ) | message[i] ;
603 message16bit[j] = (message[i + 1 ] << 8) | message[i];
604 }
605
606 CRC_CalculateBufferStart(message16bit, length_t);
607
608 while ((!CRC_CalculationIsDone()) && (trycount < 2000))
609 {
610 CRC_Tasks();
611 trycount++;
612 }
613
614 resultCRC = CRC_CalculationResultReverseGet();
615
616 if (message_odd)
617 {
618 resultCRC ^= message[length - 1];
619 for (i = 0; i < 8; ++i)
620 {
621 if (resultCRC & 0x0001)
622 {
623 resultCRC = (resultCRC >> 1)^ PBV_CRC_POLYNOM_REV;
624 }
625 else
626 {
627 resultCRC = (resultCRC >> 1);
628 }
629 }
630 }
631 // clearing shift registers.
632 CRCWDATL = 0x0;
633 CRCWDATH = 0x0;
634
635 return resultCRC;
636}
crc.h
This is the generated driver header file for the CRC driver.
uart1.h
This is the generated driver header file for the UART1 driver.
UART_MSG_TX_OBJ_t
struct UART_MSG_TX_OBJ UART_MSG_TX_OBJ_t
UART msg Transmit object.
pbvUartObjectAscii
UART_MSG_TX_OBJ_t pbvUartObjectAscii
UART object for ascii tx.
Definition PBV_UART.c:154
PBV_UART_Init
void PBV_UART_Init(PBV_Datatype_TX_t *boardToPbv, PBV_Datatype_TX_t *boardToPbvAscii, PBV_Datatype_RX_t *pbvToBoard)
initializes UART objects
Definition PBV_UART.c:165
RCV_READ_LENGTH_HIGHBYTE
#define RCV_READ_LENGTH_HIGHBYTE
Definition PBV_UART.c:77
PBV_UART_Reinit
void PBV_UART_Reinit(PBV_Datatype_TX_t *ptr)
reinitializes the UART object with new protocol id.
Definition PBV_UART.c:526
PBV_Calculate_CRC
uint16_t PBV_Calculate_CRC(uint8_t *message, uint16_t length)
Calculates the CRC on 16 bit stream of data.
Definition PBV_UART.c:582
RCV_READ_CRC_HIGHBYTE
#define RCV_READ_CRC_HIGHBYTE
Definition PBV_UART.c:80
UART_MSG_RX_OBJ_t
struct UART_MSG_RX_OBJ UART_MSG_RX_OBJ_t
UART msg receive object.
PBV_UART_Link_Data_RX
void PBV_UART_Link_Data_RX(PBV_Datatype_RX_t *ptr)
Links the data from received frame to the calling application
Definition PBV_UART.c:562
PBV_ReadyToSend
#define PBV_ReadyToSend
linking functions with UART mcc driver functions
Definition PBV_UART.c:36
RCV_MESSAGE_RECEIVED
#define RCV_MESSAGE_RECEIVED
Definition PBV_UART.c:83
PBV_END_OF_FRAME
#define PBV_END_OF_FRAME
Standard End of frame for PBV UART frames.
Definition PBV_UART.c:66
PBV_RCV_DATABUFFER_SIZE
#define PBV_RCV_DATABUFFER_SIZE
Maximum UART buffer. The max data that could be received is 64 bytes.
Definition PBV_UART.c:91
PBV_UART_Transmit_to_GUI
uint8_t PBV_UART_Transmit_to_GUI()
implements the state machine for UART numerical TX
Definition PBV_UART.c:423
pbvUartObjectTx
UART_MSG_TX_OBJ_t pbvUartObjectTx
UART object for numeric tx.
Definition PBV_UART.c:142
RCV_READ_DATA
#define RCV_READ_DATA
Definition PBV_UART.c:79
RCV_WAIT_FOR_STARTBYTE
#define RCV_WAIT_FOR_STARTBYTE
Internal STATES for RX State machine for PBV UART Frames.
Definition PBV_UART.c:74
PBV_UART_Transmit_Ascii_to_GUI
uint8_t PBV_UART_Transmit_Ascii_to_GUI()
implements the state machine for UART ascii TX
Definition PBV_UART.c:320
PBV_UART_Receive_from_GUI
uint8_t PBV_UART_Receive_from_GUI()
implements the state machine for UART Frame receiving from PBV.
Definition PBV_UART.c:189
RCV_READ_LENGTH_LOWBYTE
#define RCV_READ_LENGTH_LOWBYTE
Definition PBV_UART.c:78
PBV_HEADER_SIZE
#define PBV_HEADER_SIZE
Maximum UART buffer. The max data that could be received is 64 bytes.
Definition PBV_UART.c:98
PBV_UART_Link_Data_TX
void PBV_UART_Link_Data_TX(PBV_Datatype_TX_t *ptr)
links the data from the calling application to the UART TX object
Definition PBV_UART.c:541
RCV_READ_ID_HIGHBYTE
#define RCV_READ_ID_HIGHBYTE
Definition PBV_UART.c:75
RCV_READ_EOF
#define RCV_READ_EOF
Definition PBV_UART.c:82
PBV_CRC_POLYNOM_REV
#define PBV_CRC_POLYNOM_REV
Reversed polynomial. needed for odd byte in the data stream.
Definition PBV_UART.c:30
RCV_READ_CRC_LOWBYTE
#define RCV_READ_CRC_LOWBYTE
Definition PBV_UART.c:81
PBV_START_OF_FRAME
#define PBV_START_OF_FRAME
Standard Start of frame for PBV UART frames.
Definition PBV_UART.c:60
PBV_Read
#define PBV_Read
linking functions with UART mcc driver functions
Definition PBV_UART.c:54
RCV_READ_ID_LOWBYTE
#define RCV_READ_ID_LOWBYTE
Definition PBV_UART.c:76
PBV_Write
#define PBV_Write
linking functions with UART mcc driver functions
Definition PBV_UART.c:42
PBV_IsRxReady
#define PBV_IsRxReady
linking functions with UART mcc driver functions
Definition PBV_UART.c:48
pbvUartObjectRx
UART_MSG_RX_OBJ_t pbvUartObjectRx
UART object for numeric rx.
Definition PBV_UART.c:148
PBV_MESSAGE_READY_TO_RECEIVE
@ PBV_MESSAGE_READY_TO_RECEIVE
Message Reception triggered.
Definition PBV_interface.h:52
PBV_STATE_RECEIVING
@ PBV_STATE_RECEIVING
Message beinf received.
Definition PBV_interface.h:53
PBV_MESSAGE_RECEIVED
@ PBV_MESSAGE_RECEIVED
Message Received.
Definition PBV_interface.h:51
PBV_MESSAGE_RX_ERROR
@ PBV_MESSAGE_RX_ERROR
if some error happens (CRC ?)
Definition PBV_interface.h:54
PBV_SIGNAL_MODE
@ PBV_SIGNAL_MODE
Object will transmit/receive signals.
Definition PBV_interface.h:23
PBV_MESSAGE_TRANSMITTED
@ PBV_MESSAGE_TRANSMITTED
Message transmitted. successful transmit.
Definition PBV_interface.h:35
PBV_MESSAGE_TX_ERROR
@ PBV_MESSAGE_TX_ERROR
if some error happens. unsuccessful transmit
Definition PBV_interface.h:39
PBV_MESSAGE_TRANSMITTING
@ PBV_MESSAGE_TRANSMITTING
Transmitting Message.
Definition PBV_interface.h:38
CRC_CalculateBufferStart
void CRC_CalculateBufferStart(void *buffer, uint32_t sizeBytes)
CRC module calculation on a buffer in data space.
Definition crc.c:373
CRC_Tasks
void CRC_Tasks(void)
This function cycles through the CRC calculations. This function will load the CRC module FIFO with...
Definition crc.c:487
CRC_CalculationResultReverseGet
uint32_t CRC_CalculationResultReverseGet(void)
Gets the CRC reversed value of result if the calculation is done.
Definition crc.c:447
CRC_CalculationIsDone
bool CRC_CalculationIsDone(void)
Returns the CRC calculation complete status
Definition crc.c:420
PBV_Datatype_TX_t
Definition PBV_interface.h:75
PBV_Datatype_TX_t::PBV_Protcol_ID
uint32_t PBV_Protcol_ID
Protocol ID.
Definition PBV_interface.h:77
PBV_Datatype_TX_t::Data_Buffer
uint8_t * Data_Buffer
Pointer to the data to be transmitted.
Definition PBV_interface.h:80
PBV_Datatype_TX_t::PBV_Signal_Ascii
enum PBV_SIGNAL_ASCII_MODE PBV_Signal_Ascii
Object will transmit Signals or ASCII.
Definition PBV_interface.h:78
PBV_Datatype_TX_t::Length
uint16_t Length
Length of transmitted message in Bytes.
Definition PBV_interface.h:76
PBV_Datatype_RX_t
Definition PBV_interface.h:89
PBV_Datatype_RX_t::PBV_Protcol_ID
uint32_t PBV_Protcol_ID
Protocol ID of the received message.
Definition PBV_interface.h:91
PBV_Datatype_RX_t::PBV_Message_State
PBV_MESSAGE_RX_STATE_t PBV_Message_State
State of the received message.
Definition PBV_interface.h:93
PBV_Datatype_RX_t::Data_Buffer
uint8_t * Data_Buffer
Received Data pointer.
Definition PBV_interface.h:94
PBV_Datatype_RX_t::Length
uint16_t Length
Length of received message in Bytes.
Definition PBV_interface.h:90
UART_MSG_RX_OBJ
UART msg receive object.
Definition PBV_UART.c:105
UART_MSG_RX_OBJ::Length_in_Bytes
uint8_t Length_in_Bytes
UART bytes Received
Definition PBV_UART.c:107
UART_MSG_RX_OBJ::PBV_Header
uint8_t PBV_Header[PBV_HEADER_SIZE]
recived Header. 5bytes ( SOF + ID + Length)
Definition PBV_UART.c:111
UART_MSG_RX_OBJ::UART_Frame_State
uint8_t UART_Frame_State
UART Receive Frame states.
Definition PBV_UART.c:106
UART_MSG_RX_OBJ::Protocol_ID
uint16_t Protocol_ID
Received Frame ID.
Definition PBV_UART.c:108
UART_MSG_RX_OBJ::Offset
uint16_t Offset
Offset needed to store data in data
Definition PBV_UART.c:109
UART_MSG_RX_OBJ::data
uint8_t data[PBV_RCV_DATABUFFER_SIZE]
data buffer. linked by the calling application. STATIC(64) bytes for now.
Definition PBV_UART.c:112
UART_MSG_RX_OBJ::CRC
uint16_t CRC
received CRC
Definition PBV_UART.c:110
UART_MSG_TX_OBJ
UART msg Transmit object.
Definition PBV_UART.c:120
UART_MSG_TX_OBJ::Length_in_Bytes
uint8_t Length_in_Bytes
UART Bytes to be Transmitted.
Definition PBV_UART.c:122
UART_MSG_TX_OBJ::PBV_Header
uint8_t PBV_Header[PBV_HEADER_SIZE]
sent Header. 5bytes ( SOF + ID + Length)
Definition PBV_UART.c:126
UART_MSG_TX_OBJ::UART_Frame_State
uint8_t UART_Frame_State
UART Transmit Frame states.
Definition PBV_UART.c:121
UART_MSG_TX_OBJ::data
uint8_t * data
data buffer. linked by the calling application. STATIC(64) bytes for now.
Definition PBV_UART.c:127
UART_MSG_TX_OBJ::Protocol_ID
uint16_t Protocol_ID
Frame ID to be appended.
Definition PBV_UART.c:123
UART_MSG_TX_OBJ::Offset
uint16_t Offset
Offset needed for data transmission.
Definition PBV_UART.c:124
UART_MSG_TX_OBJ::CRC
uint16_t CRC
calculated CRC
Definition PBV_UART.c:125