PIC24 Support Libraries
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

◆ clrRxFullFlagECAN1()

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 243 of file pic24_ecan.c.

◆ clrRxFullOvfFlagsECAN1()

void clrRxFullOvfFlagsECAN1 ( void  )

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

Definition at line 271 of file pic24_ecan.c.

◆ configBaudECAN1()

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 176 of file pic24_ecan.c.

◆ configRxFilterECAN1()

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 393 of file pic24_ecan.c.

◆ configRxMaskECAN1()

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 451 of file pic24_ecan.c.

◆ configTxRxBufferECAN1()

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 284 of file pic24_ecan.c.

◆ formatExtendedDataFrameECAN()

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 121 of file pic24_ecan.c.

Referenced by formatStandardDataFrameECAN().

◆ formatStandardDataFrameECAN()

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 81 of file pic24_ecan.c.

◆ getIdExtendedDataFrameECAN()

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 157 of file pic24_ecan.c.

Referenced by formatExtendedDataFrameECAN().

◆ getRxFullFlagECAN1()

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 258 of file pic24_ecan.c.

◆ getTxInProgressECAN1()

uint8_t getTxInProgressECAN1 ( uint8_t  u8_bufNum)

Start Transmit for buffer u8_bufNum

Parameters
u8_bufNumbuffer number (0 to 7)

Definition at line 360 of file pic24_ecan.c.

◆ startTxECAN1()

void startTxECAN1 ( uint8_t  u8_bufNum)

Start Transmit for buffer u8_bufNum

Parameters
u8_bufNumbuffer number (0 to 7)

Definition at line 326 of file pic24_ecan.c.