diff options
| author | iabdalkader | 2019-09-16 01:56:38 +0200 |
|---|---|---|
| committer | Damien George | 2019-09-23 17:00:54 +1000 |
| commit | f7a07b36057d61264958e3577f7e4555e77d520c (patch) | |
| tree | cdc7cdd14f97fe54d33552e539cafc0f4d992444 /ports/stm32/can.h | |
| parent | d06fd384c2c26c18ffbcbb83f64548ec19875012 (diff) | |
stm32: Add support for FDCAN peripheral, exposed as pyb.CAN.
The new fdcan.c file provides the low-level C interface to the FDCAN
peripheral, and pyb_can.c is updated to support both traditional CAN and
FDCAN, depending on the MCU being compiled for.
Diffstat (limited to 'ports/stm32/can.h')
| -rw-r--r-- | ports/stm32/can.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ports/stm32/can.h b/ports/stm32/can.h index 777da7e45..085070b60 100644 --- a/ports/stm32/can.h +++ b/ports/stm32/can.h @@ -37,6 +37,13 @@ #define MASK32 (2) #define LIST32 (3) +#if MICROPY_HW_ENABLE_FDCAN +#define CAN_TypeDef FDCAN_GlobalTypeDef +#define CAN_HandleTypeDef FDCAN_HandleTypeDef +#define CanTxMsgTypeDef FDCAN_TxHeaderTypeDef +#define CanRxMsgTypeDef FDCAN_RxHeaderTypeDef +#endif + enum { CAN_STATE_STOPPED, CAN_STATE_ERROR_ACTIVE, @@ -74,10 +81,9 @@ void can_deinit_all(void); bool can_init(pyb_can_obj_t *can_obj, uint32_t mode, uint32_t prescaler, uint32_t sjw, uint32_t bs1, uint32_t bs2, bool auto_restart); void can_deinit(pyb_can_obj_t *self); -void can_clearfilter(uint32_t f, uint8_t bank); -int can_receive(CAN_TypeDef *can, int fifo, CanRxMsgTypeDef *msg, uint32_t timeout_ms); +void can_clearfilter(pyb_can_obj_t *self, uint32_t f, uint8_t bank); +int can_receive(CAN_HandleTypeDef *can, int fifo, CanRxMsgTypeDef *msg, uint8_t *data, uint32_t timeout_ms); HAL_StatusTypeDef CAN_Transmit(CAN_HandleTypeDef *hcan, uint32_t Timeout); - void pyb_can_handle_callback(pyb_can_obj_t *self, uint fifo_id, mp_obj_t callback, mp_obj_t irq_reason); #endif // MICROPY_INCLUDED_STM32_CAN_H |
