Nut/OS  4.10.3
API Reference
sja1000.c File Reference

Driver for SJA1000 CAN-Bus controller. More...

#include <string.h>
#include <sys/heap.h>
#include <sys/thread.h>
#include <sys/event.h>
#include <sys/atom.h>
#include <sys/timer.h>
#include <sys/semaphore.h>
#include <sys/nutconfig.h>
#include <dev/irqreg.h>
#include <dev/can_dev.h>
#include <dev/sja1000.h>
#include <cfg/arch/avr.h>
Include dependency graph for sja1000.c:

Go to the source code of this file.

Data Structures

struct  _CANBuffer


#define SJA_EICR   EICRB
#define SJA_SIGNAL_BIT   7
#define SJA_BASE   0x8800
#define CAN_BufSize   64


typedef struct _CANBuffer CANBuffer


void CANBufferInit (CANBuffer *buffer, uint16_t size)
CANFRAME CANBufferGetMutex (CANBuffer *buffer)
void CANBufferPutMutex (CANBuffer *buffer, CANFRAME *data)
CANFRAME CANBufferGet (CANBuffer *buffer)
void CANBufferPut (CANBuffer *buffer, CANFRAME *data)
uint16_t CANBufferFree (CANBuffer *buffer)
uint8_t SJARxAvail (NUTDEVICE *dev)
 checks if data is available in input buffer
uint8_t SJATxFree (NUTDEVICE *dev)
 checks if there's still space in output buffer
void SJAOutput (NUTDEVICE *dev, CANFRAME *frame)
 Write a frame from to output buffer.
uint8_t SJAInput (NUTDEVICE *dev, CANFRAME *frame)
 Reads a frame from input buffer.
void SJASetAccCode (NUTDEVICE *dev, uint8_t *ac)
 Sets the acceptance code.
void SJASetAccMask (NUTDEVICE *dev, uint8_t *am)
 Sets the acceptance mask.
uint8_t SJASetBaudrate (NUTDEVICE *dev, uint32_t baudrate)
 Sets the baudrate.
void SJATxFrame (CANFRAME *CAN_frame)
 Sends a CAN Frane.
void SJARxFrame (CANFRAME *CAN_frame)
 Receives a CAN Frane.
void CAN_Tx (void *arg)
 CAN transmitter thread.
int SJAInit (NUTDEVICE *dev)
 Initialize SJA1000 Canbus interface.


CANINFO dcb_sja1000
volatile uint16_t sja_base = 0x0000
IFCAN ifc_sja1000
 Interface information structure.
 Device information structure.

Detailed Description

Driver for SJA1000 CAN-Bus controller.

The SJA1000 controller is connected to the memory bus. It's base address and interrupt is set by NutRegisterDevice.

Have a look to our m-can board if you have questions.

Definition in file sja1000.c.