ChibiOS/RT Logo ChibiOS/RT

Architecture - Reference Manual - Guides

Modules | Defines | Enumerations | Functions

CAN Driver
[HAL]

Generic CAN Driver. More...

Collaboration diagram for CAN Driver:


Description

Generic CAN Driver.

This module implements a generic ADC driver. The driver implements a state machine internally:

inline_dotgraph_17.dot

Modules

 CAN Low Level Driver
 

CAN Driver low level driver template.


Defines

#define CAN_LIMIT_WARNING   1
 Errors rate warning.
#define CAN_LIMIT_ERROR   2
 Errors rate error.
#define CAN_BUS_OFF_ERROR   4
 Bus off condition reached.
#define CAN_FRAMING_ERROR   8
 Framing error of some kind on the CAN bus.
#define CAN_OVERFLOW_ERROR   16
 Overflow in receive queue.
#define CAN_USE_SLEEP_MODE   TRUE
 Sleep mode related APIs inclusion switch.
#define canAddFlagsI(canp, mask)   ((canp)->cd_status |= (mask))
 Adds some flags to the CAN status mask.

Enumerations

enum  canstate_t {
  CAN_UNINIT = 0, CAN_STOP = 1, CAN_STARTING = 2, CAN_READY = 3,
  CAN_SLEEP = 4
}
 

Driver state machine possible states.

More...

Functions

void canInit (void)
 CAN Driver initialization.
void canObjectInit (CANDriver *canp)
 Initializes the standard part of a CANDriver structure.
void canStart (CANDriver *canp, const CANConfig *config)
 Configures and activates the CAN peripheral.
void canStop (CANDriver *canp)
 Deactivates the CAN peripheral.
msg_t canTransmit (CANDriver *canp, const CANTxFrame *ctfp, systime_t timeout)
 Can frame transmission.
msg_t canReceive (CANDriver *canp, CANRxFrame *crfp, systime_t timeout)
 Can frame receive.
canstatus_t canGetAndClearFlags (CANDriver *canp)
 Returns the current status mask and clears it.
void canSleep (CANDriver *canp)
 Enters the sleep mode.
void canWakeup (CANDriver *canp)
 Enforces leaving the sleep mode.

Define Documentation

#define CAN_LIMIT_WARNING   1

Errors rate warning.

Definition at line 47 of file can.h.

#define CAN_LIMIT_ERROR   2

Errors rate error.

Definition at line 51 of file can.h.

#define CAN_BUS_OFF_ERROR   4

Bus off condition reached.

Definition at line 55 of file can.h.

#define CAN_FRAMING_ERROR   8

Framing error of some kind on the CAN bus.

Definition at line 59 of file can.h.

#define CAN_OVERFLOW_ERROR   16

Overflow in receive queue.

Definition at line 63 of file can.h.

#define CAN_USE_SLEEP_MODE   TRUE

Sleep mode related APIs inclusion switch.

Definition at line 73 of file can.h.

#define canAddFlagsI (   canp,
  mask 
)    ((canp)->cd_status |= (mask))

Adds some flags to the CAN status mask.

Parameters:
[in] canp pointer to the CANDriver object
[in] mask flags to be added to the status mask

Definition at line 111 of file can.h.


Enumeration Type Documentation

enum canstate_t

Driver state machine possible states.

Enumerator:
CAN_UNINIT 

Not initialized.

CAN_STOP 

Stopped.

CAN_STARTING 

Starting.

CAN_READY 

Ready.

CAN_SLEEP 

Sleep state.

Definition at line 91 of file can.h.


Function Documentation

void canInit ( void   ) 

CAN Driver initialization.

Definition at line 59 of file can.c.

References can_lld_init().

Referenced by halInit().

Here is the call graph for this function:

void canObjectInit ( CANDriver canp  ) 

Initializes the standard part of a CANDriver structure.

Parameters:
[in] canp pointer to the CANDriver object

Definition at line 69 of file can.c.

References CANDriver::cd_config, CANDriver::cd_error_event, CANDriver::cd_rxfull_event, CANDriver::cd_rxsem, CANDriver::cd_sleep_event, CANDriver::cd_state, CANDriver::cd_status, CANDriver::cd_txempty_event, CANDriver::cd_txsem, CANDriver::cd_wakeup_event, chEvtInit, and chSemInit().

Here is the call graph for this function:

void canStart ( CANDriver canp,
const CANConfig config 
)

Configures and activates the CAN peripheral.

Parameters:
[in] canp pointer to the CANDriver object
[in] config pointer to the CANConfig object

Definition at line 91 of file can.c.

References can_lld_start(), CAN_READY, CAN_STARTING, CAN_STOP, CANDriver::cd_config, CANDriver::cd_state, chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, and chThdSleepS.

Here is the call graph for this function:

void canStop ( CANDriver canp  ) 

Deactivates the CAN peripheral.

Parameters:
[in] canp pointer to the CANDriver object

Definition at line 116 of file can.c.

References can_lld_stop(), CAN_READY, CAN_STOP, CANDriver::cd_rxsem, CANDriver::cd_state, CANDriver::cd_status, CANDriver::cd_txsem, chDbgAssert, chDbgCheck, chSchRescheduleS(), chSemResetI(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

msg_t canTransmit ( CANDriver canp,
const CANTxFrame ctfp,
systime_t  timeout 
)

Can frame transmission.

The specified frame is queued for transmission, if the hardware queue is full then the invoking thread is queued.

Note:
Trying to transmit while in sleep mode simply enqueues the thread.
Parameters:
[in] canp pointer to the CANDriver object
[in] ctfp pointer to the CAN frame to be transmitted
[in] timeout the number of ticks before the operation timeouts, the following special values are allowed:

  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns:
The operation result.
Return values:
RDY_OK the frame has been queued for transmission.
RDY_TIMEOUT operation not finished within the specified time.
RDY_RESET driver stopped while waiting.

Definition at line 151 of file can.c.

References can_lld_can_transmit(), can_lld_transmit(), CAN_READY, CAN_SLEEP, CANDriver::cd_state, CANDriver::cd_txsem, chDbgAssert, chDbgCheck, chSemWaitTimeoutS(), chSysLock, chSysUnlock, and RDY_OK.

Here is the call graph for this function:

msg_t canReceive ( CANDriver canp,
CANRxFrame crfp,
systime_t  timeout 
)

Can frame receive.

The function waits until a frame is received.

Note:
Trying to receive while in sleep mode simply enqueues the thread.
Parameters:
[in] canp pointer to the CANDriver object
[out] crfp pointer to the buffer where the CAN frame is copied
[in] timeout the number of ticks before the operation timeouts, the following special values are allowed:

  • TIME_IMMEDIATE immediate timeout (useful in an event driven scenario where a thread never blocks for I/O).
  • TIME_INFINITE no timeout.
Returns:
The operation result.
Return values:
RDY_OK a frame has been received and placed in the buffer.
RDY_TIMEOUT operation not finished within the specified time or frame not immediately available if invoked using TIME_IMMEDIATE.
RDY_RESET driver stopped while waiting.

Definition at line 192 of file can.c.

References can_lld_can_receive(), can_lld_receive(), CAN_READY, CAN_SLEEP, CANDriver::cd_rxsem, CANDriver::cd_state, chDbgAssert, chDbgCheck, chSemWaitTimeoutS(), chSysLock, chSysUnlock, and RDY_OK.

Here is the call graph for this function:

canstatus_t canGetAndClearFlags ( CANDriver canp  ) 

Returns the current status mask and clears it.

Parameters:
[in] canp pointer to the CANDriver object
Returns:
The status flags mask.

Definition at line 218 of file can.c.

References CANDriver::cd_status, chSysLock, and chSysUnlock.

void canSleep ( CANDriver canp  ) 

Enters the sleep mode.

Parameters:
[in] canp pointer to the CANDriver object

Definition at line 234 of file can.c.

References can_lld_sleep(), CAN_READY, CAN_SLEEP, CANDriver::cd_sleep_event, CANDriver::cd_state, chDbgAssert, chDbgCheck, chEvtBroadcastI(), chSchRescheduleS(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

void canWakeup ( CANDriver canp  ) 

Enforces leaving the sleep mode.

Note:
The sleep mode is supposed to be usually exited automatically by an hardware event.
Parameters:
[in] canp pointer to the CANDriver object

Definition at line 258 of file can.c.

References can_lld_wakeup(), CAN_READY, CAN_SLEEP, CANDriver::cd_state, CANDriver::cd_wakeup_event, chDbgAssert, chDbgCheck, chEvtBroadcastI(), chSchRescheduleS(), chSysLock, and chSysUnlock.

Here is the call graph for this function:


Generated on Sun Nov 28 2010 14:09:57 for ChibiOS/RT by doxygen 1.7.1