aboutsummaryrefslogtreecommitdiff
path: root/include/can/mcp2515.h
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-03-08 16:10:33 +0100
committerKarel Kočí <cynerd@email.cz>2016-03-08 16:10:33 +0100
commit5d29fe79d30f430ae326d9dc57ccfaed6fe61328 (patch)
tree8341804d561c0060176cbebc3f9a57c7c07f7816 /include/can/mcp2515.h
parent4e773191d447ac434536262a6f204dd991d4ad77 (diff)
downloadavr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.gz
avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.bz2
avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.zip
Another full update of current work
Diffstat (limited to 'include/can/mcp2515.h')
-rw-r--r--include/can/mcp2515.h36
1 files changed, 36 insertions, 0 deletions
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_ */