rt-thread-official/bsp/stm32/libraries/HAL_Drivers/drivers/drv_can.h

60 lines
1.4 KiB
C
Raw Normal View History

2019-02-19 13:29:23 +08:00
/*
2023-01-09 10:20:16 +08:00
* Copyright (c) 2006-2023, RT-Thread Development Team
2019-02-19 13:29:23 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-08-05 Xeon Xu the first version
* 2019-01-22 YLZ port from stm324xx-HAL to bsp stm3210x-HAL
* 2019-01-26 YLZ redefine `struct stm32_drv_can` add member `Rx1Message`
* 2019-02-19 YLZ port to BSP [stm32]
* 2019-06-17 YLZ modify struct stm32_drv_can.
2019-02-19 13:29:23 +08:00
*/
2019-08-16 11:56:26 +08:00
#ifndef __DRV_CAN_H__
#define __DRV_CAN_H__
2019-08-16 11:56:26 +08:00
#ifdef __cplusplus
extern "C" {
#endif
#include <board.h>
2019-02-19 13:29:23 +08:00
#include <rtdevice.h>
#include <rtthread.h>
2019-08-16 11:56:26 +08:00
#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 )
2019-02-19 13:29:23 +08:00
2019-08-16 11:56:26 +08:00
struct stm32_baud_rate_tab
2019-02-19 13:29:23 +08:00
{
rt_uint32_t baud_rate;
2019-08-16 11:56:26 +08:00
rt_uint32_t config_data;
2019-02-19 13:29:23 +08:00
};
2019-08-16 11:56:26 +08:00
#define BAUD_DATA(TYPE,NO) ((can_baud_rate_tab[NO].config_data & TYPE##MASK))
2019-02-19 13:29:23 +08:00
2019-08-16 11:56:26 +08:00
/* stm32 can device */
struct stm32_can
2019-02-19 13:29:23 +08:00
{
2019-08-16 11:56:26 +08:00
char *name;
2019-02-19 13:29:23 +08:00
CAN_HandleTypeDef CanHandle;
CAN_FilterTypeDef FilterConfig;
2019-08-16 11:56:26 +08:00
struct rt_can_device device; /* inherit from can device */
2019-02-19 13:29:23 +08:00
};
2019-06-28 10:57:37 +08:00
int rt_hw_can_init(void);
2019-08-16 11:56:26 +08:00
2019-02-19 13:29:23 +08:00
#ifdef __cplusplus
2019-08-16 11:56:26 +08:00
}
2019-02-19 13:29:23 +08:00
#endif
2019-08-16 11:56:26 +08:00
#endif /*__DRV_CAN_H__ */
2019-08-16 11:56:26 +08:00
/************************** end of file ******************/