Download RCC-1.2.18 drivers Manual

Transcript
22
CAN DRIVER INTERFACE (GRCAN)
22.1
USER INTERFACE
The RTEMS CAN driver supports the standard accesses to file descriptors such as read, write
and ioctl. User applications include the grcan driver's header file (grcan.h) which contains
definitions of all necessary data structures and bit masks used when accessing the driver.
The GRCAN driver require the RTEMS Driver Manager.
22.1.1 Driver registration
The registration of the driver is crucial for threads and processes to be able to access the driver
using standard means, such as open. The RTEMS I/O driver registration is performed
automatically by the driver when CAN hardware is found for the first time. The driver is called
from the driver manager to handle detected CAN hardware. In order for the driver manager to
unite the CAN driver with the CAN hardware one must register the driver to the driver manager.
This process is described in the driver manager chapter.
22.1.2 Driver resource configuration
The driver can be configured using driver resources as described in the driver manager chapter.
Below is a description of configurable driver parameters. The driver parameters is unique per
CAN device. The parameters are all optional, the parameters only overrides the default values.
Name
Type
Parameter description
txBufSize
INT
Length of TX DMA area. Must be a multiple of 64 bytes, four messages.
rxBufSize
INT
Length of RX DMA area. Must be a multiple of 64 bytes, four messages.
txBufAdr
INT
Custom TX DMA area address. See note below.
rxBufAdr
INT
Custom RX DMA area address. See note below.
Table 83: GRCAN driver parameter description
22.1.2.1 Custom DMA area parameters
The DMA area can be configured to be located at a custom address. The standard configuration
is to leave it up to the driver to do dynamic allocation of the areas. However in some cases it may
be required to locate the DMA area on a custom location, the driver will not allocate memory but
will assume that enough memory is available and that the alignment needs of the core on the
address given is fulfilled.
For some systems it may be convenient to give the addresses as seen by the CAN core. This can
be done by setting the LSB bit in the address to one. For example a GR-RASTA-IO board with a
CAN core doesn't read from the same address as the CPU in order to access the same data. This
is dependent on the PCI mappings. Translation between CPU and CAN addresses must be done.
The CAN driver automatically translates the required addresses. This requires the bus driver, in
this case the GR-RASTA-IO driver, to set up translation addresses correctly.
22.1.3 Opening the device
Opening the device enables the user to access the hardware of a certain CAN core. The driver is
used for all GRCAN cores available. The cores are separated by assigning each device a unique
name and a number called minor. The name is passed during the opening of the driver. Some
example device names are printed out below.