lib_iso15765.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /*!
  2. @file iso15765_2.h
  3. @brief Header file of the ISO15765-2 library
  4. @t.odo -
  5. ---------------------------------------------------------------------------
  6. MIT License
  7. Copyright (c) 2020 Io. D (Devcoons.com)
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14. The above copyright notice and this permission notice shall be included in all
  15. copies or substantial portions of the Software.
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. SOFTWARE.
  23. */
  24. /******************************************************************************
  25. * Preprocessor Definitions & Macros
  26. ******************************************************************************/
  27. #ifndef DEVCOONS_ISO15765_2_H_
  28. #define DEVCOONS_ISO15765_2_H_
  29. #define I15765_MSG_SIZE 516 /* Max. size of the TP up to 4095 bytes */
  30. #define I15765_QUEUE_ELMS 32 /* No. of max incoming frames that the* reception buffer can hold */
  31. #define ARM_M4 1
  32. /* Alignment is required for Microcontrollers */
  33. #if defined(__clang__)
  34. #define ALIGNMENT __attribute__ ((aligned (4)))
  35. #elif defined(__GNUC__) || defined(__GNUG__)
  36. #define ALIGNMENT __attribute__ ((aligned (4)))
  37. #elif defined(_MSC_VER)
  38. #define ALIGNMENT __declspec(align(4))
  39. #endif
  40. #ifndef ISO_15675_UNUSED
  41. #define ISO_15675_UNUSED(x) ((void)(x))
  42. #endif
  43. /******************************************************************************
  44. * Includes
  45. ******************************************************************************/
  46. #include <stdlib.h>
  47. #include <stdint.h>
  48. #include "lib_iqueue.h"
  49. /******************************************************************************
  50. * Enumerations, structures & Variables
  51. ******************************************************************************/
  52. /* --- CANTP Mode - Frame Type (ref: ) ----------------- */
  53. #ifndef CBUS_FR_FORMAT
  54. #define CBUS_FR_FORMAT
  55. typedef enum
  56. {
  57. CBUS_FR_FRM_STD = 0x01, /* Standard CANBUS */
  58. CBUS_FR_FRM_FD = 0x02 /* FD CANBUS */
  59. } cbus_fr_format;
  60. #endif
  61. /* --- CANBus Mode [ID Type] (ref: iso15765-2 p.8) -------==---------------- */
  62. #ifndef CBUS_ID_TYPE
  63. #define CBUS_ID_TYPE
  64. typedef enum
  65. {
  66. CBUS_ID_T_STANDARD = 0x04U, /* 11bits CAN Identifier */
  67. CBUS_ID_T_EXTENDED = 0x08U /* 29bits CAN Identifier */
  68. } cbus_id_type;
  69. #endif
  70. /* --- CANBus Frame (ref: iso15765-2 p.) ----------------------------------- */
  71. #ifndef CANBUS_FRAME
  72. #define CANBUS_FRAME
  73. typedef struct
  74. {
  75. uint32_t id; /* CAN Frame Id */
  76. uint32_t id_type; /* CAN Frame Id Type `cbus_id_type` */
  77. uint16_t fr_format; /* CAN Frame Format `cbus_fr_format` */
  78. uint16_t dlc; /* Size of data */
  79. uint8_t dt[8]; /* Actual data of the frame */
  80. } canbus_frame_t;
  81. #endif
  82. /* --- CANTP Addressing Mode (ref: iso15765-2 p.28) ------------------------ */
  83. typedef enum
  84. {
  85. N_ADM_UNKN = 0x00, /* Not defined */
  86. N_ADM_NORMAL = 0x14, /* Normal Mode */
  87. N_ADM_FIXED = 0x28, /* Extended Mode */
  88. N_ADM_MIXED11 = 0x35, /* Mixed 11bits ID Mode */
  89. N_ADM_EXTENDED = 0x45, /* Fixed Mode */
  90. N_ADM_MIXED29 = 0x59, /* Mixed 29bits ID Mode */
  91. N_ADM_BMW = 0x60, /* BMW */
  92. } addr_md;
  93. /* --- Protocol Control Information Type (ref: iso15765-2 p.17) ------------ */
  94. typedef enum
  95. {
  96. N_PCI_T_SF = 0x00U, /* Single Frame µ¥Ö¡*/
  97. N_PCI_T_FF = 0x01U, /* First Frame Ê×Ö¡*/
  98. N_PCI_T_CF = 0x02U, /* Consecutive Frame Á¬ÐøÖ¡*/
  99. N_PCI_T_FC = 0x03U, /* Flow Control Frame Á÷¿ØÖ¡*/
  100. N_PCI_T_UN = 0xFF /* Unknown */
  101. } pci_type;
  102. /* --- Network Target Address Type (ref: iso15765-2 p.9,29,30) ------------- */
  103. typedef enum
  104. {
  105. N_TA_T_PHY = 0x01, /* Physical */
  106. N_TA_T_FUNC = 0x02 /* Functional */
  107. } ta_type;
  108. /* --- Message Type (ref: iso15765-2 p.8) ---------------------------------- */
  109. typedef enum
  110. {
  111. N_MT_DIAG = 0x00, /* Diagnostics */
  112. N_MT_RDIAG = 0x01 /* Remote Diagnostics */
  113. } mtype;
  114. /* --- FlowControl Parameters (ref: iso15765-2 p.--------------------------- */
  115. typedef enum
  116. {
  117. N_ST_MIN = 0x00U, /* SeparationTimeMin: the minimum time the sender should wait between the transmissions of two CF N_PDUs */
  118. N_BS = 0x01U, /* BlockSize: the max. number of N_PDUs the receiver allows the sender to send, before waiting for an authorization to continue transmission of the following N_PDUs */
  119. } fl_param;
  120. /* --- N rslts (ref: iso15765-2 p.10-11) ----------------------------------- */
  121. typedef enum
  122. {
  123. N_OK = 0x0000, /* service execution has completed successfully */
  124. N_TIMEOUT_A = 0x0001, /* when the timer N_Ar/N_As has passed its time-out * value N_Asmax / N_Armax; */
  125. N_TIMEOUT_Bs = 0x0002, /* when the timer N_Bs has passed its time-out value * N_Bsmax */
  126. N_TIMEOUT_Cr = 0x0003, /* when the timer N_Cr has passed its time-out value * N_Crmax */
  127. N_WRG_SN = 0x0004, /* upon reception of an unexpected sequence number * (PCI.SN) value */
  128. N_INV_FS = 0x0005, /* when an invalid or unknown FlowStatus value has * been received in a flow control(FC) N_PDU */
  129. N_UNE_PDU = 0x0006, /* upon reception of an unexpected protocol data unit; */
  130. N_WFT_OVRN = 0x0007, /* upon reception of flow control WAIT frame that * exceeds the maximum counter N_WFTmax */
  131. N_BUFFER_OVFLW = 0x0008, /* upon reception of a flow control (FC) N_PDU with * FlowStatus = OVFLW */
  132. N_ERROR = 0x0009, /* when an error has been detected by the network layer * and no other parameter value can be used to better * describe the error. */
  133. N_IDLE = 0x0010, /* service execution has completed successfully and not TXRX */
  134. N_TX_BUSY = 0x0011, /* service execution has completed successfully and TX pending */
  135. N_RX_BUSY = 0x0012, /* service execution has completed successfully and RX pending */
  136. N_WRG_PARAM = 0x0013, /* the service did not execute due to an undefined <Parameter> */
  137. N_WRG_VALUE = 0x0014, /* the service did not execute due to an out of range <Parameter_Value>; */
  138. N_INV = 0x0015, /* the service did not execute due to an invalid requested operation */
  139. N_MISSING_CLB = 0x0016, /* the service did not execute due to missing mandatory callback functions */
  140. N_NULL = 0x0017, /* the service has a null pointer (this should never happen) */
  141. N_FC_TIMEOUT = 0x0018, /* Flow Control Timeout. @n_timeouts.n_bs */
  142. N_CF_TIMEOUT = 0x0019, /* ConsecutiveFrame Timeout. @n_timeouts.n_cr */
  143. N_CAN_DT_INV = 0x0020, /* Invalid CAN Data Error */
  144. N_UNE_FC = 0x0021, /* FlowControl was received without being expected. */
  145. N_UNE_CF = 0x0022, /* ConsecutiveFrame was received without being expected. */
  146. N_RCV_INT_SF = 0x0023, /* Frames sequence was not correct. Service received a * single frame during a Multi-frame reception. */
  147. N_RCV_INT_FF = 0x0024, /* Frames sequence was not correct. Service received a * first frame during a Multi-frame reception. */
  148. N_RCV_INT_FC = 0x0025, /* ReceptionInterruptedWithFC */
  149. N_INV_SEQ_NUM = 0x0026, /* ConsecutiveFrame sequence number was invalid. */
  150. N_UNS_WF = 0x0027, /* Unsuported WaitFrame */
  151. N_MAX_WF_REAC = 0x0028, /* Maximum Wait Frames Reached */
  152. N_INV_PDU = 0x0029, /* PDU Conversion failed */
  153. N_INV_REQ_SZ = 0x0030, /* Invalid Request Size */
  154. N_UNE_FC_STS = 0x0031, /* Flow control status was invalid and/or unexpected. */
  155. N_OVFLW = 0x0032, /* Buffer Overflow. */
  156. } n_rslt;
  157. /* --- N_PCI_T_FC Status (ref: iso15765-2 p.8) ---------------------------- */
  158. typedef enum
  159. {
  160. N_CONTINUE = 0x00U, /* continue to send, the authorization to continue */
  161. N_WAIT = 0x01U, /* the request to continue to wait */
  162. N_OVERFLOW = 0x02U /* buffer overflow, the indication that the number of bytes specified in the FirstFrame of the segmented message exceeds the number of bytes that can be stored in the buffer of the receiver entity */
  163. } flow_sts;
  164. /* --- dt I/O Stream Status (ref: iso15765-2 p.8) ------------------------ */
  165. typedef enum
  166. {
  167. N_S_IDLE = 0x00, /* Has to pending action */
  168. N_S_RX_BUSY = 0x02, /* Reception is in progress */
  169. N_S_TX_BUSY = 0x04, /* Transmission is in progress */
  170. N_S_TX_READY = 0x05, /* Transmission is ready to begin */
  171. N_S_TX_WAIT_FC = 0x10, /* Transmission is in progress and waits
  172. * for a Flow control frame */
  173. } stream_sts;
  174. /* --- Network Layer Timing PARAMs (ref: iso15765-2 p.) -------------------- */
  175. #if ARM_M4
  176. #pragma pack(4)
  177. typedef struct
  178. #else
  179. typedef struct ALIGNMENT
  180. #endif //ARM_M4
  181. {
  182. uint32_t n_bs; /* FlowControl N_PDU not received (lost, overwritten) on the
  183. * sender side or preceding FirstFrame N_PDU or ConsecutiveFrame
  184. * N_PDU not received(lost, overwritten) on the receiver side.
  185. * Abort message transmission and issue N_USData.confirm with
  186. * <N_Result> = N_TIMEOUT_Bs. */
  187. uint32_t n_cr; /* ConsecutiveFrame N_PDU not received (lost, overwritten) on
  188. * the receiver side or preceding FC N_PDU not received(lost,
  189. * overwritten) on the sender side. Abort message reception and issue
  190. * N_USData.indication with <N_Result> = N_TIMEOUT_Cr */
  191. uint32_t n_cs;
  192. } n_timeouts;
  193. #if ARM_M4
  194. #pragma pack()
  195. #endif //ARM_M4
  196. /* --- Address information (ref: iso15765-2 p.) ---------------------------- */
  197. #if ARM_M4
  198. #pragma pack(4)
  199. typedef struct
  200. #else
  201. typedef struct ALIGNMENT
  202. #endif //ARM_M4
  203. {
  204. uint8_t n_pr; /* Network Address Priority */
  205. uint8_t n_sa; /* Network Source Address */
  206. uint8_t n_ta; /* Network Target Address */
  207. uint8_t n_ae; /* Network Address Extension */
  208. ta_type n_tt; /* Network Target Address type */
  209. } n_ai_t;
  210. #if ARM_M4
  211. #pragma pack()
  212. #endif //ARM_M4
  213. /* --- Protocol control information (ref: iso15765-2 p.) ------------------- */
  214. #if ARM_M4
  215. #pragma pack(4)
  216. typedef struct
  217. #else
  218. typedef struct ALIGNMENT
  219. #endif //ARM_M4
  220. {
  221. uint8_t fs; /* FlowStatus: whether the sending network entity can proceed with the message transmission 'flow_sts' */
  222. uint8_t bs; /* BlockSize */
  223. uint8_t sn; /* SequenceNumber: specify the order of the consecutive frames */
  224. uint8_t st; /* SeparationTime: Requested separation time */
  225. pci_type pt; /* Type of the received pdu 'pci_type' */
  226. uint16_t dl; /* PCI data length (if 0 frame must be ignored) */
  227. } n_pci_t;
  228. #if ARM_M4
  229. #pragma pack()
  230. #endif //ARM_M4
  231. /* --- Protocol dt unit (ref: iso15765-2 p.) ------------------------------- */
  232. #if ARM_M4
  233. #pragma pack(4)
  234. typedef struct
  235. #else
  236. typedef struct ALIGNMENT
  237. #endif //ARM_M4
  238. {
  239. mtype n_mt; /* Message Type */
  240. uint16_t sz; /* Actual data size */
  241. n_ai_t n_ai; /* Address information */
  242. n_pci_t n_pci; /* Protocol control information */
  243. uint8_t dt[128]; /* Data Field */
  244. uint8_t sf_dt[8]; /* single frame data field*/
  245. } n_pdu_t;
  246. #if ARM_M4
  247. #pragma pack()
  248. #endif //ARM_M4
  249. /* --- N_USdt.cfm (ref: iso15765-2 p.6) ------------------------------------ */
  250. #if ARM_M4
  251. #pragma pack(4)
  252. typedef struct
  253. #else
  254. typedef struct ALIGNMENT
  255. #endif //ARM_M4
  256. {
  257. n_ai_t n_ai; /* Address information */
  258. n_pci_t n_pci; /* Protocol control information */
  259. n_rslt rslt; /* Result of the request */
  260. pci_type frame_type; /* Received frame type*/
  261. } n_cfm_t;
  262. #if ARM_M4
  263. #pragma pack()
  264. #endif //ARM_M4
  265. /* --- N_FF.indn (ref: iso15765-2 p.6) ------------------------------------ */
  266. #if ARM_M4
  267. #pragma pack(4)
  268. typedef struct
  269. #else
  270. typedef struct ALIGNMENT
  271. #endif //ARM_M4
  272. {
  273. cbus_fr_format fr_fmt; /* CANBus Frame format */
  274. n_ai_t n_ai; /* Address information */
  275. n_pci_t n_pci; /* Protocol control information */
  276. uint16_t msg_sz; /* Size of the message that will be received */
  277. pci_type frame_type; /* Received frame type*/
  278. } n_ff_indn_t;
  279. #if ARM_M4
  280. #pragma pack()
  281. #endif //ARM_M4
  282. /* --- N_USData.request (ref: iso15765-2 p6.) ------------------------------ */
  283. #if ARM_M4
  284. #pragma pack(4)
  285. typedef struct
  286. #else
  287. typedef struct ALIGNMENT
  288. #endif //ARM_M4
  289. {
  290. cbus_fr_format fr_fmt; /* CANBus Frame format */
  291. n_ai_t n_ai; /* Address information */
  292. n_pci_t n_pci; /* Protocol control information */
  293. uint16_t msg_sz; /* Message actual size */
  294. uint8_t msg[I15765_MSG_SIZE]; /* Message to be transmitted */
  295. } n_req_t;
  296. #if ARM_M4
  297. #pragma pack()
  298. #endif //ARM_M4
  299. /* --- N_USdt.indn (ref: iso15765-2 p.7) ---------------------------------- */
  300. #if ARM_M4
  301. #pragma pack(4)
  302. typedef struct
  303. #else
  304. typedef struct ALIGNMENT
  305. #endif //ARM_M4
  306. {
  307. cbus_fr_format fr_fmt; /* CANBus Frame format */
  308. n_ai_t n_ai; /* Address information */
  309. n_pci_t n_pci; /* Protocol control information */
  310. n_rslt rslt; /* Result of the reception */
  311. uint16_t msg_sz; /* Received message actual size */
  312. pci_type frame_type; /* Received frame type*/
  313. uint8_t msg[I15765_MSG_SIZE]; /* Received message data */
  314. uint8_t sf_msg[8]; /* Received single frame message data */
  315. } n_indn_t;
  316. #if ARM_M4
  317. #pragma pack()
  318. #endif //ARM_M4
  319. #if ARM_M4
  320. #pragma pack(4)
  321. typedef struct
  322. #else
  323. typedef struct ALIGNMENT
  324. #endif //ARM_M4
  325. {
  326. n_ai_t n_ai; /* Address information. Not supported:the lib handles only 1 stream */
  327. n_pci_t n_pci; /* Protocol control information. Not supported:the lib handles only 1 stream) */
  328. fl_param param; /* Parameter to change */
  329. uint8_t pval; /* Value to set */
  330. } n_chg_param_req_t;
  331. #if ARM_M4
  332. #pragma pack()
  333. #endif //ARM_M4
  334. #if ARM_M4
  335. #pragma pack(4)
  336. typedef struct
  337. #else
  338. typedef struct ALIGNMENT
  339. #endif //ARM_M4
  340. {
  341. n_ai_t n_ai; /* Address information. Not supported:the lib handles only 1 stream */
  342. n_pci_t n_pci; /* Protocol control information. Not supported: because the lib handles only 1 stream */
  343. fl_param param; /* Requested Parameter to change */
  344. uint8_t pval; /* Requested Value to set */
  345. n_rslt rslt; /* Result of the request */
  346. } n_chg_param_cfm_t;
  347. #if ARM_M4
  348. #pragma pack()
  349. #endif //ARM_M4
  350. typedef enum
  351. {
  352. N_INDN = 0x01, /* N_USData.indication */
  353. N_FF_INDN = 0x02, /* N_USData_FF.indication */
  354. N_CONF = 0x03, /* N_USData.confirm */
  355. N_CHG_P_CONF = 0x04, /* N_ChangeParameter.confirm */
  356. N_SF_INDN = 0x05, /* N_USData.single frame indication */
  357. } signal_tp;
  358. /* --- Callbacks ---------------------------------------------------------- */
  359. #if ARM_M4
  360. #pragma pack(4)
  361. typedef struct
  362. #else
  363. typedef struct ALIGNMENT
  364. #endif //ARM_M4
  365. {
  366. void (*indn)(n_indn_t *); /* Indication Callback: Will be fired when a reception is available or an error occured during the reception. */
  367. void (*ff_indn)(n_ff_indn_t *); /* First Frame Indication Callback: Will be fired when a FF is received, giving back some useful information */
  368. void (*cfm)(n_cfm_t *); /* This callback confirms to the higher layers that the requested service has been carried out */
  369. void (*cfg_cfm)(n_chg_param_cfm_t *); /* This service confirms to the upper layer that the request to change a specific protocol has been carried out */
  370. void (*pdu_custom_pack)(n_pdu_t *, uint32_t *); /* Custom CAN ID packing for 11bits ID. If assinged the default packing will be skipped */
  371. void (*pdu_custom_unpack)(n_pdu_t *, uint32_t *); /* Custom CAN ID uppacking for 11bits ID. If assinged the default uppacking will be skipped */
  372. void (*on_error)(n_rslt); /* Will be fired in any occured error. */
  373. uint32_t(*get_ms)(); /* Time-source for the library in ms(required) */
  374. uint8_t(*send_frame) /* Callback to assing the Network Layer. This callback will be fired when a transmission of a canbus frame is ready.*/
  375. (
  376. cbus_id_type, /* - CANBus Frame ID Type [Standard or Extended] */
  377. uint32_t, /* - Frame ID */
  378. cbus_fr_format, /* - Frame Type: [CLASSIC or FD]*/
  379. uint8_t, /* - Frame Data Length */
  380. uint8_t * /* - Frame Data Array */
  381. );
  382. } n_callbacks_t;
  383. #if ARM_M4
  384. #pragma pack()
  385. #endif //ARM_M4
  386. /* --- PDU Stream --------------------------------------------------------- */
  387. #if ARM_M4
  388. #pragma pack(4)
  389. typedef struct
  390. #else
  391. typedef struct ALIGNMENT
  392. #endif //ARM_M4
  393. {
  394. cbus_fr_format fr_fmt; /* CANBus Frame format */
  395. n_pdu_t pdu; /* Keep information about the in/out frame in a PDU format */
  396. uint8_t cf_cnt; /* Current block sequence number (ConsecutiveFrame) */
  397. uint8_t wf_cnt; /* Current received wait flow control frames */
  398. uint8_t cfg_wf; /* Max supported Wait Flow Control frames */
  399. uint8_t stmin; /* Frames transmission rate */
  400. uint8_t cfg_bs; /* Max. supported block sequence (ConsecutiveFrame) */
  401. stream_sts sts; /* Stream status */
  402. uint16_t msg_sz; /* Actual message buffer size */
  403. uint16_t msg_pos; /* Transmit message buffer position */
  404. n_timeouts last_upd; /* Time keeper for timouts */
  405. uint8_t msg[I15765_MSG_SIZE]; /* Received/Transmit message buffer */
  406. uint8_t sf_msg[8]; /* Received/Transmit single frame message buffer */
  407. } n_iostream_t;
  408. #if ARM_M4
  409. #pragma pack()
  410. #endif //ARM_M4
  411. /* --- iso15765 timing configuration (ref: iso15765-2 p.25)----------------- */
  412. #if ARM_M4
  413. #pragma pack(4)
  414. typedef struct
  415. #else
  416. typedef struct ALIGNMENT
  417. #endif //ARM_M4
  418. {
  419. uint8_t stmin; /* Default min. frame transmission separation */
  420. uint8_t bs; /* Max. Block size during transmission */
  421. uint8_t wf; /* Max. accepted Wait Requests from the FlowControl */
  422. uint16_t n_bs; /* Time until reception of the next FlowControl N_PDU */
  423. uint16_t n_cr; /* Time until reception of the next ConsecutiveFrame N_PDU */
  424. } n_config_t;
  425. #if ARM_M4
  426. #pragma pack()
  427. #endif //ARM_M4
  428. /* --- iso15765 Handler --------------------------------------------------- */
  429. #if ARM_M4
  430. #pragma pack(4)
  431. typedef struct
  432. #else
  433. typedef struct ALIGNMENT
  434. #endif //ARM_M4
  435. {
  436. addr_md addr_md; /* Selected address mode of the TP */
  437. cbus_id_type fr_id_type; /* CANBus frame Id Type */
  438. n_iostream_t in; /* Incoming data stream (reception) */
  439. n_iostream_t out; /* Outcoming data stream (transmission) */
  440. n_pdu_t fl_pdu; /* Flow control pdu */
  441. n_callbacks_t clbs; /* Callbacks */
  442. n_config_t config; /* Default configuration to be used. (timing etc) */
  443. n_timeouts cfg_timeout; /* Timeouts configuration */
  444. iqueue_t inqueue; /* Queue handler for the incoming canbus frames */
  445. uint8_t inq_buf[I15765_QUEUE_ELMS * sizeof(canbus_frame_t)]; /* Queue buffer */
  446. } iso15765_t;
  447. #if ARM_M4
  448. #pragma pack()
  449. #endif //ARM_M4
  450. /******************************************************************************
  451. * Declaration | Public Functions
  452. ******************************************************************************/
  453. n_rslt iso15765_init(iso15765_t *instance);
  454. n_rslt iso15765_send(iso15765_t *instance, n_req_t *frame);
  455. n_rslt iso15765_enqueue(iso15765_t *instance, canbus_frame_t *frame);
  456. n_rslt iso15765_process(iso15765_t *instance);
  457. /******************************************************************************
  458. * EOF - NO CODE AFTER THIS LINE
  459. ******************************************************************************/
  460. #endif