Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 1 | #ifndef PERIPHERAL_CAN_H_ |
| 2 | #define PERIPHERAL_CAN_H_ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | // The code defined here calls functions in vesc/vesc_can.h from various |
| 7 | // interrupts and expects them to call back into this file to do something. |
| 8 | |
| 9 | #ifdef __cplusplus |
| 10 | extern "C" { |
| 11 | #endif |
| 12 | |
Brian Silverman | 54dd2fe | 2018-03-16 23:44:31 -0700 | [diff] [blame] | 13 | #define CAN_EFF_FLAG UINT32_C(0x80000000) /* EFF/SFF is set in the MSB */ |
| 14 | |
Brian Silverman | 7c7170e | 2018-01-13 17:41:21 -0800 | [diff] [blame] | 15 | void can_init(uint32_t id0, uint32_t id1); |
Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 16 | |
Brian Silverman | a3a172b | 2018-03-24 03:53:32 -0400 | [diff] [blame] | 17 | // Mailbox is 2-7 (inclusive) for the send mailboxes. |
Brian Silverman | 110205a | 2018-01-15 14:33:50 -0800 | [diff] [blame] | 18 | int can_send(uint32_t can_id, const unsigned char *data, unsigned int length, |
| 19 | unsigned int mailbox); |
Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 20 | |
| 21 | // Sets *length to -1 if there isn't a new piece of data to receive. |
Brian Silverman | 7c7170e | 2018-01-13 17:41:21 -0800 | [diff] [blame] | 22 | // Mailbox is 0 or 1 for the two receive mailboxes. |
Brian Silverman | 54dd2fe | 2018-03-16 23:44:31 -0700 | [diff] [blame] | 23 | void can_receive(unsigned char *data, int *length, int mailbox); |
Brian Silverman | 8d3816a | 2017-07-03 18:52:15 -0700 | [diff] [blame] | 24 | |
| 25 | #ifdef __cplusplus |
| 26 | } |
| 27 | #endif |
| 28 | |
| 29 | #endif // PERIPHERAL_CAN_H_ |