Loading...
Searching...
No Matches
mcp2515.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 OTA keys S.A.
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
21#ifndef MCP2515_H
22#define MCP2515_H
23
24#include "mcp2515_defines.h"
25#include "candev_mcp2515.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
35 MODE_NORMAL = MCP2515_CANSTAT_OPMOD_NORMAL,
36 MODE_SLEEP = MCP2515_CANSTAT_OPMOD_SLEEP,
37 MODE_LOOPBACK = MCP2515_CANSTAT_OPMOD_LOOPBACK,
38 MODE_LISTEN_ONLY = MCP2515_CANSTAT_OPMOD_LISTEN_ONLY,
39 MODE_CONFIG = MCP2515_CANSTAT_OPMOD_CONFIGURATION,
40 MODE_UNKNOWN = -1
41};
42
47 INT_RX0 = MCP2515_CANINTF_RX0IF,
48 INT_RX1 = MCP2515_CANINTF_RX1IF,
49 INT_TX0 = MCP2515_CANINTF_TX0IF,
50 INT_TX1 = MCP2515_CANINTF_TX1IF,
51 INT_TX2 = MCP2515_CANINTF_TX2IF,
52 INT_ERROR = MCP2515_CANINTF_ERRIF,
53 INT_WAKEUP = MCP2515_CANINTF_WAKIF,
54 INT_MESSAGE_ERROR = MCP2515_CANINTF_MERRF,
55};
56
61 ERR_WARNING = MCP2515_EFLG_EWARN,
62 ERR_RX_WARNING = MCP2515_EFLG_RXWAR,
63 ERR_TX_WARNING = MCP2515_EFLG_TXWAR,
64 ERR_RX_PASSIVE = MCP2515_EFLG_RXEP,
65 ERR_TX_PASSIVE = MCP2515_EFLG_TXEP,
66 ERR_TX_BUS_OFF = MCP2515_EFLG_TXBO,
67 ERR_RX_0_OVERFLOW = MCP2515_EFLG_RX0OVR,
68 ERR_RX_1_OVERFLOW = MCP2515_EFLG_RX1OVR,
69};
70
72#define MCP2515_WKUP_SRC_INTERNAL 1
73
75#ifndef MCP2515_RECV_FILTER_EN
76#define MCP2515_RECV_FILTER_EN 0
77#endif
78
95int mcp2515_init(candev_mcp2515_t *dev, void (*irq_cb)(void *));
96
105
115
126int mcp2515_send(candev_mcp2515_t *dev, const struct can_frame *frame,
127 int mailbox);
128
140 int mailbox);
141
151int mcp2515_abort(candev_mcp2515_t *dev, int mailbox);
152
161
171 enum mcp2515_mode mode);
172
179
188
199
210
222
231
263int mcp2515_set_filter(candev_mcp2515_t *dev, int filter_id, uint32_t filter);
264
292int mcp2515_set_mask(candev_mcp2515_t *dev, int mailbox, uint32_t mask);
293
294#ifdef __cplusplus
295}
296#endif
297
298#endif /* MCP2515_H */
Definition of the implementation of the CAN controller driver.
int mcp2515_tx_err_occurred(candev_mcp2515_t *dev, int mailbox)
Get if an tx error occurred on MCP2515.
mcp2515_error
MCP2515 error.
Definition mcp2515.h:60
int mcp2515_abort(candev_mcp2515_t *dev, int mailbox)
Abort communication.
int mcp2515_send(candev_mcp2515_t *dev, const struct can_frame *frame, int mailbox)
Send frame through the corresponding tx mailbox.
int mcp2515_set_mask(candev_mcp2515_t *dev, int mailbox, uint32_t mask)
Set the @ mask to the mailbox.
int mcp2515_receive(candev_mcp2515_t *dev, struct can_frame *frame, int mailbox)
Receive frame from the corresponding rx mailbox.
void mcp2515_reset(candev_mcp2515_t *dev)
Reset MCP2515 device with dedicated pin.
enum mcp2515_mode mcp2515_get_mode(candev_mcp2515_t *dev)
Get MCP2515 mode of operation.
int mcp2515_init(candev_mcp2515_t *dev, void(*irq_cb)(void *))
Initialize pins and SPI interface.
void mcp2515_wake_up(candev_mcp2515_t *dev)
Wake up MCP2515.
enum mcp2515_mode mcp2515_set_mode(candev_mcp2515_t *dev, enum mcp2515_mode mode)
Set MCP2515 mode of operation.
int mcp2515_init_irqs(candev_mcp2515_t *dev)
Initialize MCP2515 interrupts.
int mcp2515_clear_irq(candev_mcp2515_t *dev, enum mcp2515_interrupt irq)
Clear MCP2515 interrupt.
mcp2515_mode
MCP2515 mode.
Definition mcp2515.h:34
mcp2515_interrupt
MCP2515 interrupt.
Definition mcp2515.h:46
int mcp2515_configure_bittiming(candev_mcp2515_t *dev)
Configure the bit timing of the MCP2515.
int mcp2515_set_filter(candev_mcp2515_t *dev, int filter_id, uint32_t filter)
Set the @ filter_id to the position in the mailbox.
uint8_t mcp2515_get_errors(candev_mcp2515_t *dev)
Get the error flags.
enum mcp2515_interrupt mcp2515_get_irq(candev_mcp2515_t *dev)
Get MCP2515 interrupt type.
Driver for the Microchip MCP2515 can controller.
Controller Area Network frame.
Definition can.h:88
MCP2515 device descriptor.