Subversion Repositories svn.mios32

Rev

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

Rev 2646 Rev 2657
Line 155... Line 155...
155
//! \param[in] can filter bank number
155
//! \param[in] can filter bank number
156
//! \param[in] extended id for filter
156
//! \param[in] extended id for filter
157
//! \param[in] extended id for mask
157
//! \param[in] extended id for mask
158
//! \return < 0 if initialisation failed
158
//! \return < 0 if initialisation failed
159
/////////////////////////////////////////////////////////////////////////////
159
/////////////////////////////////////////////////////////////////////////////
160
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, can_ext_filter_t filter, u8 enabled)
160
s32 MIOS32_CAN_Init32bitFilter(u8 bank, u8 fifo, mios32_can_ext_filter_t filter, u8 enabled)
161
{
161
{
162
#if MIOS32_CAN_NUM == 0
162
#if MIOS32_CAN_NUM == 0
163
  return -1; // no CAN enabled
163
  return -1; // no CAN enabled
164
#else
164
#else
165
  return 0; // no error
165
  return 0; // no error
Line 171... Line 171...
171
//! \param[in] can filter bank number
171
//! \param[in] can filter bank number
172
//! \param[in] standard id for filter
172
//! \param[in] standard id for filter
173
//! \param[in] standard id for mask
173
//! \param[in] standard id for mask
174
//! \return < 0 if initialisation failed
174
//! \return < 0 if initialisation failed
175
/////////////////////////////////////////////////////////////////////////////
175
/////////////////////////////////////////////////////////////////////////////
176
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, can_std_filter_t filter1, can_std_filter_t filter2, u8 enabled)
176
s32 MIOS32_CAN_Init16bitFilter(u8 bank, u8 fifo, mios32_can_std_filter_t filter1, mios32_can_std_filter_t filter2, u8 enabled)
177
{
177
{
178
#if MIOS32_CAN_NUM == 0
178
#if MIOS32_CAN_NUM == 0
179
  return -1; // no CAN enabled
179
  return -1; // no CAN enabled
180
#else
180
#else
181
  return 0; // no error
181
  return 0; // no error
Line 187... Line 187...
187
//! \param[in] CAN number (0..1)
187
//! \param[in] CAN number (0..1)
188
//! \return -1: can not available
188
//! \return -1: can not available
189
//! \return -2: function not prepared for this CAN
189
//! \return -2: function not prepared for this CAN
190
//! \return -3: CAN Initialisation failed
190
//! \return -3: CAN Initialisation failed
191
/////////////////////////////////////////////////////////////////////////////
191
/////////////////////////////////////////////////////////////////////////////
192
s32 MIOS32_CAN_InitPacket(can_packet_t *packet)
192
s32 MIOS32_CAN_InitPacket(mios32_can_packet_t *packet)
193
{
193
{
194
#if NUM_SUPPORTED_CANS == 0
194
#if NUM_SUPPORTED_CANS == 0
195
  return -1; // no CAN available
195
  return -1; // no CAN available
196
#else
196
#else
197
  return 0;
197
  return 0;
Line 238... Line 238...
238
//! \return -1 if CAN not available
238
//! \return -1 if CAN not available
239
//! \return -2 if no new byte available
239
//! \return -2 if no new byte available
240
//! \return >= 0: number of received bytes
240
//! \return >= 0: number of received bytes
241
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
241
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
242
/////////////////////////////////////////////////////////////////////////////
242
/////////////////////////////////////////////////////////////////////////////
243
s32 MIOS32_CAN_RxBufferGet(u8 can, can_packet_t *p)
243
s32 MIOS32_CAN_RxBufferGet(u8 can, mios32_can_packet_t *p)
244
{
244
{
245
#if NUM_SUPPORTED_CANS == 0
245
#if NUM_SUPPORTED_CANS == 0
246
  return -1; // no CAN available
246
  return -1; // no CAN available
247
#else
247
#else
248
  return 0; // return received byte
248
  return 0; // return received byte
Line 256... Line 256...
256
//! \return -1 if CAN not available
256
//! \return -1 if CAN not available
257
//! \return -2 if no new byte available
257
//! \return -2 if no new byte available
258
//! \return >= 0: number of received bytes
258
//! \return >= 0: number of received bytes
259
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
259
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
260
/////////////////////////////////////////////////////////////////////////////
260
/////////////////////////////////////////////////////////////////////////////
261
s32 MIOS32_CAN_RxBufferPeek(u8 can, can_packet_t *p)
261
s32 MIOS32_CAN_RxBufferPeek(u8 can, mios32_can_packet_t *p)
262
{
262
{
263
#if NUM_SUPPORTED_CANS == 0
263
#if NUM_SUPPORTED_CANS == 0
264
  return -1; // no CAN available
264
  return -1; // no CAN available
265
#else
265
#else
266
  return 0; // return received byte
266
  return 0; // return received byte
Line 291... Line 291...
291
//! \return 0 if no error
291
//! \return 0 if no error
292
//! \return -1 if CAN not available
292
//! \return -1 if CAN not available
293
//! \return -2 if buffer full (retry)
293
//! \return -2 if buffer full (retry)
294
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
294
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
295
/////////////////////////////////////////////////////////////////////////////
295
/////////////////////////////////////////////////////////////////////////////
296
s32 MIOS32_CAN_RxBufferPut(u8 can, can_packet_t p)
296
s32 MIOS32_CAN_RxBufferPut(u8 can, mios32_can_packet_t p)
297
{
297
{
298
#if NUM_SUPPORTED_CANS == 0
298
#if NUM_SUPPORTED_CANS == 0
299
  return -1; // no CAN available
299
  return -1; // no CAN available
300
#else
300
#else
301
  return 0; // no error
301
  return 0; // no error
Line 348... Line 348...
348
//! \return -1 if CAN not available
348
//! \return -1 if CAN not available
349
//! \return -2 if no new byte available
349
//! \return -2 if no new byte available
350
//! \return >= 0: transmitted byte
350
//! \return >= 0: transmitted byte
351
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
351
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
352
/////////////////////////////////////////////////////////////////////////////
352
/////////////////////////////////////////////////////////////////////////////
353
s32 MIOS32_CAN_TxBufferGet(u8 can, can_packet_t *p)
353
s32 MIOS32_CAN_TxBufferGet(u8 can, mios32_can_packet_t *p)
354
{
354
{
355
#if NUM_SUPPORTED_CANS == 0
355
#if NUM_SUPPORTED_CANS == 0
356
  return -1; // no CAN available
356
  return -1; // no CAN available
357
#else
357
#else
358
  return 0; // no error
358
  return 0; // no error
Line 369... Line 369...
369
//! \return -1 if CAN not available
369
//! \return -1 if CAN not available
370
//! \return -2 if buffer full or cannot get all requested bytes (retry)
370
//! \return -2 if buffer full or cannot get all requested bytes (retry)
371
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
371
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
372
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
372
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
373
/////////////////////////////////////////////////////////////////////////////
373
/////////////////////////////////////////////////////////////////////////////
374
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, can_packet_t* p,u16 len)
374
s32 MIOS32_CAN_TxBufferPutMore_NonBlocking(u8 can, mios32_can_packet_t* p,u16 len)
375
{
375
{
376
#if NUM_SUPPORTED_CANS == 0
376
#if NUM_SUPPORTED_CANS == 0
377
  return -1; // no CAN available
377
  return -1; // no CAN available
378
#else
378
#else
379
  return 0; // no error
379
  return 0; // no error
Line 389... Line 389...
389
//! \return 0 if no error
389
//! \return 0 if no error
390
//! \return -1 if CAN not available
390
//! \return -1 if CAN not available
391
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
391
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
392
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
392
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
393
/////////////////////////////////////////////////////////////////////////////
393
/////////////////////////////////////////////////////////////////////////////
394
s32 MIOS32_CAN_TxBufferPutMore(u8 can, can_packet_t *packets, u16 len)
394
s32 MIOS32_CAN_TxBufferPutMore(u8 can, mios32_can_packet_t *packets, u16 len)
395
{
395
{
396
  s32 error;
396
  s32 error;
397
 
397
 
398
  while( (error=MIOS32_CAN_TxBufferPutMore_NonBlocking(can, packets, len)) == -2 );
398
  while( (error=MIOS32_CAN_TxBufferPutMore_NonBlocking(can, packets, len)) == -2 );
399
 
399
 
Line 409... Line 409...
409
//! \return -1 if CAN not available
409
//! \return -1 if CAN not available
410
//! \return -2 if buffer full (retry)
410
//! \return -2 if buffer full (retry)
411
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
411
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
412
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
412
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
413
/////////////////////////////////////////////////////////////////////////////
413
/////////////////////////////////////////////////////////////////////////////
414
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, can_packet_t p)
414
s32 MIOS32_CAN_TxBufferPut_NonBlocking(u8 can, mios32_can_packet_t p)
415
{
415
{
416
  // for more comfortable usage...
416
  // for more comfortable usage...
417
  // -> just forward to MIOS32_CAN_TxBufferPutMore
417
  // -> just forward to MIOS32_CAN_TxBufferPutMore
418
  return MIOS32_CAN_TxBufferPutMore(can, &p, 1);
418
  return MIOS32_CAN_TxBufferPutMore(can, &p, 1);
419
}
419
}
Line 427... Line 427...
427
//! \return 0 if no error
427
//! \return 0 if no error
428
//! \return -1 if CAN not available
428
//! \return -1 if CAN not available
429
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
429
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
430
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
430
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
431
/////////////////////////////////////////////////////////////////////////////
431
/////////////////////////////////////////////////////////////////////////////
432
s32 MIOS32_CAN_TxBufferPut(u8 can, can_packet_t p)
432
s32 MIOS32_CAN_TxBufferPut(u8 can, mios32_can_packet_t p)
433
{
433
{
434
  s32 error;
434
  s32 error;
435
 
435
 
436
  while( (error=MIOS32_CAN_TxBufferPutMore(can, &p, 1)) == -2 );
436
  while( (error=MIOS32_CAN_TxBufferPutMore(can, &p, 1)) == -2 );
437
 
437
 
Line 467... Line 467...
467
//! \return -1 if CAN not available
467
//! \return -1 if CAN not available
468
//! \return -2 if buffer full or cannot get all requested bytes (retry)
468
//! \return -2 if buffer full or cannot get all requested bytes (retry)
469
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
469
//! \return -3 if CAN not supported by MIOS32_CAN_TxBufferPut Routine
470
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
470
//! \note Applications shouldn't call these functions directly, instead please use \ref MIOS32_COM or \ref MIOS32_MIDI layer functions
471
/////////////////////////////////////////////////////////////////////////////
471
/////////////////////////////////////////////////////////////////////////////
472
s32 MIOS32_CAN_Transmit(u8 can, can_packet_t p, s16 block_time)
472
s32 MIOS32_CAN_Transmit(u8 can, mios32_can_packet_t p, s16 block_time)
473
{
473
{
474
#if NUM_SUPPORTED_CANS == 0
474
#if NUM_SUPPORTED_CANS == 0
475
  return -1; // no CAN available
475
  return -1; // no CAN available
476
#else
476
#else
477
  return 0; // no error
477
  return 0; // no error
Line 479... Line 479...
479
}
479
}
480
480
481
/////////////////////////////////////////////////////////////////////////////
481
/////////////////////////////////////////////////////////////////////////////
482
//
482
//
483
/////////////////////////////////////////////////////////////////////////////
483
/////////////////////////////////////////////////////////////////////////////
484
s32 MIOS32_CAN_ReportLastErr(u8 can, can_stat_err_t* err)
484
s32 MIOS32_CAN_ReportLastErr(u8 can, mios32_can_stat_err_t* err)
485
{
485
{
486
#if NUM_SUPPORTED_CANS == 0
486
#if NUM_SUPPORTED_CANS == 0
487
  return -1; // no CAN available
487
  return -1; // no CAN available
488
#else
488
#else
489
  return 0; // no error
489
  return 0; // no error
Line 491... Line 491...
491
}
491
}
492
492
493
/////////////////////////////////////////////////////////////////////////////
493
/////////////////////////////////////////////////////////////////////////////
494
//
494
//
495
/////////////////////////////////////////////////////////////////////////////
495
/////////////////////////////////////////////////////////////////////////////
496
s32 MIOS32_CAN_ReportGetCurr(u8 can, can_stat_report_t* report)
496
s32 MIOS32_CAN_ReportGetCurr(u8 can, mios32_can_stat_report_t* report)
497
{
497
{
498
#if NUM_SUPPORTED_CANS == 0
498
#if NUM_SUPPORTED_CANS == 0
499
  return -1; // no CAN available
499
  return -1; // no CAN available
500
#else
500
#else
501
  return 0; // no error
501
  return 0; // no error