grblHAL core  20240704
canbus.h
Go to the documentation of this file.
1 /*
2 
3  canbus.h -
4 
5  Part of grblHAL
6 
7  Copyright (c) 2022 Jon Escombe
8  Copyright (c) 2024 Terje Io
9 
10  grblHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  grblHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #ifndef _CANBUS_H_
26 #define _CANBUS_H_
27 
28 #include <stdint.h>
29 #include <stdbool.h>
30 
31 typedef struct {
32  uint32_t id;
33  uint8_t len;
34  uint8_t data[8];
36 
37 typedef bool (*can_rx_ptr)(canbus_message_t);
38 typedef bool (*can_rx_enqueue_fn)(canbus_message_t msg, can_rx_ptr callback); // used internally by the driver
39 
40 /*
41  * Function prototypes
42  */
43 void canbus_init (void);
44 bool canbus_enabled (void);
45 bool canbus_queue_tx (canbus_message_t message, bool ext_id);
46 bool canbus_add_filter (uint32_t id, uint32_t mask, bool ext_id, can_rx_ptr callback);
47 
48 #endif /* _CANBUS_H_ */
bool(* can_rx_ptr)(canbus_message_t)
Definition: canbus.h:37
void canbus_init(void)
Definition: canbus.c:201
bool canbus_enabled(void)
Definition: canbus.c:177
bool canbus_add_filter(uint32_t id, uint32_t mask, bool ext_id, can_rx_ptr callback)
Definition: canbus.c:196
bool(* can_rx_enqueue_fn)(canbus_message_t msg, can_rx_ptr callback)
Definition: canbus.h:38
bool canbus_queue_tx(canbus_message_t message, bool ext_id)
Definition: canbus.c:182
Definition: canbus.h:31
uint8_t len
Definition: canbus.h:33
uint32_t id
Definition: canbus.h:32