From 5d29fe79d30f430ae326d9dc57ccfaed6fe61328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 8 Mar 2016 16:10:33 +0100 Subject: Another full update of current work --- include/can/global.h | 20 ++++++++++++++++++++ include/can/mcp2515.h | 36 ++++++++++++++++++++++++++++++++++++ include/can/software.h | 9 +++++++++ 3 files changed, 65 insertions(+) create mode 100644 include/can/global.h create mode 100644 include/can/mcp2515.h create mode 100644 include/can/software.h (limited to 'include/can') 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 + +#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 +#include +#include + +#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 +#include +#include + +#ifndef _IOE_CAN_SOFTWARE_H_ +#define _IOE_CAN_SOFTWARE_H_ + + +#endif /* _IOE_CAN_SOFTWARE_H_ */ -- cgit v1.2.3