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

55 lines
1.3 KiB
C
Raw Normal View History

2019-02-19 13:29:23 +08:00
/*
* 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]
*/
#ifndef __DRV_CAN_H__
#define __DRV_CAN_H__
2019-02-19 13:29:23 +08:00
#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 )
struct stm_baud_rate_tab
{
rt_uint32_t baud_rate;
rt_uint32_t confdata;
};
/* STM32 can driver */
struct stm32_drv_can
{
CAN_HandleTypeDef CanHandle;
CAN_TxHeaderTypeDef TxMessage;
CAN_RxHeaderTypeDef RxMessage;
2019-06-15 14:05:28 +08:00
uint8_t RxMessage_Data[8];
CAN_RxHeaderTypeDef Rx1Message;
2019-06-15 14:05:28 +08:00
uint8_t Rx1Message_Data[8];
CAN_FilterTypeDef FilterConfig;
2019-02-19 13:29:23 +08:00
};
#ifdef __cplusplus
2019-06-15 14:05:28 +08:00
extern "C" {
2019-02-19 13:29:23 +08:00
#endif
extern int rt_hw_can_init(void);
#ifdef __cplusplus
2019-06-15 14:05:28 +08:00
}
2019-02-19 13:29:23 +08:00
#endif
#endif /*__DRV_CAN_H__ */