PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
pic24_ecan.c File Reference
#include "pic24_ecan.h"

Go to the source code of this file.

Functions

void formatStandardDataFrameECAN (ECANMSG *p_ecanmsg, uint16_t u16_id, uint8_t u8_len)
 
void formatExtendedDataFrameECAN (ECANMSG *p_ecanmsg, uint32_t u32_id, uint8_t u8_len)
 
uint32_t getIdExtendedDataFrameECAN (ECANMSG *p_ecanmsg)
 
void configBaudECAN1 (void)
 
void clrRxFullFlagECAN1 (uint8_t u8_bufNum)
 
uint8_t getRxFullFlagECAN1 (uint8_t u8_bufNum)
 
void clrRxFullOvfFlagsECAN1 (void)
 
void configTxRxBufferECAN1 (uint8_t u8_bufNum, uint8_t u8_type, uint8_t u8_priority)
 
void startTxECAN1 (uint8_t u8_bufNum)
 
uint8_t getTxInProgressECAN1 (uint8_t u8_bufNum)
 
void configRxFilterECAN1 (uint8_t u8_filtNum, uint32_t u32_id, uint8_t u8_idType, uint8_t u8_bufnum, uint8_t u8_maskReg)
 
void configRxMaskECAN1 (uint8_t u8_maskNum, uint32_t u32_idMask, uint8_t u8_idType, uint8_t u8_matchType)
 

Detailed Description

ECAN support functions.

See Also
pic24_ecan.h for details.

Definition in file pic24_ecan.c.

Function Documentation

void clrRxFullFlagECAN1 ( uint8_t  u8_bufNum)

Clear full bit of buffer u8_bufNum

Parameters
u8_bufNumbuffer number of full bit to clear (0 to 31)

Definition at line 176 of file pic24_ecan.c.

void clrRxFullOvfFlagsECAN1 ( void  )

Operation: Clear all of the full and overflow RX flags.

Definition at line 204 of file pic24_ecan.c.

void configBaudECAN1 ( void  )

Configure ECANx peripheral to run at 1Mbps.

Todo:
Get this working on the E family. Current code is broken.

Definition at line 112 of file pic24_ecan.c.

void configRxFilterECAN1 ( uint8_t  u8_filtNum,
uint32_t  u32_id,
uint8_t  u8_idType,
uint8_t  u8_bufnum,
uint8_t  u8_maskReg 
)

Configure an acceptance Filter

Parameters
u8_filtNumfilter number (0 to 15)
u32_ididentifier, either SID (11 bits) or EID (29 bits)
u8_idTypeID type (0: SID, nonzero: EID)
u8_bufnumRX buffer (0-14) to use for filter , if 15, then use FIFO
u8_maskRegMask register (0-2) to use for filter

Definition at line 326 of file pic24_ecan.c.

void configRxMaskECAN1 ( uint8_t  u8_maskNum,
uint32_t  u32_idMask,
uint8_t  u8_idType,
uint8_t  u8_matchType 
)

Configure an acceptance MASK

Parameters
u8_maskNummask number (0 to 3; 0 to 2 specifies mask register, 3 then no mask is used)
u32_idMaskmask for the identifier, either SID mask (11 bits) or EID mask (29 bits)
u8_idTypeID type (0: SID, nonzero: EID)
u8_matchTypeMatch type; if zero match either SID or EID addresses if filter matches (i.e, match if (Filter SID == Message SID) || (Filter SID:EID = Message SID:EID)) ) If nonzero, match only message types as specified by the filter (either SID or SID:EID).

Definition at line 384 of file pic24_ecan.c.

void configTxRxBufferECAN1 ( uint8_t  u8_bufNum,
uint8_t  u8_type,
uint8_t  u8_priority 
)

Configure a buffer as either RX or TX buffer, only has to be done for first 8 buffers.

Parameters
u8_bufNumbuffer number (0 to 7)
u8_typebuffer type (0 - receive, 1 transmit)
u8_priorityonly used for TX, priority (0-3)

Definition at line 217 of file pic24_ecan.c.

void formatExtendedDataFrameECAN ( ECANMSG *  p_ecanmsg,
uint32_t  u32_id,
uint8_t  u8_len 
)

Format an extended data frame u8_n for TX

Parameters
p_ecanmsgpointer to message buffer (ECANMSG* )
u32_idStandard Identifier (11-bit)
u8_lenNumber of data bytes in the message

Definition at line 76 of file pic24_ecan.c.

void formatStandardDataFrameECAN ( ECANMSG *  p_ecanmsg,
uint16_t  u16_id,
uint8_t  u8_len 
)

Format a standard data frame u8_n for TX

Parameters
p_ecanmsgpointer to message buffer (ECANMSG* )
u16_idStandard Identifier (11-bit)
u8_lenNumber of data bytes in the message

Definition at line 56 of file pic24_ecan.c.

uint32_t getIdExtendedDataFrameECAN ( ECANMSG *  p_ecanmsg)

Extract the 29-bit message id from an extended data frame

Parameters
p_ecanmsgpointer to RX message buffer (ECANMSG* )
Returns
29-bit message id

Definition at line 95 of file pic24_ecan.c.

uint8_t getRxFullFlagECAN1 ( uint8_t  u8_bufNum)

Get full bit of buffer u8_bufNum, zero if empty, non-zero if ull

Parameters
u8_bufNumbuffer number of full bit to read(0 to 31)

Definition at line 191 of file pic24_ecan.c.

uint8_t getTxInProgressECAN1 ( uint8_t  u8_bufNum)

Start Transmit for buffer u8_bufNum

Parameters
u8_bufNumbuffer number (0 to 7)

Definition at line 293 of file pic24_ecan.c.

void startTxECAN1 ( uint8_t  u8_bufNum)

Start Transmit for buffer u8_bufNum

Parameters
u8_bufNumbuffer number (0 to 7)

Definition at line 259 of file pic24_ecan.c.