OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [sw/] [drivers/] [can.h] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 rfajardo
 
2
struct can_type
3
{
4
    unsigned char rtr;
5
    unsigned char len;
6
    unsigned short identifier;
7
    unsigned char data[8];
8
};
9
 
10
typedef struct can_type can_type;
11
 
12
#define CAN_BUF_LEN     10
13
 
14
void can_init(void);
15
void can_irq(void);
16
 
17
can_type * can_get(void);       //return pointer to first non read received data
18
 
19
int can_send_basic();           //return (-1) or length (still processing previous) or asserted
20
void can_abort(void);
21
 
22
//BOTH MODES
23
#define CAN_MODE            0x00
24
#define CAN_CMD             0x01
25
#define CAN_STATUS          0x02
26
#define IRQ_READ            0x03
27
 
28
#define CAN_ACPT_CODE0      0x04    //only writable while in reset mode
29
#define CAN_ACPT_MASK0      0x05    //only writable while in reset mode
30
 
31
#define CAN_BUS_TIMING_0    0x06    //only writable while in reset mode
32
#define CAN_BUS_TIMING_1    0x07    //only writable while in reset mode
33
 
34
#define CAN_BUS_CLKDIV      0x1F    //only writable while NOT in reset mode
35
 
36
#define CAN_TX_BUF          0x0A   //only accessable while NOT in reset mode
37
#define CAN_TX_LEN          10
38
 
39
#define CAN_RX_BUF          0x14   //free read access for basic mode
40
#define CAN_RX_LEN          10
41
 
42
//only accessable while in reset mode
43
#define CAN_BUS_MODE        0x1F
44
 
45
 
46
//EXTENDED MODE ONLY
47
//only for extended mode & only accessable while in reset mode
48
#define CAN_IRQ_EN_EXT      0x04    //also writable if NOT in reset mode 
49
 
50
//read only regs
51
#define CAN_ARBIT_LOSS_CNT          0x0B    //cnt of arbitration loss
52
#define CAN_ERROR_CAPTURE_CODE      0x0C
53
#define CAN_RX_MSG_CNT              0x1D
54
//~read only regs
55
 
56
#define CAN_ERROR_WARN_LIMIT        0x0D
57
 
58
#define CAN_RX_ERR_CNT      0x0E
59
#define CAN_TX_ERR_CNT      0x0F
60
 
61
#define CAN_ACPT_CODE0_EXT  0x10    //also writable if NOT in reset mode
62
#define CAN_ACPT_CODE1      0x11
63
#define CAN_ACPT_CODE2      0x12
64
#define CAN_ACPT_CODE3      0x13
65
 
66
#define CAN_ACPT_MASK0_EXT  0x14    //also writable if NOT in reset mode
67
#define CAN_ACPT_MASK1      0x15
68
#define CAN_ACPT_MASK2      0x16
69
#define CAN_ACPT_MASK3      0x17
70
 
71
#define CAN_TX_BUF_EXT      0x10   //accessable if transmit_buffer_status=1 
72
#define CAN_TX_LEN_EXT      13     //ignores reset mode
73
 
74
#define CAN_RX_BUF_EXT      0x10   //read access only in NOT reset mode
75
#define CAN_RX_LEN_EXT      13
76
 
77
 
78
//BITS DEFINITIONS
79
 
80
//BASIC MODE
81
#define CAN_MODE_RESET             0x01
82
#define CAN_MODE_LISTEN_ONLY_BASIC 0x20
83
#define CAN_MODE_RECV_IRQ_EN       0x02
84
#define CAN_MODE_TX_IRQ_EN         0x04
85
#define CAN_MODE_ERROR_IRQ_EN      0x08
86
#define CAN_MODE_OVERRUN_IRQ_EN    0x10
87
//EXTENDED MODE
88
#define CAN_MODE_LISTEN_ONLY_EXT   0x02
89
#define CAN_MODE_SELF_TEST_MODE    0x04
90
#define CAN_MODE_ACPT_FILTER_MODE  0x08
91
 
92
//CMD
93
#define CAN_CMD_CLR_DATA_OVERRUN   0x08
94
#define CAN_CMD_RELEASE_BUFFER     0x04
95
#define CAN_CMD_TX_REQ             0x11
96
#define CAN_CMD_ABORT_TX           0x02
97
 
98
//STATUS
99
#define CAN_STATUS_NODE_BUS_OFF    0x80
100
#define CAN_STATUS_ERROR           0x40
101
#define CAN_STATUS_TX              0x20
102
#define CAN_STATUS_RX              0x10
103
#define CAN_STATUS_TX_COMPLETE     0x08
104
#define CAN_STATUS_TX_BUF          0x04
105
#define CAN_STATUS_OVERRUN         0x02
106
#define CAN_STATUS_RX_BUF          0x01
107
 
108
//IRQ READ
109
#define CAN_IRQ_READ_BUS_ERROR          0x80
110
#define CAN_IRQ_READ_ARBIT_LOST         0x40
111
#define CAN_IRQ_READ_ERROR_PASSIV       0x20
112
#define CAN_IRQ_READ_OVERRUN            0x08
113
#define CAN_IRQ_READ_ERROR              0x04
114
#define CAN_IRQ_READ_TX                 0x02
115
#define CAN_IRQ_READ_RX                 0x01
116
 
117
//BUS_TIMING_0
118
#define CAN_BUS_TIMING_0_SYNC_JMP_SHIFT     6
119
#define CAN_BUS_TIMING_0_SYNC_JMP           0xC0
120
#define CAN_BUS_TIMING_0_BAUD_PRESC         0x3F
121
 
122
//BUS_TIMING_1
123
#define CAN_BUS_TIMING_1_TRIPLE_SAMP_SHIFT  7
124
#define CAN_BUS_TIMING_1_TRIPLE_SAMP        0x80
125
#define CAN_BUS_TIMING_1_TIME_SEG2_SHIFT    4
126
#define CAN_BUS_TIMING_1_TIME_SEG2          0x70
127
#define CAN_BUS_TIMING_1_TIME_SEG1          0x0F
128
 
129
//CLKDIV
130
//only writable while NOT in reset mode
131
#define CAN_BUS_CLKDIV_MASK                 0x07
132
 
133
 
134
//EXTENDED MODE ONLY
135
//CLKMODE
136
//only writable while in reset mode
137
#define CAN_BUS_MODE_CLOCK_OFF              0x08
138
#define CAN_BUS_MODE_EXTENDED_MODE          0x80
139
 
140
//EXTENDED MODE IRQ
141
#define CAN_IRQ_EN_EXT_BUS_ERROR          0x80
142
#define CAN_IRQ_EN_EXT_ARBIT_LOST         0x40
143
#define CAN_IRQ_EN_EXT_ERROR_PASSIV       0x20
144
#define CAN_IRQ_EN_EXT_OVERRUN            0x08
145
#define CAN_IRQ_EN_EXT_ERROR              0x04
146
#define CAN_IRQ_EN_EXT_TX                 0x02
147
#define CAN_IRQ_EN_EXT_RX                 0x01
148
 
149
//EXTENDED ERROR CODES
150
#define CAN_ERROR_CAPTURE_CODE_TYPE_SHIFT 6
151
#define CAN_ERROR_CAPTURE_CODE_TYPE       0xC0
152
#define CAN_ERROR_CAPTURE_CODE_TYPE_BIT   0x0
153
#define CAN_ERROR_CAPTURE_CODE_TYPE_FORM  0x1
154
#define CAN_ERROR_CAPTURE_CODE_TYPE_STUFF 0x2
155
#define CAN_ERROR_CAPTURE_CODE_TYPE_OTHER 0x3
156
#define CAN_ERROR_CAPTURE_CODE_DIR        0x40  //1 = TX | 0 = RX
157
#define CAN_ERROR_CAPTURE_CODE_SEG        0x1F
158
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.