2 * FlexRay Communication driver for TMS570 header file.
6 * @copyright Copyright (C) 2013 Czech Technical University in Prague
8 * @author Michal Horn <hornmich@fel.cvut.cz>
14 #include "drv/Std_Types.h"
15 #include "drv/Fr_GeneralTypes.h"
17 /* Protocol constants specific for TMS570 */
18 #define cCASActionPointOffset 1 /**< Initialization value of the CAS action point offset timer. Units MT */
19 #define cChannelIdleDelimiter 11 /**< Duration of the channel idle delimiter. Units gdBit */
20 #define cClockDeviationMax 0.0015 /**< Maximum clock frequency deviation, equivalent to 1500ppm (1500ppm = 1500/1000000 = 0.0015). */
21 #define cCrcInitA 0xFEDCBA /**< Initialization vector for the calculation of the frame CRC on channel A (hexadecimal). */
22 #define cCrcInitB 0xABCDEF /**< Initialization vector for the calculation of the frame CRC on channel B (hexadecimal). */
23 #define cCrcPolynomial 0x5D6DCB /**< Frame CRC polynomial (hexadecimal).*/
24 #define cCrcSize 24 /**< Size of the frame CRC calculation register. Units bits. */
25 #define cCycleCountMax 63 /**< Maximum cycle counter value in a cluster. */
26 #define cdBSS 2 /**< Duration of the Byte Start Sequence. Units gdBit.*/
27 #define cdCAS 30 /**< Duration of the logical low portion of the collision avoidance symbol (CAS) and media access test symbol (MTS). Units gdBit. */
28 #define cdCASRxLowMin 29 /**< Lower limit of the CAS acceptance window. Units gdBit.*/
29 #define cdCycleMax 16000 /**< Maximum cycle length. Units us. */
30 #define cdFES 2 /**< Duration of the Frame End Sequence. Units gdBit. */
31 #define cdFSS 1 /**< Duration of the Frame Start Sequence. Units gdBit. */
32 #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. */
33 #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. */
34 #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. */
35 #define cdWakeupSymbolTxLow 6 /**< Duration of low phase of a transmitted wakeup symbol. Units us.*/
36 #define cdWakeupSymbolTxIdle 18 /**< Duration of the idle phase between two low phases inside a wakeup pattern. Units 18.*/
37 #define cHCrcInit 0x01A /**< Initialization vector for the calculation of the header CRC on channel A or channel B (hexadecimal). */
38 #define cHCrcPolynomial 0x385 /**< Header CRC polynomial (hexadecimal). */
39 #define cHCrcSize 11 /**< Size of header CRC calculation register. Units bit.*/
40 #define cPayloadLengthMax 127 /**< Maximum length of the payload segment of a frame. Units two-byte-words.*/
41 #define cMicroPerMacroMin 20 /**< Minimum number of microticks per macrotick during the offset correction phase. Units uT.*/
42 #define cMicroPerMacroNomMin 40 /**< Minimum number of microticks in a nominal (uncorrected) macrotick. Units uT. */
43 #define cMicroPerMacroNomMax 240 /**< Maximum number of microticks in a nominal (uncorrected) macrotick. Units uT. */
44 #define cSamplesPerBit 8 /**< Number of samples taken in the determination of a bit value. */
45 #define cSlotIDMax 2047 /**< Highest slot ID number. */
46 #define cStaticSlotIDMax 1023 /**< Highest static slot ID number. */
47 #define cStrobeOffset 5 /**< Sample where bit strobing is performed (first sample of a bit is considered as sample 1). */
48 #define cSyncNodeMax 15 /**< Maximum number of sync nodes in a cluster. */
49 #define cVotingSamples 5 /**< Numbers of samples in the voting window used for majority voting of the RxD input. */
50 #define cVotingDelay (cVotingSamples-1)/2 /**< Number of samples of delay between the RxD input and the majority voted output in the glitch-free case. */
52 #define FR_MAX_SYNC_FRAME_LIST_SIZE 15
54 /* Flags for indicating error during parameters check */
55 #define ERR_PARAM_NO_ERROR 0
57 /* Global parameters errors */
58 #define ERR_PARAM_gColdStartAttempts (1 << 1)
59 #define ERR_PARAM_gdActionPointOffset (1 << 2)
60 #define ERR_PARAM_gdCASRxLowMax (1 << 3)
61 #define ERR_PARAM_gdDynamicSlotIdlePhase (1 << 4)
62 #define ERR_PARAM_gdMinislot (1 << 5)
63 #define ERR_PARAM_gdMinislotActionPointOffset (1 << 6)
64 #define ERR_PARAM_gdStaticSlot (1 << 7)
65 #define ERR_PARAM_gdTSSTransmitter (1 << 8)
66 #define ERR_PARAM_gdWakeupSymbolRxIdle (1 << 9)
67 #define ERR_PARAM_gdWakeupSymbolRxLow (1 << 10)
68 #define ERR_PARAM_gdWakeupSymbolRxWindow (1 << 11)
69 #define ERR_PARAM_gdWakeupSymbolTxIdle (1 << 12)
70 #define ERR_PARAM_gdWakeupSymbolTxLow (1 << 13)
71 #define ERR_PARAM_gListenNoise (1 << 14)
72 #define ERR_PARAM_gMacroPerCycle (1 << 15)
73 #define ERR_PARAM_gMaxWithoutClockCorrectionFatal (1 << 16)
74 #define ERR_PARAM_gMaxWithoutClockCorrectionPassive (1 << 17)
75 #define ERR_PARAM_gNumberOfMinislots (1 << 18)
76 #define ERR_PARAM_gNumberOfStaticSlots (1 << 19)
77 #define ERR_PARAM_gOffsetCorrectionStart (1 << 20)
78 #define ERR_PARAM_gPayloadLengthStatic (1 << 21)
79 #define ERR_PARAM_gSyncNodeMax (1 << 22)
80 #define ERR_PARAM_gdNIT (1 << 23)
81 #define ERR_PARAM_gdSampleClockPeriod (1 << 24)
82 #define ERR_PARAM_gNetworkManagementVectorLength (1 << 25)
84 /* Local parameters errors */
85 #define ERR_PARAM_pAllowHaltDueToClock (1 << 1)
86 #define ERR_PARAM_pAllowPassiveToActive (1 << 2)
87 #define ERR_PARAM_pChannels (1 << 3)
88 #define ERR_PARAM_pdAcceptedStartupRange (1 << 4)
89 #define ERR_PARAM_pClusterDriftDamping (1 << 5)
90 #define ERR_PARAM_pDelayCompensationA (1 << 6)
91 #define ERR_PARAM_pDelayCompensationB (1 << 7)
92 #define ERR_PARAM_pdListenTimeout (1 << 8)
93 #define ERR_PARAM_pdMaxDrift (1 << 9)
94 #define ERR_PARAM_pExternOffsetCorrection (1 << 10)
95 #define ERR_PARAM_pExternRateCorrection (1 << 11)
96 #define ERR_PARAM_pKeySlotUsedForStartup (1 << 12)
97 #define ERR_PARAM_pKeySlotUsedForSync (1 << 13)
98 #define ERR_PARAM_pLatestTx (1 << 14)
99 #define ERR_PARAM_pMacroInitialOffsetA (1 << 15)
100 #define ERR_PARAM_pMacroInitialOffsetB (1 << 16)
101 #define ERR_PARAM_pMicroInitialOffsetA (1 << 17)
102 #define ERR_PARAM_pMicroInitialOffsetB (1 << 18)
103 #define ERR_PARAM_pMicroPerCycle (1 << 19)
104 #define ERR_PARAM_pRateCorrectionOut (1 << 20)
105 #define ERR_PARAM_pSingleSlotEnabled (1 << 21)
106 #define ERR_PARAM_pWakeupChannel (1 << 22)
107 #define ERR_PARAM_pWakeupPattern (1 << 23)
108 #define ERR_PARAM_pSamplesPerMicrotick (1 << 24)
109 #define ERR_PARAM_pDecodingCorrection (1 << 25)
110 #define ERR_PARAM_pOffsetCorrectionOut (1 << 26)
112 /* Message RAM parameters errors */
113 #define ERR_PARAM_statSegmentBufferCount (1 << 1)
114 #define ERR_PARAM_dynSegmentBufferCount (1 << 2)
115 #define ERR_PARAM_fifoBufferCount (1 << 3)
116 #define ERR_PARAM_maxBuffLimit (1 << 4)
118 /* Buffer configuration parameters errors */
119 #define ERR_PARAM_BUFFIFO_NOT_RX (1 << 1)
120 #define ERR_PARAM_BUFFIFO_PAYLOAD_DIFFERS (1 << 2)
121 #define ERR_PARAM_BUFFIFO_CHANNEL_DIFFERS (1 << 3)
122 #define ERR_PARAM_BUFFIFO_CCFILTER_DIFFERS (1 << 4)
123 #define ERR_PARAM_BUFDYN_FRAMEID_INVALID (1 << 5)
124 #define ERR_PARAM_BUFDYN_PAYLOAD_HIGH (1 << 6)
125 #define ERR_PARAM_BUFSTAT_FRAMEID_INVALID (1 << 7)
126 #define ERR_PARAM_BUFSTAT_PAYLOAD_HIGH (1 << 8)
127 #define ERR_PARAM_BUF_TOTAL_PAYLOAD_HIGH (1 << 9)
128 #define ERR_PARAM_BUFDYN_CHANNELS (1 << 10)
129 #define ERR_PARAM_BUFFIFO_PAYLOAD_HIGH (1 << 12)
130 #define ERR_PARAM_BUFFIFO_FIDMASK_DIFFERS (1 << 13)
131 #define ERR_PARAM_BUFFIFO_PPIT (1 << 14)
132 #define ERR_PARAM_BUFFIFO_REJNULLFR_DIFFERS (1 << 15)
133 #define ERR_PARAM_BUFFIFO_REJSTATFR_DIFFERS (1 << 16)
134 #define ERR_PARAM_BUFFIFO_SLOTID_DIFFERS (1 << 17)
136 /* Buffer reconfiguration parameters errors */
137 #define ERR_PARAM_INVALID_FRAME_ID (1 << 1)
138 #define ERR_PARAM_INVALID_CHANNEL (1 << 2)
139 #define ERR_PARAM_RECONFIG_NOT_ALLOWED (1 << 3)
140 #define ERR_PARAM_NO_BUFFER_FOUND (1 << 4)
141 #define ERR_PARAM_PAYLOAD_TOO_BIG (1 << 5)
144 /* Error codes for controller initialization */
145 #define FR_INIT_ERR_BAD_PARAM (1 << 26)
146 #define FR_INIT_ERR_CLUSTER_CONFIG (1 << 27)
147 #define FR_INIT_ERR_NODE_CONFIG (1 << 28)
148 #define FR_INIT_ERR_MSGRAM_CONFIG (1 << 29)
149 #define FR_INIT_ERR_BUFFPARAM_CONFIG (1 << 30)
150 #define FR_INIT_ERR_BUFF_CONFIG (1 << 31)
152 /* Error flags for startup failures */
153 #define FR_STARTUP_ERR_SW_STUP_FOLLOW (1 << 26)
154 #define FR_STARTUP_ERR_CSINH_DIS (1 << 27)
155 #define FR_STARTUP_ERR_SW_STUP_READY (1 << 28)
156 #define FR_STARTUP_ERR_SW_STUP_AS_NCOLD (1 << 29)
158 /* TMS570 FlexRay related constants */
159 #define FR_MAX_BUFFERS_CNT 128
160 #define FR_FCS_LISTEN_TIMEOUT 10000000U
162 /* Macros with constants for FlexRay POC status, read from CCEV register */
163 #define FR_POCS_DEFAULT_CONFIG 0x0
164 #define FR_POCS_READY 0x1
165 #define FR_POCS_NORMAL_ACTIVE 0x2
166 #define FR_POCS_NORMAL_PASSIVE 0x3
167 #define FR_POCS_HALT 0x4
168 #define FR_POCS_MONITOR_MODE 0x5
169 #define FR_POCS_LOOPBACK 0xD
170 #define FR_POCS_CONFIG 0xF
171 #define FR_POCS_WAKEUP_STANDBY 0x10
172 #define FR_POCS_WAKEUP_LISTEN 0x11
173 #define FR_POCS_WAKEUP_SEND 0x12
174 #define FR_POCS_WAKEUP_DETECT 0x13
175 #define FR_POCS_STARTUP_PREPARE 0x20
176 #define FR_POCS_COLDSTART_LISTEN 0x21
177 #define FR_POCS_COLDSTART_COLLISION_RESOLUTION 0x22
178 #define FR_POCS_COLDSTART_CONSISTENCY_CHECK 0x23
179 #define FR_POCS_COLDSTART_GAP 0x24
180 #define FR_POCS_COLDSTART_JOIN 0x25
181 #define FR_POCS_INTEGRATION_COLDSTART_CHECK 0x26
182 #define FR_POCS_INTEGRATION_LISTEN 0x27
183 #define FR_POCS_INTEGRATION_CONSISTENCY_CHECK 0x28
184 #define FR_POCS_INITIALIZE_SCHEDULE 0x29
185 #define FR_POCS_ABORT_STARTUP 0x2A
187 /* Macros with constants for Wakeup status read from CCEV register */
188 #define FR_WSV_UNDEFINED 0x0
189 #define FR_WSV_RECEIVED_HEADER 0x1
190 #define FR_WSV_RECEIVED_WUP 0x2
191 #define FR_WSV_COLLISION_HEADER 0x3
192 #define FR_WSV_COLLISION_WUP 0x4
193 #define FR_WSV_COLLISION_UNKNOWN 0x5
194 #define FR_WSV_TRANSMITTED 0x6
196 /* Macros with constants for SPI communication with the bus controller */
197 #define FRAY_SPICMD_INIT_VAL 0xFFFF
198 #define FRAY_NUM_PORTS 2
200 /* Macros with flags for buffers configuration */
201 #define FRAY_BUF_MBI_EN 0x01
202 #define FRAY_BUF_MBI_DIS 0x00
203 #define FRAY_BUF_TX_MODE_CONTINUOUS 0x02
204 #define FRAY_BUF_TX_MODE_SINGLE 0x00
205 #define FRAY_BUF_NM_EN 0x04
206 #define FRAY_BUF_NM_DIS 0x00
207 #define FRAY_BUF_TX 0x08
208 #define FRAY_BUF_RX 0x00
209 #define FRAY_BUF_CHB_EN 0x10
210 #define FRAY_BUF_CHB_DIS 0x00
211 #define FRAY_BUF_CHA_EN 0x20
212 #define FRAY_BUF_CHA_DIS 0x00
213 #define FRAY_BUF_SFI_EN 0x40
214 #define FRAY_BUF_SFI_DIS 0x00
215 #define FRAY_BUF_SYNC_EN 0x80
216 #define FRAY_BUF_SYNC_DIS 0x00
217 #define FRAY_BUF_REJECT_NULL_FRAMES 0x100
218 #define FRAY_BUF_ACCEPT_NULL_FRAMES 0x000
219 #define FRAY_BUF_REJECT_STATIC_SEGMENT 0x200
220 #define FRAY_BUF_ACCEPT_STATIC_SEGMENT 0x000
221 #define FRAY_BUF_TXREQ_EN 0x800
222 #define FRAY_BUF_TXREQ_DIS 0x000
224 #define FR_CLUSTER_PARAMS_CNT 25
225 #define FR_NODE_PARAMS_CNT 26
226 #define FR_MSGRAM_PARAMS_CNT 5
227 #define FR_STATIC_BUF_PARAMS_CNT 8
228 #define FR_DYNAMIC_BUF_PARAMS_CNT 7
229 #define FR_FIFO_BUF_PARAMS_CNT 6
231 * This structure represents global FlexRay cluster parameters.
232 * Values of all those parameters have to be equal for all nodes in cluster.
234 typedef struct Fr_TMS570LS_ClusterConfigType_st {
235 /* Protocol relevant parameters */
236 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. */
237 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. */
238 uint8_t gdCASRxLowMax; /**< Upper limit of the CAS acceptance window. Range 67-99 MT. */
239 uint8_t gdDynamicSlotIdlePhase; /**< Duration of the idle phase within a dynamic slot. Range 0-2 Minislots. */
240 uint8_t gdMinislot; /**< Duration of a minislot. Range 2-63 MT */
241 uint8_t gdMinislotActionPointOffset; /**< Number of macroticks the minislot action point is offset from the beginning of a minislot. Range 1-31 MT. */
242 uint16_t gdStaticSlot; /**< Duration of a static slot. Range 4-661 MT. */
243 uint8_t gdTSSTransmitter; /**< Number of bits in the Transmission Start Sequence. Range 3-15 gdBit. */
244 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.*/
245 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. */
246 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. */
247 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. */
248 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. */
249 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. */
250 uint16_t gMacroPerCycle; /**< Number of macroticks in a communication cycle. Range 10-16000 MT. */
251 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 */
252 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.*/
253 uint16_t gNumberOfMinislots; /**< Number of minislots in the dynamic segment. Range 0-7986. */
254 uint16_t gNumberOfStaticSlots; /**< Number of static slots in the static segment. Range 2 - cStaticSlotIDMax. */
255 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. */
256 uint8_t gPayloadLengthStatic; /**< Payload length of a static frame. Range 0 - cPayloadLengthMax two-byte-words. */
257 uint8_t gSyncNodeMax; /**< Maximum number of nodes that may send frames with the sync frame indicator bit set to one. Range 2 - cSyncNodeMax. */
258 /* Protocol related parameters */
259 uint16_t gdNIT; /**< Duration of the Network Idle Time. Range 2-805 MT. */
260 uint8_t gdSampleClockPeriod; /**< Sample clock period. 0 = 0.0125, 1 = 0.025, 2 = 0.05 us. */
261 uint8_t gNetworkManagementVectorLength; /**< Length of the Network Management vector in a cluster. Range 0-12 bytes */
262 } Fr_TMS570LS_ClusterConfigType;
265 * This structure represents local parameters of FlexRay node.
267 typedef struct Fr_TMS570LS_NodeConfigType_st {
268 /* Protocol relevant */
269 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). */
270 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. */
271 Fr_ChannelType pChannels; /**< Channels to which the node is connected. */
272 uint16_t pdAcceptedStartupRange; /**< Expanded range of measured clock deviation allowed for startup frames during integration. Range 0-1875 uT. */
273 uint8_t pClusterDriftDamping; /**< Local cluster drift damping factor used for rate correction. Range 0-20 uT*/
274 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*/
275 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*/
276 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. */
277 uint16_t pdMaxDrift; /**< Maximum drift offset between two nodes that operate with unsynchronized clocks over one communication cycle. Range 2-1923 uT. */
278 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. */
279 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. */
280 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. */
281 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. */
282 uint16_t pLatestTx; /**< Number of the last minislot in which a frame transmission can start in the dynamic segment. Range 0-7980 Minislot. */
283 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. */
284 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. */
285 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. */
286 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. */
287 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 */
288 uint16_t pRateCorrectionOut; /**< Magnitude of the maximum permissible rate correction value. Range 2-1923 uT. */
289 uint16_t pOffsetCorrectionOut; /**< Holds the maximum permitted offset correction value to be applied by the internal clock synchronization algorithm. Range 5-3BA2 uT. */
290 boolean_t pSingleSlotEnabled; /**< Flag indicating whether or not the node shall enter single slot mode following startup. */
291 Fr_ChannelType pWakeupChannel; /**< Channel used by the node to send a wakeup pattern. Range A, B. */
292 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. */
293 /* Protocol related */
294 uint8_t pSamplesPerMicrotick; /**< Number of samples per microtick. Range 1,2,4. */
295 uint8_t pDecodingCorrection; /**< Decoding correction (in microticks). Range 0xF - 0x8F. */
296 } Fr_TMS570LS_NodeConfigType;
299 * This structure provides parameters for buffer configuration.
301 typedef struct Fr_TMS570LS_BufferConfigType_st {
302 uint32_t slotId; /**< Index of the slot in which this buffer will transfer or receive data. */
303 uint8_t maxPayload; /**< Maximum data payload in buffer in 2-bytes-words. If lower than global payload maximum value, padding bytes are inserted (zeros). */
304 Fr_ChannelType channel; /**< Channel filter control. A&B should not be seleceted for dynamic segment. */
305 uint8_t cycleCounterFiltering; /**< Cycle counter filter control. */
306 boolean_t isTx; /**< Tx or Rx buffer selector */
307 boolean_t singleTransmit; /**< Single-shot or continuous mode selector */
308 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) */
309 uint16_t fidMask; /**< USED ONLY FOR FIFO - specifies which of the corresponding frame ID filter bits are relevant for rejection filtering. 1 - ignore the fid bit, 0 - consider the fid bit */
310 boolean_t rejectNullFrames; /**< USED ONLY FOR FIFO - Reject every NULL frames. */
311 boolean_t rejectStaticSegment; /**< USED ONLY FOR FIFO - Accept only static segment frames. */
312 boolean_t msgBufferInterrupt; /**< Enables TX/RX interrupt for corresponding buffer*/
313 } Fr_TMS570LS_BufferConfigType;
316 FR_SB_RECONFIG_ENABLED,
317 FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED,
318 FR_SB_ALL_REC_DISABLED,
319 FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED
320 } Fr_TMS570LS_SecureBuffersType;
323 * This data type reflect state of the FlexRay driver.
326 FR_ST_DRV_NOT_INITIALIZED, /**< No initialization procedure was performed, Fr_Init has to be processed at first. */
327 FR_ST_DRV_INITIALIZED, /**< Fr_Init procedure was performed, Fr_ControllerInit has to be processed now. */
328 FR_ST_CTRL_INITIALIZED /**< Fr_ControllerInit procedure was performed, driver and controller is ready for other actions */
329 } Fr_TMS570LS_DriverState;
332 * This structure contains the definition of the message RAM
333 * configuration parameters.
335 typedef struct Fr_TMS570LS_MsgRAMConfig_st {
336 uint8_t statSegmentBufferCount; /**< Number of buffers for static segment */
337 uint8_t dynSegmentBufferCount; /**< Number of bufferes for dynamic segment */
338 uint8_t fifoBufferCount; /**< Number of buffers for Rx fifo */
339 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. */
340 Fr_TMS570LS_SecureBuffersType secureBuffers; /**< Secure buffers against reconfiguration selector */
341 } Fr_TMS570LS_MsgRAMConfig;
343 * This type contains the definition of the implementation-specific
344 * post build configuration structure for FlexRay driver in TMS570LS MCU.
346 typedef struct Fr_TMS570LS_ConfigType_st {
347 const Fr_TMS570LS_ClusterConfigType *clusterConfiguration;
348 const Fr_TMS570LS_NodeConfigType *nodeConfiguration;
349 const Fr_TMS570LS_MsgRAMConfig *msgRAMConfig;
350 const Fr_TMS570LS_BufferConfigType *staticBufferConfigs;
351 const Fr_TMS570LS_BufferConfigType *dynamicBufferConfigs;
352 const Fr_TMS570LS_BufferConfigType *fifoBufferConfigs;
356 * @brief Initalizes the Fr.
358 * The function Fr_Init shall internally store the configuration
359 * address to enable subsequent API calls to access the configuration.
361 * @param [in] Fr_ConfigPtr Address to an Fr dependant configuration structure
362 * that contains all information for operating the Fr subsequently.
364 void Fr_Init(const Fr_ConfigType *Fr_ConfigPtr);
367 * @brief Initializes a FlexRay CC.
369 * The function Fr_ControllerInit shall perform the following tasks
370 * on FlexRay CC Fr_CtrIdx:
371 * 1. Switch CC into ‘POC:config’ (from any other POCState).
372 * 2. Configure all FlexRay cluster and node configuration parameters (e.g., cycle
373 * length, macrotick duration).
374 * 3. Configure all transmit/receive resources (e.g., buffer initialization) according to
375 * the frame triggering configuration parameters contained in the FrIf.
376 * 4. Switch CC into ‘POC:ready’
379 * @param [in] Fr_ConfigPtr Index of FlexRay CC within the context of the FlexRay Driver.
380 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
382 Std_ReturnType Fr_ControllerInit(uint8_t Fr_CtrlIdx);
385 * @brief Starts communication.
387 * The function Fr_StartCommunication shall perform the following
388 * tasks on FlexRay CC Fr_CtrIdx:
389 * 1. Invoke the CC CHI command ‘RUN’, which initiates the startup procedure
390 * within the FlexRay CC.
393 * The function call of Fr_StartCommunication changes the CC POCState to
394 * POC:startup which is a transitional state. In the case when communication startup
395 * succeeds, the CC wil change the POCState to ‘POC:normal active’ or ‘POC:normal
396 * passive’. It is not guaranteed that the FlexRay CC will reside in the ‘POC:normal
397 * active’ or ‘POC:normal passive’ state after a call of the function
398 * Fr_StartCommunication.
400 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
401 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
403 Std_ReturnType Fr_StartCommunication(uint8_t Fr_CtrlIdx);
406 * @brief Invokes the CC CHI command ‘ALLOW_COLDSTART’.
408 * The function Fr_AllowColdstart shall perform the following tasks
409 * on FlexRay CC Fr_CtrIdx:
410 * 1. Invoke the CC CHI command ‘ALLOW_COLDSTART’.
413 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
414 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
416 Std_ReturnType Fr_AllowColdstart(uint8_t Fr_CtrlIdx);
419 * @brief Invokes the CC CHI command 'ALL_SLOTS'.
421 * The function Fr_AllSlots shall perform the following tasks on
422 * FlexRay CC Fr_CtrIdx:
423 * 1. Invoke the CC CHI command ‘ALL_SLOTS’, which requests a switch from key
424 * slot only mode to all slots transmission mode at the beginning of the next
425 * communication cycle.
428 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
429 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
431 Std_ReturnType Fr_AllSlots(uint8_t Fr_CtrlIdx);
434 * @brief Invokes the CC CHI command 'DEFERRED_HALT'.
436 * The function Fr_HaltCommunication shall perform the following
437 * tasks on FlexRay CC Fr_CtrIdx:
438 * 1. Invoke the CC CHI command ‘DEFERRED_HALT’.
441 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
442 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
445 Std_ReturnType Fr_HaltCommunication(uint8_t Fr_CtrlIdx);
448 * @brief Invokes the CC CHI command ‘FREEZE‘.
450 * The function Fr_AbortCommunication shall perform the
451 * following tasks on FlexRay CC Fr_CtrIdx:
452 * 1. Invoke the CC CHI command ‘FREEZE’, which immediately aborts
453 * communication (if active) and changes to the POC:halt state from any
457 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
458 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
460 Std_ReturnType Fr_AbortCommunication(uint8_t Fr_CtrlIdx);
463 * @brief Invokes the CC CHI command ‘WAKEUP‘.
465 * The function Fr_SendWUP shall perform the following tasks on
466 * FlexRay CC Fr_CtrIdx:
467 * 1. Invoke the CC CHI command ‘WAKEUP’, which initiates the wakeup
468 * transmission procedure on the configured FlexRay channel.
471 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
472 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
474 Std_ReturnType Fr_SendWUP(uint8_t Fr_CtrlIdx);
477 * @brief Sets a wakeup channel.
479 * The function Fr_SetWakeupChannel shall perform the following
480 * tasks on FlexRay CC Fr_CtrIdx:
481 * 1. Change the CC’s POCState to POC:config by invoking the CHI command
483 * 2. Configure the wakeup channel according to parameter Fr_ChnlIdx.
484 * 3. Change the CC’s POCState to POC:ready again by invoking the CHI
485 * command ‘CONFIG_COMPLETE’.
488 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
489 * @param [in] Fr_ChnlIdx Index of FlexRay channel within the context of the FlexRay CC
490 * Fr_CtrlIdx. Valid values are FR_CHANNEL_A and FR_CHANNEL_B.
491 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
494 Std_ReturnType Fr_SetWakeupChannel(uint8_t Fr_CtrlIdx, Fr_ChannelType Fr_ChnlIdx);
497 * @brief Gets the POC status.
499 * The function Fr_GetPOCStatus shall perform the following
500 * tasks on FlexRay CC Fr_CtrIdx:
501 * 1. Query the CC’s actual POC status by reading the CHI variable ‘vPOC’ and
502 * write the result to parameter Fr_POCStatusPtr.
505 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
506 * @param [out] Fr_POCStatusPtr Address the output value is stored to.
507 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
509 Std_ReturnType Fr_GetPOCStatus(uint8_t Fr_CtrlIdx, Fr_POCStatusType *Fr_POCStatusPtr);
512 * @brief Transmits data on the FlexRay network.
514 * The function Fr_TransmitTxLPdu shall perform the following
515 * tasks on FlexRay CC Fr_CtrIdx:
516 * 1. Figure out the physical resource (e.g., a buffer) mapped to the transmission of
517 * the FlexRay frame identified by Fr_LPduIdx.
518 * 2. If the transmit Lpdu supports dynamic payload length (configuration parameter
519 * FrIfAllowDynamicLSduLength is set to true), then the transmission
520 * resource shall be reconfigured to match the payload length Fr_LsduLength
521 * passed to the API. Note that the dynamic payload length is only applicable to
522 * frames within the dynamic FlexRay segment.
523 * 3. Copy Fr_LsduLength bytes from address Fr_LsduPtr into the FlexRay CC’s
524 * transmission resource and then activate it for transmission.
527 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
528 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame buffer.
529 * @param [in] Fr_LSduPtr This reference points to a buffer where the assembled LSdu to be
530 * transmitted within this LPdu is stored at.
531 * @param [in] Fr_LSduLength Determines the length of the data (in Bytes) to be transmitted.
532 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
534 Std_ReturnType Fr_TransmitTxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, const uint8_t *Fr_LSduPtr, uint8_t Fr_LSduLength);
537 * @brief Cancels the already pending transmission of a LPdu contained in a controllers physical transmit resource (e.g. message buffer).
539 * The function Fr_CancelTxLPdu shall perform the following tasks
540 * on FlexRay CC Fr_CtrIdx:
541 * 1. Figure out the physical resource (e.g., a buffer) mapped to the transmission of
542 * the FlexRay frame identified by Fr_LpduIdx.
543 * 2. If the physical resource figured out is actively pending for transmission, then
544 * the transmit request of this particular resource shall be terminated and E_OK
545 * returned. If no transmission is pending E_NOT_OK shall be returned,
546 * indicating that no such cancelation took place.
548 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
549 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
550 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
552 Std_ReturnType Fr_CancelTxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx);
555 * @brief Receives data from the FlexRay network.
557 * The function Fr_ReceiveRxLPdu shall perform the following
558 * tasks on FlexRay CC Fr_CtrIdx:
559 * 1. Figure out the physical resource (e.g., a buffer, a receive-FIFO) mapped to the
560 * reception of the FlexRay frame as identified by Fr_LpduIdx.
561 * 2. Figure out whether a new FlexRay frame instance has been received within
562 * the receive resource as figured in bullet 1. If the receive resource is a FIFO,
563 * then consume the first element out of the FIFO.
564 * 3. If a new FlexRay frame has been accepted, then copy the received payload
565 * data to address Fr_LsduPtr, store the number of bytes copied to
566 * Fr_LsduLengthPtr and store the status FR_RECEIVED to
567 * Fr_RxLPduStatusPtr. If a FIFO is used as received resource and the FIFO is
568 * not empty, then store the status FR_RECEIVED_MORE_DATA_AVAILABLE
569 * to Fr_RxLPduStatusPtr.
570 * 4. If no new frame has been accepted, then do not copy any payload data to
571 * Fr_LsduPtr, write 0 to the parameter Fr_LsduLengthPtr and store the status
572 * FR_NOT_RECEIVED to Fr_RxLPduStatusPtr.
575 * Only reconfigurable message buffers can be canceled.
577 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
578 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame buffer.
579 * @param [out] Fr_LSduPtr This reference points to the buffer where the LSdu to be received shall be stored.
580 * @param [out] Fr_LPduStatusPtr This reference points to the memory location where the status of the LPdu shall be stored.
581 * @param [out] Fr_LSduLengthPtr This reference points to the memory location where the length
582 * of the LSdu (in bytes) shall be stored. This length represents
583 * the number of bytes copied to Fr_LSduPtr.
584 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
586 Std_ReturnType Fr_ReceiveRxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, uint8_t *Fr_LSduPtr, Fr_RxLPduStatusType *Fr_LPduStatusPtr, uint8_t *Fr_LSduLengthPtr);
589 * @brief Checks the transmit status of the LSdu.
591 * The function Fr_CheckTxLPduStatus shall perform the following
592 * tasks on FlexRay CC Fr_CtrIdx:
593 * 1. Figure out the physical resource (e.g., a buffer) mapped to the transmission of
594 * the FlexRay frame identified by Fr_LpduIdx.
595 * 2. Check whether the transmission resource as figured in bullet 1 is pending for
597 * 3. If a transmission request is pending, then store the status
598 * FR_NOT_TRANSMITTED to Fr_TxLPduStatusPtr.
599 * 4. If no transmission request is pending, then store the status
600 * FR_TRANSMITTED to Fr_TxLPduStatusPtr.
603 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
604 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame buffer.
605 * @param [out] Fr_LPduStatusPtr This reference points to the memory location where the status of the LPdu shall be stored.
606 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
608 Std_ReturnType Fr_CheckTxLPduStatus(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, Fr_TxLPduStatusType *Fr_TxLPduStatusPtr);
612 * @brief Prepares a LPdu.
614 * Function Fr_Init must be called at first to initialize global arrays Fr_BuffersPtrs and Fr_BufferConfigured.
615 * Fr_BuffersPtrs contains configuratin data for all buffers and Fr_BufferConfigured holds flags to check if the buffer
616 * was or was not configured by some previous calling of this function.
618 * Buffers are identified the frame ID on which they should receive or transmit data. The function has to find an index of
619 * the buffer in the Fr_BuffersPtrs array. When match between FrameID in the array and Fr_LPduIdx is found, the function
620 * configures this buffer and then continues to find others occurences of the same frame ID in the array of config data.
622 * The function controlls if the buffer was or was not configured by some previous functin call. Already configured buffers
623 * are skipped. For buffer reconfiguration (if allowed) is designed fuction Fr_ReconfigLPdu.
625 * The right procedure to configure static/dynamic buffers or FIFO buffers is launched according to the index of the buffer and
626 * data stored in message RAM configuration register.
628 * The function Fr_PrepareLPdu shall perform the following tasks
629 * on FlexRay CC Fr_CtrIdx:
630 * 1. Figure out the physical resource (e.g., a buffer) mapped to the processing of
631 * the FlexRay frame identified by Fr_LpduIdx.
632 * 2. Configure the physical resource (a buffer) appropriate for Fr_LpduIdx
633 * operation (SlotId, Cycle filter, payload length, header CRC, etc.) if the MCG
634 * uses the reconfiguration feature9.
637 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
638 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
639 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
641 Std_ReturnType Fr_PrepareLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx);
644 * @brief Reconfigures a given LPdu according to the parameters (FrameId, Channel, CycleRepetition, CycleOffset, PayloadLength, HeaderCRC) at runtime.
646 * The function Fr_ReconfigLPdu shall perform the following tasks
647 * on FlexRay CC Fr_CtrIdx:
648 * 1. Figure out the physical resource (e.g., a buffer) mapped to the processing of
649 * the FlexRay frame as identified by Fr_LpduIdx.
650 * 2. Configure the physical resource (a buffer) according to the parameters given
651 * at the API. The Lpdu direction is statically associated with the Lpdu and
652 * cannot be changed by this service.
655 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
656 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame buffer.
657 * @param [in] Fr_FrameId FlexRay Frame ID the FrIf_LPdu shall be configured to.
658 * @param [in] Fr_ChnlIdx FlexRay Channel the FrIf_LPdu shall be configured to.
659 * @param [in] Fr_CycleRepetition Cycle Repetition part of the cycle filter mechanism (1,2,4,8,16,32,64 is allowed)
660 * @param [in] Fr_CycleOffset Cycle Offset part of the cycle filter mechanism (0 - Fr_CycleRepetition-1 is allowed)
661 * @param [in] Fr_PayloadLength Payloadlength in units of bytes the FrIf_LPduIdx shall be configured to.
662 * @param [in] Fr_HeaderCRC This parameter is not used. CRC is calculated automaticaly inside the function.
663 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
665 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);
669 * @brief Disables the hardware resource of a LPdu for transmission/reception.
671 * The function Fr_DisableLPdu shall perform the following tasks
672 * on FlexRay CC Fr_CtrIdx:
673 * 1. Figure out the physical resource (e.g., a buffer) mapped to the processing of
674 * the FlexRay frame identified by Fr_LpduIdx.
675 * 2. Configure the physical resource (a buffer) in a way that it doesn’t take part in
676 * the transmission/reception process.
679 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
680 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame buffer.
681 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
683 Std_ReturnType Fr_DisableLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx);
686 * @brief Gets the current global FlexRay time.
688 * The function Fr_GetGlobalTime shall perform the following
689 * tasks on FlexRay CC Fr_CtrIdx:
690 * 1. Read the current global FlexRay time and write it to the output parameters
691 * Fr_CyclePtr and Fr_MacrotickPtr.
694 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
695 * @param [in] Fr_LPduIdx This index is used to uniquely identify a FlexRay frame.
696 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
698 Std_ReturnType Fr_GetGlobalTime(uint8_t Fr_CtrlIdx, uint8_t *Fr_CyclePtr, uint16_t *Fr_MacroTickPtr);
701 * @brief Gets the network management vector of the last communication cycle.
703 * The function Fr_GetNmVector shall perform the following tasks
704 * on FlexRay CC Fr_CtrIdx:
705 * 1. Read the current accrued network management vector out of the FlexRay CC
706 * and then write it to the output parameter Fr_NmVectorPtr. The number of
707 * bytes written to the output parameter is constant and is known at configuration
708 * time (FrIf configuration parameter FrIfGNetworkManagementVectorLength).
711 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
712 * @param [out] Fr_NmVectorPtr Address where the NmVector of the last communication cycle shall be stored.
713 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
715 Std_ReturnType Fr_GetNmVector(uint8_t Fr_CtrlIdx, uint8_t *Fr_NmVectorPtr);
718 * @brief Gets the current number of startup frames seen on the cluster.
720 * The function Fr_GetNumOfStartupFrames shall perform the
721 * following tasks on FlexRay CC Fr_CtrIdx:
722 * 1. Read the number of aligned startup frame pairs received or transmitted during
723 * the previous double cycle, aggregated across both channels and write it to the
724 * output parameter Fr_NumOfStartupFramesPtr.
727 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
728 * @param [out] Fr_NumOfStartupFramesPtr Address where the number of startup frames seen within the last even/odd cycle pair shall be stored.
729 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
731 Std_ReturnType Fr_GetNumOfStartupFrames(uint8_t Fr_CtrlIdx, uint8_t *Fr_NumOfStartupFramesPtr);
734 * @brief Gets the current number of startup frames seen on the cluster.
736 * The function Fr_GetChannelStatus shall perform the following
737 * tasks on FlexRay CC Fr_CtrIdx:
738 * 1. Read the aggregated channel status, NIT status, symbol window status and
739 * write it to the output parameter Fr_ChannelAStatusPtr/ Fr_ChannelBStatusPtr.
740 * The value of *Fr_ChannelAStatusPtr / *Fr_ChannelBStatusPtr is bitcoded with
741 * the following meaning (Bit 0 = LSB, Bit 15 = MSB)13:
742 * Bit 0: Channel A/B aggregated channel status vSS!ValidFrame
743 * Bit 1: Channel A/B aggregated channel status vSS!SyntaxError
744 * Bit 2: Channel A/B aggregated channel status vSS!ContentError
745 * Bit 3: Channel A/B aggregated channel status additional communication
746 * Bit 4: Channel A/B aggregated channel status vSS!Bviolation
747 * Bit 5: Channel A/B aggregated channel status vSS!TxConflict
748 * Bit 6: Not used (0)
749 * Bit 7: Not used (0)
750 * Bit 8: Channel A/B symbol window status data vSS!ValidMTS
751 * Bit 9: Channel A/B symbol window status data vSS!SyntaxError
752 * Bit 10: Channel A/B symbol window status data vSS!Bviolation
753 * Bit 11: Channel A/B symbol window status data vSS!TxConflict
754 * Bit 12: Channel A/B NIT status data vSS!SyntaxError
755 * Bit 13: Channel A/B NIT status data vSS!Bviolation
756 * Bit 14: Not used (0)
757 * Bit 15: Not used (0)
758 * 2. Reset the aggregated channel status information within the FlexRay controller.
761 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
762 * @param [out] Fr_ChannelAStatusPtr Address where the bitcoded channel A status information shall be stored.
763 * @param [out] Fr_ChannelBStatusPtr Address where the bitcoded channel B status information shall be stored.
764 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
766 Std_ReturnType Fr_GetChannelStatus(uint8_t Fr_CtrlIdx, uint16_t *Fr_ChannelAStatusPtr, uint16_t *Fr_ChannelBStatusPtr);
769 * @brief Gets the current clock correction values.
771 * The function Fr_GetClockCorrection shall perform the following
772 * tasks on FlexRay CC Fr_CtrIdx:
773 * 1. Read the rate correction value (vInterimRateCorrection14) and write it as
774 * signed integer to the output parameter Fr_RateCorrectionPtr. Read the offset
775 * correction value (vInterimOffsetCorrection15) and write it as signed integer to
776 * the output parameter Fr_OffsetCorrectionPtr
779 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
780 * @param [out] Fr_RateCorrectionPtr Address where the current rate correction value shall be stored.
781 * @param [out] Fr_OffsetCorrectionPtr Address where the current offset correction value shall be stored.
782 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
784 Std_ReturnType Fr_GetClockCorrection(uint8_t Fr_CtrlIdx, int16_t *Fr_RateCorrectionPtr, int32_t *Fr_OffsetCorrectionPtr);
787 * @brief Gets a list of syncframes received or transmitted on channel A and channel B via the even and odd communication cycle.
789 * The function Fr_ GetSyncFrameList shall perform the following
790 * tasks on FlexRay CC Fr_CtrIdx:
791 * 1. Read the list of syncframes received in the last even communication cycle on
792 * channel A and write it as array to the memory location
793 * Fr_ChannelAEvenListPtr.
794 * Read the list of syncframes received in the last even communication cycle on
795 * channel B and write it as array to the memory location
796 * Fr_ChannelBEvenListPtr.
797 * Read the list of syncframes received in the last odd communication cycle on
798 * channel A and write it as array to the memory location
799 * Fr_ChannelAOddListPtr.
800 * Read the list of syncframes received in the last odd communication cycle on
801 * channel B and write it as array to the memory location
802 * Fr_ChannelBOddListPtr.
805 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
806 * @param [in] Fr_ListSize Size of the arrays passed via parameters:
807 * Fr_ChannelAEvenListPtr
808 * Fr_ChannelBEvenListPtr
809 * Fr_ChannelAOddListPtr
810 * Fr_ChannelBOddListPtr.
811 * The service must ensure to not write more entries into those arrays than granted by this parameter.
812 * @param [out] Fr_ChannelAEvenListPtr Address the list of syncframes on channel A within the
813 * even communication cycle is written to. The exact
814 * number of elements written to the list is limited by
815 * parameter Fr_ListSize.
816 * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
817 * @param [out] Fr_ChannelBEvenListPtr Address the list of syncframes on channel B within the
818 * even communication cycle is written to. The exact
819 * number of elements written to the list is limited by
820 * parameter Fr_ListSize.
821 * @param [out] Fr_ChannelAOddListPtr Address the list of syncframes on channel A within the
822 * odd communication cycle is written to. The exact number
823 * of elements written to the list is limited by parameter
825 * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
826 * @param [out] Fr_ChannelBOddListPtr Address the list of syncframes on channel B within the
827 * odd communication cycle is written to. The exact number
828 * of elements written to the list is limited by parameter
830 * Unused list elements are filled with the value '0' to indicate that no more syncframe has been seen.
831 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
833 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);
836 * @brief Gets the wakeup received information from the FlexRay controller.
838 * The function Fr_GetWakeupRxStatus shall perform the
839 * following tasks on FlexRay CC Fr_CtrIdx:
840 * 1. Read the wakeup pattern received indicators for channel A and channel B and
841 * write it to the output parameter Fr_WakeupRxStatusPtr. The value of
842 * *Fr_WakeupRxStatusPtr is bitcoded with the following meaning (Bit 0 = LSB,
844 * Bit 0: Wakeup pattern received on channel A (1), otherwise (0)
845 * Bit 1: Wakeup pattern received on channel B (1), otherwise (0)
846 * Bit 2: Not used (always 0)
847 * Bit 3: Not used (always 0)
848 * Bit 4: Not used (always 0)
849 * Bit 5: Not used (always 0)
850 * Bit 6: Not used (always 0)
851 * Bit 7: Not used (always 0)
852 * 2. Reset the wakeup received indication status information within the FlexRay
856 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
857 * @param [out] Fr_WakeupRxStatusPtr Address where bitcoded wakeup reception status shall be stored.
858 * Bit 0: Wakeup received on channel A indicator
859 * Bit 1: Wakeup received on channel B indicator
861 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
863 Std_ReturnType Fr_GetWakeupRxStatus(uint8_t Fr_CtrlIdx, uint8_t *Fr_WakeupRxStatusPtr);
866 * @brief Sets the absolute FlexRay timer.
868 * The function Fr_SetAbsoluteTimer shall perform the following
870 * 1. Program the absolute FlexRay timer Fr_AbsTimerIdx according to the
871 * parameters Fr_Cycle and Fr_Offset.
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 * @param [in] Fr_Cycle Absolute cycle the timer shall elapse in.
877 * @param [in] Fr_Offset Offset within cycle Fr_Cycle in units of macrotick the timer shall elapse at.
878 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
880 Std_ReturnType Fr_SetAbsoluteTimer(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx, uint8_t Fr_Cycle, uint16_t Fr_Offset);
884 * @brief Stops an absolute timer.
886 * The function Fr_CancelAbsoluteTimer shall perform the
888 * 1. Stop the absolute timer Fr_AbsTimerIdx.
891 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
892 * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
893 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
895 Std_ReturnType Fr_CancelAbsoluteTimer(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
898 * @brief Enables the interrupt line of an absolute timer.
900 * The function Fr_EnableAbsoluteTimerIRQ shall perform the
902 * 1. Enable the interrupt line related to timer Fr_AbsTimerIdx.
905 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
906 * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
907 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
909 Std_ReturnType Fr_EnableAbsoluteTimerIRQ(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
913 * @brief Resets the interrupt condition of an absolute timer.
915 * The function Fr_AckAbsoluteTimerIRQ shall perform the
917 * 1. Reset the interrupt condition of absolute timer Fr_AbsTimerIdx.
920 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
921 * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
922 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
924 Std_ReturnType Fr_AckAbsoluteTimerIRQ(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
927 * @brief Disables the interrupt line of an absolute timer.
929 * The function Fr_DisableAbsoluteTimerIRQ shall perform the
931 * 1. Disable the interrupt line related to absolute timer Fr_AbsTimerIdx.
934 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
935 * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
936 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
938 Std_ReturnType Fr_DisableAbsoluteTimerIRQ(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx);
941 * @brief Gets IRQ status of an absolute timer.
943 * The function Fr_GetAbsoluteTimerIRQStatus shall perform the
945 * 1. Check whether the interrupt of absolute timer Fr_AbsTimerIdx is pending.
946 * Write TRUE to output parameter Fr_IRQStatusPtr in case the interrupt is
947 * pending, FALSE otherwise.
950 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
951 * @param [in] Fr_AbsTimerIdx Index of absolute timer within the context of the FlexRay CC.
952 * @param [out] Fr_IRQStatusPtr Address the output value is stored to.
953 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
955 Std_ReturnType Fr_GetAbsoluteTimerIRQStatus(uint8_t Fr_CtrlIdx, uint8_t Fr_AbsTimerIdx, boolean_t *Fr_IRQStatusPtr);
958 * @brief Returns the version information of this module.
960 * @param [out] VersioninfoPtr Pointer to where to store the version information of this module.
962 void Fr_GetVersionInfo(Std_VersionInfoType *VersioninfoPtr);
966 * @brief Reads a FlexRay protocol configuration parameter for a particular FlexRay controller out of the module's configuration.
968 * The function Fr_ReadCCConfig shall perform the following tasks:
969 * 1. Read the value of the configuration parameter requested by
970 * Fr_ConfigParamIdx from the configuration and write it to output parameter Fr_ConfigParamValuePtr.
973 * @param [in] Fr_CtrlIdx Index of FlexRay CC within the context of the FlexRay Driver.
974 * @param [in] Fr_ConfigParamIdx Index that identifies the configuration parameter to read. See macros FR_CIDX_<config_parameter_name>.
975 * @param [out] Fr_ConfigParamValuePtr Address the output value is stored to.
976 * @return E_OK: API call finished successfully. E_NOT_OK: API call aborted due to errors.
978 Std_ReturnType Fr_ReadCCConfig( uint8_t Fr_CtrlIdx, uint8_t Fr_ConfigParamIdx, uint32_t *Fr_ConfigParamValuePtr);
981 * @brief Function sends prepared command on SPI and stores response
983 * @param[in] port Index of flexray 0 or 1
984 * @return 0 when success, -1 when bad parameter
986 int Fr_spi_transfer(uint8_t port);
989 * @brief Returns last spi response of selected fray port
991 * @param[in] port Index of flexray 0 or 1
992 * @return spi response or -1 when bad parameter
994 int Fr_spi_response(uint8_t port);
997 * @brief Returns last spi command of selected fray port
999 * @param[in] port Index of flexray 0 or 1
1000 * @return spi command or -1 when bad parameter
1002 int Fr_spi_get_cmd(uint8_t port);