Loading...
Searching...
No Matches
candev_mcp2515.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 OTA keys S.A.
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
23
24#include <stdbool.h>
25
26#include "can/candev.h"
27#include "cpu_conf.h"
28#include "periph/gpio.h"
29#include "periph/spi.h"
30#include "mutex.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
39#ifndef CANDEV_MCP2515_DEFAULT_BITRATE
40#define CANDEV_MCP2515_DEFAULT_BITRATE 500000
41#endif
42
46#ifndef CANDEV_MCP2515_DEFAULT_SPT
47#define CANDEV_MCP2515_DEFAULT_SPT 875
48#endif
49
53#define MCP2515_TX_MAILBOXES 3
54
75#define MCP2515_RX_MAILBOXES 2
76#define MCP2515_FILTERS_MB0 2
77#define MCP2515_FILTERS_MB1 4
78#define MCP2515_FILTERS (MCP2515_FILTERS_MB0 + MCP2515_FILTERS_MB1)
80
83
96
108 struct can_frame rx_buf[MCP2515_RX_MAILBOXES];
110 uint32_t masks[MCP2515_RX_MAILBOXES];
112 canid_t filter_ids[MCP2515_RX_MAILBOXES][MCP2515_FILTERS_MB1];
115};
116
125 const candev_mcp2515_conf_t *conf);
126
127#ifdef __cplusplus
128}
129#endif
130
spi_clk_t
Definition periph_cpu.h:348
Definitions for low-level CAN driver interface.
Low-level GPIO peripheral driver interface definitions.
struct candev candev_t
Forward declaration for candev struct.
Definition candev.h:56
#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.
struct candev_mcp2515 candev_mcp2515_t
MCP2515 candev descriptor.
uint32_t canid_t
Controller Area Network Identifier structure.
Definition can.h:95
spi_mode_t
Support SPI modes.
Definition periph_cpu.h:39
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Controller Area Network frame.
Definition can.h:100
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