AtMega CAN Library
Well documented CAN library for AtMega processors utilizing the original Atmel driver
|
Go to the source code of this file.
Classes | |
struct | _canMessage |
Typedefs | |
CAN message structure. | |
The main structure for a can message. | |
typedef struct _canMessage | canMessage |
Functions | |
uint8_t | can_init () |
Initialize the bus and activate hardware. More... | |
void | can_close () |
Disable driver & hardware. More... | |
uint8_t | can_sendMessage (canMessage *m) |
Sends a can message. More... | |
int8_t | can_hasFreeTxBuffer () |
Check if there are ant free transmitting MOBs. More... | |
int8_t | can_getMessage (canMessage *m) |
Gets a can message from the reception buffer. More... | |
uint8_t | can_getRxBufferLength () |
Returns the number of messages in the buffer. More... | |
Transciever control. | |
Enable/disable the transciever if supported by your hardware. Define the pin in the configuration file. #define CANRS_PORT PORTD #define CANRS_DDR DDRD #define CANRS_PIN PIND0 | |
void | can_enableTransciever () |
void | can_disableTransciever () |
CAN library for AtMega64C1. (license: GPLv2 or LGPLv2.1)
void can_close | ( | ) |
Disable driver & hardware.
Disabled the driver and the transciever if the option has been configured.
int8_t can_getMessage | ( | canMessage * | m | ) |
Gets a can message from the reception buffer.
m | Pointer to message. |
-1 | No message in buffer. |
n | Number of messages in buffer. |
Retrieves a message from the internal circular buffer and returns the amount of messages left in the buffer OR CAN_BUFFEREMPTY if the buffer is empty. You may use either:
or
depending on your implementation, buffer length and bus speed.
uint8_t can_getRxBufferLength | ( | ) |
Returns the number of messages in the buffer.
int8_t can_hasFreeTxBuffer | ( | ) |
Check if there are ant free transmitting MOBs.
-1 | No buffers |
n | free buffer. |
uint8_t can_init | ( | ) |
Initialize the bus and activate hardware.
0 | Init/autobaud failure. |
1 | Init/autobaud success. |
Initializes the driver, speed and also activates the transciever if the option has been configured.
uint8_t can_sendMessage | ( | canMessage * | m | ) |
Sends a can message.
m | Pointer to a canMessage object that has been configured. |
0 | Message NOT sent. |
1 | Message sent. |
Sends a canmessage with the configured id and data. Usage example: