|
Open Model Railroad Network (OpenMRN)
|
CAN-bus device driver for the Pic32MX. More...
#include <Pic32mxCan.hxx>
Public Member Functions | |
| Pic32mxCan (CAN_MODULE module, const char *dev, unsigned irq_vector) | |
| Constructor. | |
| void | isr () |
| Implementation of the interrupt handler. | |
Public Member Functions inherited from Device | |
| Device (const char *name) | |
| Constructor. | |
| virtual | ~Device () |
| Destructor. | |
Private Member Functions | |
| void | enable () |
| function to enable device | |
| void | disable () |
| function to disable device | |
| void | flush_buffers () OVERRIDE |
| function to disable device | |
| ssize_t | read (File *file, void *buf, size_t count) |
| Read from a file or device. | |
| ssize_t | write (File *file, const void *buf, size_t count) |
| Write to a file or device. | |
| bool | select (File *file, int mode) OVERRIDE |
| Device select method. | |
| INT_SOURCE | can_int () |
| INT_VECTOR | can_vector () |
| DISALLOW_COPY_AND_ASSIGN (Pic32mxCan) | |
Private Attributes | |
| CAN_MODULE | hw_ |
| Hardware (enumeration value). | |
| int | overrunCount_ |
| How many times did we drop a frame because we did not have enough hardware buffers. | |
| unsigned | irqVector_ |
| Hardware interrupt vector number. Do not delete! | |
| void * | messageFifoArea_ |
| Points to the shared RAM area between the hardware and the driver. | |
| SelectInfo | txSelect_ |
| SelectInfo | rxSelect_ |
Additional Inherited Members | |
Static Public Member Functions inherited from Device | |
| static int | open (struct _reent *reent, const char *path, int flags, int mode) |
| Open a file or device. | |
| static int | close (struct _reent *reent, int fd) |
| Close a file or device. | |
| static int | stat (struct _reent *reent, const char *path, struct stat *stat) |
| Get the status information of a file or device. | |
| static int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, long long timeout) |
| POSIX select(). | |
| static void | select_clear () |
| Clears the current thread's select bits. | |
Static Public Member Functions inherited from FileIO | |
| static ssize_t | read (struct _reent *reent, int fd, void *buf, size_t count) |
| Read from a file or device. | |
| static ssize_t | write (struct _reent *reent, int fd, const void *buf, size_t count) |
| Write to a file or device. | |
| static _off_t | lseek (struct _reent *reent, int fd, _off_t offset, int whence) |
| Change the offset index of a file or device. | |
| static int | fstat (struct _reent *reent, int fd, struct stat *stat) |
| Get the status information of a file or device. | |
| static int | ioctl (int fd, unsigned long int key, unsigned long data) |
| Request and ioctl transaction. | |
| static int | fcntl (int fd, int cmd, unsigned long data) |
| Manipulate a file descriptor. | |
| static bool | is_device (int fd) |
| Test if the file descriptor belongs to a device. | |
Protected Member Functions inherited from Node | |
| Node (const char *name) | |
| Constructor. | |
| virtual | ~Node () |
| Destructor. | |
| int | open (File *, const char *, int, int) OVERRIDE |
| Open method. | |
| int | close (File *) OVERRIDE |
| Close method. | |
| virtual int | fstat (File *file, struct stat *stat) override |
| Get the status information of a file or device. | |
Protected Member Functions inherited from FileIO | |
| FileIO (const char *name) | |
| Constructor. | |
| virtual | ~FileIO () |
| Destructor. | |
| virtual off_t | lseek (File *f, off_t offset, int whence) |
| Seek method. | |
| virtual int | ioctl (File *file, unsigned long int key, unsigned long data) |
| Request an ioctl transaction. | |
| virtual int | fcntl (File *file, int cmd, unsigned long data) |
| Manipulate a file descriptor. | |
Static Protected Member Functions inherited from Device | |
| static void | select_insert (SelectInfo *info) |
| Add client to list of clients needing woken. | |
| static void | select_wakeup (SelectInfo *info) |
| Wakeup the list of clients needing woken. | |
| static void | select_wakeup_from_isr (SelectInfo *info, int *woken) |
| Wakeup the list of clients needing woken. | |
Static Protected Member Functions inherited from FileIO | |
| static int | fd_alloc (void) |
| Allocate a free file descriptor. | |
| static void | fd_free (int fd) |
| Free up a file descriptor. | |
| static File * | file_lookup (int fd) |
| Looks up a reference to a File corresponding to a given file descriptor. | |
| static int | fd_lookup (File *file) |
| Looks up a file descriptor corresponding to a given File reference. | |
Protected Attributes inherited from Node | |
| OSMutex | lock_ |
| protects internal structures. | |
| mode_t | mode_ |
| File open mode, such as O_NONBLOCK. | |
| unsigned int | references_ |
| number of open references | |
Protected Attributes inherited from FileIO | |
| const char * | name |
| device name | |
Static Protected Attributes inherited from FileIO | |
| static const unsigned int | numOpenFiles = 20 |
| static File | files [] |
| File descriptor pool. | |
| static OSMutex | mutex |
| mutual exclusion for fileio | |
CAN-bus device driver for the Pic32MX.
This driver does not inherit from the shared Can driver, because the RX and RX buffering is different. The shared CAN driver has a DeviceBuffer for transmit and receive in the format of struct can_frame; whereas the PIC32 can write directly into the memory area of the CAN controller as the queues are long enough and the CAN controller is a bus master.
Definition at line 54 of file Pic32mxCan.hxx.
| Pic32mxCan::Pic32mxCan | ( | CAN_MODULE | module, |
| const char * | dev, | ||
| unsigned | irq_vector | ||
| ) |
Constructor.
| module | defines which CAN hardware to use. (can0 or can1). |
| dev | filename of the device to create (e.g. "/dev/can0"); |
| irq_vector | fill with can1_interrupt_vector_number or can2_interrupt_vector_number. |
Definition at line 43 of file Pic32mxCan.cxx.
| Pic32mxCan::~Pic32mxCan | ( | ) |
Definition at line 53 of file Pic32mxCan.cxx.
|
inlineprivate |
Definition at line 121 of file Pic32mxCan.hxx.
|
inlineprivate |
Definition at line 128 of file Pic32mxCan.hxx.
|
privatevirtual |
|
privatevirtual |
function to enable device
Implements Node.
Definition at line 320 of file Pic32mxCan.cxx.
|
inlineprivatevirtual |
|
inline |
Implementation of the interrupt handler.
Definition at line 68 of file Pic32mxCan.hxx.
|
privatevirtual |
Read from a file or device.
| file | file reference for this device |
| buf | location to place read data |
| count | number of bytes to read |
Implements FileIO.
Definition at line 131 of file Pic32mxCan.cxx.
Device select method.
Default impementation returns true.
| file | reference to the file |
| mode | FREAD for read active, FWRITE for write active, 0 for exceptions |
Reimplemented from FileIO.
Definition at line 283 of file Pic32mxCan.cxx.
|
privatevirtual |
Write to a file or device.
| file | file reference for this device |
| buf | location to find write data |
| count | number of bytes to write |
Implements FileIO.
Definition at line 210 of file Pic32mxCan.cxx.
|
private |
Hardware (enumeration value).
Definition at line 134 of file Pic32mxCan.hxx.
|
private |
Hardware interrupt vector number. Do not delete!
Definition at line 139 of file Pic32mxCan.hxx.
|
private |
Points to the shared RAM area between the hardware and the driver.
Definition at line 141 of file Pic32mxCan.hxx.
|
private |
How many times did we drop a frame because we did not have enough hardware buffers.
Definition at line 137 of file Pic32mxCan.hxx.
|
private |
Definition at line 145 of file Pic32mxCan.hxx.
|
private |
Definition at line 143 of file Pic32mxCan.hxx.