can_esp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Gunar Schorcht
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 
9 #pragma once
10 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #include "can/candev.h"
52 #include "periph/gpio.h"
53 
55 #define ESP_CAN_MAX_RX_FILTERS (16)
56 
58 #define ESP_CAN_MAX_RX_FRAMES (8)
59 
63 typedef struct can {
67  struct can_frame *tx_frame;
71  uint32_t rx_frames_wptr;
72  uint32_t rx_frames_rptr;
73  uint32_t rx_frames_num;
74  uint32_t rx_filter_num;
76  bool powered_up;
78  uint32_t events;
80 
82 #define HAVE_CAN_T
83 
87 typedef struct {
88  uint32_t bitrate;
89  gpio_t tx_pin;
90  gpio_t rx_pin;
91 #ifdef CAN_CLK_OUT
92  gpio_t clk_out_pin;
93 #endif
94 #ifdef CAN_BUS_ON_OFF
95  gpio_t bus_on_off_pin;
96 #endif
97 } can_conf_t;
98 
100 #define HAVE_CAN_CONF_T
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
Definitions for low-level CAN driver interface.
Low-level GPIO peripheral driver interface definitions.
struct can can_t
Low level device structure for ESP32 CAN (extension of candev_t)
#define ESP_CAN_MAX_RX_FILTERS
Number of receiver acceptance filters.
Definition: can_esp.h:55
#define ESP_CAN_MAX_RX_FRAMES
Number of frames in receiver buffer, must be a power of two.
Definition: can_esp.h:58
struct candev_conf can_conf_t
Linux candev configuration.
canopt_state_t
CAN state options.
Definition: common.h:73
gpio_t tx_pin
CAN transceiver TX pin.
Definition: can_esp.h:89
uint32_t bitrate
Bitrate.
Definition: can_esp.h:88
gpio_t rx_pin
CAN transceiver RX pin.
Definition: can_esp.h:90
Controller Area Network filter.
Definition: can.h:128
Controller Area Network frame.
Definition: can.h:100
Low level device structure for ESP32 CAN (extension of candev_t)
Definition: can_esp.h:63
struct can_filter rx_filters[ESP_CAN_MAX_RX_FILTERS]
acceptance filter list
Definition: can_esp.h:69
canopt_state_t state
current state of device
Definition: can_esp.h:65
uint32_t rx_filter_num
number of acceptance filters
Definition: can_esp.h:74
uint32_t rx_frames_wptr
pointer to ring buffer for write
Definition: can_esp.h:71
uint32_t rx_frames_num
number of frames in ring buffer
Definition: can_esp.h:73
struct can_frame rx_frames[ESP_CAN_MAX_RX_FRAMES]
frames received
Definition: can_esp.h:68
uint32_t rx_frames_rptr
pointer to ring buffer for read
Definition: can_esp.h:72
struct can_frame * tx_frame
frame in transmission
Definition: can_esp.h:67
candev_t candev
candev base structure
Definition: can_esp.h:64
bool powered_up
device is powered up
Definition: can_esp.h:76
uint32_t events
events triggered by the last interrupt
Definition: can_esp.h:78
Structure to hold driver state.
Definition: candev.h:76