drv_can.h 1.1 KB
Newer Older
杨连钊 已提交
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * 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]
12
 * 2019-06-17     YLZ          modify struct stm32_drv_can.
杨连钊 已提交
13
 */
14 15
#ifndef __DRV_CAN_H__
#define __DRV_CAN_H__
16
#include <board.h>
杨连钊 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#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 )

struct stm_baud_rate_tab
{
    rt_uint32_t baud_rate;
    rt_uint32_t confdata;
};

/* STM32 can driver */
struct stm32_drv_can
{
    CAN_HandleTypeDef CanHandle;
40
    CAN_FilterTypeDef FilterConfig;
杨连钊 已提交
41 42 43
};

#ifdef __cplusplus
44
 extern "C" {
杨连钊 已提交
45
#endif
46
rt_err_t rt_hw_can_init(void);
杨连钊 已提交
47
#ifdef __cplusplus
48
 }
杨连钊 已提交
49
#endif
50
#endif /*__DRV_CAN_H__ */