Interface for CAN controller drivers.
More...
|
| #define | PBL_CAN_STATE_DEFINE(sym, _tx_slots) |
| | Define the class state of controller sym, for the PBL_CAN_*_DEFINE() macro of a driver.
|
| |
| #define | PBL_CAN_INIT(sym, _name, _parent, _ops, _limits, _data_limits, _modes, _num_filters) |
| | Initializer for the struct pbl_can of controller sym.
|
| |
Interface for CAN controller drivers.
A driver embeds a struct pbl_can in its instance, sets it up with PBL_CAN_STATE_DEFINE() and PBL_CAN_INIT(), and implements the struct pbl_can_ops the class calls.
◆ pbl_can
| Data Fields |
|
const struct pbl_can_timing_limits * |
data_limits |
Data phase bit timing limits, or NULL without CAN FD. |
|
struct pbl_device |
dev |
Device. |
|
const struct pbl_can_timing_limits * |
limits |
Nominal bit timing limits. |
|
uint32_t |
modes |
Supported modes, PBL_CAN_MODE_* flags. |
|
uint8_t |
num_filters |
Acceptance filters. |
|
const struct pbl_can_ops * |
ops |
Driver operations. |
|
struct pbl_can_state * |
state |
Runtime state. |
◆ PBL_CAN_INIT
| #define PBL_CAN_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops, |
|
|
|
_limits, |
|
|
|
_data_limits, |
|
|
|
_modes, |
|
|
|
_num_filters |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_can_state, \
.limits = (_limits), \
.data_limits = (_data_limits), \
.modes = (_modes), \
.num_filters = (_num_filters), \
}
int pbl_can_dev_init(const struct pbl_device *dev)
Device init of every controller: calls the driver's init.
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153
Initializer for the struct pbl_can of controller sym.
- Parameters
-
| sym | Symbol of the controller instance, with its state defined by PBL_CAN_STATE_DEFINE(). |
| _name | Name. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| _limits | Nominal bit timing limits. |
| _data_limits | Data phase bit timing limits, or NULL without CAN FD. |
| _modes | Supported modes. |
| _num_filters | Acceptance filters. |
◆ PBL_CAN_STATE_DEFINE
| #define PBL_CAN_STATE_DEFINE |
( |
|
sym, |
|
|
|
_tx_slots |
|
) |
| |
Value:
static struct pbl_can_state sym##_can_state = { \
}
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50
#define PBL_SEM_INITIALIZER(init, lim)
Static initializer for a semaphore.
Definition sem.h:56
Define the class state of controller sym, for the PBL_CAN_*_DEFINE() macro of a driver.
- Parameters
-
| sym | Symbol of the controller instance. |
| _tx_slots | Frames the controller can have in flight. |
◆ pbl_can_dev_init()
| int pbl_can_dev_init |
( |
const struct pbl_device * |
dev | ) |
|
Device init of every controller: calls the driver's init.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_can_receive()
Hand a received frame to the receive callback.
Called by the controller driver from its interrupt.
- Parameters
-
| can | Controller. |
| frame | Frame. |
◆ pbl_can_report_error()
Count an error.
Called by the controller driver from its interrupt.
- Parameters
-
| can | Controller. |
| error | Kind of error. |
◆ pbl_can_report_state()
Report a state change.
Called by the controller driver from its interrupt.
- Parameters
-
| can | Controller. |
| state | New state. |
| cnt | Error counters. |
◆ pbl_can_tx_done()
Complete a frame given to the driver's send().
Called by the controller driver from its interrupt, or from its stop().
- Parameters
-
| can | Controller. |
| cb | Transmit callback given to send(). |
| arg | Callback argument given to send(). |
| status | 0, -ECANCELED or -ENETDOWN, as for pbl_can_tx_callback_t. |