Loading...
Searching...
No Matches
candev_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
25#ifndef CANDEV_MCP2515_H
26#define CANDEV_MCP2515_H
27
28#include <stdbool.h>
29
30#include "can/candev.h"
31#include "cpu_conf.h"
32#include "periph/gpio.h"
33#include "periph/spi.h"
34#include "mutex.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
43#ifndef CANDEV_MCP2515_DEFAULT_BITRATE
44#define CANDEV_MCP2515_DEFAULT_BITRATE 500000
45#endif
46
50#ifndef CANDEV_MCP2515_DEFAULT_SPT
51#define CANDEV_MCP2515_DEFAULT_SPT 875
52#endif
53
57#define MCP2515_TX_MAILBOXES 3
58
79#define MCP2515_RX_MAILBOXES 2
80#define MCP2515_FILTERS_MB0 2
81#define MCP2515_FILTERS_MB1 4
82#define MCP2515_FILTERS (MCP2515_FILTERS_MB0 + MCP2515_FILTERS_MB1)
87
100
112 struct can_frame rx_buf[MCP2515_RX_MAILBOXES];
114 uint32_t masks[MCP2515_RX_MAILBOXES];
116 canid_t filter_ids[MCP2515_RX_MAILBOXES][MCP2515_FILTERS_MB1];
119};
120
129 const candev_mcp2515_conf_t *conf);
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* CANDEV_MCP2515_H */
spi_clk_t
Definition periph_cpu.h:352
Definitions for low-level CAN driver interface.
Low-level GPIO peripheral driver interface definitions.
#define MCP2515_TX_MAILBOXES
Number of transmit mailboxes.
void candev_mcp2515_init(candev_mcp2515_t *dev, const candev_mcp2515_conf_t *conf)
Initialize a mcp2515 device by assigning a timing and an SPI configuration conf.
struct candev_mcp2515_conf candev_mcp2515_conf_t
MCP2515 configuration descriptor.
uint32_t canid_t
Controller Area Network Identifier structure.
Definition can.h:83
spi_mode_t
Support SPI modes.
Definition periph_cpu.h:43
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Controller Area Network frame.
Definition can.h:88
MCP2515 configuration descriptor.
gpio_t cs_pin
Slave select pin.
uint32_t clk
External clock frequency.
gpio_t rst_pin
Reset pin.
spi_clk_t spi_clk
SPI clock speed.
gpio_t int_pin
Interrupt pin.
spi_mode_t spi_mode
SPI mode.
MCP2515 device descriptor.
struct can_frame rx_buf[MCP2515_RX_MAILBOXES]
rx mailboxes local copy
canid_t filter_ids[MCP2515_RX_MAILBOXES][MCP2515_FILTERS_MB1]
filters list
candev_t candev
candev driver
int wakeup_src
wakeup source
const candev_mcp2515_conf_t * conf
driver configuration
const struct can_frame * tx_mailbox[MCP2515_TX_MAILBOXES]
tx mailboxes local copy
uint32_t masks[MCP2515_RX_MAILBOXES]
masks list
Structure to hold driver state.
Definition candev.h:77