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  uint32_t events;
81 
83 #define HAVE_CAN_T
84 
88 typedef struct {
89  uint32_t bitrate;
90  gpio_t tx_pin;
91  gpio_t rx_pin;
92 #ifdef CAN_CLK_OUT
93  gpio_t clk_out_pin;
94 #endif
95 #ifdef CAN_BUS_ON_OFF
96  gpio_t bus_on_off_pin;
97 #endif
98 } can_conf_t;
99 
101 #define HAVE_CAN_CONF_T
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* CAN_ESP_H */
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:56
#define ESP_CAN_MAX_RX_FRAMES
Number of frames in receiver buffer, must be a power of two.
Definition: can_esp.h:59
struct candev_conf can_conf_t
Linux candev configuration.
canopt_state_t
CAN state options.
Definition: common.h:74
gpio_t tx_pin
CAN transceiver TX pin.
Definition: can_esp.h:90
uint32_t bitrate
Bitrate.
Definition: can_esp.h:89
gpio_t rx_pin
CAN transceiver RX pin.
Definition: can_esp.h:91
Controller Area Network filter.
Definition: can.h:129
Controller Area Network frame.
Definition: can.h:101
Low level device structure for ESP32 CAN (extension of candev_t)
Definition: can_esp.h:64
struct can_filter rx_filters[ESP_CAN_MAX_RX_FILTERS]
acceptance filter list
Definition: can_esp.h:70
canopt_state_t state
current state of device
Definition: can_esp.h:66
uint32_t rx_filter_num
number of acceptance filters
Definition: can_esp.h:75
uint32_t rx_frames_wptr
pointer to ring buffer for write
Definition: can_esp.h:72
uint32_t rx_frames_num
number of frames in ring buffer
Definition: can_esp.h:74
struct can_frame rx_frames[ESP_CAN_MAX_RX_FRAMES]
frames received
Definition: can_esp.h:69
uint32_t rx_frames_rptr
pointer to ring buffer for read
Definition: can_esp.h:73
struct can_frame * tx_frame
frame in transmission
Definition: can_esp.h:68
candev_t candev
candev base structure
Definition: can_esp.h:65
bool powered_up
device is powered up
Definition: can_esp.h:77
uint32_t events
events triggered by the last interrupt
Definition: can_esp.h:79
Structure to hold driver state.
Definition: candev.h:77