File indexing completed on 2025-05-11 08:22:58
0001
0002
0003
0004
0005
0006
0007
0008 #include "fsl_aoi.h"
0009
0010
0011 #ifndef FSL_COMPONENT_ID
0012 #define FSL_COMPONENT_ID "platform.drivers.aoi"
0013 #endif
0014
0015
0016
0017
0018
0019 static AOI_Type *const s_aoiBases[] = AOI_BASE_PTRS;
0020
0021 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
0022
0023 static const clock_ip_name_t s_aoiClocks[] = AOI_CLOCKS;
0024 #endif
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 static uint32_t AOI_GetInstance(AOI_Type *base);
0036
0037
0038
0039
0040 static uint32_t AOI_GetInstance(AOI_Type *base)
0041 {
0042 uint32_t instance;
0043
0044
0045 for (instance = 0; instance < ARRAY_SIZE(s_aoiBases); instance++)
0046 {
0047 if (s_aoiBases[instance] == base)
0048 {
0049 break;
0050 }
0051 }
0052
0053 assert(instance < ARRAY_SIZE(s_aoiBases));
0054
0055 return instance;
0056 }
0057
0058
0059
0060
0061
0062
0063
0064
0065 void AOI_Init(AOI_Type *base)
0066 {
0067 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
0068
0069 CLOCK_EnableClock(s_aoiClocks[AOI_GetInstance(base)]);
0070 #endif
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080 void AOI_Deinit(AOI_Type *base)
0081 {
0082 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
0083
0084 CLOCK_DisableClock(s_aoiClocks[AOI_GetInstance(base)]);
0085 #endif
0086 }
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 void AOI_GetEventLogicConfig(AOI_Type *base, aoi_event_t event, aoi_event_config_t *config)
0105 {
0106 assert((uint32_t)event < (uint32_t)FSL_FEATURE_AOI_EVENT_COUNT);
0107 assert(config != NULL);
0108
0109 uint16_t value;
0110 uint16_t temp;
0111
0112 value = base->BFCRT[event].BFCRT01;
0113
0114 temp = (value & AOI_BFCRT01_PT0_AC_MASK) >> AOI_BFCRT01_PT0_AC_SHIFT;
0115 config->PT0AC = (aoi_input_config_t)temp;
0116 temp = (value & AOI_BFCRT01_PT0_BC_MASK) >> AOI_BFCRT01_PT0_BC_SHIFT;
0117 config->PT0BC = (aoi_input_config_t)temp;
0118 temp = (value & AOI_BFCRT01_PT0_CC_MASK) >> AOI_BFCRT01_PT0_CC_SHIFT;
0119 config->PT0CC = (aoi_input_config_t)temp;
0120 temp = (value & AOI_BFCRT01_PT0_DC_MASK) >> AOI_BFCRT01_PT0_DC_SHIFT;
0121 config->PT0DC = (aoi_input_config_t)temp;
0122
0123 temp = (value & AOI_BFCRT01_PT1_AC_MASK) >> AOI_BFCRT01_PT1_AC_SHIFT;
0124 config->PT1AC = (aoi_input_config_t)temp;
0125 temp = (value & AOI_BFCRT01_PT1_BC_MASK) >> AOI_BFCRT01_PT1_BC_SHIFT;
0126 config->PT1BC = (aoi_input_config_t)temp;
0127 temp = (value & AOI_BFCRT01_PT1_CC_MASK) >> AOI_BFCRT01_PT1_CC_SHIFT;
0128 config->PT1CC = (aoi_input_config_t)temp;
0129 temp = (value & AOI_BFCRT01_PT1_DC_MASK) >> AOI_BFCRT01_PT1_DC_SHIFT;
0130 config->PT1DC = (aoi_input_config_t)temp;
0131
0132
0133 value = base->BFCRT[event].BFCRT23;
0134
0135 temp = (value & AOI_BFCRT23_PT2_AC_MASK) >> AOI_BFCRT23_PT2_AC_SHIFT;
0136 config->PT2AC = (aoi_input_config_t)temp;
0137 temp = (value & AOI_BFCRT23_PT2_BC_MASK) >> AOI_BFCRT23_PT2_BC_SHIFT;
0138 config->PT2BC = (aoi_input_config_t)temp;
0139 temp = (value & AOI_BFCRT23_PT2_CC_MASK) >> AOI_BFCRT23_PT2_CC_SHIFT;
0140 config->PT2CC = (aoi_input_config_t)temp;
0141 temp = (value & AOI_BFCRT23_PT2_DC_MASK) >> AOI_BFCRT23_PT2_DC_SHIFT;
0142 config->PT2DC = (aoi_input_config_t)temp;
0143
0144 temp = (value & AOI_BFCRT23_PT3_AC_MASK) >> AOI_BFCRT23_PT3_AC_SHIFT;
0145 config->PT3AC = (aoi_input_config_t)temp;
0146 temp = (value & AOI_BFCRT23_PT3_BC_MASK) >> AOI_BFCRT23_PT3_BC_SHIFT;
0147 config->PT3BC = (aoi_input_config_t)temp;
0148 temp = (value & AOI_BFCRT23_PT3_CC_MASK) >> AOI_BFCRT23_PT3_CC_SHIFT;
0149 config->PT3CC = (aoi_input_config_t)temp;
0150 temp = (value & AOI_BFCRT23_PT3_DC_MASK) >> AOI_BFCRT23_PT3_DC_SHIFT;
0151 config->PT3DC = (aoi_input_config_t)temp;
0152 }
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193 void AOI_SetEventLogicConfig(AOI_Type *base, aoi_event_t event, const aoi_event_config_t *eventConfig)
0194 {
0195 assert(eventConfig != NULL);
0196 assert((uint32_t)event < (uint32_t)FSL_FEATURE_AOI_EVENT_COUNT);
0197
0198 uint16_t value;
0199
0200 value = AOI_BFCRT01_PT0_AC(eventConfig->PT0AC) | AOI_BFCRT01_PT0_BC(eventConfig->PT0BC) |
0201 AOI_BFCRT01_PT0_CC(eventConfig->PT0CC) | AOI_BFCRT01_PT0_DC(eventConfig->PT0DC) |
0202 AOI_BFCRT01_PT1_AC(eventConfig->PT1AC) | AOI_BFCRT01_PT1_BC(eventConfig->PT1BC) |
0203 AOI_BFCRT01_PT1_CC(eventConfig->PT1CC) | AOI_BFCRT01_PT1_DC(eventConfig->PT1DC);
0204
0205 base->BFCRT[event].BFCRT01 = value;
0206
0207
0208 value = AOI_BFCRT23_PT2_AC(eventConfig->PT2AC) | AOI_BFCRT23_PT2_BC(eventConfig->PT2BC) |
0209 AOI_BFCRT23_PT2_CC(eventConfig->PT2CC) | AOI_BFCRT23_PT2_DC(eventConfig->PT2DC) |
0210 AOI_BFCRT23_PT3_AC(eventConfig->PT3AC) | AOI_BFCRT23_PT3_BC(eventConfig->PT3BC) |
0211 AOI_BFCRT23_PT3_CC(eventConfig->PT3CC) | AOI_BFCRT23_PT3_DC(eventConfig->PT3DC);
0212
0213 base->BFCRT[event].BFCRT23 = value;
0214 }