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 
45 #ifndef CAN_ESP_H
46 #define CAN_ESP_H
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 #include "can/candev.h"
53 #include "periph/gpio.h"
54 
56 #define ESP_CAN_MAX_RX_FILTERS (16)
57 
59 #define ESP_CAN_MAX_RX_FRAMES (8)
60 
64 typedef struct can {
68  struct can_frame *tx_frame;
72  uint32_t rx_frames_wptr;
73  uint32_t rx_frames_rptr;
74  uint32_t rx_frames_num;
75  uint32_t rx_filter_num;
77  bool powered_up;
79  gpio_t tx_pin;
80  gpio_t rx_pin;
81 #ifdef ESP_CAN_CLK_OUT
82  gpio_t clk_out_pin;
83 #endif
84 #ifdef ESP_CAN_BUS_ON_OFF
85  gpio_t bus_on_off_pin;
86 #endif
87 
88  uint32_t events;
90 } can_t;
91 
93 #define HAVE_CAN_T
94 
98 typedef struct {
99  uint32_t bitrate;
100  gpio_t tx_pin;
101  gpio_t rx_pin;
102 #ifdef ESP_CAN_CLK_OUT
103  gpio_t clk_out_pin;
104 #endif
105 #ifdef ESP_CAN_BUS_ON_OFF
106  gpio_t bus_on_off_pin;
107 #endif
108 } can_conf_t;
109 
111 #define HAVE_CAN_CONF_T
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif /* CAN_ESP_H */
118 
canopt_state_t
canopt_state_t
CAN state options.
Definition: common.h:61
can::state
canopt_state_t state
current state of device
Definition: can_esp.h:66
can_conf_t::tx_pin
gpio_t tx_pin
CAN transceiver TX pin.
Definition: can_esp.h:100
candev
Structure to hold driver state.
Definition: candev.h:78
can_conf_t::bitrate
uint32_t bitrate
Bitrate.
Definition: can_esp.h:99
can::events
uint32_t events
events triggered by the last interrupt
Definition: can_esp.h:88
can_filter
Controller Area Network filter.
Definition: can.h:101
can_conf_t::rx_pin
gpio_t rx_pin
CAN transceiver RX pin.
Definition: can_esp.h:101
can::powered_up
bool powered_up
device is powered up
Definition: can_esp.h:77
can::rx_filter_num
uint32_t rx_filter_num
number of acceptance filters
Definition: can_esp.h:75
can::rx_frames_wptr
uint32_t rx_frames_wptr
pointer to ring buffer for write
Definition: can_esp.h:72
can_t
struct can can_t
Low level device structure for ESP32 CAN (extension of candev_t)
can_frame
Controller Area Network frame.
Definition: can.h:88
can::tx_frame
struct can_frame * tx_frame
frame in transmission
Definition: can_esp.h:68
candev.h
Definitions for low-level CAN driver interface.
can::rx_filters
struct can_filter rx_filters[ESP_CAN_MAX_RX_FILTERS]
acceptance filter list
Definition: can_esp.h:70
can::rx_frames_num
uint32_t rx_frames_num
number of frames in ring buffer
Definition: can_esp.h:74
gpio.h
Low-level GPIO peripheral driver interface definitions.
ESP_CAN_MAX_RX_FILTERS
#define ESP_CAN_MAX_RX_FILTERS
Number of receiver acceptance filters.
Definition: can_esp.h:56
ESP_CAN_MAX_RX_FRAMES
#define ESP_CAN_MAX_RX_FRAMES
Number of frames in receiver buffer, must be a power of two.
Definition: can_esp.h:59
can::tx_pin
gpio_t tx_pin
CAN transceiver TX pin.
Definition: can_esp.h:79
can_conf_t
struct candev_conf can_conf_t
Linux candev configuration.
can::rx_pin
gpio_t rx_pin
CAN transceiver RX pin.
Definition: can_esp.h:80
can
Low level device structure for ESP32 CAN (extension of candev_t)
Definition: can_esp.h:64
can::rx_frames
struct can_frame rx_frames[ESP_CAN_MAX_RX_FRAMES]
frames received
Definition: can_esp.h:69
can::rx_frames_rptr
uint32_t rx_frames_rptr
pointer to ring buffer for read
Definition: can_esp.h:73
can::candev
candev_t candev
candev base structure
Definition: can_esp.h:65