MCUSW
Icu.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2021 Texas Instruments Incorporated
4 *
5 * All rights reserved not granted herein.
6 *
7 * Limited License.
8 *
9 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10 * license under copyrights and patents it now or hereafter owns or controls to make,
11 * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12 * terms herein. With respect to the foregoing patent license, such license is granted
13 * solely to the extent that any such patent is necessary to Utilize the software alone.
14 * The patent license shall not apply to any combinations which include this software,
15 * other than combinations with devices manufactured by or for TI ("TI Devices").
16 * No hardware patent is licensed hereunder.
17 *
18 * Redistributions must preserve existing copyright notices and reproduce this license
19 * (including the above copyright notice and the disclaimer and (if applicable) source
20 * code license limitations below) in the documentation and/or other materials provided
21 * with the distribution
22 *
23 * Redistribution and use in binary form, without modification, are permitted provided
24 * that the following conditions are met:
25 *
26 * * No reverse engineering, decompilation, or disassembly of this software is
27 * permitted with respect to any software provided in binary form.
28 *
29 * * any redistribution and use are licensed by TI for use only with TI Devices.
30 *
31 * * Nothing shall obligate TI to provide you with source code for the software
32 * licensed and provided to you in object code.
33 *
34 * If software source code is provided to you, modification and redistribution of the
35 * source code are permitted provided that the following conditions are met:
36 *
37 * * any redistribution and use of the source code, including any resulting derivative
38 * works, are licensed by TI for use only with TI Devices.
39 *
40 * * any redistribution and use of any object code compiled from the source code
41 * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42 *
43 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44 *
45 * may be used to endorse or promote products derived from this software without
46 * specific prior written permission.
47 *
48 * DISCLAIMER.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59 * OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 */
62 
84  /*
85  * Below are the global requirements which are met by this PWM
86  * driver which can't be mapped to a particular source ID
87  */
88 /* DesignId : DES_ICU_002*/
89 /* Requirements : MCAL-4569, MCAL-4570, MCAL-4571, MCAL-4572, MCAL-4573,
90  * MCAL-4574, MCAL-4575, MCAL-4576, MCAL-4577, MCAL-4578, MCAL-4579
91  */
92 
93 /*
94  * Below are the PWM module's environment requirements which can't be mapped
95  * to this driver
96  */
97 /* DesignId : DES_ICU_003, DES_ICU_004*/
98  /*
99  * Requirements : MCAL-4534, MCAL-4535, MCAL-4536, MCAL-4538, MCAL-4539,
100  * MCAL-4541, MCAL-4542, MCAL-4544, MCAL-4545, MCAL-4546, MCAL-4547, MCAL-4549,
101  * MCAL-4550, MCAL-4552, MCAL-4553, MCAL-4554, MCAL-4555, MCAL-4557, MCAL-4558,
102  * MCAL-4559, MCAL-4560, MCAL-4561, MCAL-4562, MCAL-4563, MCAL-4566, MCAL-4567,
103  * MCAL-5168, MCAL-5169, MCAL-5170
104  */
105 
106 #ifndef ICU_H_
107 #define ICU_H_
108 
109 /* ========================================================================== */
110 /* Include Files */
111 /* ========================================================================== */
112 /* Design : DES_ICU_002 */
113 /* Requirements : MCAL-4585, MCAL-4586 MCAL-4569, MCAL-4570, MCAL-4571, MCAL-4572,
114  MCAL-4573, MCAL-4574, MCAL-4575, MCAL-4576, MCAL-4577, MCAL-4578, MCAL-4579*/
115 #include "Std_Types.h"
116 #include "Icu_Cfg.h"
117 
118 #ifdef __cplusplus
119 extern "C"
120 {
121 #endif
122 
123 /* ========================================================================== */
124 /* Macros & Typedefs */
125 /* ========================================================================== */
126 
132 #define ICU_VENDOR_ID ((uint16) 44U)
133 
134 #define ICU_MODULE_ID ((uint16) 122U)
135 
136 #define ICU_INSTANCE_ID ((uint8) 0U)
137 /* @} */
138 
146 #define ICU_SW_MAJOR_VERSION (1U)
147 
148 #define ICU_SW_MINOR_VERSION (3U)
149 
150 #define ICU_SW_PATCH_VERSION (2U)
151 /* @} */
152 
160 #define ICU_AR_RELEASE_MAJOR_VERSION (4U)
161 
162 #define ICU_AR_RELEASE_MINOR_VERSION (3U)
163 
164 #define ICU_AR_RELEASE_REVISION_VERSION (1U)
165 /* @} */
166 
175 #define ICU_INIT_ID ((uint8) 0x00U)
176 
177 #define ICU_DEINIT_ID ((uint8) 0x01U)
178 
179 #define ICU_SETMODE_ID ((uint8) 0x02U)
180 
181 #define ICU_SETACTIVATIONCONDITION_ID ((uint8) 0x05U)
182 
183 #define ICU_DISABLENOTIFICATION_ID ((uint8) 0x06U)
184 
185 #define ICU_ENABLENOTIFICATION_ID ((uint8) 0x07U)
186 
187 #define ICU_GETINPUTSTATE_ID ((uint8) 0x08U)
188 
189 #define ICU_STARTTIMESTAMP_ID ((uint8) 0x09U)
190 
191 #define ICU_STOPTIMESTAMP_ID ((uint8) 0x0AU)
192 
193 #define ICU_GETTIMESTAMPINDEX_ID ((uint8) 0x0BU)
194 
195 #define ICU_RESETEDGECOUNT_ID ((uint8) 0x0CU)
196 
197 #define ICU_ENABLEEDGECOUNT_ID ((uint8) 0x0DU)
198 
199 #define ICU_ENABLEEDGEDETECTION_ID ((uint8) 0x16U)
200 
201 #define ICU_DISABLEEDGEDETECTION_ID ((uint8) 0x17U)
202 
203 #define ICU_DISABLEEDGECOUNT_ID ((uint8) 0x0EU)
204 
205 #define ICU_GETEDGENUMBERS_ID ((uint8) 0x0FU)
206 
207 #define ICU_STARTSIGNALMEASUREMENT_ID ((uint8) 0x13U)
208 
209 #define ICU_STOPSIGNALMEASUREMENT_ID ((uint8) 0x14U)
210 
211 #define ICU_GETTIMEELAPSED_ID ((uint8) 0x10U)
212 
213 #define ICU_GETDUTYCYCLEVALUES_ID ((uint8) 0x11U)
214 
215 #define ICU_GETVERSIONINFO_ID ((uint8) 0x12U)
216 /* @} */
217 
224 /* Design : DES_ICU_005 */
225 /* Requirements : MCAL-4585, MCAL-4586 */
227 #define ICU_E_PARAM_POINTER ((uint8) 0x0AU)
228 
232 #define ICU_E_PARAM_CHANNEL ((uint8) 0x0BU)
233 
234 #define ICU_E_PARAM_ACTIVATION ((uint8) 0x0CU)
235 
236 #define ICU_E_INIT_FAILED ((uint8) 0x0DU)
237 
238 #define ICU_E_PARAM_BUFFER_SIZE ((uint8) 0x0EU)
239 
240 #define ICU_E_PARAM_MODE ((uint8) 0x0FU)
241 
242 #define ICU_E_UNINIT ((uint8) 0x14U)
243 
244 #define ICU_E_NOT_STARTED ((uint8) 0x16U)
245 
246 #define ICU_E_BUSY_OPERATION ((uint8) 0x16U)
247 
248 #define ICU_E_ALREADY_INITIALIZED ((uint8) 0x17U)
249 
250 #define ICU_E_PARAM_NOTIFY_INTERVAL ((uint8) 0x18U)
251 
252 #define ICU_E_PARAM_VINFO ((uint8) 0x19U)
253 /* @} */
254 
261 /* Design : DES_ICU_001 */
262 /* Requirements : MCAL-4591 */
264 #define ICU_STATUS_UNINIT ((uint8)(0U))
265 
266 #define ICU_STATUS_INIT ((uint8)(1U))
267 /* @} */
268 
274 #define ICU_FALLING ((uint8)(0U))
275 
276 #define ICU_RISING ((uint8)(1U))
277 
278 #if defined (SOC_J721E) || defined (SOC_J7200)
279 #define ICU_MAX_NUM_CHANNELS (3U)
280 
281 /*
282  * ICU channels available for user
283  */
285 #define ICU_CHANNEL0 (0U)
286 
287 #define ICU_CHANNEL1 (1U)
288 
289 #define ICU_CHANNEL2 (2U)
290 
291 #endif /* SOC_J721E */
292 
293 /* ========================================================================== */
294 /* Structures and Enums */
295 /* ========================================================================== */
296 
305 typedef enum
306 {
311 } Icu_ModeType;
312 
316 typedef enum
317 {
323 
324 
328 typedef enum
329 {
337 
341 typedef uint16 Icu_ValueType;
342 
346 typedef struct
347 {
353 
357 typedef uint32 Icu_IndexType;
358 
362 typedef uint32 Icu_EdgeNumberType;
363 
367 typedef enum
368 {
378 
382 typedef enum
383 {
393 
397 typedef enum
398 {
404 
406 typedef void (*Icu_NotifyFuncType)(void);
407 
411 typedef uint8 Icu_ChannelType;
412 
417 
421 typedef struct
422 {
426 
430 typedef struct Icu_ConfigType_PC_s
431 {
435 
439 typedef struct {
452  uint32 prescaler;
455 
459 typedef struct Icu_ConfigType_s
460 {
466 /* @} */
467 
468 
469 
470 /* ========================================================================== */
471 /* Function Declarations */
472 /* ========================================================================== */
473 
474 
493 FUNC(void, ICU_CODE) Icu_Init(
494  P2CONST(Icu_ConfigType, AUTOMATIC, ICU_PBCFG) ConfigPtr);
495 
496 
497 
498 #if (STD_ON == ICU_DE_INIT_API)
499 
515 FUNC(void, ICU_CODE) Icu_DeInit( void );
516 #endif
517 
538 FUNC(void, ICU_CODE) Icu_SetActivationCondition( Icu_ChannelType Channel, Icu_ActivationType Activation );
539 
556 FUNC(void, ICU_CODE) Icu_DisableNotification( Icu_ChannelType Channel );
557 
574 FUNC(void, ICU_CODE) Icu_EnableNotification( Icu_ChannelType Channel );
575 
576 
577 #if (ICU_GET_INPUT_STATE_API == STD_ON)
578 
594 FUNC(Icu_InputStateType, ICU_CODE) Icu_GetInputState( Icu_ChannelType Channel );
595 #endif
596 
597 #if (ICU_TIMESTAMP_API == STD_ON)
598 
619 FUNC(void, ICU_CODE) Icu_StartTimestamp( Icu_ChannelType Channel, Icu_ValueType* BufferPtr, uint16 BufferSize, uint16 NotifyInterval );
620 
637 FUNC(void, ICU_CODE) Icu_StopTimestamp( Icu_ChannelType Channel );
638 
655 FUNC(Icu_IndexType, ICU_CODE) Icu_GetTimestampIndex( Icu_ChannelType Channel );
656 #endif
657 
658 #if (ICU_EDGE_COUNT_API == STD_ON)
659 
675 FUNC(void, ICU_CODE) Icu_ResetEdgeCount( Icu_ChannelType Channel );
676 
693 FUNC(void, ICU_CODE) Icu_EnableEdgeCount( Icu_ChannelType Channel );
694 
711 FUNC(void, ICU_CODE) Icu_DisableEdgeCount( Icu_ChannelType Channel );
712 
729 FUNC(Icu_EdgeNumberType, ICU_CODE) Icu_GetEdgeNumbers( Icu_ChannelType Channel );
730 #endif
731 
732 #if (ICU_EDGE_DETECT_API == STD_ON)
733 
749 FUNC(void, ICU_CODE) Icu_EnableEdgeDetection( Icu_ChannelType Channel );
750 
767 FUNC(void, ICU_CODE) Icu_DisableEdgeDetection( Icu_ChannelType Channel );
768 #endif
769 
770 #if (ICU_SIGNAL_MEASUREMENT_API == STD_ON)
771 
787 FUNC(void, ICU_CODE) Icu_StartSignalMeasurement( Icu_ChannelType Channel );
788 
805 FUNC(void, ICU_CODE) Icu_StopSignalMeasurement( Icu_ChannelType Channel );
806 #endif
807 
808 #if (ICU_GET_TIME_ELAPSED_API == STD_ON)
809 
825 FUNC (Icu_ValueType, ICU_CODE) Icu_GetTimeElapsed( Icu_ChannelType Channel );
826 #endif
827 
828 #if (ICU_GET_DUTY_CYCLE_VALUES_API == STD_ON)
829 
846 FUNC (void, ICU_CODE) Icu_GetDutyCycleValues( Icu_ChannelType Channel,
847  Icu_DutyCycleType* DutyCycleValues );
848 #endif
849 
850 #if (ICU_GET_VERSION_INFO_API)
851 
869 FUNC(void, ICU_CODE) Icu_GetVersionInfo(
870  P2VAR(Std_VersionInfoType, AUTOMATIC, sICU_APPL_DATA) VersionInfoPtr);
871 
872 #endif
873 
874 #ifdef __cplusplus
875 }
876 #endif
877 /* @} */
878 
879 #endif /* ICU_H_ */
880 
881 /* @} */
uint32 instanceClkMHz
Definition: Icu.h:450
Icu_TimestampBufferType bufferType
Definition: Icu.h:448
Definition: Icu.h:318
Icu_TimestampBufferType
This type defines TimeStamp Property range.
Definition: Icu.h:397
Definition: Icu.h:386
void Icu_StartSignalMeasurement(Icu_ChannelType Channel)
Service for starting the measurement of signals.
uint8 Icu_ChannelPrescalerType
This type defines Prescaler type.
Definition: Icu.h:416
Definition: Icu.h:390
This type defines Duty Cycle struct.
Definition: Icu.h:346
Definition: Icu.h:375
Definition: Icu.h:371
Definition: Icu.h:401
Icu_ModeType
This type defines a range of mode type.
Definition: Icu.h:305
void Icu_Init(const Icu_ConfigType *ConfigPtr)
Service for ICU initialization.
Icu_InputStateType Icu_GetInputState(Icu_ChannelType Channel)
Service for getting the ICU input status.
void Icu_StopSignalMeasurement(Icu_ChannelType Channel)
Service for stopping the measurement of signals.
ICU Channel Config Structure of Pre-Compile only.
Definition: Icu.h:421
Icu_ActivationType defaultStartEdge
Definition: Icu.h:440
uint32 Icu_EdgeNumberType
This type defines return value of Icu-Icu_GetEdgeNumbers.
Definition: Icu.h:362
Definition: Icu.h:384
Definition: Icu.h:399
Icu_EdgeNumberType Icu_GetEdgeNumbers(Icu_ChannelType Channel)
Service for reading the number of counted edges.
Icu_ChannelType channelId
Definition: Icu.h:423
ICU Channel Config Structure.
Definition: Icu.h:439
void Icu_DisableNotification(Icu_ChannelType Channel)
Service for disabling notification.
Definition: Icu.h:320
This file contains generated pre compile configuration file for ICU MCAL driver.
Definition: Icu.h:334
Icu_ChannelType icuMaxChannel
Definition: Icu.h:461
Icu_NotifyFuncType notificationHandler
Definition: Icu.h:446
void Icu_DisableEdgeCount(Icu_ChannelType Channel)
Service for disabling the couting of edges of the given channel.
Icu_ValueType PeriodTime
Definition: Icu.h:350
ICU Config Structure.
Definition: Icu.h:459
void Icu_EnableNotification(Icu_ChannelType Channel)
Service for enabling notification.
uint32 prescaler
Definition: Icu.h:452
Icu_ValueType ActiveTime
Definition: Icu.h:348
void Icu_ResetEdgeCount(Icu_ChannelType Channel)
Service for resets the value of the counted edges to zero.
Icu_SignalMeasurementPropertyType signalMeasurementProperty
Definition: Icu.h:444
void(* Icu_NotifyFuncType)(void)
Notification callback function pointer.
Definition: Icu.h:406
Definition: Icu.h:388
Icu_InputStateType
This type defines a input state of ICU driver.
Definition: Icu.h:316
Icu_ValueType Icu_GetTimeElapsed(Icu_ChannelType Channel)
Service for reading the elasped time for the given channel.
Definition: Icu.h:307
void Icu_StartTimestamp(Icu_ChannelType Channel, Icu_ValueType *BufferPtr, uint16 BufferSize, uint16 NotifyInterval)
Service for starts the captuing of timer values on the edges.
ICU Config Structure of Pre-Compile only.
Definition: Icu.h:430
Icu_IndexType Icu_GetTimestampIndex(Icu_ChannelType Channel)
Service for reading the timestamp index of a givem channel.
Icu_ActivationType
This type defines Activation range.
Definition: Icu.h:328
Definition: Icu.h:369
uint16 Icu_ValueType
This type defines Value type.
Definition: Icu.h:341
Definition: Icu.h:309
void Icu_DeInit(void)
Service for ICU de-initialization.
uint8 Icu_ChannelType
This type defines Channel type.
Definition: Icu.h:411
void Icu_EnableEdgeDetection(Icu_ChannelType Channel)
Service for enabling/re-enabling the detection of edges of the given channel.
Definition: Icu.h:332
uint32 Icu_IndexType
This type defines return value Icu_GetTimeStampIndex.
Definition: Icu.h:357
void Icu_DisableEdgeDetection(Icu_ChannelType Channel)
Service for disabling the detection of edges of the given channel.
Icu_MeasurementModeType measurementMode
Definition: Icu.h:442
#define ICU_MAX_NUM_CHANNELS
Definition: Icu.h:279
Definition: Icu.h:373
Icu_MeasurementModeType
This type defines available measurement modes.
Definition: Icu.h:367
Icu_SignalMeasurementPropertyType
This type defines Signal Measurement Property range.
Definition: Icu.h:382
void Icu_SetActivationCondition(Icu_ChannelType Channel, Icu_ActivationType Activation)
Service for setting Activation Condition.
Definition: Icu.h:330
void Icu_GetDutyCycleValues(Icu_ChannelType Channel, Icu_DutyCycleType *DutyCycleValues)
Service for reading the coherent active time and period time of given channel.
void Icu_StopTimestamp(Icu_ChannelType Channel)
Service for stopping the timestamp measurement.
void Icu_EnableEdgeCount(Icu_ChannelType Channel)
Service enabling the counting of edges of a given channel.