12#include "canfestival.h"
18volatile unsigned char msg_received = 0;
20volatile UNS16 BitErrors = 0 ;
21volatile UNS16 StuffErrors = 0;
22volatile UNS16 FormErrors = 0;
23volatile UNS16 OtherErrors = 0;
24volatile UNS16 receivedMessages = 0;
29unsigned char canInit()
37 for ( j = 0; j < 4; j++)
39 getODentry( &ObjDict_Data,
49 0x0000, 0x0140, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 };
52 TxHeader.StdId = identifiers[1];
57void UpdateCANerrors(
void)
60 CAN_BitErrors = BitErrors;
61 CAN_StuffErrors = StuffErrors;
62 CAN_FormErrors = FormErrors;
63 CAN_OtherErrors = OtherErrors;
64 CAN_Rx_ErrCounter = (
UNS16)rxErr;
65 CAN_Tx_ErrCounter = (
UNS16)txErr;
79 if(HAL_CAN_GetTxMailboxesFreeLevel(hcan) > 0)
81 TxHeader.StdId = m->
cob_id;
82 TxHeader.IDE = CAN_ID_STD;
84 TxHeader.RTR = CAN_RTR_REMOTE;
86 TxHeader.RTR = CAN_RTR_DATA;
88 TxHeader.DLC = m->
len;
89 memcpy(&TxData, m->
data, m->
len);
91 if (HAL_CAN_AddTxMessage(hcan, &TxHeader, TxData, &TxMailbox) != HAL_OK)
96 CAN_Transmit_Messages++;
104void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
106 HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxData);
107 CAN_Receive_Messages++;
111 if(RxHeader.IDE == CAN_ID_EXT)
114 rxm.
cob_id = RxHeader.StdId;
115 if(RxHeader.RTR == CAN_RTR_REMOTE)
117 rxm.
len = RxHeader.DLC;
118 memcpy(&rxm.
data, RxData, RxHeader.DLC);
124void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan)
126 HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO1, &RxHeader, RxData);
127 CAN_Receive_Messages++;
130void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)
132 if(hcan->ErrorCode & HAL_CAN_ERROR_NONE)
136 if(hcan->ErrorCode & HAL_CAN_ERROR_STF)
140 if(hcan->ErrorCode & HAL_CAN_ERROR_FOR)
144 if(hcan->ErrorCode & HAL_CAN_ERROR_ACK)
148 if((hcan->ErrorCode & HAL_CAN_ERROR_BR) ||
149 (hcan->ErrorCode & HAL_CAN_ERROR_BD))
153 if((hcan->ErrorCode & HAL_CAN_ERROR_TIMEOUT) ||
154 (hcan->ErrorCode & HAL_CAN_ERROR_EWG) ||
155 (hcan->ErrorCode & HAL_CAN_ERROR_EPV) ||
156 (hcan->ErrorCode & HAL_CAN_ERROR_TIMEOUT) ||
157 (hcan->ErrorCode & HAL_CAN_ERROR_NOT_INITIALIZED) ||
158 (hcan->ErrorCode & HAL_CAN_ERROR_NOT_READY) ||
159 (hcan->ErrorCode & HAL_CAN_ERROR_NOT_STARTED) ||
160 (hcan->ErrorCode & HAL_CAN_ERROR_PARAM))
164 if(hcan->ErrorCode & HAL_CAN_ERROR_BOF)
168 if(hcan->ErrorCode & HAL_CAN_ERROR_CRC)
172 if((hcan->ErrorCode & HAL_CAN_ERROR_TX_TERR0) || (hcan->ErrorCode & HAL_CAN_ERROR_TX_TERR1) || (hcan->ErrorCode & HAL_CAN_ERROR_TX_TERR2))
176 if((hcan->ErrorCode & HAL_CAN_ERROR_RX_FOV0) || (hcan->ErrorCode & HAL_CAN_ERROR_RX_FOV1))
180 if(hcan->ErrorCode & HAL_CAN_ERROR_STF){
This file is generated by the NNP Tool – Object Dictionary Editor, as originally developed by CAN Fes...
#define UNS8
Unsigned int8 representation in CANFest.
#define UNS16
Unsigned int16 representation in CANFest.
#define UNS32
Unsigned int32 representation in CANFest.
unsigned char canChangeBaudRate_driver(CAN_HandleTypeDef *hcan, char *baud)
UNS8 canSend(CAN_HandleTypeDef *hcan, Message *m)
The driver send a CAN message passed from the CANopen stack.
UNS8 getNodeId(CO_Data *d)
Returns the nodId.
: Header for main.c file. This file contains the common defines of the application.
void canDispatch(CO_Data *d, Message *m)
Called by driver/app when receiving messages.