can.h
Go to the documentation of this file.
1 /*
2 Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
3 Copyright (C) 2012 GomSpace ApS (http://www.gomspace.com)
4 Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
5 
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10 
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15 
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
27 #ifndef _CAN_H_
28 #define _CAN_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <stdint.h>
35 
36 #include <csp/csp.h>
38 
39 /* The can_frame_t and can_id_t types intentionally matches the
40  * can_frame struct and can_id types in include/linux/can.h
41  *
42  *
43  */
44 
46 typedef uint32_t can_id_t;
47 
52 typedef struct {
54  can_id_t id;
56  uint8_t dlc;
58  union __attribute__((aligned(8))) {
59  uint8_t data[8];
60  uint16_t data16[4];
61  uint32_t data32[2];
62  };
63 } can_frame_t;
64 
69 typedef enum {
70  CAN_ERROR = 0,
72 } can_error_t;
73 
78 int can_init(uint32_t id, uint32_t mask, struct csp_can_config *conf);
79 
84 int can_send(can_id_t id, uint8_t * data, uint8_t dlc);
85 
90 int csp_can_rx_frame(can_frame_t *frame, CSP_BASE_TYPE *task_woken);
91 
92 #ifdef __cplusplus
93 } /* extern "C" */
94 #endif
95 
96 #endif /* _CAN_H_ */
97 
98 /* @} */
Definition: can.h:70
uint8_t dlc
Data Length Code.
Definition: can.h:56
can_error_t
Definition: can.h:69
Definition: can.h:71
int can_init(uint32_t id, uint32_t mask, struct csp_can_config *conf)
CAN Frame.
Definition: can.h:52
int can_send(can_id_t id, uint8_t *data, uint8_t dlc)
Definition: csp_if_can.h:50
uint32_t can_id_t
CAN Identifier.
Definition: can.h:46
int csp_can_rx_frame(can_frame_t *frame, CSP_BASE_TYPE *task_woken)
can_id_t id
32 bit CAN identifier
Definition: can.h:54