Data Structures | |
struct | _CANFRAME |
CAN frame structure. More... | |
struct | _CANINFO |
CAN controller information structure. This is installed in heap at initializaton of a bus. More... | |
struct | ifcan |
CAN interface structure. More... | |
struct | _CANFILTER |
CAN message filter structure. More... | |
Defines | |
#define | CAN_IF_2A 0x01 |
#define | CAN_IF_2B 0x02 |
#define | CAN_SPEED_10K 0 |
10 kbit/s, max. cable length 5000 m | |
#define | CAN_SPEED_20K 1 |
20 kbit/s, max. cable length 2500 m | |
#define | CAN_SPEED_50K 2 |
50 kbit/s, max. cable length 1000 m | |
#define | CAN_SPEED_100K 3 |
100 kbit/s, max. cable length 600 m | |
#define | CAN_SPEED_125K 4 |
125 kbit/s, max. cable length 500 m | |
#define | CAN_SPEED_250K 5 |
250 kbit/s, max. cable length 250 m | |
#define | CAN_SPEED_500K 6 |
500 kbit/s, max. cable length 100 m | |
#define | CAN_SPEED_800K 7 |
800 kbit/s, max. cable length 50 m | |
#define | CAN_SPEED_1M 8 |
1 Mbit/s, max. cable length 25 m | |
#define | CAN_SPEED_CUSTOM 255 |
#define | CAN_SPEED_10K 0 |
CAN Baud rate constants. | |
#define | CAN_SPEED_20K 1 |
20 kbit/s, max. cable length 2500 m | |
#define | CAN_SPEED_50K 2 |
50 kbit/s, max. cable length 1000 m | |
#define | CAN_SPEED_100K 3 |
100 kbit/s, max. cable length 600 m | |
#define | CAN_SPEED_125K 4 |
125 kbit/s, max. cable length 500 m | |
#define | CAN_SPEED_250K 5 |
250 kbit/s, max. cable length 250 m | |
#define | CAN_SPEED_500K 6 |
500 kbit/s, max. cable length 100 m | |
#define | CAN_SPEED_800K 7 |
800 kbit/s, max. cable length 50 m | |
#define | CAN_SPEED_1M 8 |
1 Mbit/s, max. cable length 25 m | |
#define | CAN_SPEED_CUSTOM 255 |
#define | CAN_TTCM 0x0001 |
#define | CAN_ABOM 0x0002 |
#define | CAN_AWUM 0x0004 |
#define | CAN_NART 0x0008 |
#define | CAN_RFLM 0x0010 |
#define | CAN_TXFP 0x0020 |
#define | FILTER_EXPLICIT 0xffffffff |
Typedefs | |
typedef struct _CANFRAME | CANFRAME |
CAN frame type. | |
typedef struct _CANINFO | CANINFO |
CAN controller information type. | |
typedef struct ifcan | IFCAN |
Canbus interface type. | |
typedef struct _NUTCANBUS | NUTCANBUS |
CAN bus structure, defined by device. | |
typedef struct _CANBUSINFO | CANBUSINFO |
CAN bus info structure, defined by device. | |
typedef struct _CANBUFFER | CANBUFFER |
CAN BUFFER structure, defined by device. | |
typedef struct _CANFRAME | CANFRAME |
CAN frame type. | |
typedef struct _CANFILTER | CANFILTER |
CAN message filter type. | |
Enumerations | |
enum | CAN_RESULT { CAN_SUCCESS = 0, CAN_ERROR = -1, CAN_TXBUF_FULL = -2, CAN_RXBUF_EMPTY = -3, CAN_ILLEGAL_MOB = -4, CAN_INVALID_SPEED = -5, CAN_PASSIVE = -6, CAN_BUS_OFF = -7, CAN_NO_COMPANION = -8, CAN_IS_COMPANION = -9 } |
CAN error codes. More... | |
enum | CAN_COUNTERS { CAN_RX_FRAMES = 0, CAN_TX_FRAMES = 1, CAN_INTERRUPTS = 2, CAN_RX_INTERRUPTS = 3, CAN_TX_INTERRUPTS = 4, CAN_SCE_INTERRUPTS = 5, CAN_OVERRUNS = 6, CAN_ERRORS = 7, CAN_NO_COUNTERS = 8 } |
CAN event counters. More... | |
Functions | |
uint8_t | CAN_SetSpeed (NUTDEVICE *dev, uint32_t baudrate) |
void | CAN_SetFilter (NUTDEVICE *dev, uint8_t *ac, uint8_t *am) |
void | CAN_TxFrame (NUTDEVICE *dev, CANFRAME *frame) |
uint8_t | CAN_TryTxFrame (NUTDEVICE *dev, CANFRAME *frame) |
uint8_t | CAN_TxFree (NUTDEVICE *dev) |
uint8_t | CAN_RxFrame (NUTDEVICE *dev, CANFRAME *frame) |
uint8_t | CAN_TryRxFrame (NUTDEVICE *dev, CANFRAME *frame) |
uint8_t | CAN_RxAvail (NUTDEVICE *dev) |
void | CAN_SetRxTimeout (NUTDEVICE *dev, uint32_t timeout) |
int | NutRegisterCanBus (NUTCANBUS *bus, int8_t ln2_size) |
_NUTCANBUS | |
int | CanAddFilter (NUTCANBUS *bus, CANFILTER *filter) |
int | CanSetBaud (NUTCANBUS *bus, uint8_t baud, uint32_t alt_btr) |
void | CANSetRxTimeout (NUTCANBUS *bus, uint32_t timeout) |
void | CanEnableRx (NUTCANBUS *bus) |
int | CanRxAvail (NUTCANBUS *bus) |
int | CanInput (NUTCANBUS *bus, CANFRAME *output) |
int | CanTxFree (NUTCANBUS *can) |
int | CanOutput (NUTCANBUS *bus, CANFRAME *output) |
int | CanGetCounter (NUTCANBUS *bus, enum CAN_COUNTERS index) |
Variables | |
uint32_t | _CANFRAME::id |
uint8_t | _CANFRAME::byte [8] |
uint8_t | _CANFRAME::len |
uint8_t | _CANFRAME::ext |
uint8_t | _CANFRAME::rtr |
uint32_t | _CANFILTER::id |
Identifier. | |
uint32_t | _CANFILTER::mask |
Mask, use 0xffffffff for ecavt match. | |
uint8_t | _CANFILTER::id_ext |
Boolean, extended frame. | |
uint8_t | _CANFILTER::id_rtr |
Boolean, remote transmition bit. | |
uint8_t | _CANFILTER::mask_ext |
Boolean, match id_ext. | |
uint8_t | _CANFILTER::mask_rtr |
Boolean, match id_rtr. |
#define CAN_IF_2A 0x01 |
#define CAN_IF_2B 0x02 |
#define CAN_SPEED_10K 0 |
10 kbit/s, max. cable length 5000 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_20K 1 |
20 kbit/s, max. cable length 2500 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_50K 2 |
50 kbit/s, max. cable length 1000 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_100K 3 |
100 kbit/s, max. cable length 600 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_125K 4 |
125 kbit/s, max. cable length 500 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_250K 5 |
250 kbit/s, max. cable length 250 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_500K 6 |
500 kbit/s, max. cable length 100 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_800K 7 |
800 kbit/s, max. cable length 50 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_1M 8 |
1 Mbit/s, max. cable length 25 m
Referenced by AtCanSetBaudrate(), CanSetBaud(), SJAInit(), and SJASetBaudrate().
#define CAN_SPEED_CUSTOM 255 |
Referenced by AtCanSetBaudrate(), and CanSetBaud().
#define CAN_SPEED_10K 0 |
CAN Baud rate constants.
10 kbit/s, max. cable length 5000 m
#define CAN_SPEED_20K 1 |
20 kbit/s, max. cable length 2500 m
#define CAN_SPEED_50K 2 |
50 kbit/s, max. cable length 1000 m
#define CAN_SPEED_100K 3 |
100 kbit/s, max. cable length 600 m
#define CAN_SPEED_125K 4 |
125 kbit/s, max. cable length 500 m
#define CAN_SPEED_250K 5 |
250 kbit/s, max. cable length 250 m
#define CAN_SPEED_500K 6 |
500 kbit/s, max. cable length 100 m
#define CAN_SPEED_800K 7 |
800 kbit/s, max. cable length 50 m
#define CAN_SPEED_1M 8 |
1 Mbit/s, max. cable length 25 m
#define CAN_SPEED_CUSTOM 255 |
#define CAN_TTCM 0x0001 |
Referenced by CanGetFeatures(), and CanSetFeatures().
#define CAN_ABOM 0x0002 |
Referenced by CanGetFeatures(), and CanSetFeatures().
#define CAN_AWUM 0x0004 |
Referenced by CanGetFeatures(), and CanSetFeatures().
#define CAN_NART 0x0008 |
Referenced by CanGetFeatures(), and CanSetFeatures().
#define CAN_RFLM 0x0010 |
Referenced by CanGetFeatures(), and CanSetFeatures().
#define CAN_TXFP 0x0020 |
Referenced by CanGetFeatures(), and CanSetFeatures().
#define FILTER_EXPLICIT 0xffffffff |
Referenced by CanAddFilter().
typedef struct _NUTCANBUS NUTCANBUS |
CAN bus structure, defined by device.
typedef struct _CANBUSINFO CANBUSINFO |
CAN bus info structure, defined by device.
typedef struct _CANBUFFER CANBUFFER |
CAN BUFFER structure, defined by device.
typedef struct _CANFILTER CANFILTER |
CAN message filter type.
enum CAN_RESULT |
CAN error codes.
enum CAN_COUNTERS |
CAN event counters.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
References _NUTDEVICE::dev_icb.
Sets the CAN receive timeout
dev | Pointer to the device structure |
timeout | Timeout in milliseconds, NUT_WAIT_INFINITE = no time-out |
References _NUTDEVICE::dev_icb.
baud | Baudrate to set. CAN_SPEED_CUSTOM will use alt_btr |
alt_btr | Custom setting for the Baud Rate Registers, Device dependant. |
Here we set up the Hardware, baudrate and special setting
References _BI32, _NUTCANBUS::bus_ci, CAN_DEF_RX_ENTRIES, CAN_ERROR, _CANBUSINFO::can_rx_timeout, _CANBUSINFO::can_RxBuf, _CANBUFFER::dataindex, _CANBUFFER::datalength, _CANBUFFER::dataptr, memset(), NULL, NUT_WAIT_INFINITE, NutHeapAlloc, NutHeapFree, NutIrqEnable(), NutIrqSetPriority(), NutRegisterIrqHandler(), rc, _NUTCANBUS::sig_rx_irq, _NUTCANBUS::sig_sce_irq, _NUTCANBUS::sig_tx_irq, and _CANBUFFER::size.
Set the baudrate
bus | Identifies the CANBUS |
baud | Symbolic value for the Baudrate |
alt_btr | Use given value with CAN_SPEED_CUSTOM |
For STM32, alt_btr may be used for setting silent/loopback silent+loopback mode
References CAN_TypeDef::BTR, _NUTCANBUS::bus_base, CAN_BUS_OFF, CAN_ERROR, CAN_IS_COMPANION, CAN_SPEED_100K, CAN_SPEED_10K, CAN_SPEED_125K, CAN_SPEED_1M, CAN_SPEED_20K, CAN_SPEED_250K, CAN_SPEED_500K, CAN_SPEED_50K, CAN_SPEED_800K, CAN_SPEED_CUSTOM, and _NUTCANBUS::sig_tx_irq.
References _NUTCANBUS::bus_ci, and _CANBUSINFO::can_rx_timeout.
void CanEnableRx | ( | NUTCANBUS * | bus | ) |
References __IO, _BI32, _NUTCANBUS::bb_base, CAN_FMR_FINIT, CAN_IER_FMPIE0, CAN_IER_FMPIE1, CM3BB_OFFSET, IER, and _NUTCANBUS::sig_tx_irq.
int CanRxAvail | ( | NUTCANBUS * | bus | ) |
References _NUTCANBUS::bus_ci, _CANBUSINFO::can_RxBuf, and _CANBUFFER::datalength.
Reads a frame from input buffer
This function reads a frame from the input buffer. If the input buffer is empty the function will block unitl new frames are received, or the timeout is reached.
dev | Pointer to the device structure |
frame | Pointer to the receive frame |
References __IO, __MAY_ALIAS, _BI32, _NUTCANBUS::bb_base, _NUTCANBUS::bus_ci, _CANFRAME::byte, CAN_IER_FMPIE0, CAN_IER_FMPIE1, CAN_RI0R_IDE, CAN_RI0R_RTR, _CANBUSINFO::can_rx_rdy, _CANBUSINFO::can_rx_timeout, _CANBUSINFO::can_RxBuf, CM3BB_OFFSET, _CANBUFFER::dataindex, _CANBUFFER::datalength, _CANBUFFER::dataptr, _CANFRAME::ext, _CANFRAME::id, IER, _CANFRAME::len, NutEnterCritical, NutEventWait(), NutExitCritical, CAN_FIFOMailBox_TypeDef::RDHR, CAN_FIFOMailBox_TypeDef::RDLR, CAN_FIFOMailBox_TypeDef::RDTR, CAN_FIFOMailBox_TypeDef::RIR, _CANFRAME::rtr, _NUTCANBUS::sig_tx_irq, and _CANBUFFER::size.
int CanTxFree | ( | NUTCANBUS * | bus | ) |
Checks if there's still space in output buffer
dev | Pointer to the device structure |
References _NUTCANBUS::sig_tx_irq.
Write a frame from to output buffer
This function writes a frame to the output buffer. If the output buffer is full the function will block until frames are send.
bus | Pointer to the device structure |
frame | Pointer to the receive frame |
References _NUTCANBUS::bus_ci, CAN_IS_COMPANION, _CANBUSINFO::can_tx_frames, _CANBUSINFO::can_tx_rdy, CAN_TXBUF_FULL, NUT_WAIT_INFINITE, NutEventWait(), rc, and _NUTCANBUS::sig_tx_irq.
int CanGetCounter | ( | NUTCANBUS * | bus, |
enum CAN_COUNTERS | index | ||
) |
Report the counter values
This function writes a frame to the output buffer. If the output buffer is full the function will block until frames are send.
bus | Pointer to the device structure |
index | Number of pointer to receive |
References _NUTCANBUS::bus_ci, _CANBUSINFO::can_errors, CAN_ERRORS, CAN_INTERRUPTS, _CANBUSINFO::can_overruns, CAN_OVERRUNS, _CANBUSINFO::can_rx_frames, CAN_RX_FRAMES, _CANBUSINFO::can_rx_interrupts, CAN_RX_INTERRUPTS, _CANBUSINFO::can_sce_interrupts, CAN_SCE_INTERRUPTS, _CANBUSINFO::can_tx_frames, CAN_TX_FRAMES, _CANBUSINFO::can_tx_interrupts, and CAN_TX_INTERRUPTS.
Referenced by AtCanSendMsg(), CanInput(), SJARxFrame(), and SJATxFrame().
Referenced by AtCanSendMsg(), CanInput(), SJARxFrame(), and SJATxFrame().
Referenced by AtCanSendMsg(), CanInput(), SJARxFrame(), and SJATxFrame().
Referenced by AtCanSendMsg(), CanInput(), SJARxFrame(), and SJATxFrame().
Referenced by AtCanSendMsg(), CanInput(), SJARxFrame(), and SJATxFrame().
Identifier.
Referenced by CanAddFilter().
Mask, use 0xffffffff for ecavt match.
Referenced by CanAddFilter().
Boolean, extended frame.
Referenced by CanAddFilter().
Boolean, remote transmition bit.
Referenced by CanAddFilter().
Boolean, match id_ext.
Referenced by CanAddFilter().
Boolean, match id_rtr.
Referenced by CanAddFilter().