]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/drv/fr_tms570.h
Code cleanup
[pes-rpp/rpp-lib.git] / rpp / include / drv / fr_tms570.h
1 /*
2  * fr.h
3  *
4  *  Created on: 8.7.2013
5  *      Author: michal
6  */
7
8 #ifndef FR_H_
9 #define FR_H_
10
11 #include "drv/Std_Types.h"
12 #include "drv/Fr_GeneralTypes.h"
13
14 /* Protocol constants */
15 #define cCASActionPointOffset 1         /**< Initialization value of the CAS action point offset timer. Units MT */
16 #define cChannelIdleDelimiter 11        /**< Duration of the channel idle delimiter. Units gdBit */
17 #define cClockDeviationMax 0.0015       /**< Maximum clock frequency deviation, equivalent to 1500ppm (1500ppm = 1500/1000000 = 0.0015). */
18 #define cCrcInitA 0xFEDCBA                      /**< Initialization vector for the calculation of the frame CRC on channel A (hexadecimal). */
19 #define cCrcInitB 0xABCDEF                      /**< Initialization vector for the calculation of the frame CRC on channel B (hexadecimal). */
20 #define cCrcPolynomial 0x5D6DCB         /**< Frame CRC polynomial (hexadecimal).*/
21 #define cCrcSize 24                                     /**< Size of the frame CRC calculation register. Units bits. */
22 #define cCycleCountMax 63                       /**< Maximum cycle counter value in a cluster. */
23 #define cdBSS 2                                         /**< Duration of the Byte Start Sequence. Units gdBit.*/
24 #define cdCAS 30                                        /**< Duration of the logical low portion of the collision avoidance symbol (CAS) and media access test symbol (MTS). Units gdBit. */
25 #define cdCASRxLowMin 29                        /**< Lower limit of the CAS acceptance window.  Units gdBit.*/
26 #define cdCycleMax 16000                        /**< Maximum cycle length. Units us. */
27 #define cdFES 2                                         /**< Duration of the Frame End Sequence. Units gdBit. */
28 #define cdFSS 1                                         /**< Duration of the Frame Start Sequence. Units gdBit. */
29 #define cdMaxMTNom 6                            /**< Maximum duration of a nominal macrotick. Each implementation must be able to support macroticks of at least this length. Different implementations may support higher values. Units us. */
30 #define cdMinMTNom 1                            /**< Minimum duration of a nominal macrotick. Each implementation must be able to support macroticks of at least this length. Different implementations may support lower values. Units us. */
31 #define cdWakeupMaxCollision 5          /**< Number of continuous bit times at LOW during the idle phase of a WUS that will cause a sending node to detect a wakeup collision. Units gdBit. */
32 #define cdWakeupSymbolTxLow 6           /**< Duration of low phase of a transmitted wakeup symbol.  Units us.*/
33 #define cdWakeupSymbolTxIdle 18         /**< Duration of the idle phase between two low phases inside a wakeup pattern.  Units 18.*/
34 #define cHCrcInit 0x01A                         /**< Initialization vector for the calculation of the header CRC on channel A or channel B (hexadecimal). */
35 #define cHCrcPolynomial 0x385           /**< Header CRC polynomial (hexadecimal). */
36 #define cHCrcSize 11                            /**< Size of header CRC calculation register.  Units bit.*/
37 #define cPayloadLengthMax 127           /**< Maximum length of the payload segment of a frame.  Units two-byte-words.*/
38 #define cMicroPerMacroMin 20            /**< Minimum number of microticks per macrotick during the offset correction phase.  Units uT.*/
39 #define cMicroPerMacroNomMin 40         /**< Minimum number of microticks in a nominal (uncorrected) macrotick. Units uT. */
40 #define cMicroPerMacroNomMax 240        /**< Maximum number of microticks in a nominal (uncorrected) macrotick. Units uT. */
41 #define cSamplesPerBit 8                        /**< Number of samples taken in the determination of a bit value. */
42 #define cSlotIDMax 2047                         /**< Highest slot ID number. */
43 #define cStaticSlotIDMax 1023           /**< Highest static slot ID number. */
44 #define cStrobeOffset 5                         /**< Sample where bit strobing is performed (first sample of a bit is considered as sample 1). */
45 #define cSyncNodeMax 15                         /**< Maximum number of sync nodes in a cluster. */
46 #define cVotingSamples 5                        /**< Numbers of samples in the voting window used for majority voting of the RxD input. */
47 #define cVotingDelay (cVotingSamples-1)/2       /**< Number of samples of delay between the RxD input and the majority voted output in the glitch-free case. */
48
49 #define FR_MAX_SYNC_FRAME_LIST_SIZE     15
50
51 /* Flags for indicating error during parameters check */
52 #define ERR_PARAM_NO_ERROR                                              0
53
54 /* Global parameters errors */
55 #define ERR_PARAM_gColdStartAttempts                    (1 << 1)
56 #define ERR_PARAM_gdActionPointOffset                   (1 << 2)
57 #define ERR_PARAM_gdCASRxLowMax                                 (1 << 3)
58 #define ERR_PARAM_gdDynamicSlotIdlePhase                (1 << 4)
59 #define ERR_PARAM_gdMinislot                                    (1 << 5)
60 #define ERR_PARAM_gdMinislotActionPointOffset   (1 << 6)
61 #define ERR_PARAM_gdStaticSlot                                  (1 << 7)
62 #define ERR_PARAM_gdTSSTransmitter                              (1 << 8)
63 #define ERR_PARAM_gdWakeupSymbolRxIdle                  (1 << 9)
64 #define ERR_PARAM_gdWakeupSymbolRxLow                   (1 << 10)
65 #define ERR_PARAM_gdWakeupSymbolRxWindow                (1 << 11)
66 #define ERR_PARAM_gdWakeupSymbolTxIdle                  (1 << 12)
67 #define ERR_PARAM_gdWakeupSymbolTxLow                   (1 << 13)
68 #define ERR_PARAM_gListenNoise                                  (1 << 14)
69 #define ERR_PARAM_gMacroPerCycle                                (1 << 15)
70 #define ERR_PARAM_gMaxWithoutClockCorrectionFatal (1 << 16)
71 #define ERR_PARAM_gMaxWithoutClockCorrectionPassive     (1 << 17)
72 #define ERR_PARAM_gNumberOfMinislots                    (1 << 18)
73 #define ERR_PARAM_gNumberOfStaticSlots                  (1 << 19)
74 #define ERR_PARAM_gOffsetCorrectionStart                (1 << 20)
75 #define ERR_PARAM_gPayloadLengthStatic                  (1 << 21)
76 #define ERR_PARAM_gSyncNodeMax                                  (1 << 22)
77 #define ERR_PARAM_gdNIT                                                 (1 << 23)
78 #define ERR_PARAM_gdSampleClockPeriod                   (1 << 24)
79 #define ERR_PARAM_gNetworkManagementVectorLength (1 << 25)
80
81 /* Local parameters errors */
82 #define ERR_PARAM_pAllowHaltDueToClock                  (1 << 1)
83 #define ERR_PARAM_pAllowPassiveToActive                 (1 << 2)
84 #define ERR_PARAM_pChannels                                             (1 << 3)
85 #define ERR_PARAM_pdAcceptedStartupRange                (1 << 4)
86 #define ERR_PARAM_pClusterDriftDamping                  (1 << 5)
87 #define ERR_PARAM_pDelayCompensationA                   (1 << 6)
88 #define ERR_PARAM_pDelayCompensationB                   (1 << 7)
89 #define ERR_PARAM_pdListenTimeout                               (1 << 8)
90 #define ERR_PARAM_pdMaxDrift                                    (1 << 9)
91 #define ERR_PARAM_pExternOffsetCorrection               (1 << 10)
92 #define ERR_PARAM_pExternRateCorrection                 (1 << 11)
93 #define ERR_PARAM_pKeySlotUsedForStartup                (1 << 12)
94 #define ERR_PARAM_pKeySlotUsedForSync                   (1 << 13)
95 #define ERR_PARAM_pLatestTx                                             (1 << 14)
96 #define ERR_PARAM_pMacroInitialOffsetA                  (1 << 15)
97 #define ERR_PARAM_pMacroInitialOffsetB                  (1 << 16)
98 #define ERR_PARAM_pMicroInitialOffsetA                  (1 << 17)
99 #define ERR_PARAM_pMicroInitialOffsetB                  (1 << 18)
100 #define ERR_PARAM_pMicroPerCycle                                (1 << 19)
101 #define ERR_PARAM_pRateCorrectionOut                    (1 << 20)
102 #define ERR_PARAM_pSingleSlotEnabled                    (1 << 21)
103 #define ERR_PARAM_pWakeupChannel                                (1 << 22)
104 #define ERR_PARAM_pWakeupPattern                                (1 << 23)
105 #define ERR_PARAM_pSamplesPerMicrotick                  (1 << 24)
106 #define ERR_PARAM_pDecodingCorrection                   (1 << 25)
107 #define ERR_PARAM_pOffsetCorrectionOut                  (1 << 26)
108
109 /* Message RAM parameters errors */
110 #define ERR_PARAM_statSegmentBufferCount                (1 << 0)
111 #define ERR_PARAM_dynSegmentBufferCount                 (1 << 1)
112 #define ERR_PARAM_fifoBufferCount                               (1 << 2)
113 #define ERR_PARAM_maxBuffLimit                                  (1 << 3)
114
115 /* Buffer configuration parameters errors */
116 #define ERR_PARAM_BUFFIFO_PAYLOAD_HIGH                  (1 << 0)
117 #define ERR_PARAM_BUFFIFO_NOT_RX                                (1 << 1)
118 #define ERR_PARAM_BUFFIFO_PAYLOAD_DIFFERS               (1 << 2)
119 #define ERR_PARAM_BUFFIFO_CHANNEL_DIFFERS               (1 << 3)
120 #define ERR_PARAM_BUFFIFO_CCFILTER_DIFFERS              (1 << 4)
121 #define ERR_PARAM_BUFDYN_FRAMEID_INVALID                (1 << 5)
122 #define ERR_PARAM_BUFDYN_PAYLOAD_HIGH                   (1 << 6)
123 #define ERR_PARAM_BUFSTAT_FRAMEID_INVALID               (1 << 7)
124 #define ERR_PARAM_BUFSTAT_PAYLOAD_HIGH                  (1 << 8)
125 #define ERR_PARAM_BUF_TOTAL_PAYLOAD_HIGH                (1 << 9)
126 #define ERR_PARAM_BUFDYN_CHANNELS                               (1 << 10)
127
128 /* Error codes for controller initialization */
129 #define FR_INIT_ERR_BAD_PARAM                                   (1 << 26)
130 #define FR_INIT_ERR_CLUSTER_CONFIG                              (1 << 27)
131 #define FR_INIT_ERR_NODE_CONFIG                                 (1 << 28)
132 #define FR_INIT_ERR_MSGRAM_CONFIG                               (1 << 29)
133 #define FR_INIT_ERR_BUFFPARAM_CONFIG                    (1 << 30)
134 #define FR_INIT_ERR_BUFF_CONFIG                                 (1 << 31)
135
136 /* Error flags for startup failures */
137 #define FR_STARTUP_ERR_SW_STUP_FOLLOW                   (1 << 26)
138 #define FR_STARTUP_ERR_CSINH_DIS                                (1 << 27)
139 #define FR_STARTUP_ERR_SW_STUP_READY                    (1 << 28)
140 #define FR_STARTUP_ERR_SW_STUP_AS_NCOLD                 (1 << 29)
141
142 /* TMS570 FlexRay related constants */
143 #define FR_MAX_BUFFERS_CNT      128
144 #define FR_FCS_LISTEN_TIMEOUT 10000000U
145
146 /* Macros with constants for FlexRay POC status, read from CCEV register */
147 #define FR_POCS_DEFAULT_CONFIG 0x0
148 #define FR_POCS_READY 0x1
149 #define FR_POCS_NORMAL_ACTIVE 0x2
150 #define FR_POCS_NORMAL_PASSIVE 0x3
151 #define FR_POCS_HALT 0x4
152 #define FR_POCS_MONITOR_MODE 0x5
153 #define FR_POCS_LOOPBACK 0xD
154 #define FR_POCS_CONFIG 0xF
155 #define FR_POCS_WAKEUP_STANDBY 0x10
156 #define FR_POCS_WAKEUP_LISTEN 0x11
157 #define FR_POCS_WAKEUP_SEND 0x12
158 #define FR_POCS_WAKEUP_DETECT 0x13
159 #define FR_POCS_STARTUP_PREPARE 0x20
160 #define FR_POCS_COLDSTART_LISTEN 0x21
161 #define FR_POCS_COLDSTART_COLLISION_RESOLUTION 0x22
162 #define FR_POCS_COLDSTART_CONSISTENCY_CHECK 0x23
163 #define FR_POCS_COLDSTART_GAP 0x24
164 #define FR_POCS_COLDSTART_JOIN 0x25
165 #define FR_POCS_INTEGRATION_COLDSTART_CHECK 0x26
166 #define FR_POCS_INTEGRATION_LISTEN 0x27
167 #define FR_POCS_INTEGRATION_CONSISTENCY_CHECK 0x28
168 #define FR_POCS_INITIALIZE_SCHEDULE 0x29
169 #define FR_POCS_ABORT_STARTUP 0x2A
170
171 /* Macros with constants for Wakeup status read from CCEV register */
172 #define FR_WSV_UNDEFINED 0x0
173 #define FR_WSV_RECEIVED_HEADER 0x1
174 #define FR_WSV_RECEIVED_WUP 0x2
175 #define FR_WSV_COLLISION_HEADER 0x3
176 #define FR_WSV_COLLISION_WUP 0x4
177 #define FR_WSV_COLLISION_UNKNOWN 0x5
178 #define FR_WSV_TRANSMITTED 0x6
179
180 /* Macros with constants for SPI communication with the bus controller */
181 #define FRAY_SPICMD_INIT_VAL    0xFFFF
182 #define FRAY_NUM_PORTS          2
183
184 /* Macros with flags for buffers configuration */
185 #define FRAY_BUF_MBI_EN                 0x01
186 #define FRAY_BUF_MBI_DIS                0x00
187 #define FRAY_BUF_TX_MODE_CONTINUOUS     0x02
188 #define FRAY_BUF_TX_MODE_SINGLE         0x00
189 #define FRAY_BUF_NM_EN                  0x04
190 #define FRAY_BUF_NM_DIS                 0x00
191 #define FRAY_BUF_TX                     0x08
192 #define FRAY_BUF_RX                     0x00
193 #define FRAY_BUF_CHB_EN                 0x10
194 #define FRAY_BUF_CHB_DIS                0x00
195 #define FRAY_BUF_CHA_EN                 0x20
196 #define FRAY_BUF_CHA_DIS                0x00
197 #define FRAY_BUF_SFI_EN                 0x40
198 #define FRAY_BUF_SFI_DIS                0x00
199 #define FRAY_BUF_SYNC_EN                0x80
200 #define FRAY_BUF_SYNC_DIS               0x00
201 #define FRAY_BUF_REJECT_NULL_FRAMES             0x100
202 #define FRAY_BUF_ACCEPT_NULL_FRAMES             0x000
203 #define FRAY_BUF_REJECT_STATIC_SEGMENT  0x200
204 #define FRAY_BUF_ACCEPT_STATIC_SEGMENT  0x000
205 #define FRAY_BUF_TXREQ_EN                               0x800
206 #define FRAY_BUF_TXREQ_DIS                              0x000
207
208 #define FR_CLUSTER_PARAMS_CNT   25
209 #define FR_NODE_PARAMS_CNT              26
210 #define FR_MSGRAM_PARAMS_CNT    5
211 #define FR_STATIC_BUF_PARAMS_CNT 8
212 #define FR_DYNAMIC_BUF_PARAMS_CNT 7
213 #define FR_FIFO_BUF_PARAMS_CNT 6
214 /**
215  * This structure represents global FlexRay cluster parameters.
216  * Values of all those parameters have to be equal for all nodes in cluster.
217  */
218 typedef struct Fr_TMS570LS_ClusterConfigType_st {
219         /* Protocol relevant parameters */
220         uint8_t gColdStartAttempts;                                             /**< Maximum number of times a node in the cluster is permitted to attempt to start the cluster by initiating schedule synchronization. Range 2-31. */
221         uint8_t gdActionPointOffset;                                    /**< Number of macroticks the action point is offset from the beginning of a static slot or symbol window. Range 1-63 MT. */
222         uint8_t gdCASRxLowMax;                                                  /**< Upper limit of the CAS acceptance window. Range 67-99 MT. */
223         uint8_t gdDynamicSlotIdlePhase;                                 /**< Duration of the idle phase within a dynamic slot. Range 0-2 Minislots. */
224         uint8_t gdMinislot;                                                             /**< Duration of a minislot. Range 2-63 MT */
225         uint8_t gdMinislotActionPointOffset;                    /**< Number of macroticks the minislot action point is offset from the beginning of a minislot. Range 1-31 MT. */
226         uint16_t gdStaticSlot;                                                  /**< Duration of a static slot. Range 4-661 MT. */
227         uint8_t gdTSSTransmitter;                                               /**< Number of bits in the Transmission Start Sequence. Range 3-15 gdBit. */
228         uint8_t gdWakeupSymbolRxIdle;                                   /**< Number of bits used by the node to test the duration of the 'idle' portion of a received wakeup symbol. Duration is equal to (gdWakeupSymbolTxIdle - gdWakeupSymbolTxLow)/2 minus a safe part. (Collisions, clock differences, and other effects can deform the Tx-wakeup pattern.)  14-59 gdBit.*/
229         uint8_t gdWakeupSymbolRxLow;                                    /**< Number of bits used by the node to test the LOW portion of a received wakeup symbol. This lower limit of zero bits has to be received to detect the LOW portion by the receiver. The duration is equal to gdWakeupSymbolTxLow minus a safe part. (Active stars, clock differences, and other effects can deform the Tx-wakeup pattern.). Range 11-59. */
230         uint16_t gdWakeupSymbolRxWindow;                                /**< The size of the window used to detect wakeups. Detection of a wakeup requires a low and idle period (from one WUS) and a low period (from another WUS) to be detected entirely within a window of this size. The duration is equal to gdWakeupSymbolTxIdle + 2 * gdWakeupSymbolTxLow plus a safe part. (Clock differences and other effects can deform the Tx-wakeup pattern.). Range 76-301 gdBit.  */
231         uint8_t gdWakeupSymbolTxIdle;                                   /**< Number of bits used by the node to transmit the 'idle' part of a wakeup symbol. The duration is equal to cdWakeupSymbolTxIdle.  45-180 gdBit. */
232         uint8_t gdWakeupSymbolTxLow;                                    /**< Number of bits used by the node to transmit the LOW part of a wakeup symbol. The duration is equal to cdWakeupSymbolTxLow. Range 15-60 gdBit. */
233         uint8_t gListenNoise;                                                   /**< Upper limit for the startup listen timeout and wakeup listen timeout in the presence of noise. It is used as a multiplier of the node parameter pdListenTimeout. Range 2-16. */
234         uint16_t gMacroPerCycle;                                                /**< Number of macroticks in a communication cycle. Range 10-16000 MT. */
235         uint8_t gMaxWithoutClockCorrectionFatal;                /**< Threshold used for testing the vClockCorrectionFailed counter. Defines the number of consecutive even/odd cycle pairs with missing clock correction terms that will cause the protocol to transition from the POC:normal active or POC:normal passive state into the POC:halt state. Range gMaxWithoutClockCorrectionPassive - 15 even/odd cycle pairs */
236         uint8_t gMaxWithoutClockCorrectionPassive;              /**< Threshold used for testing the vClockCorrectionFailed counter. Defines the number of consecutive even/odd cycle pairs with missing clock correction terms that will cause the protocol to transition from the POC:normal active state to the POC:normal passive state. Note that gMaxWithoutClockCorrectionPassive <= gMaxWithoutClockCorrectionFatal <= 15. Range 1-15 even/odd cycle pairs.*/
237         uint16_t gNumberOfMinislots;                                    /**< Number of minislots in the dynamic segment. Range 0-7986. */
238         uint16_t gNumberOfStaticSlots;                                  /**< Number of static slots in the static segment. Range 2 - cStaticSlotIDMax. */
239         uint16_t gOffsetCorrectionStart;                                /**< Start of the offset correction phase within the NIT, expressed as the number of macroticks from the start of cycle. Range 9-15999 MT. */
240         uint8_t gPayloadLengthStatic;                                   /**< Payload length of a static frame. Range 0 - cPayloadLengthMax two-byte-words. */
241         uint8_t gSyncNodeMax;                                                   /**< Maximum number of nodes that may send frames with the sync frame indicator bit set to one. Range 2 - cSyncNodeMax. */
242         /* Protocol related parameters */
243         uint16_t gdNIT;                                                                 /**< Duration of the Network Idle Time. Range 2-805 MT. */
244         uint8_t gdSampleClockPeriod;                                    /**< Sample clock period. 0 = 0.0125, 1 = 0.025, 2 = 0.05 us. */
245         uint8_t gNetworkManagementVectorLength;                 /**< Length of the Network Management vector in a cluster. Range 0-12 bytes */
246 } Fr_TMS570LS_ClusterConfigType;
247
248 /**
249  * This structure represents local parameters of FlexRay node.
250  */
251 typedef struct Fr_TMS570LS_NodeConfigType_st {
252         /* Protocol relevant */
253         boolean_t pAllowHaltDueToClock;                                 /**< Boolean flag that controls the transition to the POC:halt state due to a clock synchronization errors. If set to true, the CC is allowed to transition to POC:halt. If set to false, the CC will not transition to the POC:halt state but will enter or remain in the POC:normal passive state (self healing would still be possible). */
254         uint8_t pAllowPassiveToActive;                                  /**< Number of consecutive even/odd cycle pairs that must have valid clock correction terms before the CC will be allowed to transition from the POC:normal passive state to POC:normal active state. If set to zero, the CC is not allowed to transition from POC:normal passive to POC:normal active. Range 0-31 even/odd cycle pairs. */
255         Fr_ChannelType pChannels;                                               /**< Channels to which the node is connected.  */
256         uint16_t pdAcceptedStartupRange;                                /**< Expanded range of measured clock deviation allowed for startup frames during integration. Range 0-1875 uT. */
257         uint8_t pClusterDriftDamping;                                   /**< Local cluster drift damping factor used for rate correction. Range 0-20 uT*/
258         uint16_t pDelayCompensationA;                                   /**< Value used to compensate for reception delays on the indicated channel. This covers assumed propagation delay up to cPropagationDelayMax for microticks in the range of 0.0125 Î¼s to 0.05 Î¼s. In practice, the minimum of the propagation delays of all sync nodes should be applied. Range 0-200 uT*/
259         uint16_t pDelayCompensationB;                                   /**< Value used to compensate for reception delays on the indicated channel. This covers assumed propagation delay up to cPropagationDelayMax for microticks in the range of 0.0125 Î¼s to 0.05 Î¼s. In practice, the minimum of the propagation delays of all sync nodes should be applied. Range 0-200 uT*/
260         uint32_t pdListenTimeout;                                               /**< Value for the startup listen timeout and wakeup listen timeout. Although this is a node local parameter, the real time equivalent of this value should be the same for all nodes in the cluster. Range 1284-1283846 uT. */
261         uint16_t pdMaxDrift;                                                    /**< Maximum drift offset between two nodes that operate with unsynchronized clocks over one communication cycle. Range 2-1923 uT. */
262         uint8_t pExternOffsetCorrection;                                /**< Number of microticks added or subtracted to the NIT to carry out a host-requested external offset correction. Range 0-7 uT. */
263         uint8_t pExternRateCorrection;                                  /**< Number of microticks added or subtracted to the cycle to carry out a host-requested external rate correction. Range 0-7 uT. */
264         boolean_t pKeySlotUsedForStartup;                               /**< Flag indicating whether the Key Slot is used to transmit a startup frame. If pKeySlotUsedForStartup is set to true then pKeySlotUsedForSync must also be set to true. */
265         boolean_t pKeySlotUsedForSync;                                  /**< Flag indicating whether the Key Slot is used to transmit a sync frame. If pKeySlotUsedForStartup is set to true then pKeySlotUsedForSync must also be set to true.  */
266         uint16_t pLatestTx;                                                             /**< Number of the last minislot in which a frame transmission can start in the dynamic segment. Range 0-7980 Minislot. */
267         uint8_t pMacroInitialOffsetA;                                   /**< Integer number of macroticks between the static slot boundary and the following macrotick boundary of the secondary time reference point based on the nominal macrotick duration. Range 2-68 MT. */
268         uint8_t pMacroInitialOffsetB;                                   /**< Integer number of macroticks between the static slot boundary and the following macrotick boundary of the secondary time reference point based on the nominal macrotick duration. Range 2-68 MT. */
269         uint8_t pMicroInitialOffsetA;                                   /**< Number of microticks between the closest macrotick boundary described by pMacroInitialOffset[Ch] and the secondary time reference point. The parameter depends on pDelayCompensation[Ch] and therefore it has to be set independently for each channel. Range 0-239 uT. */
270         uint8_t pMicroInitialOffsetB;                                   /**< Number of microticks between the closest macrotick boundary described by pMacroInitialOffset[Ch] and the secondary time reference point. The parameter depends on pDelayCompensation[Ch] and therefore it has to be set independently for each channel. Range 0-239 uT. */
271         uint32_t pMicroPerCycle;                                                /**< Nominal number of microticks in the communication cycle of the local node. If nodes have different microtick durations this number will differ from node to node. Range 640-640000 uT */
272         uint16_t pRateCorrectionOut;                                    /**< Magnitude of the maximum permissible rate correction value. Range 2-1923 uT. */
273         uint16_t pOffsetCorrectionOut;                                  /**< Holds the maximum permitted offset correction value to be applied by the internal clock synchronization algorithm. Range 5-3BA2 uT. */
274         boolean_t pSingleSlotEnabled;                                   /**< Flag indicating whether or not the node shall enter single slot mode following startup.  */
275         Fr_ChannelType pWakeupChannel;                                  /**< Channel used by the node to send a wakeup pattern. Range A, B. */
276         uint8_t pWakeupPattern;                                                 /**< Number of repetitions of the wakeup symbol that are combined to form a wakeup pattern when the node enters the POC:wakeup send state. Range 2-63. */
277         /* Protocol related */
278         uint8_t pSamplesPerMicrotick;                                   /**< Number of samples per microtick. Range 1,2,4. */
279         uint8_t pDecodingCorrection;                                    /**< Decoding correction (in microticks). Range 0xF - 0x8F. */
280 } Fr_TMS570LS_NodeConfigType;
281
282 /**
283  * This structure provides parameters for buffer configuration.
284  */
285 typedef struct Fr_TMS570LS_BufferConfigType_st {
286         uint32_t slotId;                                /**< Index of the slot in which this buffer will transfer or receive data. */
287         uint8_t maxPayload;                             /**< Maximum data payload in buffer in 2-bytes-words. If lower than global payload maximum value, padding bytes are inserted (zeros). */
288         Fr_ChannelType channel;                 /**< Channel filter control. A&B should not be seleceted for dynamic segment. */
289         uint8_t cycleCounterFiltering;  /**< Cycle counter filter control. */
290         boolean_t isTx;                                 /**< Tx or Rx buffer selector */
291         boolean_t singleTransmit;               /**< Single-shot or continuous mode selector */
292         boolean_t payloadPreambleIndicatorTr;           /**< For static segment - indicates that data section contains network management data. For dynamic segment - the first two data bytes can be used for message ID filtering (done manualy by MCU) */
293         boolean_t rejectNullFrames;             /**< USED ONLY FOR FIFO - Reject every NULL frames. */
294         boolean_t rejectStaticSegment;  /**< USED ONLY FOR FIFO - Accept only static segment frames. */
295         boolean_t msgBufferInterrupt;   /**< Enables TX/RX interrupt for corresponding buffer*/
296 } Fr_TMS570LS_BufferConfigType;
297
298 typedef enum {
299         FR_SB_RECONFIG_ENABLED,
300         FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED,
301         FR_SB_ALL_REC_DISABLED,
302         FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED
303 } Fr_TMS570LS_SecureBuffersType;
304
305 /**
306  * This data type reflect state of the FlexRay driver.
307  */
308 typedef enum {
309         FR_ST_DRV_NOT_INITIALIZED,      /**< No initialization procedure was performed, Fr_Init has to be processed at first. */
310         FR_ST_DRV_INITIALIZED,          /**< Fr_Init procedure was performed, Fr_ControllerInit has to be processed now. */
311         FR_ST_CTRL_INITIALIZED          /**< Fr_ControllerInit procedure was performed, driver and controller is ready for other actions */
312 } Fr_TMS570LS_DriverState;
313
314 /**
315  * This structure contains the definition of the message RAM
316  * configuration parameters.
317  */
318 typedef struct Fr_TMS570LS_MsgRAMConfig_st {
319         uint8_t statSegmentBufferCount;                                 /**< Number of buffers for static segment */
320         uint8_t dynSegmentBufferCount;                                  /**< Number of bufferes for dynamic segment */
321         uint8_t fifoBufferCount;                                                /**< Number of buffers for Rx fifo */
322         boolean_t syncFramePayloadMultiplexEnabled;             /**< Selector of Payload multiplexing. 0 - Only message buffer 0 locked against reconfiguration; 1 - Both message buffers 0 and 1 are locked against reconfiguration. */
323         Fr_TMS570LS_SecureBuffersType secureBuffers;    /**< Secure buffers against reconfiguration selector */
324 } Fr_TMS570LS_MsgRAMConfig;
325 /*
326  * This type contains the definition of the implementation-specific
327  * post build configuration structure for FlexRay driver in TMS570LS MCU.
328  */
329 typedef struct Fr_TMS570LS_ConfigType_st {
330         const Fr_TMS570LS_ClusterConfigType* clusterConfiguration;
331         const Fr_TMS570LS_NodeConfigType* nodeConfiguration;
332         const Fr_TMS570LS_MsgRAMConfig* msgRAMConfig;
333         Fr_TMS570LS_BufferConfigType* staticBufferConfigs;
334         Fr_TMS570LS_BufferConfigType* dynamicBufferConfigs;
335         Fr_TMS570LS_BufferConfigType* fifoBufferConfigs;
336 } Fr_ConfigType;
337
338 /**
339  * @brief Initalizes the Fr.
340  *
341  * The function Fr_Init shall internally store the configuration
342  * address to enable subsequent API calls to access the configuration.
343  *
344  * @param [in] Fr_ConfigPtr Address to an Fr dependant configuration structure
345  * that contains all information for operating the Fr subsequently.
346  */
347 void Fr_Init(const Fr_ConfigType* Fr_ConfigPtr);
348
349 /**
350  * @brief Initializes a FlexRay CC.
351  *
352  * The function Fr_ControllerInit shall perform the following tasks
353  * on FlexRay CC Fr_CtrIdx:
354  * 1. Switch CC into â€˜POC:config’ (from any other POCState).
355  * 2. Configure all FlexRay cluster and node configuration parameters (e.g., cycle
356  * length, macrotick duration).
357  * 3. Configure all transmit/receive resources (e.g., buffer initialization) according to
358  * the frame triggering configuration parameters contained in the FrIf.
359  * 4. Switch CC into â€˜POC:ready’
360  * 5. Return E_OK.
361  *
362  * @param [in] Fr_ConfigPtr Index of FlexRay CC within the context of the FlexRay Driver.
363  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
364  */
365 Std_ReturnType Fr_ControllerInit(uint8_t Fr_CtrlIdx);
366
367 /**
368  * @brief Starts communication.
369  *
370  * The function Fr_StartCommunication shall perform the following
371  * tasks on FlexRay CC Fr_CtrIdx:
372  * 1. Invoke the CC CHI command â€˜RUN’, which initiates the startup procedure
373  * within the FlexRay CC.
374  * 2. Return E_OK.
375  *
376  * The function call of Fr_StartCommunication changes the CC POCState to
377  * POC:startup which is a transitional state. In the case when communication startup
378  * succeeds, the CC wil change the POCState to â€˜POC:normal active’ or â€˜POC:normal
379  * passive’. It is not guaranteed that the FlexRay CC will reside in the â€˜POC:normal
380  * active’ or â€˜POC:normal passive’ state after a call of the function
381  * Fr_StartCommunication.
382  *
383  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
384  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
385  */
386 Std_ReturnType Fr_StartCommunication(uint8_t Fr_CtrlIdx);
387
388 /**
389  * @brief Invokes the CC CHI command â€˜ALLOW_COLDSTART’.
390  *
391  * The function Fr_AllowColdstart shall perform the following tasks
392  * on FlexRay CC Fr_CtrIdx:
393  * 1. Invoke the CC CHI command â€˜ALLOW_COLDSTART’.
394  * 2. Return E_OK.
395  *
396  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
397  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
398  */
399 Std_ReturnType Fr_AllowColdstart(uint8_t Fr_CtrlIdx);
400
401 /**
402  * @brief Invokes the CC CHI command 'ALL_SLOTS'.
403  *
404  * The function Fr_AllSlots shall perform the following tasks on
405  * FlexRay CC Fr_CtrIdx:
406  * 1. Invoke the CC CHI command â€˜ALL_SLOTS’, which requests a switch from key
407  * slot only mode to all slots transmission mode at the beginning of the next
408  * communication cycle.
409  * 2. Return E_OK.
410  *
411  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
412  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
413  */
414 Std_ReturnType Fr_AllSlots(uint8_t Fr_CtrlIdx);
415
416 /**
417  * @brief Invokes the CC CHI command 'DEFERRED_HALT'.
418  *
419  * The function Fr_HaltCommunication shall perform the following
420  * tasks on FlexRay CC Fr_CtrIdx:
421  * 1. Invoke the CC CHI command â€˜DEFERRED_HALT’.
422  * 2. Return E_OK.
423  *
424  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
425  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
426  */
427
428 Std_ReturnType Fr_HaltCommunication(uint8_t Fr_CtrlIdx);
429
430 /**
431  * @brief Invokes the CC CHI command â€˜FREEZE‘.
432  *
433  * The function Fr_AbortCommunication shall perform the
434  * following tasks on FlexRay CC Fr_CtrIdx:
435  * 1. Invoke the CC CHI command â€˜FREEZE’, which immediately aborts
436  * communication (if active) and changes to the POC:halt state from any
437  * previous POCState.
438  * 2. Return E_OK.
439  *
440  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
441  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
442  */
443 Std_ReturnType Fr_AbortCommunication(uint8_t Fr_CtrlIdx);
444
445 /**
446  * @brief Invokes the CC CHI command â€˜WAKEUP‘.
447  *
448  * The function Fr_SendWUP shall perform the following tasks on
449  * FlexRay CC Fr_CtrIdx:
450  * 1. Invoke the CC CHI command â€˜WAKEUP’, which initiates the wakeup
451  * transmission procedure on the configured FlexRay channel.
452  * 2. Return E_OK.
453  *
454  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
455  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
456  */
457 Std_ReturnType Fr_SendWUP(uint8_t Fr_CtrlIdx);
458
459 /**
460  * @brief Sets a wakeup channel.
461  *
462  * The function Fr_SetWakeupChannel shall perform the following
463  * tasks on FlexRay CC Fr_CtrIdx:
464  * 1. Change the CC’s POCState to POC:config by invoking the CHI command
465  * â€˜CONFIG’.
466  * 2. Configure the wakeup channel according to parameter Fr_ChnlIdx.
467  * 3. Change the CC’s POCState to POC:ready again by invoking the CHI
468  * command â€˜CONFIG_COMPLETE’.
469  * 4. Return E_OK.
470  *
471  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
472  * @param [in] Fr_ChnlIdx Index of FlexRay channel within the context of the FlexRay CC
473  * Fr_CtrlIdx. Valid values are FR_CHANNEL_A and FR_CHANNEL_B.
474  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
475  *
476  */
477 Std_ReturnType Fr_SetWakeupChannel(uint8_t Fr_CtrlIdx, Fr_ChannelType Fr_ChnlIdx);
478
479 /**
480  * @brief Gets the POC status.
481  *
482  * The function Fr_GetPOCStatus shall perform the following
483  * tasks on FlexRay CC Fr_CtrIdx:
484  * 1. Query the CC’s actual POC status by reading the CHI variable â€˜vPOC’ and
485  * write the result to parameter Fr_POCStatusPtr.
486  * 2. Return E_OK.
487  *
488  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
489  * @param [out] Fr_POCStatusPtr Address the output value is stored to.
490  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
491  */
492 Std_ReturnType Fr_GetPOCStatus(uint8_t Fr_CtrlIdx, Fr_POCStatusType* Fr_POCStatusPtr);
493
494 /**
495  * @brief Transmits data on the FlexRay network.
496  *
497  * The function Fr_TransmitTxLPdu shall perform the following
498  * tasks on FlexRay CC Fr_CtrIdx:
499  * 1. Figure out the physical resource (e.g., a buffer) mapped to the transmission of
500  * the FlexRay frame identified by Fr_LPduIdx.
501  * 2. If the transmit Lpdu supports dynamic payload length (configuration parameter
502  * FrIfAllowDynamicLSduLength is set to true), then the transmission
503  * resource shall be reconfigured to match the payload length Fr_LsduLength
504  * passed to the API. Note that the dynamic payload length is only applicable to
505  * frames within the dynamic FlexRay segment.
506  * 3. Copy Fr_LsduLength bytes from address Fr_LsduPtr into the FlexRay CC’s
507  * transmission resource and then activate it for transmission.
508  * 4. Return E_OK.
509  *
510  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
511  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
512  * @param [in] Fr_LSduPtr This reference points to a buffer where the assembled LSdu to be
513  * transmitted within this LPdu is stored at.
514  * @param [in] Fr_LSduLength Determines the length of the data (in Bytes) to be transmitted.
515  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
516  */
517 Std_ReturnType Fr_TransmitTxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, const uint8_t* Fr_LSduPtr, uint8_t Fr_LSduLength);
518
519 /**
520  * @brief Cancels the already pending transmission of a LPdu contained in a controllers physical transmit resource (e.g. message buffer).
521  *
522  * The function Fr_CancelTxLPdu shall perform the following tasks
523  * on FlexRay CC Fr_CtrIdx:
524  * 1. Figure out the physical resource (e.g., a buffer) mapped to the transmission of
525  * the FlexRay frame identified by Fr_LpduIdx.
526  * 2. If the physical resource figured out is actively pending for transmission, then
527  * the transmit request of this particular resource shall be terminated and E_OK
528  * returned. If no transmission is pending E_NOT_OK shall be returned,
529  * indicating that no such cancelation took place.
530  *
531  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
532  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
533  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
534  */
535 Std_ReturnType Fr_CancelTxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx);
536
537 /**
538  * @brief Receives data from the FlexRay network.
539  *
540  * The function Fr_ReceiveRxLPdu shall perform the following
541  * tasks on FlexRay CC Fr_CtrIdx:
542  * 1. Figure out the physical resource (e.g., a buffer, a receive-FIFO) mapped to the
543  * reception of the FlexRay frame as identified by Fr_LpduIdx.
544  * 2. Figure out whether a new FlexRay frame instance has been received within
545  * the receive resource as figured in bullet 1. If the receive resource is a FIFO,
546  * then consume the first element out of the FIFO.
547  * 3. If a new FlexRay frame has been accepted, then copy the received payload
548  * data to address Fr_LsduPtr, store the number of bytes copied to
549  * Fr_LsduLengthPtr and store the status FR_RECEIVED to
550  * Fr_RxLPduStatusPtr. If a FIFO is used as received resource and the FIFO is
551  * not empty, then store the status FR_RECEIVED_MORE_DATA_AVAILABLE
552  * to Fr_RxLPduStatusPtr.
553  * 4. If no new frame has been accepted, then do not copy any payload data to
554  * Fr_LsduPtr, write 0 to the parameter Fr_LsduLengthPtr and store the status
555  * FR_NOT_RECEIVED to Fr_RxLPduStatusPtr.
556  * 5. Return E_OK.
557  *
558  * Only reconfigurable message buffers can be canceled.
559  *
560  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
561  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
562  * @param [out] Fr_LSduPtr This reference points to the buffer where the LSdu to be received shall be stored.
563  * @param [out] Fr_LPduStatusPtr This reference points to the memory location where the status of the LPdu shall be stored.
564  * @param [out] Fr_LSduLengthPtr This reference points to the memory location where the length
565  * of the LSdu (in bytes) shall be stored. This length represents
566  * the number of bytes copied to Fr_LSduPtr.
567  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
568  */
569 Std_ReturnType Fr_ReceiveRxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, uint8_t* Fr_LSduPtr, Fr_RxLPduStatusType* Fr_LPduStatusPtr, uint8_t* Fr_LSduLengthPtr);
570
571 /**
572  * @brief Checks the transmit status of the LSdu.
573  *
574  * The function Fr_CheckTxLPduStatus shall perform the following
575  * tasks on FlexRay CC Fr_CtrIdx:
576  * 1. Figure out the physical resource (e.g., a buffer) mapped to the transmission of
577  * the FlexRay frame identified by Fr_LpduIdx.
578  * 2. Check whether the transmission resource as figured in bullet 1 is pending for
579  * transmission.
580  * 3. If a transmission request is pending, then store the status
581  * FR_NOT_TRANSMITTED to Fr_TxLPduStatusPtr.
582  * 4. If no transmission request is pending, then store the status
583  * FR_TRANSMITTED to Fr_TxLPduStatusPtr.
584  * 5. Return E_OK.
585  *
586  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
587  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
588  * @param [out] Fr_LPduStatusPtr This reference points to the memory location where the status of the LPdu shall be stored.
589  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
590  */
591 Std_ReturnType Fr_CheckTxLPduStatus(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, Fr_TxLPduStatusType* Fr_TxLPduStatusPtr);
592
593
594 /**
595  * @brief Prepares a LPdu.
596  *
597  * Function Fr_Init must be called at first to initialize global arrays Fr_BuffersPtrs and Fr_BufferConfigured.
598  * Fr_BuffersPtrs contains configuratin data for all buffers and Fr_BufferConfigured holds flags to check if the buffer
599  * was or was not configured by some previous calling of this function.
600  *
601  * Buffers are identified the frame ID on which they should receive or transmit data. The function has to find an index of
602  * the buffer in the Fr_BuffersPtrs array. When match between FrameID in the array and Fr_LPduIdx is found, the function
603  * configures this buffer and then continues to find others occurences of the same frame ID in the array of config data.
604  *
605  * The function controlls if the buffer was or was not configured by some previous functin call. Already configured buffers
606  * are skipped. For buffer reconfiguration (if allowed) is designed fuction Fr_ReconfigLPdu.
607  *
608  * The right procedure to configure static/dynamic buffers or FIFO buffers is launched according to the index of the buffer and
609  * data stored in message RAM configuration register.
610  *
611  * The function Fr_PrepareLPdu shall perform the following tasks
612  * on FlexRay CC Fr_CtrIdx:
613  * 1. Figure out the physical resource (e.g., a buffer) mapped to the processing of
614  * the FlexRay frame identified by Fr_LpduIdx.
615  * 2. Configure the physical resource (a buffer) appropriate for Fr_LpduIdx
616  * operation (SlotId, Cycle filter, payload length, header CRC, etc.) if the MCG
617  * uses the reconfiguration feature9.
618  * 3. Return E_OK.
619  *
620  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
621  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
622  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
623  */
624 Std_ReturnType Fr_PrepareLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx);
625
626 /**
627  * @brief Reconfigures a given LPdu according to the parameters (FrameId, Channel, CycleRepetition, CycleOffset, PayloadLength, HeaderCRC) at runtime.
628  *
629  * The function Fr_ReconfigLPdu shall perform the following tasks
630  * on FlexRay CC Fr_CtrIdx:
631  * 1. Figure out the physical resource (e.g., a buffer) mapped to the processing of
632  * the FlexRay frame as identified by Fr_LpduIdx.
633  * 2. Configure the physical resource (a buffer) according to the parameters given
634  * at the API. The Lpdu direction is statically associated with the Lpdu and
635  * cannot be changed by this service.
636  * 3. Return E_OK.
637  *
638  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
639  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
640  * @param [in] Fr_FrameId FlexRay Frame ID the FrIf_LPdu shall be configured to.
641  * @param [in] Fr_ChnlIdx FlexRay Channel the FrIf_LPdu shall be configured to.
642  * @param [in] Fr_CycleRepetition Cycle Repetition part of the cycle filter mechanism FrIf_LPdu shall be configured to.
643  * @param [in] Fr_CycleOffset Cycle Offset part of the cycle filter mechanism FrIf_LPdu shall be configured to.
644  * @param [in] Fr_PayloadLength Payloadlength in units of bytes the FrIf_LPduIdx shall be configured to.
645  * @param [in] Fr_HeaderCRC Header CRC the FrIf_LPdu shall be configured to.
646  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
647  */
648 Std_ReturnType Fr_ReconfigLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, uint16_t Fr_FrameId, Fr_ChannelType Fr_ChnlIdx, uint8_t Fr_CycleRepetition, uint8_t Fr_CycleOffset, uint8_t Fr_PayloadLength, uint16_t Fr_HeaderCRC);
649
650
651 /**
652  * @brief Disables the hardware resource of a LPdu for transmission/reception.
653  *
654  * The function Fr_DisableLPdu shall perform the following tasks
655  * on FlexRay CC Fr_CtrIdx:
656  * 1. Figure out the physical resource (e.g., a buffer) mapped to the processing of
657  * the FlexRay frame identified by Fr_LpduIdx.
658  * 2. Configure the physical resource (a buffer) in a way that it doesn’t take part in
659  * the transmission/reception process.
660  * 3. Return E_OK.
661  *
662  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
663  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
664  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
665  */
666 Std_ReturnType Fr_DisableLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx);
667
668 /**
669  * @brief Gets the current global FlexRay time.
670  *
671  * The function Fr_GetGlobalTime shall perform the following
672  * tasks on FlexRay CC Fr_CtrIdx:
673  * 1. Read the current global FlexRay time and write it to the output parameters
674  * Fr_CyclePtr and Fr_MacrotickPtr.
675  * 2. Return E_OK.
676  *
677  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
678  * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
679  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
680  */
681 Std_ReturnType Fr_GetGlobalTime(uint8_t Fr_CtrlIdx, uint8_t* Fr_CyclePtr, uint16_t* Fr_MacroTickPtr);
682
683 /**
684  * @brief Gets the network management vector of the last communication cycle.
685  *
686  * The function Fr_GetNmVector shall perform the following tasks
687  * on FlexRay CC Fr_CtrIdx:
688  * 1. Read the current accrued network management vector out of the FlexRay CC
689  * and then write it to the output parameter Fr_NmVectorPtr. The number of
690  * bytes written to the output parameter is constant and is known at configuration
691  * time (FrIf configuration parameter FrIfGNetworkManagementVectorLength).
692  * 2. Return E_OK.
693  *
694  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
695  * @param [out] Fr_NmVectorPtr Address where the NmVector of the last communication cycle shall be stored.
696  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
697  */
698 Std_ReturnType Fr_GetNmVector(uint8_t Fr_CtrlIdx, uint8_t* Fr_NmVectorPtr);
699
700 /**
701  * @brief Gets the current number of startup frames seen on the cluster.
702  *
703  * The function Fr_GetNumOfStartupFrames shall perform the
704  * following tasks on FlexRay CC Fr_CtrIdx:
705  * 1. Read the number of aligned startup frame pairs received or transmitted during
706  * the previous double cycle, aggregated across both channels and write it to the
707  * output parameter Fr_NumOfStartupFramesPtr.
708  * 2. Return E_OK.
709  *
710  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
711  * @param [out] Fr_NumOfStartupFramesPtr Address where the number of startup frames seen within the last even/odd cycle pair shall be stored.
712  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
713  */
714 Std_ReturnType Fr_GetNumOfStartupFrames(uint8_t Fr_CtrlIdx, uint8_t* Fr_NumOfStartupFramesPtr);
715
716 /**
717  * @brief Gets the current number of startup frames seen on the cluster.
718  *
719  * The function Fr_GetChannelStatus shall perform the following
720  * tasks on FlexRay CC Fr_CtrIdx:
721  * 1. Read the aggregated channel status, NIT status, symbol window status and
722  * write it to the output parameter Fr_ChannelAStatusPtr/ Fr_ChannelBStatusPtr.
723  * The value of *Fr_ChannelAStatusPtr / *Fr_ChannelBStatusPtr is bitcoded with
724  * the following meaning (Bit 0 = LSB, Bit 15 = MSB)13:
725  * Bit 0: Channel A/B aggregated channel status vSS!ValidFrame
726  * Bit 1: Channel A/B aggregated channel status vSS!SyntaxError
727  * Bit 2: Channel A/B aggregated channel status vSS!ContentError
728  * Bit 3: Channel A/B aggregated channel status additional communication
729  * Bit 4: Channel A/B aggregated channel status vSS!Bviolation
730  * Bit 5: Channel A/B aggregated channel status vSS!TxConflict
731  * Bit 6: Not used (0)
732  * Bit 7: Not used (0)
733  * Bit 8: Channel A/B symbol window status data vSS!ValidMTS
734  * Bit 9: Channel A/B symbol window status data vSS!SyntaxError
735  * Bit 10: Channel A/B symbol window status data vSS!Bviolation
736  * Bit 11: Channel A/B symbol window status data vSS!TxConflict
737  * Bit 12: Channel A/B NIT status data vSS!SyntaxError
738  * Bit 13: Channel A/B NIT status data vSS!Bviolation
739  * Bit 14: Not used (0)
740  * Bit 15: Not used (0)
741  * 2. Reset the aggregated channel status information within the FlexRay controller.
742  * 3. Return E_OK.
743  *
744  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
745  * @param [out] Fr_ChannelAStatusPtr Address where the bitcoded channel A status information shall be stored.
746  * @param [out] Fr_ChannelBStatusPtr Address where the bitcoded channel B status information shall be stored.
747  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
748  */
749 Std_ReturnType Fr_GetChannelStatus(uint8_t Fr_CtrlIdx, uint16_t* Fr_ChannelAStatusPtr, uint16_t* Fr_ChannelBStatusPtr);
750
751 /**
752  * @brief Gets the current clock correction values.
753  *
754  * The function Fr_GetClockCorrection shall perform the following
755  * tasks on FlexRay CC Fr_CtrIdx:
756  * 1. Read the rate correction value (vInterimRateCorrection14) and write it as
757  * signed integer to the output parameter Fr_RateCorrectionPtr. Read the offset
758  * correction value (vInterimOffsetCorrection15) and write it as signed integer to
759  * the output parameter Fr_OffsetCorrectionPtr
760  * 2. Return E_OK.
761  *
762  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
763  * @param [out] Fr_RateCorrectionPtr Address where the current rate correction value shall be stored.
764  * @param [out] Fr_OffsetCorrectionPtr Address where the current offset correction value shall be stored.
765  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
766  */
767 Std_ReturnType Fr_GetClockCorrection(uint8_t Fr_CtrlIdx, int16_t* Fr_RateCorrectionPtr, int32_t* Fr_OffsetCorrectionPtr);
768
769 /**
770  * @brief Gets a list of syncframes received or transmitted on channel A and channel B via the even and odd communication cycle.
771  *
772  * The function Fr_ GetSyncFrameList shall perform the following
773  * tasks on FlexRay CC Fr_CtrIdx:
774  * 1. Read the list of syncframes received in the last even communication cycle on
775  * channel A and write it as array to the memory location
776  * Fr_ChannelAEvenListPtr.
777  * Read the list of syncframes received in the last even communication cycle on
778  * channel B and write it as array to the memory location
779  * Fr_ChannelBEvenListPtr.
780  * Read the list of syncframes received in the last odd communication cycle on
781  * channel A and write it as array to the memory location
782  * Fr_ChannelAOddListPtr.
783  * Read the list of syncframes received in the last odd communication cycle on
784  * channel B and write it as array to the memory location
785  * Fr_ChannelBOddListPtr.
786  * 2. Return E_OK.
787  *
788  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
789  * @param [in] Fr_ListSize Size of the arrays passed via parameters:
790  * Fr_ChannelAEvenListPtr
791  * Fr_ChannelBEvenListPtr
792  * Fr_ChannelAOddListPtr
793  * Fr_ChannelBOddListPtr.
794  * The service must ensure to not write more entries into those arrays than granted by this parameter.
795  * @param [out] Fr_ChannelAEvenListPtr Address the list of syncframes on channel A within the
796  * even communication cycle is written to. The exact
797  * number of elements written to the list is limited by
798  * parameter Fr_ListSize.
799  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
800  * @param [out] Fr_ChannelBEvenListPtr Address the list of syncframes on channel B within the
801  * even communication cycle is written to. The exact
802  * number of elements written to the list is limited by
803  * parameter Fr_ListSize.
804  * @param [out] Fr_ChannelAOddListPtr Address the list of syncframes on channel A within the
805  * odd communication cycle is written to. The exact number
806  * of elements written to the list is limited by parameter
807  * Fr_ListSize.
808  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
809  * @param [out] Fr_ChannelBOddListPtr Address the list of syncframes on channel B within the
810  * odd communication cycle is written to. The exact number
811  * of elements written to the list is limited by parameter
812  * Fr_ListSize.
813  * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
814  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
815  */
816 Std_ReturnType Fr_GetSyncFrameList(uint8_t Fr_CtrlIdx, uint8_t Fr_ListSize, uint16_t* Fr_ChannelAEvenListPtr, uint16_t* Fr_ChannelBEvenListPtr, uint16_t* Fr_ChannelAOddListPtr, uint16_t* Fr_ChannelBOddListPtr);
817
818 /**
819  * @brief Gets the wakeup received information from the FlexRay controller.
820  *
821  * The function Fr_GetWakeupRxStatus shall perform the
822  * following tasks on FlexRay CC Fr_CtrIdx:
823  * 1. Read the wakeup pattern received indicators for channel A and channel B and
824  * write it to the output parameter Fr_WakeupRxStatusPtr. The value of
825  * *Fr_WakeupRxStatusPtr is bitcoded with the following meaning (Bit 0 = LSB,
826  * Bit 7 = MSB):
827  * Bit 0: Wakeup pattern received on channel A (1), otherwise (0)
828  * Bit 1: Wakeup pattern received on channel B (1), otherwise (0)
829  * Bit 2: Not used (always 0)
830  * Bit 3: Not used (always 0)
831  * Bit 4: Not used (always 0)
832  * Bit 5: Not used (always 0)
833  * Bit 6: Not used (always 0)
834  * Bit 7: Not used (always 0)
835  * 2. Reset the wakeup received indication status information within the FlexRay
836  * controller.
837  * 3. Return E_OK.
838  *
839  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
840  * @param [out] Fr_WakeupRxStatusPtr Address where bitcoded wakeup reception status shall be stored.
841  * Bit 0: Wakeup received on channel A indicator
842  * Bit 1: Wakeup received on channel B indicator
843  * Bit 2-7: Unused
844  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
845  */
846 Std_ReturnType Fr_GetWakeupRxStatus(uint8_t Fr_CtrlIdx, uint8_t* Fr_WakeupRxStatusPtr);
847
848 /**
849  * @brief Sets the absolute FlexRay timer.
850  *
851  * The function Fr_SetAbsoluteTimer shall perform the following
852  * tasks:
853  * 1. Program the absolute FlexRay timer Fr_AbsTimerIdx according to the
854  * parameters Fr_Cycle and Fr_Offset.
855  * 2. Return E_OK.
856  *
857  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
858  * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
859  * @param [in] Fr_Cycle Absolute cycle the timer shall elapse in.
860  * @param [in] Fr_Offset Offset within cycle Fr_Cycle in units of macrotick the timer shall elapse at.
861  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
862  */
863 Std_ReturnType Fr_SetAbsoluteTimer(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx, uint8_t Fr_Cycle, uint16_t Fr_Offset);
864
865
866 /**
867  * @brief Stops an absolute timer.
868  *
869  * The function Fr_CancelAbsoluteTimer shall perform the
870  * following tasks:
871  * 1. Stop the absolute timer Fr_AbsTimerIdx.
872  * 2. Return E_OK.
873  *
874  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
875  * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
876  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
877  */
878 Std_ReturnType Fr_CancelAbsoluteTimer(uint8_t Fr_CtrlIdx,       uint8_t Fr_AbsTimerIdx);
879
880 /**
881  * @brief Enables the interrupt line of an absolute timer.
882  *
883  * The function Fr_EnableAbsoluteTimerIRQ shall perform the
884  * following tasks:
885  * 1. Enable the interrupt line related to timer Fr_AbsTimerIdx.
886  * 2. Return E_OK.
887  *
888  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
889  * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
890  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
891  */
892 Std_ReturnType Fr_EnableAbsoluteTimerIRQ(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
893
894
895 /**
896  * @brief Resets the interrupt condition of an absolute timer.
897  *
898  * The function Fr_AckAbsoluteTimerIRQ shall perform the
899  * following tasks:
900  * 1. Reset the interrupt condition of absolute timer Fr_AbsTimerIdx.
901  * 2. Return E_OK.
902  *
903  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
904  * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
905  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
906  */
907 Std_ReturnType Fr_AckAbsoluteTimerIRQ(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
908
909 /**
910  * @brief Disables the interrupt line of an absolute timer.
911  *
912  * The function Fr_DisableAbsoluteTimerIRQ shall perform the
913  * following tasks:
914  * 1. Disable the interrupt line related to absolute timer Fr_AbsTimerIdx.
915  * 2. Return E_OK.
916  *
917  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
918  * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
919  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
920  */
921 Std_ReturnType Fr_DisableAbsoluteTimerIRQ(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
922
923 /**
924  * @brief Gets IRQ status of an absolute timer.
925  *
926  * The function Fr_GetAbsoluteTimerIRQStatus shall perform the
927  * following tasks:
928  * 1. Check whether the interrupt of absolute timer Fr_AbsTimerIdx is pending.
929  * Write TRUE to output parameter Fr_IRQStatusPtr in case the interrupt is
930  * pending, FALSE otherwise.
931  * 2. Return E_OK.
932  *
933  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
934  * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
935  * @param [out] Fr_IRQStatusPtr Address the output value is stored to.
936  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
937  */
938 Std_ReturnType Fr_GetAbsoluteTimerIRQStatus(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx, boolean_t* Fr_IRQStatusPtr);
939
940 /**
941  * @brief Returns the version information of this module.
942  *
943  * @param [out] VersioninfoPtr Pointer to where to store the version information of this module.
944  */
945 void Fr_GetVersionInfo(Std_VersionInfoType* VersioninfoPtr);
946
947
948 /**
949  * @brief Reads a FlexRay protocol configuration parameter for a particular FlexRay controller out of the module's configuration.
950  *
951  * The function Fr_ReadCCConfig shall perform the following tasks:
952  * 1. Read the value of the configuration parameter requested by
953  * Fr_ConfigParamIdx from the configuration and write it to output parameter Fr_ConfigParamValuePtr.
954  * 2. Return E_OK.
955
956  * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
957  * @param [in] Fr_ConfigParamIdx Index that identifies the configuration parameter to read. See macros FR_CIDX_<config_parameter_name>.
958  * @param [out] Fr_ConfigParamValuePtr Address the output value is stored to.
959  * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
960  */
961 Std_ReturnType Fr_ReadCCConfig( uint8_t Fr_CtrlIdx, uint8_t Fr_ConfigParamIdx, uint32_t* Fr_ConfigParamValuePtr);
962
963 /**
964  * @brief   Function sends prepared command on SPI and stores response
965  *
966  * @param[in] port Index of flexray 0 or 1
967  * @return 0 when success, -1 when bad parameter
968  */
969 int Fr_spi_transfer(uint8_t port);
970
971 /**
972  * @brief Returns last spi response of selected fray port
973  *
974  * @param[in] port Index of flexray 0 or 1
975  * @return spi response or -1 when bad parameter
976  */
977 int Fr_spi_response(uint8_t port);
978
979 /**
980  * @brief Returns last spi command of selected fray port
981  *
982  * @param[in] port Index of flexray 0 or 1
983  * @return spi command or -1 when bad parameter
984  */
985 int Fr_spi_get_cmd(uint8_t port);
986
987 #endif /* FR_H_ */