mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
[bsp] [stm32] fix drv_can.c
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -11,40 +11,49 @@
|
||||
* 2019-02-19 YLZ port to BSP [stm32]
|
||||
* 2019-06-17 YLZ modify struct stm32_drv_can.
|
||||
*/
|
||||
|
||||
#ifndef __DRV_CAN_H__
|
||||
#define __DRV_CAN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <board.h>
|
||||
#include <rtdevice.h>
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#define BS1SHIFT 16
|
||||
#define BS2SHIFT 20
|
||||
#define RRESCLSHIFT 0
|
||||
#define SJWSHIFT 24
|
||||
#define BS1MASK ( (0x0F) << BS1SHIFT )
|
||||
#define BS2MASK ( (0x07) << BS2SHIFT )
|
||||
#define RRESCLMASK ( 0x3FF << RRESCLSHIFT )
|
||||
#define SJWMASK ( 0x3 << SJWSHIFT )
|
||||
#define BS1SHIFT 16
|
||||
#define BS2SHIFT 20
|
||||
#define RRESCLSHIFT 0
|
||||
#define SJWSHIFT 24
|
||||
#define BS1MASK ((0x0F) << BS1SHIFT )
|
||||
#define BS2MASK ((0x07) << BS2SHIFT )
|
||||
#define RRESCLMASK (0x3FF << RRESCLSHIFT )
|
||||
#define SJWMASK (0x3 << SJWSHIFT )
|
||||
|
||||
struct stm_baud_rate_tab
|
||||
struct stm32_baud_rate_tab
|
||||
{
|
||||
rt_uint32_t baud_rate;
|
||||
rt_uint32_t confdata;
|
||||
rt_uint32_t config_data;
|
||||
};
|
||||
#define BAUD_DATA(TYPE,NO) ((can_baud_rate_tab[NO].config_data & TYPE##MASK))
|
||||
|
||||
/* STM32 can driver */
|
||||
struct stm32_drv_can
|
||||
/* stm32 can device */
|
||||
struct stm32_can
|
||||
{
|
||||
char *name;
|
||||
CAN_HandleTypeDef CanHandle;
|
||||
CAN_FilterTypeDef FilterConfig;
|
||||
struct rt_can_device device; /* inherit from can device */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int rt_hw_can_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__DRV_CAN_H__ */
|
||||
|
||||
/************************** end of file ******************/
|
||||
|
||||
@@ -29,9 +29,9 @@ STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c
|
||||
''')
|
||||
|
||||
if GetDepend(['RT_USING_SERIAL']):
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c']
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c']
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c']
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c']
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c']
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c']
|
||||
|
||||
if GetDepend(['RT_USING_I2C']):
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c']
|
||||
@@ -49,7 +49,7 @@ if GetDepend(['RT_USING_USB_HOST']) or GetDepend(['RT_USING_USB_DEVICE']):
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c']
|
||||
|
||||
if GetDepend(['RT_USING_CAN']):
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_can.c']
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fdcan.c']
|
||||
|
||||
if GetDepend(['RT_USING_HWTIMER']) or GetDepend(['RT_USING_PWM']):
|
||||
src += ['STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c']
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -221,7 +221,7 @@ struct rt_can_msg
|
||||
rt_uint32_t rsv : 1;
|
||||
rt_uint32_t len : 8;
|
||||
rt_uint32_t priv : 8;
|
||||
rt_uint32_t hdr : 8;
|
||||
rt_int32_t hdr : 8;
|
||||
rt_uint32_t reserved : 8;
|
||||
rt_uint8_t data[8];
|
||||
};
|
||||
@@ -252,7 +252,7 @@ struct rt_can_rx_fifo
|
||||
|
||||
#define RT_CAN_EVENT_RX_IND 0x01 /* Rx indication */
|
||||
#define RT_CAN_EVENT_TX_DONE 0x02 /* Tx complete */
|
||||
#define RT_CAN_EVENT_TX_FAIL 0x03 /* Tx complete */
|
||||
#define RT_CAN_EVENT_TX_FAIL 0x03 /* Tx fail */
|
||||
#define RT_CAN_EVENT_RX_TIMEOUT 0x05 /* Rx timeout */
|
||||
#define RT_CAN_EVENT_RXOF_IND 0x06 /* Rx overflow */
|
||||
|
||||
@@ -278,7 +278,7 @@ struct rt_can_ops
|
||||
int (*recvmsg)(struct rt_can_device *can, void *buf, rt_uint32_t boxno);
|
||||
};
|
||||
|
||||
rt_err_t rt_hw_can_register(struct rt_can_device *can,
|
||||
rt_err_t rt_hw_can_register(struct rt_can_device *can,
|
||||
const char *name,
|
||||
const struct rt_can_ops *ops,
|
||||
void *data);
|
||||
|
||||
@@ -847,7 +847,7 @@ long list_device(void)
|
||||
device->parent.name,
|
||||
(device->type <= RT_Device_Class_Unknown) ?
|
||||
device_type_str[device->type] :
|
||||
device_type_str[RT_Device_Class_Unknown],
|
||||
device_type_str[RT_Device_Class_Unknown - 1],
|
||||
device->ref_count);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user