2022-10-20 09:40:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2022, RT-Thread Development Team
|
2022-07-13 19:56:14 +08:00
|
|
|
*
|
2022-10-20 09:40:14 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2022-07-13 19:56:14 +08:00
|
|
|
*
|
2022-10-20 09:40:14 +08:00
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2022-10-19 Nations first version
|
2022-07-13 19:56:14 +08:00
|
|
|
*/
|
2022-07-23 11:53:42 +08:00
|
|
|
|
2022-07-13 19:56:14 +08:00
|
|
|
#ifndef __DRV_CAN_H__
|
|
|
|
#define __DRV_CAN_H__
|
|
|
|
|
|
|
|
#include <rtdevice.h>
|
|
|
|
#include <rtthread.h>
|
2022-10-20 09:40:14 +08:00
|
|
|
#include <board.h>
|
2022-07-13 19:56:14 +08:00
|
|
|
|
2022-10-20 09:40:14 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2022-07-13 19:56:14 +08:00
|
|
|
|
|
|
|
struct n32_baud_rate_tab
|
|
|
|
{
|
2022-10-20 09:40:14 +08:00
|
|
|
uint32_t baud_rate;
|
|
|
|
uint16_t PRESCALE;
|
|
|
|
uint8_t RSJW;
|
|
|
|
uint8_t TBS1;
|
|
|
|
uint8_t TBS2;
|
|
|
|
uint8_t Reserved;
|
2022-07-13 19:56:14 +08:00
|
|
|
};
|
|
|
|
|
2022-10-20 09:40:14 +08:00
|
|
|
#define N32_CAN_BAUD_DEF(rate, rsjw, tbs1, tbs2, prescale) \
|
|
|
|
{ \
|
|
|
|
.baud_rate = rate, \
|
|
|
|
.RSJW = rsjw, \
|
|
|
|
.TBS1 = tbs1, \
|
|
|
|
.TBS2 = tbs2, \
|
|
|
|
.PRESCALE = prescale \
|
|
|
|
}
|
2022-07-13 19:56:14 +08:00
|
|
|
|
|
|
|
/* n32 can device */
|
|
|
|
struct n32_can
|
|
|
|
{
|
|
|
|
char *name;
|
2022-10-20 09:40:14 +08:00
|
|
|
CAN_Module *CANx;
|
|
|
|
CAN_InitType can_init;
|
2022-07-13 19:56:14 +08:00
|
|
|
CAN_FilterInitType FilterConfig;
|
|
|
|
struct rt_can_device device; /* inherit from can device */
|
|
|
|
};
|
|
|
|
|
|
|
|
int rt_hw_can_init(void);
|
|
|
|
|
2022-10-20 09:40:14 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-07-13 19:56:14 +08:00
|
|
|
#endif /* __DRV_CAN_H__ */
|