Software Library API naibrd 2.24.0
See all documentation at naii.docs.com
can_common_utils.h
Go to the documentation of this file.
1
2/****** NAI CAN Common Sample Program Configuration Functions and Definitions ******/
3
4#ifndef NAI_CAN_CFG_H
5#define NAI_CAN_CFG_H
6
7#if !defined (NAI_PROCESSED_USING_SSK_GENERATOR)
8/* Combo Modules */
9#if !defined(NAIBRD_SSK_MODULE_ID_CB1)
10#define NAIBRD_SSK_MODULE_ID_CB1
11#endif
12#if !defined(NAIBRD_SSK_MODULE_ID_CB2)
13#define NAIBRD_SSK_MODULE_ID_CB2
14#endif
15#if !defined(NAIBRD_SSK_MODULE_ID_CB3)
16#define NAIBRD_SSK_MODULE_ID_CB3
17#endif
18#if !defined(NAIBRD_SSK_MODULE_ID_CB6)
19#define NAIBRD_SSK_MODULE_ID_CB6
20#endif
21
22#endif
23
24#define PRESCALER_1MBit 0 /*1M Bit*/
25#define SJW_1MBit 0 /*1M Bit*/
26#define TSEG1_1MBit 3 /*1M Bit*/
27#define TSEG2_1MBit 2 /*1M Bit*/
28
29#define PRESCALER_500K 0 /*500K Bit*/
30#define SJW_500K 0 /*500K Bit*/
31#define TSEG1_500K 12 /*500K Bit*/
32#define TSEG2_500K 1 /*500K Bit*/
33
34#define PRESCALER_250K 1 /*250K Bit*/
35#define SJW_250K 0 /*250K Bit*/
36#define TSEG1_250K 12 /*250K Bit*/
37#define TSEG2_250K 1 /*250K Bit*/
38
39typedef struct FIFO
40{
41 uint32_t dataJ1939[NAIBRD_CAN_J1939_MAX_DATA_LEN];
42 uint32_t dataAB[NAIBRD_CAN_AB_MAX_DATA_LEN];
43 int32_t length;
45
46typedef struct CanDataFrame
47{
49 uint32_t minLength;
50 int32_t maxLength;
53
54extern CanDataFrame fifoData[NAIBRD_GEN5_CAN_MAX_CHANNEL_COUNT];
55
56void naiapp_Cfg_Rx_CAN(int32_t cardIndex, int32_t module, int32_t channel, naibrd_can_baud_rate_type_t baudRate);
57void naiapp_Cfg_Tx_CAN(int32_t cardIndex, int32_t module, int32_t channel, naibrd_can_baud_rate_type_t baudRate);
58bool_t naiapp_IsCAN(uint32_t moduleID);
59bool_t naiapp_IsCAN_AB(int32_t cardIdx, int32_t module, int32_t channel);
60bool_t naiapp_IsCAN_J1939(int32_t cardIndex, int32_t module, int32_t channel);
61bool_t naiapp_GetCANCfg(int32_t defCard, int32_t defMod, int32_t defChan, int32_t *cardIndex, int32_t *module, int32_t *canChan,
62 bool_t *isCanAB);
63void naiapp_getCANTimingParameters(naibrd_can_baud_rate_type_t canTiming, int32_t* prescaler, int32_t* sjw, int32_t* tseg1, int32_t* tseg2);
67void naiapp_setChannelToCANAB(int32_t cardIndex, int32_t module, int32_t modId, int32_t* channelList, int32_t channelListSize);
68void naiapp_setChannelToCANJ1939(int32_t cardIndex, int32_t module, int32_t modId, int32_t* channelList, int32_t channelListSize);
69void naiapp_setChannelToCANJ1939_R(int32_t cardIndex, int32_t module, int32_t modId, int32_t channel);
70void naiapp_setChannelToCANAB_R(int32_t cardIndex, int32_t module, int32_t modId, int32_t channel);
71void naiapp_setCANTiming(int32_t cardIndex, int32_t module, naibrd_can_baud_rate_type_t canTiming, int32_t channel);
72void naiapp_setTxEnable(int32_t cardIndex, int32_t module, int32_t channel, bool_t enable);
73void naiapp_setRxEnable(int32_t cardIndex, int32_t module, int32_t channel, bool_t enable);
74void naiapp_printFIFOChannelData(int32_t channel, CanDataFrame* frameData, bool_t bJ1939);
75void naiapp_setCANFIFOStatusConditions(int32_t cardIndex, int32_t module, int32_t channel);
76void naiapp_getFIFOChannelData(int32_t cardIndex, int32_t module, int32_t channel, CanDataFrame* frameData);
77void naiapp_transmitFIFOChannelData_PGN(int32_t cardIndex, int32_t module, int32_t channel, int32_t pgn, CanDataFrame* frameData,
78 int32_t numOfFramesOnFifo);
79#if defined (NAIBRD_SSK_MODULE_ID_CB2) || defined (NAIBRD_SSK_MODULE_ID_CB3) || defined (NAIBRD_SSK_MODULE_ID_CB6)
80void naiapp_claimAddresses(int32_t card, int32_t mod, int32_t channel);
81#endif
82bool_t naiapp_isInputValidChannel(int8_t inputBuffer[80], int32_t* channelOut);
85bool_t naiapp_QueryForNumOfFramesToTransmit(int32_t* frames, int32_t minFrame, int32_t maxFrame);
86bool_t naiapp_QueryForPayload(int32_t *size, int32_t minPayload, int32_t maxPayload, bool_t isJ1939);
87bool_t naiapp_QueryForChannelProtocol(uint32_t modId, bool_t* isJ1939);
88bool_t naiapp_QueryForPGN(uint32_t* pgn);
89bool_t naiapp_QueryChannelForRxEnable(bool_t* rxEnable);
90bool_t naiapp_QueryChannelForTxEnable(bool_t* txEnable);
91bool_t naiapp_QueryForChannels(int32_t *minChannel, int32_t* maxChannel);
92bool_t naiapp_QueryForTransmissionSource(bool_t* generateInput);
93void naiapp_generateData(int32_t channel, int32_t numOfFrames, int32_t payLoadSize, bool_t isJ1939, CanDataFrame* buffer);
94
95#endif
char * naiapp_getFaultTypeString(naibrd_can_swt_fault_type_t faultType)
Definition can_common_utils.c:501
void naiapp_Cfg_Tx_CAN(int32_t cardIndex, int32_t module, int32_t channel, naibrd_can_baud_rate_type_t baudRate)
This function configures the baud rate of the can channel and enables the channels to Tx.
Definition can_common_utils.c:702
void naiapp_setChannelToCANJ1939_R(int32_t cardIndex, int32_t module, int32_t modId, int32_t channel)
Sets the channel protocol to J1939 if supported by module.
Definition can_common_utils.c:605
bool_t naiapp_isInputValidChannel(int8_t inputBuffer[80], int32_t *channelOut)
CanDataFrame fifoData[NAIBRD_GEN5_CAN_MAX_CHANNEL_COUNT]
Definition can_common_utils.c:20
void naiapp_claimAddresses(int32_t card, int32_t mod, int32_t channel)
void naiapp_getCANTimingParameters(naibrd_can_baud_rate_type_t canTiming, int32_t *prescaler, int32_t *sjw, int32_t *tseg1, int32_t *tseg2)
Definition can_common_utils.c:402
void naiapp_printFIFOChannelData(int32_t channel, CanDataFrame *frameData, bool_t bJ1939)
Prints the data in the FIFO.
Definition can_common_utils.c:750
bool_t naiapp_QueryChannelForTxEnable(bool_t *txEnable)
void naiapp_setRxEnable(int32_t cardIndex, int32_t module, int32_t channel, bool_t enable)
Sets the CAN channel to Rx or disables Rx depending on the "enable" parameter.
Definition can_common_utils.c:667
bool_t naiapp_QueryForChannels(int32_t *minChannel, int32_t *maxChannel)
bool_t naiapp_QueryForChannelProtocol(uint32_t modId, bool_t *isJ1939)
char * naiapp_getProtocolString(naibrd_can_protocol_type_t protocol)
Converts protocol passed in to a string.
Definition can_common_utils.c:482
bool_t naiapp_QueryChannelForRxEnable(bool_t *rxEnable)
bool_t naiapp_QueryForTransmissionSource(bool_t *generateInput)
bool_t naiapp_IsCAN_J1939(int32_t cardIndex, int32_t module, int32_t channel)
Determines if channel is set to J1939 protocol.
Definition can_common_utils.c:54
bool_t naiapp_IsCAN_AB(int32_t cardIdx, int32_t module, int32_t channel)
Determines if channel is set to CAN AB protocol.
Definition can_common_utils.c:111
void naiapp_generateData(int32_t channel, int32_t numOfFrames, int32_t payLoadSize, bool_t isJ1939, CanDataFrame *buffer)
bool_t naiapp_QueryForNumOfFramesToTransmit(int32_t *frames, int32_t minFrame, int32_t maxFrame)
bool_t naiapp_QueryUserForCANTiming(naibrd_can_baud_rate_type_t *baudRate, bool_t bJ1939)
void naiapp_transmitFIFOChannelData_PGN(int32_t cardIndex, int32_t module, int32_t channel, int32_t pgn, CanDataFrame *frameData, int32_t numOfFramesOnFifo)
Transmits the FIFO data found on a given channel.
Definition can_common_utils.c:826
void naiapp_setChannelToCANAB_R(int32_t cardIndex, int32_t module, int32_t modId, int32_t channel)
Sets the channel protocol to CAN AB if supported by module.
Definition can_common_utils.c:631
void naiapp_setChannelToCANAB(int32_t cardIndex, int32_t module, int32_t modId, int32_t *channelList, int32_t channelListSize)
Sets the channels' protocols within channelList to CAN AB.
Definition can_common_utils.c:572
bool_t naiapp_QueryForPGN(uint32_t *pgn)
bool_t naiapp_GetCANCfg(int32_t defCard, int32_t defMod, int32_t defChan, int32_t *cardIndex, int32_t *module, int32_t *canChan, bool_t *isCanAB)
Gets CAN configuration.
Definition can_common_utils.c:169
void naiapp_Cfg_Rx_CAN(int32_t cardIndex, int32_t module, int32_t channel, naibrd_can_baud_rate_type_t baudRate)
This function configures the baud rate of the CAN channel and enables the channel to Rx.
Definition can_common_utils.c:681
void naiapp_setCANFIFOStatusConditions(int32_t cardIndex, int32_t module, int32_t channel)
Sets the thresholds for the status register of the passed in channel.
Definition can_common_utils.c:723
struct FIFO FIFO
void naiapp_setCANTiming(int32_t cardIndex, int32_t module, naibrd_can_baud_rate_type_t canTiming, int32_t channel)
Set CAN timing for channel.
Definition can_common_utils.c:392
char * naiapp_getBaudRateString(naibrd_can_baud_rate_type_t baud)
Converts baud rate passed in to a string.
Definition can_common_utils.c:445
void naiapp_getFIFOChannelData(int32_t cardIndex, int32_t module, int32_t channel, CanDataFrame *frameData)
Reads all the frames off the FIFO of the passed in channel and stores them in a buffer....
Definition can_common_utils.c:790
void naiapp_setTxEnable(int32_t cardIndex, int32_t module, int32_t channel, bool_t enable)
Sets the CAN channel to Tx or disables Tx depending on the "enable" parameter.
Definition can_common_utils.c:653
bool_t naiapp_QueryForPayload(int32_t *size, int32_t minPayload, int32_t maxPayload, bool_t isJ1939)
void naiapp_setChannelToCANJ1939(int32_t cardIndex, int32_t module, int32_t modId, int32_t *channelList, int32_t channelListSize)
Sets the channels' protocols in channelList to CAN J1939.
Definition can_common_utils.c:539
bool_t naiapp_QueryUserForAddressClaiming(bool_t *naiapp_claimAddresses)
bool_t naiapp_IsCAN(uint32_t moduleID)
Determines if is CAN module.
Definition can_common_utils.c:28
struct CanDataFrame CanDataFrame
enum naibrd_can_protocol_type naibrd_can_protocol_type_t
enum naibrd_can_swt_fault_type naibrd_can_swt_fault_type_t
enum naibrd_can_baud_rate_type naibrd_can_baud_rate_type_t
Definition can_common_utils.h:47
int32_t numOfFramesOnFifo
Definition can_common_utils.h:51
FIFO data[50]
Definition can_common_utils.h:48
int32_t maxLength
Definition can_common_utils.h:50
uint32_t minLength
Definition can_common_utils.h:49
Definition can_common_utils.h:40
int32_t length
Definition can_common_utils.h:43
uint32_t dataAB[NAIBRD_CAN_AB_MAX_DATA_LEN]
Definition can_common_utils.h:42
uint32_t dataJ1939[NAIBRD_CAN_J1939_MAX_DATA_LEN]
Definition can_common_utils.h:41