diff options
Diffstat (limited to 'include/can')
-rw-r--r-- | include/can/global.h | 20 | ||||
-rw-r--r-- | include/can/mcp2515.h | 36 | ||||
-rw-r--r-- | include/can/software.h | 9 |
3 files changed, 65 insertions, 0 deletions
diff --git a/include/can/global.h b/include/can/global.h new file mode 100644 index 0000000..5d88fe6 --- /dev/null +++ b/include/can/global.h @@ -0,0 +1,20 @@ +#include <stdint.h> + +#ifndef _IOE_CAN_GLOBAL_ +#define _IOE_CAN_GLOBAL_ + +typedef struct { + uint16_t id; + uint8_t length; + uint8_t data[8]; +} CanFrame; + +typedef struct { + CanFrame **buffer; + void *udata; +} Can; + + +void can_send(Can *can, CanFrame *frame); + +#endif /* _IOE_CAN_GLOBAL_ */ diff --git a/include/can/mcp2515.h b/include/can/mcp2515.h new file mode 100644 index 0000000..59376f7 --- /dev/null +++ b/include/can/mcp2515.h @@ -0,0 +1,36 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +#include "spi.h" +#include "global.h" + +#ifndef _IOE_CAN_MCP2515_H_ +#define _IOE_CAN_MCP2515_H_ +#ifdef CONFIG_IOE_CAN_MCP2515 +#ifndef CONFIG_IOE_SPI +#error "Please define CONFIG_IOE_SPI. MCP2515 requires SPI." +#endif + +// TODO registers +#define CAN_MCP2515_CANCTL +// TODO buffers + +typedef struct { + uint8_t group, mask; +} CanMcp2515; + +int8_t can_mcp2515_init(CanMcp2515 * can, uint8_t group, uint8_t mask); + +void can_mcp2515_reset(CanMcp2515 * can); +uint8_t can_mcp2515_read(CanMcp2515 * can, uint8_t address); +uint8_t can_mcp2515_readrx(CanMcp2515 * can, uint8_t buffer); +void can_mcp2515_write(CanMcp2515 * can, uint8_t address, uint8_t data); +void can_mcp2515_loadrx(CanMcp2515 * can, uint8_t buffer, uint8_t data); +uint8_t can_mcp2515_rdstat(CanMcp2515 * can); +uint8_t can_mcp2515_rxstat(CanMcp2515 * can); +void can_mcp2515_bitmod(CanMcp2515 * can, uint8_t address, uint8_t mask, + uint8_t data); + +#endif /* CONFIG_IOE_CAN_MCP2515 */ +#endif /* _IOE_CAN_MCP2515_H_ */ diff --git a/include/can/software.h b/include/can/software.h new file mode 100644 index 0000000..b443e42 --- /dev/null +++ b/include/can/software.h @@ -0,0 +1,9 @@ +#include <avr/io.h> +#include <util/delay.h> +#include <stdint.h> + +#ifndef _IOE_CAN_SOFTWARE_H_ +#define _IOE_CAN_SOFTWARE_H_ + + +#endif /* _IOE_CAN_SOFTWARE_H_ */ |