CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Can.c
Go to the documentation of this file.
1
2
3#include "tutti_gli_header.h"
4
5
6/*****DOCUMENTAZIONE DOXYGEN*******/
7/// \file
8// \file GPIO_LPC17xx.c
9// \file GPIO_LPC17xx.h
10/// \file CAN_LPC17xx.c
11// \file CAN_LPC17xx.h
12// \file Driver_CAN.h
13
14/*!
15\page CAN The CAN bus
16\brief <span style="color:red;"> <b> Can Bus operation </b> </span>
17
18 \b SUMMARY:
19*\arg \ref user_use_of_CAN_bus
20
21
22*\section user_use_of_CAN_bus User use of CAN bus
23<hr width="75%" size="10" align="left">
24
25\n CAN bus, as well I2C, is a communication protocol based on the CMSIS drivers. Adaptation and use of some
26drivers is exploited, as it will be explained in the following.
27First of all it needs to read the hw parte of the the address of the board at some pins of the microcontroller.
28The addresses are set by means of some switches and the function to be used within the initialization function is
29lettura_indirizzi_CAN(). The function returns a char with the hw address.
30\n After the communication is completed, either transmission or reception, the interrupt call the CAN_SignalObjectEvent() and
31CAN_SignalUnitEvent() that have as an input the var \b event that containes some flags.
32\n The flags from CAN_SignalUnitEvent() are general from the CAN and are the following:
33
34\n
35<center>
36\anchor Table_interrupt_signal_event \b Table \b signal \b Interrupt: Flags of the mask \b event from CAN_SignalUnitEvent()
37Parameter event | Bit | Description |
38:------------------------------- | :-----: | :---------------------------------------------------------------------|
39ARM_CAN_EVENT_UNIT_INACTIVE | 0 | Unit entered Inactive state. |
40ARM_CAN_EVENT_UNIT_ACTIVE | 1 | Unit entered Error Active state. |
41ARM_CAN_EVENT_UNIT_WARNING | 2 | Unit entered Error Warning state (one or both error counters >= 96). |
42ARM_CAN_EVENT_UNIT_PASSIVE | 3 | Unit entered Error Passive state. |
43ARM_CAN_EVENT_UNIT_BUS_OFF | 4 | Unit entered Bus-off state. |
44</center>
45
46\n CAN_SignalObjectEvent() merely marks the ened of operation and the \b event var that generates is replicated to the global #evento_CAN
47with the flags that summarazies the results from the objcet under consideration, reception or transmission. In addition to
48the var \b event also the var \b obj_idx is a mark of the data transmission or reception.
49\n The flags of #evento_CAN have the following meaning:
50
51\n
52<center>
53\anchor Table_interrupt_obj_event \b Table \b object \b Interrput: Flags of the mask #evento_I2C from CAN_SignalObjectEvent().
54<span style="color:red;"> The row highlighted in red marks the state expected after a successfully communication. </span>
55Parameter event | Bit | Description |
56:------------------------------- | :-----: | :--------------------------------------------------------------------|
57<span style="color:red;"> ARM_CAN_EVENT_SEND_COMPLETE </span> | <span style="color:red;"> 1 << 0 </span> | <span style="color:red;"> Message was sent successfully by the obj_idx object. </span> |
58<span style="color:red;"> ARM_CAN_EVENT_RECEIVE </span> | <span style="color:red;"> 1 << 1 </span> | <span style="color:red;"> Message was received successfully by the obj_idx object. </span> |
59ARM_CAN_EVENT_RECEIVE_OVERRUN | 1 << 2 | Message was overwritten before it was read on the obj_idx object. |
60</center>
61
62\n The function CAN_Inizialize() is used once to set the CAN into operation. The speed of the bus is defined in #CAN_speed.
63In CAN_Inizialize() the hw address is exploited to compose the final 29 bis long address.
64
65\n To communicate with the CAN bus we exploit part of the structure of functions from CMSIS. The structure typedef is this:
66<span style="color:orange;"> <I>
67\code {.c}
68typedef struct _ARM_DRIVER_CAN {
69 ARM_DRIVER_VERSION (*GetVersion) (void); ///< Pointer to \ref ARM_CAN_GetVersion : Get driver version.
70 ARM_CAN_CAPABILITIES (*GetCapabilities) (void); ///< Pointer to \ref ARM_CAN_GetCapabilities : Get driver capabilities.
71 int32_t (*Initialize) (ARM_CAN_SignalUnitEvent_t cb_unit_event,
72 ARM_CAN_SignalObjectEvent_t cb_object_event); ///< Pointer to \ref ARM_CAN_Initialize : Initialize CAN interface.
73 int32_t (*Uninitialize) (void); ///< Pointer to \ref ARM_CAN_Uninitialize : De-initialize CAN interface.
74 int32_t (*PowerControl) (ARM_POWER_STATE state); ///< Pointer to \ref ARM_CAN_PowerControl : Control CAN interface power.
75 uint32_t (*GetClock) (void); ///< Pointer to \ref ARM_CAN_GetClock : Retrieve CAN base clock frequency.
76 int32_t (*SetBitrate) (ARM_CAN_BITRATE_SELECT select,
77 uint32_t bitrate,
78 uint32_t bit_segments); ///< Pointer to \ref ARM_CAN_SetBitrate : Set bitrate for CAN interface.
79 int32_t (*SetMode) (ARM_CAN_MODE mode); ///< Pointer to \ref ARM_CAN_SetMode : Set operating mode for CAN interface.
80 ARM_CAN_OBJ_CAPABILITIES (*ObjectGetCapabilities) (uint32_t obj_idx); ///< Pointer to \ref ARM_CAN_ObjectGetCapabilities : Retrieve capabilities of an object.
81 int32_t (*ObjectSetFilter) (uint32_t obj_idx,
82 ARM_CAN_FILTER_OPERATION operation,
83 uint32_t id,
84 uint32_t arg); ///< Pointer to \ref ARM_CAN_ObjectSetFilter : Add or remove filter for message reception.
85 int32_t (*ObjectConfigure) (uint32_t obj_idx,
86 ARM_CAN_OBJ_CONFIG obj_cfg); ///< Pointer to \ref ARM_CAN_ObjectConfigure : Configure object.
87 int32_t (*MessageSend) (uint32_t obj_idx,
88 ARM_CAN_MSG_INFO *msg_info,
89 const uint8_t *data,
90 uint8_t size); ///< Pointer to \ref ARM_CAN_MessageSend : Send message on CAN bus.
91 int32_t (*MessageRead) (uint32_t obj_idx,
92 ARM_CAN_MSG_INFO *msg_info,
93 uint8_t *data,
94 uint8_t size); ///< Pointer to \ref ARM_CAN_MessageRead : Read message received on CAN bus.
95 int32_t (*Control) (uint32_t control,
96 uint32_t arg); ///< Pointer to \ref ARM_CAN_Control : Control CAN interface.
97 ARM_CAN_STATUS (*GetStatus) (void); ///< Pointer to \ref ARM_CAN_GetStatus : Get CAN status.
98} const ARM_DRIVER_CAN;
99\endcode
100</I> </span>
101
102\n We use only CAN1 which is defined here:
103
104<span style="color:orange;"> <I>
105\code {.c}
106ARM_DRIVER_CAN Driver_CAN1 = {
107 CAN_GetVersion,
108 CAN_GetCapabilities,
109 CAN1_Initialize,
110 CAN1_Uninitialize,
111 CAN1_PowerControl,
112 CAN1_GetClock,
113 CAN1_SetBitrate,
114 CAN1_SetMode,
115 CAN1_ObjectGetCapabilities,
116 CAN1_ObjectSetFilter,
117 CAN1_ObjectConfigure,
118 CAN1_MessageSend, //This is the function exploited for transmission
119 CAN1_MessageRead, //This is the function exploited for reception
120 CAN1_Control,
121 CAN1_GetStatus
122};
123\endcode
124</I> </span>
125
126\n We exploit mainly \b CAN1_MessageSend, for transmission, \b CAN1_MessageRead, for reception.
127If a polling is needed tehere are 3 varaibles that can be used. The first was mentioned above and is #evento_CAN
128that assumes value according to Table \ref Table_interrupt_obj_event. This variable marks a concluded reception or transmission.
129Other 2 boolean variables have been introduced, #messaggio_CAN_arrivato and #messaggio_CAN_spedito that are set
130to true when the operation is conlcuded. In case these 2 variables are used they need to be set to false just before the
131CAN operation is started.
132
133\remark There are several available functions. we exploit only a few of them. Some are exploited in CAN_Inizialize().
134Two important functions we need to consider are the transmission and reception.
135Although we use only one of the 2 available CAN bus, for generality an example of the suggested use is as it follows:
136<span style="color:orange;"> <I>
137
138
139\code {.c}
140extern ARM_DRIVER_CAN Driver_CAN1; // Viene inclusa la Periferica CAN1
141ARM_DRIVER_CAN *CANdrv= &Driver_CAN1; //!< Puntatore alla periferica CAN
142tx_msg_info.id = ARM_CAN_EXTENDED_ID(some_address); //In case it needs to specify the address
143
144messaggio_CAN_spedito =false;
145CANdrv->MessageSend(tx_obj_idx, &tx_msg_info, tx_data, 8U);
146while( messaggio_CAN_spedito==false ); // Wait transmission completes, if we need to wait
147
148messaggio_CAN_arrivato =false;
149CANdrv->MessageRead(rx_obj_idx, &rx_msg_info, (uint8_t *) rx_data, 8U);
150while( messaggio_CAN_arrivato == false ); // Wait reception completes, if we need to wait
151\endcode
152</I> </span>
153
154\note To the CAN a generic address is assigned. Every board will answer to this address. To identify the answer of the board of interest
155only the board should be connecte to the bus or oits switch is the "generic address" position. The generic address set is the following #indirizzo_generico_CAN:
156\snippetlineno Can.h var_indirizzo_generico_CAN
157
158\remark Another polling alternative is this:
159<span style="color:orange;"> <I>
160\code {.c}
161CANdrv->MessageSend(tx_obj_idx, &tx_msg_info, tx_data, 8U);
162while( evento_CAN !=ARM_CAN_EVENT_SEND_COMPLETE ){} // Wait transmission completes, if we need to wait
163
164CANdrv->MessageRead(rx_obj_idx, &rx_msg_info, (uint8_t *) rx_data, 8U);
165while( evento_CAN != ARM_CAN_EVENT_RECEIVE ); // Wait reception completes, if we need to wait
166\endcode
167</I> </span>
168
169\n
170\n
171\sa That shown above is an extraction of the documentation from CMSIS drivers.
172For a complete reference to the CAN bus driver from CMSIS see the webs at Keil or ARM (in case of failure of either):
173- <a href="https://arm-software.github.io/CMSIS_5/Driver/html/group__can__interface__gr.html" target=_blank><b>CMSIS doc for CAN bus from ARM</b></a>,
174- <a href="https://www.keil.com/pack/doc/CMSIS/Driver/html/group__can__interface__gr.html" target=_blank><b>CMSIS doc for CAN bus from KEIL</b></a>
175
176\n The codes for CAN bus is at:
177- \ref Can.c
178- \ref Can.h
179
180*/
181
182/*! <!-- La funzione driver I2C0 -->
183<!-- ************************************************************************************************ -->
184
185\fn CAN1_Initialize (ARM_CAN_SignalUnitEvent_t cb_unit_event, ARM_CAN_SignalObjectEvent_t cb_object_event)
186\param[in] cb_unit_event Pointer to \b ARM_CAN_SignalUnitEvent callback function
187\param[in] cb_object_event Pointer to \b ARM_CAN_SignalObjectEvent callback function
188\return #Status_Error_Codes_CAN
189
190\brief Initialize CAN interface and register signal (callback) functions.
191
192The function initializes the CAN interface.
193
194The function performs the following operations:
195
196Initializes the resources needed for the CAN interface, for example dynamic memory allocation, RTOS object allocation, and possibly hardware pin configuration.
197Registers the \b ARM_CAN_SignalUnitEvent callback function.
198Registers the \b ARM_CAN_SignalObjectEvent callback function.
199The parameter cb_unit_event is a pointer to the \b ARM_CAN_SignalUnitEvent callback function; use a NULL pointer when no callback signals are required.
200
201The parameter cb_object_event is a pointer to the \b ARM_CAN_SignalObjectEvent callback function; use a NULL pointer when no callback signals are required.
202
203<!-- ************************************************************************************************ -->
204\fn CAN1_Uninitialize(void)
205\retrun #Status_Error_Codes_CAN
206
207\brief De-initialize CAN interface.
208
209The function CAN1_Uninitialize() de-initializes the resources of the CAN interface.
210It is called to release the software resources used by the interface such as deallocate any
211RTOS objects, dynamic memory and pin de-configuration.
212
213<!-- ************************************************************************************************ -->
214\fn CAN1_PowerControl(ARM_POWER_STATE state)
215\param[in] state Power state
216- \b ARM_POWER_OFF : power off: no operation possible
217- \b ARM_POWER_LOW : low power mode: retain state, detect and signal wake-up events
218- \b ARM_POWER_FULL : power on: full operation at maximum performance
219\return #Status_Error_Codes_CAN
220
221\brief Control CAN interface power.
222The function ARM_CAN_PowerControl controls the power modes of the CAN interface.
223
224<!-- ************************************************************************************************ -->
225\fn CAN1_MessageSend(uint32_t obj_idx, ARM_CAN_MSG_INFO *msg_info, const uint8_t *data, uint8_t size)
226\param[in] obj_idx Object index
227\param[in] msg_info Pointer to CAN message information
228\param[in] data Pointer to data buffer
229\param[in] size Number of data bytes to send
230\return value >= 0 number of data bytes accepted to send, value < 0 #Status_Error_Codes_CAN
231\brief Send message on CAN bus.
232The function CAN1_MessageSend() sends a CAN message on the CAN bus, or sets data message that will be automatically returned upon RTR reception with matching CAN ID.
233
234Only one message can be sent with a call to this function (for CAN up to 8 bytes; for CAN FD up to 64 bytes of data). A message transmission can be terminated with a
235call to the function \b ARM_CAN_Control with control = \b ARM_CAN_ABORT_MESSAGE_SEND.
236
237The parameter obj_idx specifies the message object index.
238
239The parameter msg_info is a pointer to the structure \b ARM_CAN_MSG_INFO, which contains the following relevant data fields for sending message:
240
241- id: Identifier of the message; bit 31 specifies if this is an 11-bit or 29-bit identifier.
242- rtr: Specifies if Remote Transmission Request should be sent (dlc is used for number of requested bytes), otherwise the data message will be sent. Refer to Remote Frame for details.
243- edl: Specifies if Extended Data Length is used; for CAN FD, message can contain up to 64 data bytes.
244- brs: Specifies if Bit Rate Switching is to be used; for CAN FD, the bit rate can be increased during data phase.
245- dlc: Data Length Code of requested data bytes when sending Remote Transmission Request.
246
247The parameter data is a pointer to the data buffer.
248\n The parameter size is the number of data bytes to send.
249\n The function returns the number of bytes accepted to be sent or \b ARM_DRIVER_ERROR_BUSY if the hardware is not ready to accept a new message for transmission.
250
251\n When the message is sent, the callback function ARM_CAN_SignalObjectEvent is called signalling \b ARM_CAN_EVENT_SEND_COMPLETE on specified object.
252
253<!-- ************************************************************************************************ -->
254\fn CAN1_MessageRead(uint32_t obj_idx, ARM_CAN_MSG_INFO *msg_info, uint8_t *data, uint8_t size)
255\param[in] obj_idx Object index
256\param[out] msg_info Pointer to read CAN message information
257\param[out] data Pointer to data buffer for read data
258\param[in] size Maximum number of data bytes to read
259\return value >= 0 number of data bytes read, value < 0 #Status_Error_Codes_CAN
260
261\brief Read message received on CAN bus.
262The function CAN1_MessageRead() reads the message received on the CAN bus, if obj_idx was configured for reception
263or for automatic Data Message reception using RTR and the callback function \b ARM_CAN_SignalObjectEvent was called signalling
264\b ARM_CAN_EVENT_RECEIVE. If the message was overrun by another received message, then the callback function
265\b ARM_CAN_SignalObjectEvent will be called signalling \b ARM_CAN_EVENT_RECEIVE_OVERRUN.
266
267The function can read a maximum of 8 data bytes for CAN and 64 bytes for CAN FD.
268
269\n The parameter obj_idx specifies the message object index.
270\n The parameter msg_info is a pointer to the CAN information structure.
271\n The parameter data is a pointer to the data buffer for reading data.
272\n The parameter size is data buffer size in bytes and indicates the maximum number of bytes that can be read.
273
274The function returns the number of read data in bytes or the #Status_Error_Codes_CAN.
275
276All data fields of the structure ARM_CAN_MSG_INFO are updated as described below:
277
278- id: Identifier of the message that was received, bit 31 specifies if it is a 11-bit identifier or 29-bit identifier.
279- rtr: 1 = Remote Frame Request was received (dlc is number of requested bytes). 0 = data message
280- edl: 1 = CAN FD Extended Data Length message was received. 0 = not Extended Data Length message.
281- brs: 1 = CAN FD Bit Rate Switching was used for message transfer. 0 = no Bit Rate Switching was used.
282- esi: 1 = CAN FD Error State Indicator is active for received message. 0 = Error State Indicator is not active.
283- dlc: Data Length Code is the number of data bytes in the received message or number of data bytes requested by RTR.
284
285Message reception can be disabled by de-configuring the receive object with the function ARM_CAN_ObjectConfigure.
286*/
287
288// <!-- ************************************************************************************************ -->
289// <!-- Definizione solo per creare un commento -->
290/*! \brief
291Macros
292- \b ARM_DRIVER_OK 0
293 Operation succeeded.
294- \b ARM_DRIVER_ERROR -1
295 Unspecified error.
296- \b ARM_DRIVER_ERROR_BUSY -2
297 Driver is busy.
298- \b ARM_DRIVER_ERROR_TIMEOUT -3
299 Timeout occurred.
300- \b ARM_DRIVER_ERROR_UNSUPPORTED -4
301 Operation not supported.
302- \b ARM_DRIVER_ERROR_PARAMETER -5
303 Parameter error.
304- \b ARM_DRIVER_ERROR_SPECIFIC -6
305 Start of driver specific errors.
306
307Description
308Negative return values of functions indicate errors occurred during execution.
309
310Most functions return a status information using negative return values.
311The following list provides the status error codes that are common in all drivers.
312The drivers may return also status error codes that are specific to the peripheral.
313*/
314int8_t Status_Error_Codes_CAN; //Creata solo per generare un commento
315
316// Vengono inizializzati alcuni parametri
317int32_t status;
318volatile uint8_t rx_data[8]; //!< Received data vector
319ARM_CAN_MSG_INFO rx_msg_info;
320uint32_t rx_obj_idx = 0U;
321uint8_t tx_data[8]; //!< Transmission data vector
322ARM_CAN_MSG_INFO tx_msg_info;
323uint32_t tx_obj_idx = 1U;
324
325//!< This is the variable which resembles the flags from the communication
326uint32_t volatile evento_CAN; //!< This is the variable which resembles the flags from the communication
327
328bool messaggio_CAN_arrivato = false; //!< This variable is set to true as soon as a reception have been concluded
329bool messaggio_CAN_spedito = false; //!< This variable is set to true as soon as a transmission have been concluded
330
331
332extern ARM_DRIVER_CAN Driver_CAN1; //!< Viene inclusa la Periferica CAN1
333ARM_DRIVER_CAN *CANdrv= &Driver_CAN1; /*!< Puntatore alla periferica CAN*/
334 // Viene creato un puntatore a Driver_CAN1
335unsigned int indirizzo_CAN_della_scheda=0x12345678; //!< Per ora lo assegnamo cos\i l'indirizzo della scheda
336
337
338/*! \brief The CAN bus address
339
340*\return A char with the hw CAN bus address
341\callgraph
342\showrefs
343*\snippet{lineno} Can.c fun_lettura_indirizzi_CAN
344 */
345//! <!-- [fun_lettura_indirizzi_CAN] -->
346unsigned char lettura_indirizzi_CAN(void){
347 //Lettura indirizzo PIN
348 uint8_t lettura,indirizzo;
349 uint8_t iii;
350
351// lettura[0]=GPIO_PinRead(0,B0);
352 indirizzo=0;
353 for (iii=0;iii<8;iii++){
354 lettura = GPIO_PinRead(CAN_indirizzo_hw[iii].porta_num, CAN_indirizzo_hw[iii].pin_num);
355 if(lettura) indirizzo += 1 << iii;
356 }
357
358 return indirizzo;
359}
360//! <!-- [fun_lettura_indirizzi_CAN] -->
361
362
363 /*****************************************************************************
364 Callback della Periferica CAN
365 ******************************************************************************/
366/*! \brief After that CAN aneded operation eand the interrupt is generated this signal function is called which marks errors, if any
367
368*\param[in] event
369*\return No parameters
370 \showrefby
371\showrefs
372*\snippet{lineno} Can.c fun_CAN_SignalUnitEvent
373 */
374//! <!-- [fun_CAN_SignalUnitEvent] -->
375void CAN_SignalUnitEvent (uint32_t event) {}
376 //! <!-- [fun_CAN_SignalUnitEvent] -->
377
378/*! \brief After that CAN aneded operation eand the interrupt is generated this object function is called which marks which action completed
379
380*\param[in] obj_idx
381*\param[in] event
382*\return No parameters
383\showrefby
384\showrefs
385*\snippet{lineno} Can.c fun_CAN_SignalObjectEvent
386 */
387//! <!-- [fun_CAN_SignalObjectEvent] -->
388void CAN_SignalObjectEvent(uint32_t obj_idx, uint32_t event)
389{
390 uint8_t i;
391
392 tempo=0; //Si resetta il contatore per il powerdown
393 evento_CAN= event;
394 if(event==ARM_CAN_EVENT_RECEIVE) // Se c'\'e un evento di ricezione
395 {
396 if (obj_idx == rx_obj_idx) // Se si riceve l'evento dell'oggetto
397 {
398 messaggio_CAN_arrivato=true; // Se c'\'e un'istruzione dal can, il flag diventa true
399 CANdrv->MessageRead(rx_obj_idx, &rx_msg_info, (uint8_t *) rx_data, 8U); // Viene letto il dato ricevuto
400// for(i=0;i<8;++i)
401// {
402// tx_data[i]=rx_data[i]; // Viene copiato il dato nell'array di ricezione
403// }
404 }
405 }
406
407 if (event == ARM_CAN_EVENT_SEND_COMPLETE) // Se c'\'e un evento di trasmissione
408 {
409 if (obj_idx == tx_obj_idx)
410 {
412 rx_msg_info.id = ARM_CAN_EXTENDED_ID(indirizzo_CAN_della_scheda); // Viene impostato l'indirizzo esteso per il prossimo messaggio da ricevere
413 }
414 }
415}
416//! <!-- [fun_CAN_SignalObjectEvent] -->
417
418
419/******************************************************************************
420 Inizializzazione della Periferica CAN
421*******************************************************************************/
422
423/*! \brief The CAN initialization function
424
425*\return No parameters
426\showrefby
427\showrefs
428\showrefs
429\callgraph
430*\snippet{lineno} Can.c fun_CAN_Inizialize
431 */
432//! <!-- [fun_CAN_Inizialize] -->
434{
435 uint32_t test_addr;
436 indirizzo_CAN_della_scheda= lettura_indirizzi_CAN(); //Leggiamo l'indirizzo del CAN dagli interruttori
437
438 EPROM_lettura_M24C32_64(0,I2C_postmainboard, Canale_EPROM_postmainboard_down, Memory_postmainboard_CAN_from_hw_switch_1_from_EPROM_0 <<2 , (uint8_t *)&test_addr);
439 if (test_addr ==0) EPROM_lettura_M24C32_64(0,I2C_postmainboard, Canale_EPROM_postmainboard_down, Memory_postmainboard_address_CAN_own_filter <<2 , (uint8_t *)&indirizzo_CAN_della_scheda);
440// LED_accendi_spegni(LED_GREEN, accendi);
441// LED_accendi_spegni(LED_RED, spegni);
442
443 status = CANdrv ->PowerControl(ARM_POWER_OFF); //AL risveglio serve per resettare tutti i registri, altrimenti
444 status = CANdrv -> Uninitialize();
445 //gli interrupt non li configura e bisogna farlo a mano.
447 status = CANdrv->PowerControl(ARM_POWER_FULL); // Viene accesa la periferica CAN
448 status = CANdrv->SetMode(ARM_CAN_MODE_INITIALIZATION); // Viene attivata la modalit\'a inizializzazione
449
450 // Vengono impostati i valori per il BitRate
451 status = CANdrv->SetBitrate (ARM_CAN_BITRATE_NOMINAL,
452 CAN_speed,
453 ARM_CAN_BIT_PROP_SEG(5U) |
454 ARM_CAN_BIT_PHASE_SEG1(1U) |
455 ARM_CAN_BIT_PHASE_SEG2(1U) |
456 ARM_CAN_BIT_SJW(1U));
457 // Viene impostato il filtro per ricevere i messaggi con ID esteso 0x12345678 per ricevere l'oggetto
458
459 LPC_CANAF->ENDofTable =0; //Resettiamo la tabella dei filtri: se c'e' un semplice reset sw rimane quella precedente e si aggiungono
460 LPC_CANAF->EFF_GRP_sa=0;
461
462 status = CANdrv->ObjectSetFilter(rx_obj_idx, ARM_CAN_FILTER_ID_EXACT_ADD, ARM_CAN_EXTENDED_ID(indirizzo_CAN_della_scheda), 0U);
463 status = CANdrv->ObjectSetFilter(rx_obj_idx, ARM_CAN_FILTER_ID_EXACT_ADD, ARM_CAN_EXTENDED_ID(indirizzo_generico_CAN), 0U);
464
465
466 status = CANdrv->ObjectConfigure(tx_obj_idx, ARM_CAN_OBJ_TX); // Viene configurata la trasmissione
467 status = CANdrv->ObjectConfigure(rx_obj_idx, ARM_CAN_OBJ_RX); // Viene configurata la ricezione
468 status = CANdrv->SetMode (ARM_CAN_MODE_NORMAL); // Viene attivata la modalit\'a normale
469}
470//! <!-- [fun_CAN_Inizialize] -->
471
void CAN_SignalUnitEvent(uint32_t event)
After that CAN aneded operation eand the interrupt is generated this signal function is called which ...
Definition: Can.c:375
uint8_t tx_data[8]
Transmission data vector.
Definition: Can.c:321
uint32_t volatile evento_CAN
This is the variable which resembles the flags from the communication.
Definition: Can.c:326
unsigned char lettura_indirizzi_CAN(void)
The CAN bus address.
Definition: Can.c:346
uint32_t tx_obj_idx
This is the variable which resembles the flags from the communication.
Definition: Can.c:323
unsigned int indirizzo_CAN_della_scheda
Per ora lo assegnamo cos\i l'indirizzo della scheda.
Definition: Can.c:335
bool messaggio_CAN_arrivato
This variable is set to true as soon as a reception have been concluded.
Definition: Can.c:328
void CAN_SignalObjectEvent(uint32_t obj_idx, uint32_t event)
After that CAN aneded operation eand the interrupt is generated this object function is called which ...
Definition: Can.c:388
volatile uint8_t rx_data[8]
Received data vector.
Definition: Can.c:318
void CAN_Inizialize(void)
The CAN initialization function.
Definition: Can.c:433
int8_t Status_Error_Codes_CAN
Macros.
Definition: Can.c:314
ARM_DRIVER_CAN * CANdrv
Definition: Can.c:333
bool messaggio_CAN_spedito
This variable is set to true as soon as a transmission have been concluded.
Definition: Can.c:329
ARM_DRIVER_CAN Driver_CAN1
Viene inclusa la Periferica CAN1.
#define indirizzo_generico_CAN
snippetlineno Can.h var_indirizzo_generico_CAN
Definition: Can.h:13
const porta_pin_def CAN_indirizzo_hw[]
hw Can address
Definition: Gpio.c:118
void EPROM_lettura_M24C32_64(uint8_t scheda_su_scheda_giu_, uint8_t mainboard_postmainboard, uint8_t canale, short indirizzo_memoria, uint8_t *dati_letti)
Read from preamplifier and on-board flashes.
@ Memory_postmainboard_address_CAN_own_filter
This is the filter of the board.
@ Memory_postmainboard_CAN_from_hw_switch_1_from_EPROM_0
CAN bu from memory or from switches on board