summaryrefslogtreecommitdiff
path: root/bsp/at32/libraries/rt_drivers/drv_can_v2.h
blob: 90be8266ca8ff906a3cb267919ebadd2668b092f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-08-30     shelton      first version
 */

#ifndef __DRV_CAN_H__
#define __DRV_CAN_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <rtdevice.h>
#include <rtthread.h>
#include "drv_common.h"

#define CANFD_DATA_1MBaud                (1*1000*1000UL)
#define CANFD_DATA_2MBaud                (2*1000*1000UL)
#define CANFD_DATA_3MBaud                (3*1000*1000UL)
#define CANFD_DATA_4MBaud                (4*1000*1000UL)
#define CANFD_DATA_5MBaud                (5*1000*1000UL)
#define CANFD_DATA_6MBaud                (6*1000*1000UL)

struct at32_baud_rate
{
    rt_uint32_t baud_rate;
    rt_uint8_t div;
    rt_uint8_t rsaw_size;
    rt_uint16_t bts1_size;
    rt_uint8_t bts2_size;
};

struct at32_baud_rate_fd
{
    rt_uint32_t baud_rate;
    rt_uint8_t div;
    rt_uint8_t rsaw_size;
    rt_uint16_t bts1_size;
    rt_uint8_t bts2_size;
    rt_uint16_t ssoffset;
};

/* at32 can device */
struct at32_can
{
    char *name;
    can_type *can_x;
    IRQn_Type tx_irqn;
    IRQn_Type rx_irqn;
    IRQn_Type stat_irqn;
    IRQn_Type err_irqn;
    uint8_t enable_canfd;
    can_bittime_type bittime_init_struct;
    can_filter_config_type filter_init_struct;
    struct rt_can_device device;     /* inherit from can device */
};

int rt_hw_can_init(void);

#ifdef __cplusplus
}
#endif

#endif /*__DRV_CAN_H__ */

/************************** end of file ******************/