CANpie FD
CAN programming interface environment - Version 3.08
Migration from CANpie to CANpie FD

Configuration of bit-rate

The function for bit-rate setup CpCoreBaudrate() has been renamed to CpCoreBitrate(), the new function has an additional parameter for configuration of the data bit-rate. The following code example shows the difference between the two API versions for a bit-rate setting of 500 kBit/s.

//-----------------------------------------------------
// CANpie configuration of bit-rate
//
CpCoreBaudrate(&tsCanPortG, CP_BAUD_500K);
//-----------------------------------------------------
// CANpie FD configuration of bit-rate
//

Configuration of message buffer

The functions CpCoreBufferInit() and CpCoreBufferAccMask() have been removed, the function CpCoreBufferConfig() is the replacement.

Configuration for message transmission

The following example code depicts the difference for initialization of a transmit message buffer between CANpie and CANpie FD. New new API does not require a CAN message structure CpCanMsg_ts any more.

//-----------------------------------------------------
// CANpie configuration
//
CpCanMsg_ts tsCanMsgT; // CAN message structure
CpCoreBufferRelease(&tsCanPortG, CP_BUFFER_2);
CpMsgClear(&tsCanMsgT);
CpMsgSetStdId(&tsCanMsgT, (uint16_t) 0x123);
CpMsgSetDlc(&tsCanMsgT, 8);
CpCoreBufferInit(&tsCanPortG, &tsCanMsgT, CP_BUFFER_2, CP_BUFFER_DIR_TX);
//-----------------------------------------------------
// CANpie FD configuration
//
(uint32_t) 0x123, CP_MASK_STD_FRAME,
CpCoreBufferSetDlc( &tsCanPortG, eCP_BUFFER_2, 8);

Configuration for message reception

The following example code depicts the difference for initialization of a receive message buffer between CANpie and CANpie FD. New new API does not require a CAN message structure CpCanMsg_ts any more.

//-----------------------------------------------------
// CANpie configuration
// accept identifier in the range from 700h .. 77Fh
//
CpCanMsg_ts tsCanMsgT; // CAN message structure
CpMsgClear(&tsCanMsgT);
CpMsgSetStdId(&tsCanMsgT, 0x700 );
CpMsgSetDlc(&tsCanMsgT, 1);
CpCoreBufferInit( &tsCanPortG, &tsCanMsgT,
CP_BUFFER_4, CP_BUFFER_DIR_RX);
CpCoreBufferAccMask(&tsCanPortG, CP_BUFFER_4, 0x780);
//-----------------------------------------------------
// CANpie FD configuration
// accept identifier in the range from 700h .. 77Fh
//
CpCoreBufferConfig( &tsCanPortG, eCP_BUFFER_4,
(uint32_t) 0x700, // identifier
(uint32_t) 0x780, // mask
CP_MSG_FORMAT_CBFF, // format


CpCoreBitrate
CpStatus_tv CpCoreBitrate(CpPort_ts *ptsPortV, int32_t slNomBitRateV, int32_t slDatBitRateV)
Set bit-rate of CAN controller.
CpCoreBufferConfig
CpStatus_tv CpCoreBufferConfig(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint32_t ulIdentifierV, uint32_t ulAcceptMaskV, uint8_t ubFormatV, uint8_t ubDirectionV)
Initialise message buffer.
eCP_BITRATE_500K
@ eCP_BITRATE_500K
Definition: canpie.h:676
CP_MASK_STD_FRAME
#define CP_MASK_STD_FRAME
Definition: canpie.h:297
CpCoreBufferSetDlc
CpStatus_tv CpCoreBufferSetDlc(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t ubDlcV)
Set DLC of specified buffer.
CpCoreBufferRelease
CpStatus_tv CpCoreBufferRelease(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV)
Release message buffer.
eCP_BUFFER_DIR_RCV
@ eCP_BUFFER_DIR_RCV
Definition: canpie.h:937
CpMsgClear
void CpMsgClear(CpCanMsg_ts *ptsCanMsgV)
Clear message structure.
CP_MSG_FORMAT_CBFF
#define CP_MSG_FORMAT_CBFF
Definition: canpie.h:414
CpCanMsg_s
CAN message structure.
Definition: canpie.h:1003
CpMsgSetDlc
void CpMsgSetDlc(CpCanMsg_ts *ptsCanMsgV, uint8_t ubDlcV)
Set Data Length Code.
eCP_BUFFER_2
@ eCP_BUFFER_2
Definition: canpie.h:901
eCP_BUFFER_DIR_TRM
@ eCP_BUFFER_DIR_TRM
Definition: canpie.h:940
CpMsgSetStdId
void CpMsgSetStdId(CpCanMsg_ts *ptsCanMsgV, uint16_t uwStdIdV)
Set 11 Bit Identifier Value.