]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/fr.h
Merge branch 'master' of rtime.felk.cvut.cz:pes-rpp/rpp-lib
[pes-rpp/rpp-lib.git] / rpp / include / rpp / fr.h
1 /**
2  * FlexRay Communication RPP API header file.
3  *
4  * @file fr.h
5  *
6  * @copyright Copyright (C) 2013 Czech Technical University in Prague
7  *
8  * @author Carlos Jenkins <carlos@jenkins.co.cr>
9  * @author Michal Horn <hornmich@fel.cvut.cz>
10  */
11
12
13 #ifndef __RPP_FR_H
14 #define __RPP_FR_H
15
16 #include "drv/Fr_GeneralTypes.h"
17 #include "drv/fr_tms570.h"
18
19 typedef enum {
20         RPP_FR_UNKNOWN,
21         RPP_FR_CONFIGURED,
22         RPP_FR_NOT_INITIALIZED,
23         RPP_FR_DRV_INITIALIZED,
24         RPP_FR_CTR_INITIALIZED,
25         RPP_FR_RUNNING,
26         RPP_FR_HALTED,
27         RPP_FR_ABORTED
28 } rpp_fr_state_t;
29
30 /**
31  * Store cluster configuration parameters.
32  *
33  * This function provides a mechanism to do the user FlexRay configuration.
34  * The function parses the string with parameters and stores them into an
35  * internal structure.
36  * For a complete user configuration also rpp_fr_config_node_params and
37  * rpp_fr_config_static_buffer have to be called to configure local
38  * FlexRay parameters and at least one static buffer.
39  *
40  * The string with configuration contains hexadecimal numbers separated by spaces.
41  * Each number stands for one parameter in this order:
42  * gColdStartAttempts
43  * gListenNoise
44  * gMacroPerCycle
45  * gMaxWithoutClockCorrectionFatal
46  * gMaxWithoutClockCorrectionPassive
47  * gNetworkManagementVectorLength
48  * gNumberOfMinislots
49  * gNumberOfStaticSlots
50  * gOffsetCorrectionStart
51  * gPayloadLengthStatic
52  * gSyncNodeMax
53  * gdActionPointOffset
54  * gdCASRxLowMax
55  * gdDynamicSlotIdlePhase
56  * gdMinislot
57  * gdMinislotActionPointOffset
58  * gdNIT
59  * gdSampleClockPeriod
60  * gdStaticSlot
61  * gdTSSTransmitter
62  * gdWakeupSymbolRxIdle
63  * gdWakeupSymbolRxLow
64  * gdWakeupSymbolRxWindow
65  * gdWakeupSymbolTxIdle
66  * gdWakeupSymbolTxLow
67  *
68  * For example:
69  * "0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C"
70  *
71  * @param [in] params Address of the string with configuration parameters
72  *
73  * @return SUCCESS if configuration successful.
74  *         FAILURE if parameter parsing fails.
75  */
76 int8_t rpp_fr_config_cluster_params(const char* params);
77
78 /**
79  * Store node configuration parameters.
80  *
81  * This functions provides a mechanism to do the user FlexRay configuration.
82  * The function parses the string with parameters and stores them into an
83  * internal structure.
84  * For complete user configuration also rpp_fr_config_cluster_params and
85  * rpp_fr_config_static_buffer have to be called to configure global
86  * FlexRay parameters and at least one static buffer.
87  *
88  * The string with configuration contains hexadecimal numbers separated by spaces.
89  * Each number stands for one parameter in this order:
90  * pAllowHaltDueToClock
91  * pAllowPassiveToActive
92  * pChannels (0 - A, 1 - B, 2 - AB)
93  * pClusterDriftDamping
94  * pDelayCompensationA
95  * pDelayCompensationB
96  * pExternOffsetCorrection
97  * pExternRateCorrection
98  * pKeySlotUsedForStartup
99  * pKeySlotUsedForSync
100  * pLatestTx
101  * pMacroInitialOffsetA
102  * pMacroInitialOffsetB
103  * pMicroInitialOffsetA
104  * pMicroInitialOffsetB
105  * pMicroPerCycle
106  * pRateCorrectionOut
107  * pOffsetCorrectionOut
108  * pSamplesPerMicrotick
109  * pSingleSlotEnabled
110  * pWakeupChannel (0 - A, 1 - B)
111  * pWakeupPattern
112  * pdAcceptedStartupRange
113  * pdListenTimeout
114  * pdMaxDrift
115  * pDecodingCorrection
116  * syncFramePayloadMultiplexEnabled
117  * secureBuffers (0 - FR_SB_RECONFIG_ENABLED, 1 - FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED, 2 - FR_SB_ALL_REC_DISABLED, 3 - FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED)
118  *
119  * For example:
120  * "0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0"
121  *
122  * @param [in] params Address of the string with configuration parameters
123  *
124  * @return SUCCESS if configuration successful.
125  *         FAILURE if parameter parsing fails.
126  */
127 int8_t rpp_fr_config_node_params(const char* params);
128
129 /**
130  * Add new static buffer configuration into the list of buffers.
131  *
132  * This functions provides a mechanism to do the user FlexRay configuration.
133  * The function parses the string with parameters and stores them into an
134  * internal structure.
135  * For complete user configuration also rpp_fr_config_cluster_params and
136  * rpp_fr_config_node_params have to be called to configure global and local
137  * FlexRay parameters.
138  * At least one static buffer must be configured as TX. For sync and coldstart nodes
139  * the first buffer should be configured as TX.
140  *
141  * The string with configuration contains hexadecimal numbers or strings separated by spaces.
142  * Each number or string stands for one parameter in this order:
143  * channel (0 - A, 1 - B, 2 - AB)
144  * cycleCounterFiltering
145  * isTx
146  * maxPayload
147  * msgBufferInterrupt
148  * payloadPreambleIndicatorTr
149  * singleTransmit
150  * slotId
151  *
152  * For example:
153  * "0x2 0x0 0x1 0x9 0x1 0x0 0x0 0x1"
154  *
155  * @param [in] params Address of the string with configuration parameters
156  *
157  * @return SUCCESS if configuration successful.
158  *         FAILURE if parameter parsing fails.
159  */
160 int8_t rpp_fr_config_static_buffer(const char* params);
161
162 /**
163  * Add new dynamic buffer configuration into the list of buffers.
164  *
165  * This functions provides a mechanism to do the user FlexRay configuration.
166  * The function parses the string with parameters and stores them into an
167  * internal structure.
168  * For complete user configuration also rpp_fr_config_cluster_params,
169  * rpp_fr_config_node_params and rpp_fr_config_static_buffer have to be called
170  * to configure global, local FlexRay parameters and at least one static buffer.
171  *
172  * The string with configuration contains hexadecimal numbers or strings separated by spaces.
173  * Each number or string stands for one parameter in this order:
174  * channel (0 - A, 1 - B)
175  * cycleCounterFiltering
176  * isTx
177  * maxPayload
178  * msgBufferInterrupt
179  * singleTransmit
180  * slotId
181  *
182  * For example:
183  * "0x0 0x0 0x1 0x9 0x1 0x0 0x1"
184  *
185  * @param [in] params Address of the string with configuration parameters
186  *
187  * @return SUCCESS if configuration successful.
188  *         FAILURE if parameter parsing fails.
189  */
190 int8_t rpp_fr_config_dynamic_buffer(const char* params);
191
192 /**
193  * Configures new RX FIFO buffer configuration into the list of buffers.
194  *
195  * This functions provides a mechanism to do the user FlexRay configuration.
196  * The function parses the string with parameters and stores them into an
197  * internal structure.
198  * For complete user configuration also rpp_fr_config_cluster_params,
199  * rpp_fr_config_node_params and rpp_fr_config_static_buffer have to be called
200  * to configure global, local FlexRay parameters and at least one static buffer.
201  * Only one RX FIFO buffer with specified depth can be configured.
202  *
203  * The string with configuration contains hexadecimal numbers or strings separated by spaces.
204  * Each number or string stands for one parameter in this order:
205  * depth
206  * channel (0 - A, 1 - B, 2 - AB)
207  * cycleCounterFiltering
208  * maxPayload
209  * rejectNullFrames
210  * rejectStaticSegment
211  * slotId (zero means no frame will be rejected)
212  *
213  * For example:
214  * "0x5 0x2 0x0 0x40 0x1 0x0 0x0"
215  *
216  * @param [in] params Address of the string with configuration parameters
217  *
218  * @return SUCCESS if configuration successful.
219  *         FAILURE if parameter parsing fails.
220  */
221 int8_t rpp_fr_config_fifo_buffer(const char* params);
222
223 /* AUTOSAR-like API */
224
225 /**
226  * FlexRay driver initialization.
227  *
228  * This method should be called before any other function from this
229  * module, except rpp_fr_config_* functions.
230  *
231  * The function copies configuration data into drivers internal
232  * structures and initializes the driver.
233  *
234  * There are two ways how to configure FlexRay.
235  * 1) Passing address of the config structure as an argument from the application.
236  * 2) Using rpp_fr_config_* functions to create configuration at run-time. Then the argument
237  * for this function has to be NULL and configuration functions have to be called before
238  * this function.
239  *
240  * After a successful driver initialization, the driver is ready for calling:
241  * - rpp_fr_init_controller()
242  * - rpp_fr_get_poc_status()
243  * - rpp_fr_get_wakeup_rx_status()
244  * - rpp_fr_get_timer_irq_status()
245  *
246  * @param [in] Fr_ConfigPtr Address of the structure with all FlexRay
247  * configuration parameters. If it is NULL, then the default structure,
248  * filled by rpp_fr_config functions, is used.
249  * @param [out] error Address where error flags will be stored. The flags
250  * definitions can be found in fr_tms570h, with ERR_PARAM prefix.
251  *
252  * @return SUCCESS if initialization successful.
253  *         FAILURE if module already initialized.
254  *
255  */
256 int8_t rpp_fr_init_driver(const Fr_ConfigType* config_ptr, uint32_t* error);
257
258 /**
259  * FlexRay controller initialization.
260  *
261  * This method should be called after rpp_fr_init_driver() and before any
262  * other function from this module.
263  *
264  * The functions checks configuration parameters and configures FlexRay
265  * controller registers.
266  *
267  * After successful controller initialization, the FlexRay driver is ready for calling:
268  * - rpp_fr_get_poc_status()
269  * - rpp_fr_get_wakeup_rx_status()
270  * - rpp_fr_get_timer_irq_status()
271  * - rpp_fr_start_communication()
272  * - rpp_fr_send_wup()
273  * - rpp_fr_set_wu_channel()
274  * - rpp_fr_get_global_time()
275  * - rpp_fr_get_network_management_vector()
276  * - rpp_fr_get_channel_status()
277  *
278  * @param [in] ctrl Not used, set always to zero.
279  * @param [out] error Address where error flags will be stored. The flags
280  * definitions can be found in fr_tms570h, with ERR_PARAM and FR_INIT_ERR
281  * prefix.
282  *
283  * @return SUCCESS if initialization if successful.
284  *         FAILURE if module already initialized.
285  *
286  */
287 int8_t rpp_fr_init_controller(uint8_t ctrl, uint32_t* error);
288
289 /**
290  * FlexRay start communication
291  *
292  * This method should be called after rpp_fr_init_controller() and
293  * before any attempt to send or receive messages.
294  *
295  * For coldstarter node the function tries to listen and join an
296  * existing network. If it fails, it tries to initiate the new one.
297  * For regular node it only listens on the bus and tries to join to
298  * some existing network.
299  *
300  * After successful communication start, the FlexRay is ready for:
301  * - rpp_fr_get_poc_status()
302  * - rpp_fr_get_wakeup_rx_status()
303  * - rpp_fr_get_timer_irq_status()
304  * - rpp_fr_set_wu_channel()
305  * - rpp_fr_get_global_time()
306  * - rpp_fr_get_network_management_vector()
307  * - rpp_fr_get_channel_status()
308  * - rpp_fr_all_slots()
309  * - rpp_fr_halt_communication()
310  * - rpp_fr_abort_communication()
311  * - rpp_fr_transmit_lpdu()
312  * - rpp_fr_cancel_transmit_lpdu()
313  * - rpp_fr_receive_lpdu()
314  * - rpp_fr_check_tx_lpdu_status()
315  * - rpp_fr_disable_lpdu()
316  * - rpp_fr_get_clock_correction()
317  * - rpp_fr_get_sync_frame_list()
318  * - rpp_fr_set_timer()
319  * - rpp_fr_cancel_timer()
320  *
321  * @param [in] ctrl Not used, set always to zero.
322  * @param [out] error Address where error flags will be stored. The flags
323  * definitions can be found in fr_tms570h, with FR_STARTUP_ERR prefix.
324  *
325  * @return SUCCESS if initialization successful.
326  *         FAILURE if module already initialized.
327  *
328  */
329 int8_t rpp_fr_start_communication(uint8_t ctrl, uint32_t* error);
330
331 /**
332  * FlexRay allow communication on all slots
333  *
334  * The FlexRay node can be configured to communicate only on key
335  * frames after the startup. If this is the case, after calling this
336  * function, communication on all configured slots is allowed.
337  *
338  * The function should be called only after rpp_fr_start_communication() has been called.
339  *
340  * @param [in] ctrl Not used, set always to zero.
341  *
342  * @return SUCCESS if started successfully.
343  *         FAILURE if timeout reached.
344  *
345  */
346 int8_t rpp_fr_all_slots(uint8_t ctrl);
347
348 /**
349  * FlexRay stop communication after the end of the communication cycle.
350  *
351  * The function should be called only after
352  * rpp_fr_start_communication() has been called.
353  *
354  * After the communication is stopped, only those functions are allowed to be called:
355  * - rpp_fr_set_wu_channel()
356  * - rpp_fr_get_global_time()
357  * - rpp_fr_get_network_management_vector()
358  * - rpp_fr_get_channel_status()
359  * - rpp_fr_get_clock_correction()
360  * - rpp_fr_get_sync_frame_list()
361  * - rpp_fr_get_wakeup_rx_status()
362  * - rpp_fr_get_poc_status()
363  *
364  * To establish new communication, it is necessary to reset the
365  * device.
366  * @param [in] ctrl Not used, set always to zero.
367  *
368  * @return SUCCESS if command passed successfully.
369  *         FAILURE if command rejected.
370  *
371  */
372 int8_t rpp_fr_halt_communication(uint8_t ctrl);
373
374 /**
375  * FlexRay stop communication immediately.
376  *
377  * The function should be called only after
378  * rpp_fr_start_communication() has been called.
379  *
380  * After the communication is stopped, only those functions are allowed to be called:
381  * - rpp_fr_set_wu_channel()
382  * - rpp_fr_get_global_time()
383  * - rpp_fr_get_network_management_vector()
384  * - rpp_fr_get_channel_status()
385  * - rpp_fr_get_clock_correction()
386  * - rpp_fr_get_sync_frame_list()
387  * - rpp_fr_get_wakeup_rx_status()
388  * - rpp_fr_get_poc_status()
389  *
390  * To establish new communication, it is necessary to reset the
391  * device.
392  *
393  * @param [in] ctrl Not used, set always to zero.
394  *
395  * @return SUCCESS if command passed successfully.
396  *         FAILURE if command rejected.
397  *
398  */
399 int8_t rpp_fr_abort_communication(uint8_t ctrl);
400
401 /**
402  * FlexRay send wakeup pattern.
403  *
404  * The function should be called after FlexRay controller is initialized
405  * and before the communication start.
406  *
407  * @param [in] ctrl Not used, set always to zero.
408  *
409  * @return SUCCESS if command passed successfully.
410  *         FAILURE if command rejected.
411  *
412  */
413 int8_t rpp_fr_send_wup(uint8_t ctrl);
414
415 /**
416  * FlexRay set channel for wakeup pattern sending.
417  *
418  * This allows to change the configuration passed to the
419  * rpp_fr_init_driver().
420  *
421  * The function should be called after FlexRay controller is initialized
422  * and before the communication start.
423  *
424  * @param [in] ctrl Not used, set always to zero.
425  *
426  * @return SUCCESS if command passed successfully.
427  *         FAILURE if command rejected.
428  *
429  */
430 int8_t rpp_fr_set_wu_channel(uint8_t ctrl, Fr_ChannelType channel);
431
432 /**
433  * Get FlexRay POC state
434  *
435  * The function can be called any time after the driver is
436  * initialized.
437  *
438  * @param [in] ctrl Not used, set always to zero.
439  * @parap [out] poc_status_ptr Address where status will be stored.
440  *
441  * @return SUCCESS if status retrieved successfully.
442  *         FAILURE if something failed.
443  *
444  */
445 int8_t rpp_fr_get_poc_status(uint8_t ctrl, Fr_POCStatusType* poc_status_ptr);
446
447 /**
448  * Send a message on the bus in the specified frame
449  *
450  * The function can be called any time when communication is running
451  * (rpp_fr_start_communication() was called).
452  *
453  * If the buffer assigned to the frame is configured for continuous
454  * mode, this functions starts sending the message periodically. The
455  * transmission can be stopped by rpp_fr_cancel_transmit_lpdu(). If
456  * the buffer assigned to the frame is configured for single-shot
457  * mode, the message is sent only once.
458  *
459  * @param [in] ctrl Not used, set always to zero.
460  * @param [in] lpdu_idx Index of the frame, where the message will be sent.
461  * @param [in] lsdu Address of the first byte of the message.
462  * @param [in] lsdu_length Number of bytes of the message.
463  *
464  * @return SUCCESS if message was transmitted.
465  *         FAILURE if something failed.
466  *
467  */
468 int8_t rpp_fr_transmit_lpdu(uint8_t ctrl, uint16_t lpdu_idx, const uint8_t* lsdu, uint8_t lsdu_length);
469
470 /**
471  * Cancel a transmission of the message.
472  *
473  * The function can be called any time when communication is running
474  * (rpp_fr_start_communication() was called).
475  *
476  * This is one way to stop transmission for buffers configured for
477  * continuous mode. The other way is to use rpp_fr_disable_lpdu().
478  *
479  * @param [in] ctrl Not used, set always to zero.
480  * @param [in] lpdu_idx Index of the frame, where the message transmission will be stopped.
481  *
482  * @return SUCCESS if the transmission was stopped.
483  *         FAILURE if something failed.
484  *
485  */
486 int8_t rpp_fr_cancel_transmit_lpdu(uint8_t ctrl, uint16_t lpdu_idx);
487
488 /**
489  * Receive a message from the bus from the specified frame.
490  *
491  * The function can be called any time when communication is running
492  * (rpp_fr_start_communication() was called).
493  *
494  * If a new message was received in a buffer configured for the static
495  * or dynamic segment, this function can retrieve it.
496  *
497  * @param [in] ctrl Not used, set always to zero.
498  * @param [in] lpdu_idx Index of the frame where message will be received from.
499  * @param [out] lsdu Address of the first byte of the buffer, where message will be stored.
500  * @param [out] lpdu_status Address where the status will be stored. It can be:
501  * FR_NOT_RECEIVED, FR_RECEIVED, FR_RECEIVED_MORE_DATA_AVAILABLE - for FIFO only.
502  * @param [out] lsdu_length Number of bytes of the message.
503  *
504  * @return SUCCESS if message was received.
505  *         FAILURE if something failed.
506  *
507  */
508 int8_t rpp_fr_receive_lpdu(uint8_t ctrl, uint16_t lpdu_idx, uint8_t* lsdu, Fr_RxLPduStatusType* lpdu_status, uint8_t* lsdu_length);
509
510 /**
511  * Check TX buffer status
512  *
513  * The function can be called any time when communication is running
514  * (rpp_fr_start_communication() was called).
515  *
516  * The status says whther a transmission request (TXR) is pending or
517  * not.
518  *
519  * If the buffer is configured for single-shot mode, the (TXR) is
520  * pending until the message is sent. For buffers configured in
521  * continuous mode, the transmission request is always pending.
522  *
523  *
524  * @param [in] ctrl Not used, set always to zero.
525  * @param [in] lpdu_idx Index of the frame to which the buffer is assigned.
526  * @param [out] lpdu_status Address of the status. It can be FR_TRANSMITTED,
527  * which means the TXR is not pending, or FR_NOT_TRANSMITTED which means that
528  * TXR is pending.
529  *
530  * @return SUCCESS if everything is OK.
531  *         FAILURE if something failed.
532  */
533 int8_t rpp_fr_check_tx_lpdu_status(uint8_t ctrl, uint16_t lpdu_idx, Fr_TxLPduStatusType* lpdu_status);
534
535 /**
536  * Disable a FlexRay buffer
537  *
538  * The function can be called any time when communication is running
539  * (rpp_fr_start_communication() was called).
540  *
541  * This functions resets the configuration of the selected buffer.
542  * The disabled buffer is not usable any more.
543  *
544  * @param [in] ctrl Not used, set always to zero.
545  * @param [in] lpdu_idx Index of the frame to which the buffer is assigned.
546  *
547  * @return SUCCESS if buffer was disabled.
548  *         FAILURE if something failed.
549  *
550  */
551 int8_t rpp_fr_disable_lpdu(uint8_t ctrl, uint16_t lpdu_idx);
552
553 /**
554  * Get FlexRay global time
555  *
556  * The function can be called any time after the controller is initialized.
557  *
558  * @param [in] ctrl Not used, set always to zero.
559  * @param [out] cycle Adress where the number of actual cycle will be stored.
560  * @param [out] macroticks Address where offset in the cycle will be stored.
561  *
562  * @return SUCCESS if everything is OK.
563  *         FAILURE if something failed.
564  *
565  */
566 int8_t rpp_fr_get_global_time(uint8_t ctrl, uint8_t* cycle, uint16_t* macroticks);
567
568 /**
569  * Get Network management vector.
570  *
571  * The function can be called any time after the controller is initialized.
572  *
573  * The FlexRay controller updates the vector at the end of every cycle
574  * by doing bit-wise OR on every network managemet (NM) vectors
575  * received from all nodes.
576  *
577  * The NM vector can be sent in a frame by a buffer with the
578  * payloadPreambleIndicatorTr parameter set. Those frames are
579  * automatically processed by all the receiving controllers. But
580  * sending the vector has to be done manually by copying the NM vector
581  * data (obtainable by this function) into the TX buffer (using the
582  * rpp_fr_transmit_lpdu() function).
583  *
584  * @param [in] ctrl Not used, set always to zero.
585  * @param [out] nm_vector Address where the vector will be stored. The size of the buffer has to be at least gNetworkManagementVectorLength.
586  *
587  * @return SUCCESS if everything is OK.
588  *         FAILURE if something failed.
589  */
590 int8_t rpp_fr_get_network_management_vector(uint8_t ctrl, uint8_t* nm_vector);
591
592 /**
593  * Get Channel status.
594  *
595  * The function can be called any time after the controller is
596  * initialized.
597  *
598  * The output of the function is bitcoded in this way:
599  * - Bit 0: Channel A/B aggregated channel status vSS!ValidFrame
600  * - Bit 1: Channel A/B aggregated channel status vSS!SyntaxError
601  * - Bit 2: Channel A/B aggregated channel status vSS!ContentError
602  * - Bit 3: Channel A/B aggregated channel status additional communication
603  * - Bit 4: Channel A/B aggregated channel status vSS!Bviolation
604  * - Bit 5: Channel A/B aggregated channel status vSS!TxConflict
605  * - Bit 6: Not used (0)
606  * - Bit 7: Not used (0)
607  * - Bit 8: Channel A/B symbol window status data vSS!ValidMTS
608  * - Bit 9: Channel A/B symbol window status data vSS!SyntaxError
609  * - Bit 10: Channel A/B symbol window status data vSS!Bviolation
610  * - Bit 11: Channel A/B symbol window status data vSS!TxConflict
611  * - Bit 12: Channel A/B NIT status data vSS!SyntaxError
612  * - Bit 13: Channel A/B NIT status data vSS!Bviolation
613  * - Bit 14: Not used (0)
614  * - Bit 15: Not used (0)
615  *
616  * @param [in] ctrl Not used, set always to zero.
617  * @param [out] channel_a_status Address where the bitcoded status of the channel A will be stored.
618  * @param [out] channel_b_status Address where the bitcoded status of the channel B will be stored.
619  *
620  * @return SUCCESS if everything is OK.
621  *         FAILURE if something failed.
622  *
623  */
624 int8_t rpp_fr_get_channel_status(uint8_t ctrl, uint16_t* channel_a_status, uint16_t* channel_b_status);
625
626 /**
627  * Get clock correction.
628  *
629  * The function can be called while the communication is running or
630  * was stopped.
631  *
632  * @param [in] ctrl Not used, set always to zero.
633  * @param [out] rate_correction Address where the rate will be stored.
634  * @param [out] offset_correction Address where the offset will be stored.
635  *
636  * @return SUCCESS if everything is OK.
637  *         FAILURE if something failed.
638  *
639  */
640 int8_t rpp_fr_get_clock_correction(uint8_t ctrl, int16_t* rate_correction, int32_t* offset_correction);
641
642 /**
643  * Gets a list of syncframes received or transmitted on channel A and channel B via the even and odd communication cycle.
644  *
645  * The function can be called while communication is running or was stopped.
646  *
647  * @param [in] ctrl Not used, set always to zero.
648  * @param [in] list_size Size of the arrays passed via parameters:
649  * @param [out] channel_a_even_list Address the list of syncframes on channel A within the
650  * even communication cycle is written to. The exact
651  * number of elements written to the list is limited by
652  * parameter Fr_ListSize.
653  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
654  * @param [out] channel_b_even_list Address the list of syncframes on channel B within the
655  * even communication cycle is written to. The exact
656  * number of elements written to the list is limited by
657  * parameter Fr_ListSize.
658  * @param [out] channel_a_odd_list Address the list of syncframes on channel A within the
659  * odd communication cycle is written to. The exact number
660  * of elements written to the list is limited by parameter
661  * Fr_ListSize.
662  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
663  * @param [out] channel_b_odd_list Address the list of syncframes on channel B within the
664  *
665  * @return SUCCESS if everything is OK.
666  *         FAILURE if something failed.
667  *
668  */
669 int8_t rpp_fr_get_sync_frame_list(uint8_t ctrl, uint8_t list_size, uint16_t* channel_a_even_list,
670                                   uint16_t* channel_b_even_list, uint16_t* channel_a_odd_list, uint16_t* channel_b_odd_list);
671
672 /**
673  * Get the status of WUP receiving
674  *
675  * The function can be called any time after controller is initialized.
676  *
677  * If the Wake Up Pattern was received on some channel, the flag is set in status address.
678  * Bit 0: Wakeup received on channel A indicator
679  * Bit 1: Wakeup received on channel B indicator
680  * Bit 2-7: Unused
681  *
682  * @param [in] ctrl Not used, set always to zero.
683  * @param [out] status Address where the status will be stored.
684  *
685  * @return SUCCESS if everything is OK.
686  *         FAILURE if something failed.
687  *
688  */
689 int8_t rpp_fr_get_wakeup_rx_status(uint8_t ctrl, uint8_t* status);
690
691 /**
692  * Set an absolute timer and start it.
693  *
694  * The function can be called any time after communication is running.
695  * The FlexRay controller has two absolute timers. Each of them can be
696  * configured to request the interrupt, when the global time reaches
697  * configured cycle and offset.
698  *
699  * Timer interrupt request can be detected by
700  * rpp_fr_get_timer_irq_status(). The timer interrupt request can be
701  * cleared by rpp_fr_clear_timer_irq(). The timer can be canceled by
702  * rpp_fr_cancel_timer().
703  *
704  * @param [in] ctrl Not used, set always to zero.
705  * @param [in] timer_idx Index of the timer (0,1).
706  * @param [in] cycle_threshold Number of the cycle.
707  * @param [in] offset_threshold Offset in the cycle in mactroticks.
708  *
709  * @return SUCCESS if everything is OK.
710  *         FAILURE if something failed.
711  *
712  */
713 int8_t rpp_fr_set_timer(uint8_t ctrl, uint8_t timer_idx, uint8_t cycle_threshold, uint16_t offset_threshold);
714
715 /**
716  * Stops an absolute timer, clear IRQ.
717  *
718  * The function can be called any time after communication is running.
719  *
720  * The FlexRay controller has two absolute timers. Each of them can be
721  * configured to request the interrupt, when the global time reaches
722  * configured cycle and offset. This function stops the timer and clears
723  * the interrupt request.
724  *
725  * Timer interrupt request can be detected by
726  * rpp_fr_get_timer_irq_status(). Timer interrupt request can be
727  * cleared by rpp_fr_clear_timer_irq() Timer can be started by
728  * rpp_fr_set_timer().
729  *
730  * @param [in] ctrl Not used, set always to zero.
731  * @param [in] timer_idx Index of the timer (0,1).
732  *
733  * @return SUCCESS if everything is OK.
734  *         FAILURE if something failed.
735  *
736  */
737 int8_t rpp_fr_cancel_timer(uint8_t ctrl, uint8_t timer_idx);
738
739 /**
740  * Clear the IRQ flag of the absolute timer
741  *
742  * The function can be called any time after communication is running.
743  *
744  * The FlexRay controller has two absolute timers. Each of them can be
745  * configured to request the interrupt, when the global time reaches
746  * configured cycle and offset. This function clears the IRQ flag.
747  *
748  * Timer interrupt request can be detected by rpp_fr_get_timer_irq_status().
749  * The timer can be started by rpp_fr_set_timer().
750  * The timer can be canceled by rpp_fr_cancel_timer().
751  *
752  * @param [in] ctrl Not used, set always to zero.
753  * @param [in] timer_idx Index of the timer (0,1).
754  *
755  * @return SUCCESS if everything is OK.
756  *         FAILURE if something failed.
757  *
758  */
759 int8_t rpp_fr_clear_timer_irq(uint8_t ctrl, uint8_t timer_idx);
760
761 /**
762  * Get IRQ flag of the absolute timer
763  *
764  * The function can be called any time after communication is running.
765  *
766  * The FlexRay controller has two absolute timers. Each of them can be
767  * configured to request the interrupt, when the global time reaches
768  * configured cycle and offset. Using this function the IRQ can be detected.
769  *
770  * Timer interrupt request can be cleared by rpp_fr_clear_timer_irq().
771  * The timer can be started by rpp_fr_set_timer().
772  * The timer can be canceled by rpp_fr_cancel_timer().
773  *
774  * @param [in] ctrl Not used, set always to zero.
775  * @param [in] timer_idx Index of the timer (0,1).
776  *
777  * @return SUCCESS if everything is OK.
778  *         FAILURE if something failed.
779  *
780  */
781 int8_t rpp_fr_get_timer_irq_status(uint8_t ctrl, uint8_t timer_idx, boolean_t* irq_pending);
782
783 /**
784  * Get information about the driver vendor, module and version.
785  *
786  * The function can be called any time.
787  *
788  * @param [out] version Address, where the information will be stored.
789  *
790  * @return always SUCCESS
791  *
792  */
793 int8_t rpp_fr_get_driver_version(Std_VersionInfoType* version);
794
795 /**
796  * Get configuration parameter value from the internal driver structures.
797  *
798  * The function can be called any time.
799  *
800  * @param [in] ctrl Not used, set always to zero.
801  * @param [in] param_idx The index if the parameter. You can find the indexes in Fr_GeneralTypes.h file with FR_CIDX prefix.
802  * @param [out] param_value Address, where the information will be stored.
803  *
804  * @return SUCCESS if everything is OK.
805  *         FAILURE if something failed.
806  *
807  */
808 int8_t rpp_fr_read_com_ctrl_config(uint8_t ctrl, uint8_t param_idx, uint32_t* param_value);
809
810 #endif /* __RPP_FR_H */