16FXlib
Routing Level access (can3.h)

Detailed Description

Overview
This library enables addressed messaging over the CAN Controller.

Modules

 Internal configurations (can3.cfg.h)
 

Functions

uint8_t can3_init (uint8_t address)
 
uint8_t can3_send (uint8_t dest, uint16_t uid, uint8_t *data, uint8_t len, uint8_t interrupt)
 
uint8_t can3_open (uint16_t uid)
 
uint8_t can3_maskedOpen (uint16_t uid, uint16_t idMask)
 
uint8_t can3_getData (uint8_t buffer, uint8_t *data, uint8_t *source, uint16_t *id)
 
void can3_close (uint8_t buffer)
 
void can3_setAddress (uint8_t address)
 
uint8_t can3_getAddress (void)
 
uint8_t can3_registerIRQHandler (IRQHandler handler)
 
uint8_t can3_removeIRQHandler (IRQHandler handler)
 

CAN3 fixed values

Values of the implementation, that cannot be changed

#define CAN3_MAX_ADDRESS   63
 
#define CAN3_MAX_MESSAGELENGTH   8
 
#define CAN3_MULTICAST   255
 

Function Documentation

uint8_t can3_init ( uint8_t  address)

Initializes the CAN controller.

Parameters
addressAddress to be used
Returns
1 if everything went fine, 0 if there was an error

Definition at line 120 of file can3.c.

uint8_t can3_send ( uint8_t  dest,
uint16_t  uid,
uint8_t data,
uint8_t  len,
uint8_t  interrupt 
)

Sends a message over the CAN controller to the destination.

Parameters
destDestination of the message (0 - CAN3_MAX_ADDRESS)
uidUsed identifier for this message
dataPointer to byte data array
lenlength of the data (1 - 8)
interrupt
Returns
1 if everything went fine, 0 if there was an error, in most cased wrong input data

Definition at line 150 of file can3.c.

uint8_t can3_open ( uint16_t  uid)

Opens an 'Port' to accept messages with suitable id

Parameters
uidMessageid
Returns
buffer reference

Definition at line 193 of file can3.c.

uint8_t can3_maskedOpen ( uint16_t  uid,
uint16_t  idMask 
)

Opens an 'Port' to accept messages with suitable id and idMask

Parameters
uidMessageid
idMaskMessage Mask
Returns
buffer reference

Definition at line 197 of file can3.c.

uint8_t can3_getData ( uint8_t  buffer,
uint8_t data,
uint8_t source,
uint16_t id 
)

Checks if data was received and in case returns the data

Parameters
bufferBuffer to check
dataArray to save data to (max 8 Byte)
sourcepointer to save the source of this message (1 Byte)
idpointer to save received id of this message (2 Byte)
Returns
length of data field, or 0 if there was no data

Definition at line 225 of file can3.c.

void can3_close ( uint8_t  buffer)

Closes an buffer, so no data is longer received

Parameters
bufferBuffer to be closed

Definition at line 257 of file can3.c.

void can3_setAddress ( uint8_t  address)

Updates the address of the CAN Controller.

Parameters
addressnew address

Definition at line 252 of file can3.c.

uint8_t can3_getAddress ( void  )

Gets the address of the CAN Controller.

Returns
address

Definition at line 248 of file can3.c.

uint8_t can3_registerIRQHandler ( IRQHandler  handler)

Adds an IRQHandler to the IRQHandler list.

Parameters
handler
Returns
1 if everything went fine

Definition at line 273 of file can3.c.

uint8_t can3_removeIRQHandler ( IRQHandler  handler)

Removes an IRQHandler from the IRQHandler list.

Parameters
handler
Returns
1 if everything went fine

Definition at line 286 of file can3.c.

Macro Definition Documentation

#define CAN3_MAX_ADDRESS   63

Sets the maximum Maximum of available addresses

Definition at line 123 of file can3.h.

#define CAN3_MAX_MESSAGELENGTH   8

Maximum of message length, fixed by CAN specification

Definition at line 128 of file can3.h.

#define CAN3_MULTICAST   255

Defines an address for multicast messages

Definition at line 133 of file can3.h.