NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
can_driver.h
Go to the documentation of this file.
1
8#ifndef INC_CAN_DRIVER_H_
9#define INC_CAN_DRIVER_H_
10
11struct struct_s_BOARD;
12
13typedef struct struct_s_BOARD s_BOARD;
14
15#include "applicfg.h"
16#include "can.h"
17
24 char * busname;
25 char * baudrate;
26};
27
28#ifndef DLL_CALL
29#define DLL_CALL(funcname) funcname##_driver
30#endif
31
32#ifndef FCT_PTR_INIT
33#define FCT_PTR_INIT
34#endif
35
36
37UNS8 DLL_CALL(canReceive)(CAN_HANDLE, Message *)FCT_PTR_INIT;
38UNS8 DLL_CALL(canSend)(CAN_HANDLE, Message *)FCT_PTR_INIT;
39CAN_HANDLE DLL_CALL(canOpen)(s_BOARD *)FCT_PTR_INIT;
40int DLL_CALL(canClose)(CAN_HANDLE)FCT_PTR_INIT;
41UNS8 DLL_CALL(canChangeBaudRate)(CAN_HANDLE, char *)FCT_PTR_INIT;
42
43#if defined DEBUG_MSG_CONSOLE_ON || defined NEED_PRINT_MESSAGE
44#include "def.h"
45
46#define _P(fc) case fc: MSG(#fc" ");break;
47
48static inline void print_message(Message *m)
49{
50 int i;
51 UNS8 fc;
52 MSG("id:%02x ", m->cob_id & 0x7F);
53 fc = m->cob_id >> 7;
54 switch(fc)
55 {
56 case SYNC:
57 if(m->cob_id == 0x080)
58 MSG("SYNC ");
59 else
60 MSG("EMCY ");
61 break;
62#ifdef CO_ENABLE_LSS
63 case LSS:
64 if(m->cob_id == 0x7E5)
65 MSG("MLSS ");
66 else
67 MSG("SLSS ");
68 break;
69#endif
70 _P(TIME_STAMP)
71 _P(PDO1tx)
72 _P(PDO1rx)
73 _P(PDO2tx)
74 _P(PDO2rx)
75 _P(PDO3tx)
76 _P(PDO3rx)
77 _P(PDO4tx)
78 _P(PDO4rx)
79 _P(SDOtx)
80 _P(SDOrx)
81 _P(NODE_GUARD)
82 _P(NMT)
83 }
84 if( fc == SDOtx)
85 {
86 switch(m->data[0] >> 5)
87 {
88 /* scs: server command specifier */
89 _P(UPLOAD_SEGMENT_RESPONSE)
90 _P(DOWNLOAD_SEGMENT_RESPONSE)
91 _P(INITIATE_DOWNLOAD_RESPONSE)
92 _P(INITIATE_UPLOAD_RESPONSE)
93 _P(ABORT_TRANSFER_REQUEST)
94 }
95 }else if( fc == SDOrx)
96 {
97 switch(m->data[0] >> 5)
98 {
99 /* ccs: client command specifier */
100 _P(DOWNLOAD_SEGMENT_REQUEST)
101 _P(INITIATE_DOWNLOAD_REQUEST)
102 _P(INITIATE_UPLOAD_REQUEST)
103 _P(UPLOAD_SEGMENT_REQUEST)
104 _P(ABORT_TRANSFER_REQUEST)
105 }
106 }
107 MSG(" rtr:%d", m->rtr);
108 MSG(" len:%d", m->len);
109 for (i = 0 ; i < m->len ; i++)
110 MSG(" %02x", m->data[i]);
111 MSG("\n");
112}
113#endif /* defined DEBUG_MSG_CONSOLE_ON || defined NEED_PRINT_MESSAGE */
114
115#endif /* INC_CAN_DRIVER_H_ */
#define UNS8
Unsigned int8 representation in CANFest.
Definition applicfg.h:25
Definition can.h:13
UNS16 cob_id
Definition can.h:14
UNS8 data[8]
Definition can.h:17
UNS8 rtr
Definition can.h:15
UNS8 len
Definition can.h:16
The CAN board configuration.
Definition can_driver.h:23
char * baudrate
Definition can_driver.h:25