]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/fr.h
Make the RPP layer thread safe
[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, 2015 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 /**
20  * Enumeration of states for the FlexRay
21  */
22 typedef enum {
23         RPP_FR_UNKNOWN, /**< FlexRay is in unknown state, this should not happen */
24         RPP_FR_NOT_INITIALIZED, /**< FlexRay driver was not yet configured and initialized, communication is not running. This is the default state after reset */
25         RPP_FR_DRV_INITIALIZED, /**< FlexRay driver was initialized, communication is not running, Driver is ready for controller initialization */
26         RPP_FR_CTR_INITIALIZED, /**< FlexRay controller was initlized, communicatin is not running, but can be started */
27         RPP_FR_RUNNING, /**< Communication is running */
28         RPP_FR_HALTED,  /**< Communication was halted, controller is ready for reconfiguration and restart of the communication */
29         RPP_FR_ABORTED  /**< Communication was aborted, controller is ready for reconfiguration and restart of the communication */
30 } rpp_fr_state_t;
31
32 #define RPP_FR_MAX_STATIC_BUF_CNT   32  /**< Maximum number of the buffers for static segment of the communication cycle */
33 #define RPP_FR_MAX_DYNAMIC_BUF_CNT  32  /**< Maximum number of the buffers for dynamic segment of the communication cycle */
34 #define RPP_FR_MAX_FIFO_BUF_DEPTH   32  /**< Maximal depth of the RX FIFO buffer */
35
36 /* AUTOSAR-like API */
37
38 /**
39  * FlexRay driver initialization.
40  *
41  * This function is not thread safe. Do not call it from multiple threads.
42  *
43  * This method should be called before any other function from this
44  * module.
45  *
46  * The function copies configuration data into drivers internal
47  * structures and initializes the driver.
48  *
49  * After a successful driver initialization, the driver is ready for calling:
50  * - rpp_fr_init_controller()
51  * - rpp_fr_get_poc_status()
52  * - rpp_fr_get_wakeup_rx_status()
53  * - rpp_fr_get_timer_irq_status()
54  *
55  * @param [in] config_ptr Address of the structure with all FlexRay
56  * configuration parameters.
57  * @param [out] error Address where error flags will be stored. The flags
58  * definitions can be found in fr_tms570.h, with ERR_PARAM prefix.
59  *
60  * @return SUCCESS if initialization successful.
61  *         FAILURE if module already initialized.
62  *
63  */
64 int8_t rpp_fr_init_driver(const Fr_ConfigType *config_ptr, uint32_t *error);
65
66 /**
67  * FlexRay controller initialization.
68  *
69  * The function is thread safe, unless compiled with
70  * -DRPP_THREADSAFE=0.
71  *
72  * This method should be called after rpp_fr_init_driver(), rpp_fr_halt_communication() or
73  * rpp_fr_abort_communication() and before any other function from this module.
74  *
75  * Use this sequence to restart communication after halt or abort functions were called:
76  * - rpp_fr_init_controller()
77  * - rpp_fr_start_communication()
78  * - rpp_fr_all_slots() (optionally)
79  *
80  * The functions checks configuration parameters and configures FlexRay
81  * controller registers.
82  *
83  * After successful controller initialization, the FlexRay driver is ready for calling:
84  * - rpp_fr_get_poc_status()
85  * - rpp_fr_get_wakeup_rx_status()
86  * - rpp_fr_get_timer_irq_status()
87  * - rpp_fr_start_communication()
88  * - rpp_fr_send_wup()
89  * - rpp_fr_set_wu_channel()
90  * - rpp_fr_get_global_time()
91  * - rpp_fr_get_network_management_vector()
92  * - rpp_fr_get_channel_status()
93  * - rpp_fr_reconfigure_lpdu()
94  *
95  * @param [in] ctrl Not used, set always to zero.
96  * @param [out] error Address where error flags will be stored. The flags
97  * definitions can be found in fr_tms570.h, with ERR_PARAM and FR_INIT_ERR
98  * prefix.
99  *
100  * @return SUCCESS if initialization if successful.
101  *         FAILURE if module already initialized.
102  */
103
104 int8_t rpp_fr_init_controller(uint8_t ctrl, uint32_t *error);
105
106 /**
107  * Start communication
108  *
109  * The function is thread safe, unless compiled with
110  * -DRPP_THREADSAFE=0.
111  *
112  * This method should be called after rpp_fr_init_controller() and
113  * before any attempt to send or receive messages.
114  *
115  * For coldstarter node the function listens and tries to join an
116  * existing network. If it fails, it tries to initiate the new one.
117  * For regular node it only listens on the bus and tries to join to
118  * some existing network.
119  *
120  * After successful communication start, the FlexRay is ready for:
121  * - rpp_fr_get_poc_status()
122  * - rpp_fr_get_wakeup_rx_status()
123  * - rpp_fr_get_timer_irq_status()
124  * - rpp_fr_set_wu_channel()
125  * - rpp_fr_get_global_time()
126  * - rpp_fr_get_network_management_vector()
127  * - rpp_fr_get_channel_status()
128  * - rpp_fr_all_slots()
129  * - rpp_fr_halt_communication()
130  * - rpp_fr_abort_communication()
131  * - rpp_fr_transmit_lpdu()
132  * - rpp_fr_cancel_transmit_lpdu()
133  * - rpp_fr_receive_lpdu()
134  * - rpp_fr_check_tx_lpdu_status()
135  * - rpp_fr_disable_lpdu()
136  * - rpp_fr_get_clock_correction()
137  * - rpp_fr_get_sync_frame_list()
138  * - rpp_fr_set_timer()
139  * - rpp_fr_cancel_timer()
140  * - rpp_fr_reconfigure_lpdu()
141  *
142  *
143  * @param [in] ctrl Not used, set always to zero.
144  * @param [out] error Address where error flags will be stored. The flags
145  * definitions can be found in fr_tms570h, with FR_STARTUP_ERR prefix.
146  *
147  * @return SUCCESS if initialization successful.
148  *         FAILURE if module already initialized.
149  *
150  */
151 int8_t rpp_fr_start_communication(uint8_t ctrl, uint32_t *error);
152
153 /**
154  * Allow communication on all slots
155  *
156  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
157  *
158  * The FlexRay node can be configured to communicate only on key
159  * frames after the startup. If this is the case, after calling this
160  * function, communication on all configured slots is allowed.
161  *
162  * The function should be called only after rpp_fr_start_communication() has been called.
163  *
164  * @param [in] ctrl Not used, set always to zero.
165  *
166  * @return SUCCESS if started successfully.
167  *         FAILURE if timeout reached.
168  *
169  */
170 int8_t rpp_fr_all_slots(uint8_t ctrl);
171
172 /**
173  * Stop communication after the end of the communication cycle.
174  *
175  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
176  *
177  * The function should be called only after
178  * rpp_fr_start_communication() has been called.
179  *
180  * After the communication is stopped, only those functions are allowed to be called:
181  * - rpp_fr_set_wu_channel()
182  * - rpp_fr_get_global_time()
183  * - rpp_fr_get_network_management_vector()
184  * - rpp_fr_get_channel_status()
185  * - rpp_fr_get_clock_correction()
186  * - rpp_fr_get_sync_frame_list()
187  * - rpp_fr_get_wakeup_rx_status()
188  * - rpp_fr_get_poc_status()
189  * - rpp_fr_init_controller()
190  *
191  * To restart the communication, the following sequence has to be called:
192  * - rpp_fr_init_controller()
193  * - rpp_fr_start_communication()
194  * - rpp_fr_all_slots() (optionally)
195  *
196  *
197  * @param [in] ctrl Not used, set always to zero.
198  *
199  * @return SUCCESS if command passed successfully.
200  *         FAILURE if command rejected.
201  *
202  */
203 int8_t rpp_fr_halt_communication(uint8_t ctrl);
204
205 /**
206  * Stop communication immediately.
207  *
208  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
209  *
210  * The function should be called only after
211  * rpp_fr_start_communication() has been called.
212  *
213  * After the communication is stopped, only those functions are allowed to be called:
214  * - rpp_fr_set_wu_channel()
215  * - rpp_fr_get_global_time()
216  * - rpp_fr_get_network_management_vector()
217  * - rpp_fr_get_channel_status()
218  * - rpp_fr_get_clock_correction()
219  * - rpp_fr_get_sync_frame_list()
220  * - rpp_fr_get_wakeup_rx_status()
221  * - rpp_fr_get_poc_status()
222  * - rpp_fr_init_controller()
223  *
224  * To restart the communication, the following sequence has to be called:
225  * - rpp_fr_init_controller()
226  * - rpp_fr_start_communication()
227  * - rpp_fr_all_slots() (optionally)
228  *
229  * @param [in] ctrl Not used, set always to zero.
230  *
231  * @return SUCCESS if command passed successfully.
232  *         FAILURE if command rejected.
233  *
234  */
235 int8_t rpp_fr_abort_communication(uint8_t ctrl);
236
237 /**
238  * Send wakeup pattern.
239  *
240  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
241  *
242  * The function should be called after FlexRay controller is initialized
243  * and before the communication start.
244  *
245  * @param [in] ctrl Not used, set always to zero.
246  *
247  * @return SUCCESS if command passed successfully.
248  *         FAILURE if command rejected.
249  *
250  */
251 int8_t rpp_fr_send_wup(uint8_t ctrl);
252
253 /**
254  * Set channel for wakeup pattern sending.
255  *
256  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
257  *
258  * This allows to change the configuration passed to the
259  * rpp_fr_init_driver().
260  *
261  * The function should be called after FlexRay controller is initialized
262  * and before the communication started.
263  *
264  * @param [in] ctrl Not used, set always to zero.
265  * @param [in] channel Channel selector, where wakeup pattern will be sent
266  *
267  * @return SUCCESS if command passed successfully.
268  *         FAILURE if command rejected.
269  *
270  */
271 int8_t rpp_fr_set_wu_channel(uint8_t ctrl, Fr_ChannelType channel);
272
273 /**
274  * Get FlexRay POC state
275  *
276  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
277  *
278  * The function can be called any time after the driver is
279  * initialized.
280  *
281  * @param [in] ctrl Not used, set always to zero.
282  * @param [out] poc_status_ptr Address where status will be stored.
283  *
284  * @return SUCCESS if status retrieved successfully.
285  *         FAILURE if something failed.
286  *
287  */
288 int8_t rpp_fr_get_poc_status(uint8_t ctrl, Fr_POCStatusType *poc_status_ptr);
289
290 /**
291  * Send a message on the bus in the specified frame
292  *
293  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
294  *
295  * The function can be called any time when communication is running
296  * (rpp_fr_start_communication() was called).
297  *
298  * If the buffer assigned to the frame is configured for continuous
299  * mode, this functions starts sending the message periodically. The
300  * transmission can be stopped by rpp_fr_cancel_transmit_lpdu(). If
301  * the buffer assigned to the frame is configured for single-shot
302  * mode, the message is sent only once.
303  *
304  * @param [in] ctrl Not used, set always to zero.
305  * @param [in] lpdu_idx Index of the frame, where the message will be sent.
306  * @param [in] lsdu Address of the first byte of the message.
307  * @param [in] lsdu_length Number of bytes of the message.
308  *
309  * @return SUCCESS if message was transmitted.
310  *         FAILURE if something failed.
311  *
312  */
313 int8_t rpp_fr_transmit_lpdu(uint8_t ctrl, uint16_t lpdu_idx, const uint8_t *lsdu, uint8_t lsdu_length);
314
315 /**
316  * Cancel a transmission of the message.
317  *
318  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
319  *
320  * The function can be called any time when communication is running
321  * (rpp_fr_start_communication() was called).
322  *
323  * This is one way to stop transmission for buffers configured for
324  * continuous mode. The other way is to use rpp_fr_disable_lpdu().
325  *
326  * @param [in] ctrl Not used, set always to zero.
327  * @param [in] lpdu_idx Index of the frame, where the message transmission will be stopped.
328  *
329  * @return SUCCESS if the transmission was stopped.
330  *         FAILURE if something failed.
331  *
332  */
333 int8_t rpp_fr_cancel_transmit_lpdu(uint8_t ctrl, uint16_t lpdu_idx);
334
335 /**
336  * Receive a message from the bus from the specified frame.
337  *
338  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
339  *
340  * The function can be called any time when communication is running
341  * (rpp_fr_start_communication() was called).
342  *
343  * If a new message was received in a buffer configured for the static
344  * and dynamic segment or FIFO, this function can retrieve it.
345  *
346  * The buffers with lower index (specified in configuration) have higher
347  * priority in retrieving process. This means for example if some buffer is
348  * configured to accept messages from slot 2 on channel A and another buffer
349  * accepts from slot 2 on channel B, the message from the first buffer
350  * will be retrieved first. If there is a FIFO buffer configured to accept
351  * messages from slot 2 in different cyclesets then other buffers, those
352  * messages accepted by the FIFO will be retrieved at the end of the process.
353  *
354  * @param [in] ctrl Not used, set always to zero.
355  * @param [in] lpdu_idx Index of the frame where message will be received from.
356  * @param [out] lsdu Address of the first byte of the buffer, where message will be stored.
357  * @param [out] lpdu_status Address where the status will be stored. It can be:
358  * FR_NOT_RECEIVED, FR_RECEIVED, FR_RECEIVED_MORE_DATA_AVAILABLE - for FIFO only.
359  * @param [out] lsdu_length Number of bytes of the message.
360  *
361  * @return SUCCESS if message was received.
362  *         FAILURE if something failed.
363  *
364  */
365 int8_t rpp_fr_receive_lpdu(uint8_t ctrl, uint16_t lpdu_idx, uint8_t *lsdu, Fr_RxLPduStatusType *lpdu_status, uint8_t *lsdu_length);
366
367 /**
368  * Check TX buffer status
369  *
370  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
371  *
372  * The function can be called any time when communication is running
373  * (rpp_fr_start_communication() was called).
374  *
375  * The status says whether a transmission request (TXR) is pending or
376  * not.
377  *
378  * If the buffer is configured for single-shot mode, the (TXR) is
379  * pending until the message is sent. For buffers configured in
380  * continuous mode, the transmission request is always pending.
381  *
382  *
383  * @param [in] ctrl Not used, set always to zero.
384  * @param [in] lpdu_idx Index of the frame to which the buffer is assigned.
385  * @param [out] lpdu_status Address of the status. It can be FR_TRANSMITTED,
386  * which means the TXR is not pending, or FR_NOT_TRANSMITTED which means that
387  * TXR is pending.
388  *
389  * @return SUCCESS if everything is OK.
390  *         FAILURE if something failed.
391  */
392 int8_t rpp_fr_check_tx_lpdu_status(uint8_t ctrl, uint16_t lpdu_idx, Fr_TxLPduStatusType *lpdu_status);
393
394
395 /**
396  * Reconfigure buffer
397  *
398  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
399  *
400  * The function can be called any time when after controller was initialized
401  * (rpp_fr_init_controller() was called).
402  *
403  * If the node is configured to allow buffer reconfiguration, some of the buffers
404  * can be reconfigured in runtime. Buffers used for synchronization and buffers
405  * assigned to the RX FIFO can not be reconfigured.
406  *
407  * It is not possible to change the direction (TX/RX) of the buffer or to change
408  * the mode (single-shot/continuous).
409  *
410  * Messages that were planned to be sent or received might not be transmitted or received
411  * if reconfiguration occurs in bad time.
412  *
413  * @param [in] ctrl Not used, set always to zero.
414  * @param [in] lpdu_idx Index of the frame, where reconfigured buffer is communicating.
415  * @param [in] frame_id Frame ID, where the buffer will be communicating after the reconfiguration.
416  * @param [in] channel Channel, where the buffer will be communicating. For dynamic segment it should not be AB.
417  * @param [in] cycle_set Cycle set value for cycle filtering. Can be 1, 2, 4, 8, 16, 32, 64.
418  * @param [in] cycle_offset Cycle offset value for cycle filtering. Must be 0 - cycle_set-1
419  * @param [in] payload Maximum payload for the reconfigured buffer in bytes. Must not be higher than the original payload, defined in half-words.
420  * @param [in] header_crc Not used, set to zero. The CRC is calculated automaticaly inside the function.
421  *
422  * @return SUCCESS if everything is OK.
423  *         FAILURE if something failed.
424  */
425 int8_t rpp_fr_reconfigure_lpdu(uint8_t ctrl, uint16_t lpdu_idx, uint16_t frame_id, Fr_ChannelType channel, uint8_t cycle_set, uint8_t cycle_offset, uint8_t payload, uint16_t header_crc);
426
427 /**
428  * Disable a FlexRay buffer
429  *
430  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
431  *
432  * The function can be called any time when communication is running
433  * (rpp_fr_start_communication() was called).
434  *
435  * This functions resets the configuration of the selected buffer.
436  * The disabled buffer is not accessible or reconfigurable any more.
437  *
438  * @param [in] ctrl Not used, set always to zero.
439  * @param [in] lpdu_idx Index of the frame to which the buffer is assigned.
440  *
441  * @return SUCCESS if buffer was disabled.
442  *         FAILURE if something failed.
443  *
444  */
445 int8_t rpp_fr_disable_lpdu(uint8_t ctrl, uint16_t lpdu_idx);
446
447 /**
448  * Get FlexRay global time
449  *
450  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
451  *
452  * The function can be called any time after the controller is initialized.
453  *
454  * @param [in] ctrl Not used, set always to zero.
455  * @param [out] cycle Adress where the number of actual cycle will be stored.
456  * @param [out] macroticks Address where offset in the cycle will be stored.
457  *
458  * @return SUCCESS if everything is OK.
459  *         FAILURE if something failed.
460  *
461  */
462 int8_t rpp_fr_get_global_time(uint8_t ctrl, uint8_t *cycle, uint16_t *macroticks);
463
464 /**
465  * Get Network management vector.
466  *
467  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
468  *
469  * The function can be called any time after the controller is initialized.
470  *
471  * The FlexRay controller updates the vector at the end of every cycle
472  * by doing bit-wise OR on every network management (NM) vectors
473  * received from all nodes.
474  *
475  * The NM vector can be sent in a frame by a buffer with the
476  * payloadPreambleIndicatorTr parameter set. Those frames are
477  * automatically processed by all the receiving controllers. But
478  * sending the vector has to be done manually by copying the NM vector
479  * data into the TX buffer (using the rpp_fr_transmit_lpdu() function).
480  *
481  * @param [in] ctrl Not used, set always to zero.
482  * @param [out] nm_vector Address where the vector will be stored. The size of the buffer has to be at least gNetworkManagementVectorLength.
483  *
484  * @return SUCCESS if everything is OK.
485  *         FAILURE if something failed.
486  */
487 int8_t rpp_fr_get_network_management_vector(uint8_t ctrl, uint8_t *nm_vector);
488
489 /**
490  * Get channel status.
491  *
492  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
493  *
494  * The function can be called any time after the controller is
495  * initialized.
496  *
497  * The output of the function is bitcoded in this way:
498  * - Bit 0: Channel A/B aggregated channel status vSS!ValidFrame
499  * - Bit 1: Channel A/B aggregated channel status vSS!SyntaxError
500  * - Bit 2: Channel A/B aggregated channel status vSS!ContentError
501  * - Bit 3: Channel A/B aggregated channel status additional communication
502  * - Bit 4: Channel A/B aggregated channel status vSS!Bviolation
503  * - Bit 5: Channel A/B aggregated channel status vSS!TxConflict
504  * - Bit 6: Not used (0)
505  * - Bit 7: Not used (0)
506  * - Bit 8: Channel A/B symbol window status data vSS!ValidMTS
507  * - Bit 9: Channel A/B symbol window status data vSS!SyntaxError
508  * - Bit 10: Channel A/B symbol window status data vSS!Bviolation
509  * - Bit 11: Channel A/B symbol window status data vSS!TxConflict
510  * - Bit 12: Channel A/B NIT status data vSS!SyntaxError
511  * - Bit 13: Channel A/B NIT status data vSS!Bviolation
512  * - Bit 14: Not used (0)
513  * - Bit 15: Not used (0)
514  *
515  * @param [in] ctrl Not used, set always to zero.
516  * @param [out] channel_a_status Address where the bitcoded status of the channel A will be stored.
517  * @param [out] channel_b_status Address where the bitcoded status of the channel B will be stored.
518  *
519  * @return SUCCESS if everything is OK.
520  *         FAILURE if something failed.
521  *
522  */
523 int8_t rpp_fr_get_channel_status(uint8_t ctrl, uint16_t *channel_a_status, uint16_t *channel_b_status);
524
525 /**
526  * Get clock correction.
527  *
528  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
529  *
530  * The function can be called while the communication is running or
531  * was stopped.
532  *
533  * @param [in] ctrl Not used, set always to zero.
534  * @param [out] rate_correction Address where the rate will be stored.
535  * @param [out] offset_correction Address where the offset will be stored.
536  *
537  * @return SUCCESS if everything is OK.
538  *         FAILURE if something failed.
539  *
540  */
541 int8_t rpp_fr_get_clock_correction(uint8_t ctrl, int16_t *rate_correction, int32_t *offset_correction);
542
543 /**
544  * Gets a list of syncframes received or transmitted on channel A and channel B via the even and odd communication cycle.
545  *
546  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
547  *
548  * The function can be called while communication is running or was stopped.
549  *
550  * @param [in] ctrl Not used, set always to zero.
551  * @param [in] list_size Size of the arrays passed via parameters:
552  * @param [out] channel_a_even_list Address the list of syncframes on channel A within the
553  * even communication cycle is written to. The exact
554  * number of elements written to the list is limited by
555  * parameter Fr_ListSize.
556  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
557  * @param [out] channel_b_even_list Address the list of syncframes on channel B within the
558  * even communication cycle is written to. The exact
559  * number of elements written to the list is limited by
560  * parameter Fr_ListSize.
561  * @param [out] channel_a_odd_list Address the list of syncframes on channel A within the
562  * odd communication cycle is written to. The exact number
563  * of elements written to the list is limited by parameter
564  * Fr_ListSize.
565  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
566  * @param [out] channel_b_odd_list Address the list of syncframes on channel B within the
567  *
568  * @return SUCCESS if everything is OK.
569  *         FAILURE if something failed.
570  *
571  */
572 int8_t rpp_fr_get_sync_frame_list(uint8_t ctrl, uint8_t list_size, uint16_t *channel_a_even_list,
573                                                                   uint16_t *channel_b_even_list, uint16_t *channel_a_odd_list, uint16_t *channel_b_odd_list);
574
575 /**
576  * Get the status of WUP receiving
577  *
578  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
579  *
580  * The function can be called any time after controller is initialized.
581  *
582  * If the Wake Up Pattern was received on some channel, the flag is set in status address.
583  * Bit 0: Wakeup received on channel A indicator
584  * Bit 1: Wakeup received on channel B indicator
585  * Bit 2-7: Unused
586  *
587  * @param [in] ctrl Not used, set always to zero.
588  * @param [out] status Address where the status will be stored.
589  *
590  * @return SUCCESS if everything is OK.
591  *         FAILURE if something failed.
592  *
593  */
594 int8_t rpp_fr_get_wakeup_rx_status(uint8_t ctrl, uint8_t *status);
595
596 /**
597  * Set the absolute timer and start it.
598  *
599  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
600  *
601  * The function can be called any time after communication is running.
602  *
603  * The FlexRay controller has two absolute timers. Each of them can be
604  * configured to request the interrupt, when the global time reaches
605  * configured cycle set and offset.
606  *
607  * Timer interrupt request can be detected by
608  * rpp_fr_get_timer_irq_status(). The timer interrupt request can be
609  * cleared by rpp_fr_clear_timer_irq(). The timer can be canceled by
610  * rpp_fr_cancel_timer().
611  *
612  * @param [in] ctrl Not used, set always to zero.
613  * @param [in] timer_idx Index of the timer (0,1).
614  * @param [in] cycle_set Determines the set of cycles that trigger the interrupt (see Table 23-6 in TMS570 datasheet (SPNU499))
615  * @param [in] offset_threshold Offset in the cycle in mactroticks.
616  *
617  * @return SUCCESS if everything is OK.
618  *         FAILURE if something failed.
619  *
620  */
621 int8_t rpp_fr_set_timer(uint8_t ctrl, uint8_t timer_idx, uint8_t cycle_set, uint16_t offset_threshold);
622
623 /**
624  * Stop the absolute timer, clear IRQ.
625  *
626  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
627  *
628  * The function can be called any time after communication is running.
629  *
630  * The FlexRay controller has two absolute timers. Each of them can be
631  * configured to request the interrupt, when the global time reaches
632  * configured cycle and offset. This function stops the timer and clears
633  * the interrupt request.
634  *
635  * Timer interrupt request can be detected by
636  * rpp_fr_get_timer_irq_status(). Timer interrupt request can be
637  * cleared by rpp_fr_clear_timer_irq() Timer can be started by
638  * rpp_fr_set_timer().
639  *
640  * @param [in] ctrl Not used, set always to zero.
641  * @param [in] timer_idx Index of the timer (0,1).
642  *
643  * @return SUCCESS if everything is OK.
644  *         FAILURE if something failed.
645  *
646  */
647 int8_t rpp_fr_cancel_timer(uint8_t ctrl, uint8_t timer_idx);
648
649 /**
650  * Clear the IRQ flag of the absolute timer
651  *
652  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
653  *
654  * The function can be called any time after communication is running.
655  *
656  * The FlexRay controller has two absolute timers. Each of them can be
657  * configured to request the interrupt, when the global time reaches
658  * configured cycle and offset. This function clears the IRQ flag.
659  *
660  * Timer interrupt request can be detected by rpp_fr_get_timer_irq_status().
661  * The timer can be started by rpp_fr_set_timer().
662  * The timer can be canceled by rpp_fr_cancel_timer().
663  *
664  * @param [in] ctrl Not used, set always to zero.
665  * @param [in] timer_idx Index of the timer (0,1).
666  *
667  * @return SUCCESS if everything is OK.
668  *         FAILURE if something failed.
669  *
670  */
671 int8_t rpp_fr_clear_timer_irq(uint8_t ctrl, uint8_t timer_idx);
672
673 /**
674  * Get IRQ flag of the absolute timer
675  *
676  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
677  *
678  * The function can be called any time after communication is running.
679  *
680  * The FlexRay controller has two absolute timers. Each of them can be
681  * configured to request the interrupt, when the global time reaches
682  * configured cycle and offset. Using this function the IRQ can be detected.
683  *
684  * Timer interrupt request can be cleared by rpp_fr_clear_timer_irq().
685  * The timer can be started by rpp_fr_set_timer().
686  * The timer can be canceled by rpp_fr_cancel_timer().
687  *
688  * @param [in] ctrl Not used, set always to zero.
689  * @param [in] timer_idx Index of the timer (0,1).
690  * @param [out] irq_pending Address, where status of the IRQ flag will be stored.
691  *
692  * @return SUCCESS if everything is OK.
693  *         FAILURE if something failed.
694  *
695  */
696 int8_t rpp_fr_get_timer_irq_status(uint8_t ctrl, uint8_t timer_idx, boolean_t *irq_pending);
697
698 /**
699  * Get information about the driver vendor, module and version.
700  *
701  * The function is thread safe
702  *
703  * The function can be called any time.
704  *
705  * @param [out] version Address, where the information will be stored.
706  *
707  * @return always SUCCESS
708  *
709  */
710 int8_t rpp_fr_get_driver_version(Std_VersionInfoType *version);
711
712 /**
713  * Get configuration parameter value from the internal driver structures.
714  *
715  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
716  *
717  * The function can be called any time.
718  *
719  * @param [in] ctrl Not used, set always to zero.
720  * @param [in] param_idx The index if the parameter. You can find the indexes in Fr_GeneralTypes.h file with FR_CIDX prefix.
721  * @param [out] param_value Address, where the information will be stored.
722  *
723  * @return SUCCESS if everything is OK.
724  *         FAILURE if something failed.
725  *
726  */
727 int8_t rpp_fr_read_com_ctrl_config(uint8_t ctrl, uint8_t param_idx, uint32_t *param_value);
728
729 #endif /* __RPP_FR_H */