1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2019 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 #ifndef _FSL_AOI_H_
9 #define _FSL_AOI_H_
10 
11 #include "fsl_common.h"
12 
13 /*!
14  * @addtogroup aoi
15  * @{
16  */
17 
18 /*******************************************************************************
19  * Definitions
20  ******************************************************************************/
21 #ifndef AOI
22 #define AOI AOI0 /*!< AOI peripheral address */
23 #endif
24 
25 /*! @name Driver version */
26 /*@{*/
27 #define FSL_AOI_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1. */
28 /*@}*/
29 
30 /*!
31  * @brief AOI input configurations.
32  *
33  * The selection item represents the Boolean evaluations.
34  */
35 typedef enum _aoi_input_config
36 {
37     kAOI_LogicZero      = 0x0U, /*!< Forces the input to logical zero. */
38     kAOI_InputSignal    = 0x1U, /*!< Passes the input signal. */
39     kAOI_InvInputSignal = 0x2U, /*!< Inverts the input signal. */
40     kAOI_LogicOne       = 0x3U  /*!< Forces the input to logical one. */
41 } aoi_input_config_t;
42 
43 /*!
44  * @brief AOI event indexes, where an event is the collection of the four product
45  *        terms (0, 1, 2, and 3) and the four signal inputs (A, B, C, and D).
46  */
47 typedef enum _aoi_event
48 {
49     kAOI_Event0 = 0x0U, /*!< Event 0 index */
50     kAOI_Event1 = 0x1U, /*!< Event 1 index */
51     kAOI_Event2 = 0x2U, /*!< Event 2 index */
52     kAOI_Event3 = 0x3U  /*!< Event 3 index */
53 } aoi_event_t;
54 
55 /*!
56  * @brief AOI event configuration structure
57  *
58  * Defines structure _aoi_event_config and use the AOI_SetEventLogicConfig() function to make
59  * whole event configuration.
60  */
61 typedef struct _aoi_event_config
62 {
63     aoi_input_config_t PT0AC; /*!< Product term 0 input A */
64     aoi_input_config_t PT0BC; /*!< Product term 0 input B */
65     aoi_input_config_t PT0CC; /*!< Product term 0 input C */
66     aoi_input_config_t PT0DC; /*!< Product term 0 input D */
67     aoi_input_config_t PT1AC; /*!< Product term 1 input A */
68     aoi_input_config_t PT1BC; /*!< Product term 1 input B */
69     aoi_input_config_t PT1CC; /*!< Product term 1 input C */
70     aoi_input_config_t PT1DC; /*!< Product term 1 input D */
71     aoi_input_config_t PT2AC; /*!< Product term 2 input A */
72     aoi_input_config_t PT2BC; /*!< Product term 2 input B */
73     aoi_input_config_t PT2CC; /*!< Product term 2 input C */
74     aoi_input_config_t PT2DC; /*!< Product term 2 input D */
75     aoi_input_config_t PT3AC; /*!< Product term 3 input A */
76     aoi_input_config_t PT3BC; /*!< Product term 3 input B */
77     aoi_input_config_t PT3CC; /*!< Product term 3 input C */
78     aoi_input_config_t PT3DC; /*!< Product term 3 input D */
79 } aoi_event_config_t;
80 
81 /*******************************************************************************
82  * API
83  ******************************************************************************/
84 
85 #if defined(__cplusplus)
86 extern "C" {
87 #endif /* __cplusplus*/
88 
89 /*!
90  * @name  AOI Initialization
91  * @{
92  */
93 
94 /*!
95  * @brief Initializes an AOI instance for operation.
96  *
97  * This function un-gates the AOI clock.
98  *
99  * @param base AOI peripheral address.
100  */
101 void AOI_Init(AOI_Type *base);
102 
103 /*!
104  * @brief Deinitializes an AOI instance for operation.
105  *
106  * This function shutdowns AOI module.
107  *
108  * @param  base AOI peripheral address.
109  */
110 void AOI_Deinit(AOI_Type *base);
111 
112 /*@}*/
113 
114 /*!
115  * @name  AOI Get Set Operation
116  * @{
117  */
118 
119 /*!
120  * @brief Gets the Boolean evaluation associated.
121  *
122  * This function returns the Boolean evaluation associated.
123  *
124  * Example:
125   @code
126     aoi_event_config_t demoEventLogicStruct;
127 
128     AOI_GetEventLogicConfig(AOI, kAOI_Event0, &demoEventLogicStruct);
129   @endcode
130  *
131  * @param  base AOI peripheral address.
132  * @param  event Index of the event which will be set of type aoi_event_t.
133  * @param  config Selected input configuration .
134  */
135 void AOI_GetEventLogicConfig(AOI_Type *base, aoi_event_t event, aoi_event_config_t *config);
136 
137 /*!
138  * @brief Configures an AOI event.
139  *
140  * This function configures an AOI event according
141  * to the aoiEventConfig structure. This function configures all  inputs (A, B, C, and D)
142  * of all  product terms (0, 1, 2, and 3) of a desired event.
143  *
144  * Example:
145   @code
146     aoi_event_config_t demoEventLogicStruct;
147 
148     demoEventLogicStruct.PT0AC = kAOI_InvInputSignal;
149     demoEventLogicStruct.PT0BC = kAOI_InputSignal;
150     demoEventLogicStruct.PT0CC = kAOI_LogicOne;
151     demoEventLogicStruct.PT0DC = kAOI_LogicOne;
152 
153     demoEventLogicStruct.PT1AC = kAOI_LogicZero;
154     demoEventLogicStruct.PT1BC = kAOI_LogicOne;
155     demoEventLogicStruct.PT1CC = kAOI_LogicOne;
156     demoEventLogicStruct.PT1DC = kAOI_LogicOne;
157 
158     demoEventLogicStruct.PT2AC = kAOI_LogicZero;
159     demoEventLogicStruct.PT2BC = kAOI_LogicOne;
160     demoEventLogicStruct.PT2CC = kAOI_LogicOne;
161     demoEventLogicStruct.PT2DC = kAOI_LogicOne;
162 
163     demoEventLogicStruct.PT3AC = kAOI_LogicZero;
164     demoEventLogicStruct.PT3BC = kAOI_LogicOne;
165     demoEventLogicStruct.PT3CC = kAOI_LogicOne;
166     demoEventLogicStruct.PT3DC = kAOI_LogicOne;
167 
168     AOI_SetEventLogicConfig(AOI, kAOI_Event0, demoEventLogicStruct);
169   @endcode
170  *
171  * @param  base AOI peripheral address.
172  * @param  event Event which will be configured of type aoi_event_t.
173  * @param  eventConfig Pointer to type aoi_event_config_t structure. The user is responsible for
174  * filling out the members of this structure and passing the pointer to this function.
175  */
176 void AOI_SetEventLogicConfig(AOI_Type *base, aoi_event_t event, const aoi_event_config_t *eventConfig);
177 
178 #if defined(__cplusplus)
179 }
180 #endif /* __cplusplus*/
181 
182 /*@}*/
183 
184 /*!* @} */
185 
186 #endif /* _FSL_AOI_H_*/
187