Subversion Repositories svn.mios32

Rev

Rev 2652 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2652 Rev 2657
Line 79... Line 79...
79
    u16 ide:1;
79
    u16 ide:1;
80
    u16 rtr:1;
80
    u16 rtr:1;
81
    u16 :11;
81
    u16 :11;
82
  };
82
  };
83
 
83
 
84
} can_std_id_t;
84
} mios32_can_std_id_t;
85
85
86
// CAN Extended 29bits Id(32Bits reg), CAN_RIxR/CAN_TIxR
86
// CAN Extended 29bits Id(32Bits reg), CAN_RIxR/CAN_TIxR
87
typedef union {
87
typedef union {
88
  u32 ALL;
88
  u32 ALL;
89
  struct {
89
  struct {
Line 112... Line 112...
112
  struct {
112
  struct {
113
    u32 :1;
113
    u32 :1;
114
    u32 lpc_ctrl:2; // special field for lpc,
114
    u32 lpc_ctrl:2; // special field for lpc,
115
    u32 ext_id:29;
115
    u32 ext_id:29;
116
  };
116
  };
117
} can_ext_id_t;
117
} mios32_can_ext_id_t;
118
118
119
// CAN control registers CAN_TDTxR/CAN_RDTxR
119
// CAN control registers CAN_TDTxR/CAN_RDTxR
120
typedef union {
120
typedef union {
121
  u32 ALL;
121
  u32 ALL;
122
  struct {
122
  struct {
Line 129... Line 129...
129
    u32 DLC:4;
129
    u32 DLC:4;
130
    u32 :4;
130
    u32 :4;
131
    u32 tgt:1;
131
    u32 tgt:1;
132
    u32 :23;
132
    u32 :23;
133
  };
133
  };
134
} can_ctrl_t;
134
} mios32_can_ctrl_t;
135
135
136
// CAN data registers CAN_TDLxR/CAN_TDHxR/CAN_RDLxR/CAN_RDHxR
136
// CAN data registers CAN_TDLxR/CAN_TDHxR/CAN_RDLxR/CAN_RDHxR
137
typedef union {
137
typedef union {
138
  struct {
138
  struct {
139
    u32 ALL[2];
139
    u32 ALL[2];
Line 146... Line 146...
146
    u16 data[4];
146
    u16 data[4];
147
  };
147
  };
148
  struct {
148
  struct {
149
    u8 bytes[8];
149
    u8 bytes[8];
150
  };
150
  };
151
} can_data_t;
151
} mios32_can_data_t;
152
152
153
// CAN mailboxes packet
153
// CAN mailboxes packet
154
typedef struct can_packet_t {
154
typedef struct mios32_can_packet_t {
155
  can_ext_id_t id;
155
  mios32_can_ext_id_t id;
156
  can_ctrl_t ctrl;
156
  mios32_can_ctrl_t ctrl;
157
  can_data_t data;
157
  mios32_can_data_t data;
158
} can_packet_t;
158
} mios32_can_packet_t;
159
159
160
// CAN 16bits filter
160
// CAN 16bits filter
161
typedef struct can_std_filter_t {
161
typedef struct mios32_can_std_filter_t {
162
  can_std_id_t   filt;
162
  mios32_can_std_id_t   filt;
163
  can_std_id_t   mask;
163
  mios32_can_std_id_t   mask;
164
} can_std_filter_t;
164
} mios32_can_std_filter_t;
165
165
166
// CAN 32bits filter
166
// CAN 32bits filter
167
typedef struct can_ext_filter_t {
167
typedef struct mios32_can_ext_filter_t {
168
  can_ext_id_t   filt;
168
  mios32_can_ext_id_t   filt;
169
  can_ext_id_t   mask;
169
  mios32_can_ext_id_t   mask;
170
} can_ext_filter_t;
170
} mios32_can_ext_filter_t;
171
171
172
// CAN bus state
172
// CAN bus state
173
typedef enum {
173
typedef enum {
174
  BUS_OK = 2,
174
  BUS_OK = 2,
175
  WARNING = 1,
175
  WARNING = 1,
176
  PASSIVE = 0,
176
  PASSIVE = 0,
177
  BUS_OFF = -1
177
  BUS_OFF = -1
178
} can_bus_stat_t;
178
} mios32_can_bus_stat_t;
179
179
180
// CAN error staus
180
// CAN error staus
181
typedef union {
181
typedef union {
182
  struct {
182
  struct {
183
    u32 ALL;
183
    u32 ALL;
Line 200... Line 200...
200
    u32 lec:3;
200
    u32 lec:3;
201
    u32 :9;
201
    u32 :9;
202
    u32 tec:8;
202
    u32 tec:8;
203
    u32 rec:8;
203
    u32 rec:8;
204
  };
204
  };
205
} can_stat_err_t;
205
} mios32_can_stat_err_t;
206
206
207
// CAN status report
207
// CAN status report
208
typedef struct can_stat_report_t {
208
typedef struct mios32_can_stat_report_t {
209
  u32            rx_packets_err;
209
  u32            rx_packets_err;
210
  u32            tx_packets_ctr;
210
  u32            tx_packets_ctr;
211
  u32            rx_packets_ctr;
211
  u32            rx_packets_ctr;
212
  u32            rx_buff_err_ctr;
212
  u32            rx_buff_err_ctr;
213
  u8             rx_last_buff_err;
213
  u8             rx_last_buff_err;
214
  can_bus_stat_t bus_state;
214
  mios32_can_bus_stat_t bus_state;
215
  can_stat_err_t bus_curr_err;
215
  mios32_can_stat_err_t bus_curr_err;
216
  can_stat_err_t bus_last_err;
216
  mios32_can_stat_err_t bus_last_err;
217
} can_stat_report_t;
217
} mios32_can_stat_report_t;
218
218
219
/////////////////////////////////////////////////////////////////////////////
219
/////////////////////////////////////////////////////////////////////////////
220
// Prototypes
220
// Prototypes
221
/////////////////////////////////////////////////////////////////////////////
221
/////////////////////////////////////////////////////////////////////////////
222
222
Line 227... Line 227...
227
extern s32 MIOS32_CAN_IsAssignedToMIDI(u8 can);
227
extern s32 MIOS32_CAN_IsAssignedToMIDI(u8 can);
228
228
229
extern s32 MIOS32_CAN_InitPort(u8 can, u8 is_midi);
229
extern s32 MIOS32_CAN_InitPort(u8 can, u8 is_midi);
230
extern s32 MIOS32_CAN_InitPortDefault(u8 can);
230
extern s32 MIOS32_CAN_InitPortDefault(u8 can);
231
extern s32 MIOS32_CAN_InitPeriph(u8 can);
231
extern s32 MIOS32_CAN_InitPeriph(u8 can);
232
extern s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, can_ext_filter_t filter, u8 enabled);
232
extern s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, mios32_can_ext_filter_t filter, u8 enabled);
233
extern s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, can_std_filter_t filter1, can_std_filter_t filter2, u8 enabled);
233
extern s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, mios32_can_std_filter_t filter1, mios32_can_std_filter_t filter2, u8 enabled);
234
extern s32 MIOS32_CAN_InitPacket(can_packet_t *packet);
234
extern s32 MIOS32_CAN_InitPacket(mios32_can_packet_t *packet);
235
235
236
extern s32 MIOS32_CAN_RxBufferFree(u8 can);
236
extern s32 MIOS32_CAN_RxBufferFree(u8 can);
237
extern s32 MIOS32_CAN_RxBufferUsed(u8 can);
237
extern s32 MIOS32_CAN_RxBufferUsed(u8 can);
238
extern s32 MIOS32_CAN_RxBufferGet(u8 can, can_packet_t *p);
238
extern s32 MIOS32_CAN_RxBufferGet(u8 can, mios32_can_packet_t *p);
239
extern s32 MIOS32_CAN_RxBufferPeek(u8 can, can_packet_t *p);
239
extern s32 MIOS32_CAN_RxBufferPeek(u8 can, mios32_can_packet_t *p);
240
extern s32 MIOS32_CAN_RxBufferRemove(u8 can);
240
extern s32 MIOS32_CAN_RxBufferRemove(u8 can);
241
extern s32 MIOS32_CAN_RxBufferPut(u8 can, can_packet_t p);
241
extern s32 MIOS32_CAN_RxBufferPut(u8 can, mios32_can_packet_t p);
242
242
243
extern s32 MIOS32_CAN_TxBufferFree(u8 can);
243
extern s32 MIOS32_CAN_TxBufferFree(u8 can);
244
extern s32 MIOS32_CAN_TxBufferUsed(u8 can);
244
extern s32 MIOS32_CAN_TxBufferUsed(u8 can);
245
extern s32 MIOS32_CAN_TxBufferGet(u8 can, can_packet_t *p);
245
extern s32 MIOS32_CAN_TxBufferGet(u8 can, mios32_can_packet_t *p);
246
extern s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, can_packet_t* p,u16 len);
246
extern s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, mios32_can_packet_t* p,u16 len);
247
extern s32 MIOS32_CAN_TxBufferPutMore(u8 can, can_packet_t *packets, u16 len);
247
extern s32 MIOS32_CAN_TxBufferPutMore(u8 can, mios32_can_packet_t *packets, u16 len);
248
extern s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, can_packet_t p);
248
extern s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, mios32_can_packet_t p);
249
extern s32 MIOS32_CAN_TxBufferPut(u8 can, can_packet_t p);
249
extern s32 MIOS32_CAN_TxBufferPut(u8 can, mios32_can_packet_t p);
250
250
251
extern s32 MIOS32_CAN_BusErrorCheck(u8 can);
251
extern s32 MIOS32_CAN_BusErrorCheck(u8 can);
252
252
253
extern s32 MIOS32_CAN_Transmit(u8 can, can_packet_t p, s16 block_time);
253
extern s32 MIOS32_CAN_Transmit(u8 can, mios32_can_packet_t p, s16 block_time);
254
254
255
extern s32 MIOS32_CAN_ReportLastErr(u8 can, can_stat_err_t* err);
255
extern s32 MIOS32_CAN_ReportLastErr(u8 can, mios32_can_stat_err_t* err);
256
extern s32 MIOS32_CAN_ReportGetCurr(u8 can, can_stat_report_t* report);
256
extern s32 MIOS32_CAN_ReportGetCurr(u8 can, mios32_can_stat_report_t* report);
257
extern s32 MIOS32_CAN_ReportReset(u8 can);
257
extern s32 MIOS32_CAN_ReportReset(u8 can);
258
/////////////////////////////////////////////////////////////////////////////
258
/////////////////////////////////////////////////////////////////////////////
259
// Export global variables
259
// Export global variables
260
/////////////////////////////////////////////////////////////////////////////
260
/////////////////////////////////////////////////////////////////////////////
261
extern u32 can_temp;
-
 
262
261
263
#endif /* _MIOS32_CAN_H */
262
#endif /* _MIOS32_CAN_H */