1<?xml version="1.0" encoding="utf-8"?>
2
3
4<!--****************************************************************************
5* \file adcmic.cypersonality
6* \version 1.0
7*
8* \brief
9* ADCMic personality description file.
10*
11********************************************************************************
12* \copyright
13* Copyright 2022 Cypress Semiconductor Corporation
14* SPDX-License-Identifier: Apache-2.0
15*
16* Licensed under the Apache License, Version 2.0 (the "License");
17* you may not use this file except in compliance with the License.
18* You may obtain a copy of the License at
19*
20*     http://www.apache.org/licenses/LICENSE-2.0
21*
22* Unless required by applicable law or agreed to in writing, software
23* distributed under the License is distributed on an "AS IS" BASIS,
24* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25* See the License for the specific language governing permissions and
26* limitations under the License.
27*****************************************************************************-->
28
29<Personality id="mxs40adcmic" name="ADCMic" version="1.0" xmlns="http://cypress.com/xsd/cyhwpersonality_v7">
30  <Dependencies>
31    <IpBlock name="mxs40adcmic" />
32    <Resource name="adcmic" />
33  </Dependencies>
34  <ExposedMembers/>
35  <Parameters>
36    <!-- PDL documentation -->
37    <ParamDoc id="pdlDoc" name="Configuration Help" group="Overview" default="file:///`${cy_libs_path()}`/docs/pdl_api_reference_manual/html/group__group__adcmic.html" linkText="Open ADCMic Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />
38
39    <ParamBool id="debug" name="debug" group="Internal" default="false" visible="false" editable="false" desc="" />
40    <ParamString id="version" name="version number" group="Internal" default="`${getVersion()}`" visible="`${debug}`" editable="false" desc="" />
41    <ParamRange id="inst" name="inst" group="Internal" default="`${getInstNumber(&quot;adcmic&quot;)}`" min="0" max="3" resolution="1" visible="`${debug}`" editable="false" desc="" />
42    <ParamString id="hwName" name="hwName" group="Internal" default="`${&quot;MXS40ADCMIC&quot; . inst}`" visible="false" editable="false" desc="HW name of ADCMIC instance." />
43
44    <!-- Internal : HF clock query info -->
45    <ParamString id="sysClkRsc" name="sysClkRsc" group="Internal" default="srss[0].clock[0].hfclk[0]" visible="`${debug}`" editable="false" desc="" />
46    <ParamString id="hfClkRsc" name="hfClkRsc" group="Internal" default="srss[0].clock[0].hfclk[3]" visible="`${debug}`" editable="false" desc="" />
47    <ParamBool id="hfClkEnabled" name="isHFClkEnabled" group="Internal" default="`${isBlockUsed(hfClkRsc)}`" visible="`${debug}`" editable="false" desc="" />
48    <ParamRange id="hfClkFreqHz" name="sourceFrequency" group="Internal" default="`${hfClkEnabled ? getExposedMember(hfClkRsc, &quot;frequency&quot;) : 1}`" min="0" max="400000000" resolution="1" visible="`${debug}`" editable="false" desc="" />
49
50    <ParamBool id="dcCfg" name="Enable Configuration" group="DC Measurement Path" default="true" visible="true" editable="true" desc="DC measurement path configuration enable for application usage" />
51    <ParamBool id="micCfg" name="Enable Configuration" group="Analog Microphone Path" default="true" visible="true" editable="true" desc="Analog microphone path configuration enable for application usage" />
52    <ParamBool id="pdmCfg" name="Enable Configuration" group="PDM Microphone Path" default="true" visible="true" editable="true" desc="PDM microphone path configuration enable for application usage" />
53
54    <!-- DC -->
55    <Repeat count="8">
56      <ParamBool id="gpio$idxok" name="gpio$idxok" group="Internal" default="`${hasVisibleOption(&quot;gpio_adc_in[$idx]&quot;)}`" visible="`${debug}`" editable="false" desc="" />
57    </Repeat>
58
59    <ParamChoice id="dcIn" name="DC Input" group="DC Measurement Path" default="`${gpio0ok ? CY_ADCMIC_GPIO0 :
60                                                                                   gpio1ok ? CY_ADCMIC_GPIO1 :
61                                                                                   gpio2ok ? CY_ADCMIC_GPIO2 :
62                                                                                   gpio3ok ? CY_ADCMIC_GPIO3 :
63                                                                                   gpio4ok ? CY_ADCMIC_GPIO4 :
64                                                                                   gpio5ok ? CY_ADCMIC_GPIO5 :
65                                                                                   gpio6ok ? CY_ADCMIC_GPIO6 :
66                                                                                   CY_ADCMIC_GPIO7}`" visible="`${dcCfg}`" editable="true" desc="Select the DC measurement input" >
67      <Entry name="REFGND" value="CY_ADCMIC_REFGND" visible="true" />
68      <Entry name="BGREF" value="CY_ADCMIC_BGREF" visible="true" />
69      <Entry name="VDDC" value="CY_ADCMIC_VDDC" visible="true" />
70      <Entry name="VDDIO" value="CY_ADCMIC_VDDIO" visible="true" />
71      <Entry name="GPIO$idx" value="CY_ADCMIC_GPIO$idx" visible="`${gpio$idxok}`" repeatCount="8" />
72    </ParamChoice>
73    <ParamChoice id="range" name="Voltage Range" group="DC Measurement Path" default="CY_ADCMIC_DC_RANGE_3_6V" visible="`${dcCfg}`" editable="true" desc="Select the DC measurement range" >
74      <Entry name="0 - 3.6V" value="CY_ADCMIC_DC_RANGE_3_6V" visible="true" />
75      <Entry name="0 - 1.8V" value="CY_ADCMIC_DC_RANGE_1_8V" visible="true" />
76    </ParamChoice>
77    <ParamRange id="period" name="Timer Period" group="DC Measurement Path" default="2400" min="0" max="65535" resolution="1" visible="`${dcCfg}`" editable="true" desc="The timer period" />
78    <ParamChoice id="tmin" name="Timer Input" group="DC Measurement Path" default="CY_ADCMIC_TIMER_COUNT_INPUT_CIC_UPDATE" visible="`${dcCfg}`" editable="true" desc="The timer input signal" >
79      <Entry name="CIC" value="CY_ADCMIC_TIMER_COUNT_INPUT_CIC_UPDATE" visible="true" />
80      <Entry name="SysClk" value="CY_ADCMIC_TIMER_COUNT_INPUT_CLK_SYS" visible="true" />
81    </ParamChoice>
82
83    <!-- MIC -->
84    <ParamChoice id="micSampleRate" name="Sample Rate" group="Analog Microphone Path" default="CY_ADCMIC_8KSPS" visible="`${micCfg}`" editable="true" desc="Select the ADC sample rate" >
85      <Entry name="8 ksps" value="CY_ADCMIC_8KSPS" visible="true" />
86      <Entry name="16 ksps" value="CY_ADCMIC_16KSPS" visible="true" />
87    </ParamChoice>
88
89    <ParamChoice id="micBias" name="Microphone Bias" group="Analog Microphone Path" default="CY_ADCMIC_BIAS_1_12_REF" visible="`${micCfg}`" editable="true" desc="Select the microphone bias" >
90      <Entry name="1.12 x Reference Voltage" value="CY_ADCMIC_BIAS_1_12_REF" visible="true" />
91      <Entry name="1.14 x Reference Voltage" value="CY_ADCMIC_BIAS_1_14_REF" visible="true" />
92      <Entry name="1.17 x Reference Voltage" value="CY_ADCMIC_BIAS_1_17_REF" visible="true" />
93      <Entry name="1.10 x Reference Voltage" value="CY_ADCMIC_BIAS_1_10_REF" visible="true" />
94    </ParamChoice>
95
96    <ParamBool id="micBiasLz" name="MIC bias Low Impedance" group="Analog Microphone Path" default="false" visible="`${micCfg}`" editable="true" desc="Microphone bias output low impedance during power down mode: checked - low impedance, unchecked - high impedance" />
97    <ParamBool id="clamp" name="PGA Clamping" group="Analog Microphone Path" default="false" visible="`${micCfg}`" editable="true" desc="Enable Microphone PGA inputs clamping to avoid possible signal clipping" />
98
99    <ParamChoice id="pgaGain" name="PGA Gain" group="Analog Microphone Path" default="CY_ADCMIC_PGA_GAIN_0" visible="`${micCfg}`" editable="true" desc="Select the PGA gain" >
100      <Entry name="$idx db" value="CY_ADCMIC_PGA_GAIN_$idx" visible="true" repeatCount="43" />
101    </ParamChoice>
102
103    <ParamChoice id="pgaInCm" name="PGA Input Common Mode" group="Analog Microphone Path" default="CY_ADCMIC_INCM_0_4" visible="`${micCfg}`" editable="true" desc="Select the PGA input common mode voltage" >
104      <Entry name="0.4 x aVdd" value="CY_ADCMIC_INCM_0_4" visible="true" />
105      <Entry name="0.45 x aVdd" value="CY_ADCMIC_INCM_0_45" visible="true" />
106      <Entry name="0.35 x aVdd" value="CY_ADCMIC_INCM_0_35" visible="true" />
107    </ParamChoice>
108
109    <ParamChoice id="pgaOutCm" name="PGA Output Common Mode" group="Analog Microphone Path" default="CY_ADCMIC_OUTCM_0_6" visible="`${micCfg}`" editable="true" desc="Select the PGA output common mode voltage" >
110      <Entry name="0.6" value="CY_ADCMIC_OUTCM_0_6" visible="true" />
111      <Entry name="0.7" value="CY_ADCMIC_OUTCM_0_7" visible="true" />
112      <Entry name="0.5" value="CY_ADCMIC_OUTCM_0_5" visible="true" />
113    </ParamChoice>
114
115    <ParamBool id="micBiquadEnable" name="Biquad Filter Enable" group="Analog Microphone Path" default="false" visible="`${micCfg}`" editable="true" desc="Enable the biquad filter" />
116    <ParamBool id="micFifoEnable" name="FIFO Enable" group="Analog Microphone Path" default="false" visible="`${micCfg}`" editable="true" desc="Enable the FIFO" />
117    <ParamRange id="micFull" name="FIFO Full Threshold" group="Analog Microphone Path" default="7" min="0" max="63" resolution="1" visible="`${micCfg &amp;&amp; micFifoEnable}`" editable="true" desc="The programmable FIFO full threshold" />
118    <ParamRange id="micEmpty" name="FIFO Empty Threshold" group="Analog Microphone Path" default="7" min="0" max="63" resolution="1" visible="`${micCfg &amp;&amp; micFifoEnable}`" editable="true" desc="The programmable FIFO empty threshold" />
119
120    <!-- PDM -->
121    <ParamChoice id="pdmSampleRate" name="Sample Rate" group="PDM Microphone Path" default="CY_ADCMIC_8KSPS" visible="`${pdmCfg}`" editable="true" desc="Select the ADC sample rate" >
122      <Entry name="8 ksps" value="CY_ADCMIC_8KSPS" visible="true" />
123      <Entry name="16 ksps" value="CY_ADCMIC_16KSPS" visible="true" />
124    </ParamChoice>
125
126    <ParamBool id="clockInv" name="PDM Clock Inversion" group="PDM Microphone Path" default="false" visible="`${pdmCfg}`" editable="true" desc="PDM clock signal inversion (latch on negative edge)" />
127    <ParamRange id="latchDelay" name="PDM Latch Delay" group="PDM Microphone Path" default="2" min="`${clockInv ? 3 : 2}`" max="`${clockInv ? 9 : 8}`" resolution="1" visible="`${pdmCfg}`" editable="true" desc="Number of clk_hf cycles from edge of pdm_clk to latch the pdm_data" />
128    <ParamBool id="pdmBiquadEnable" name="Biquad Filter Enable" group="PDM Microphone Path" default="false" visible="`${pdmCfg}`" editable="true" desc="Enable the biquad filter" />
129    <ParamBool id="pdmFifoEnable" name="FIFO Enable" group="PDM Microphone Path" default="false" visible="`${pdmCfg}`" editable="true" desc="Enable the FIFO" />
130    <ParamRange id="pdmFull" name="FIFO Full Threshold" group="PDM Microphone Path" default="7" min="0" max="63" resolution="1" visible="`${pdmCfg &amp;&amp; pdmFifoEnable}`" editable="true" desc="The programmable FIFO full threshold" />
131    <ParamRange id="pdmEmpty" name="FIFO Empty Threshold" group="PDM Microphone Path" default="7" min="0" max="63" resolution="1" visible="`${pdmCfg &amp;&amp; pdmFifoEnable}`" editable="true" desc="The programmable FIFO empty threshold" />
132
133    <Repeat count="8">
134      <ParamSignal name="GPIO$idx" port="gpio_adc_in[$idx]" group="Connections" visible="`${dcCfg &amp;&amp; gpio$idxok}`" canBeEmpty="`${!(dcCfg &amp;&amp; gpio$idxok) || (dcIn ne CY_ADCMIC_GPIO$idx)}`" desc="GPIO$idx input for DC measurement" />
135    </Repeat>
136
137    <ParamSignal name="PDM Clock" port="clk_pdm[0]" group="Connections" visible="`${pdmCfg}`" canBeEmpty="`${!pdmCfg}`" desc="PDM clock output" >
138      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
139        <Parameter id="DriveModes" severity="ERROR" reason="">
140          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
141        </Parameter>
142      </Constraint>
143    </ParamSignal>
144    <ParamSignal name="PDM Data" port="pdm_data[0]" group="Connections" visible="`${pdmCfg}`" canBeEmpty="`${!pdmCfg}`" desc="PDM data input" >
145      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
146        <Parameter id="DriveModes" severity="ERROR" reason="">
147          <Fixed value="CY_GPIO_DM_HIGHZ" />
148        </Parameter>
149      </Constraint>
150    </ParamSignal>
151
152    <ParamSignal name="DC Trigger" port="tr_adcmic_dc[0]" group="Connections" visible="`${dcCfg}`" canBeEmpty="true" desc="Trigger output for DC measurement" />
153    <ParamSignal name="DATA Trigger" port="tr_adcmic_data[0]" group="Connections" visible="`${micFifoEnable || pdmFifoEnable}`" canBeEmpty="true" desc="Trigger output for MIC or PDM audio streaming" />
154
155    <ParamBool id="inFlash" name="Store Config in Flash" group="Advanced" default="true" visible="true" editable="true" desc="Controls whether the configuration structure is stored in flash (const, true) or SRAM (not const, false)." />
156  </Parameters>
157
158  <DRCs>
159    <DRC type="ERROR" text="The ADCMic clock source should be enabled" condition="`${!hfClkEnabled}`" >
160      <FixIt action="ENABLE_BLOCK" target="`${hfClkRsc}`" value="" valid="true" />
161    </DRC>
162    <DRC type="ERROR" text="At least one mode configuration should be enabled" condition="`${!dcCfg &amp;&amp; !micCfg &amp;&amp; !pdmCfg}`" >
163      <FixIt action="SET_PARAM" target="dcCfg" value="true" valid="true" />
164      <FixIt action="SET_PARAM" target="micCfg" value="true" valid="true" />
165      <FixIt action="SET_PARAM" target="pdmCfg" value="true" valid="true" />
166    </DRC>
167    <DRC type="WARNING" text="The ADCMic clock source frequency should be 24 MHz" condition="`${hfClkEnabled &amp;&amp; (hfClkFreqHz != 24000000)}`" />
168  </DRCs>
169
170  <ConfigFirmware>
171
172    <ConfigInclude value="cy_adcmic.h" include="true" />
173    <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" />
174
175    <ConfigDefine name="`${INST_NAME}`_HW" value="`${hwName}`" public="true" include="true" />
176    <ConfigDefine name="`${INST_NAME}`_IRQ" value="adcmic_interrupt_adcmic_IRQn" public="true" include="true" />
177    <ConfigDefine name="`${INST_NAME}`_FIFO_DATA_REG_PTR" value="CY_ADCMIC_FIFO_DATA_REG_PTR(`${hwName}`)" public="true" include="true" />
178    <ConfigDefine name="`${INST_NAME}`_TRIGGER_CLR_REG_PTR" value="CY_ADCMIC_TRIGGER_CLR_REG_PTR(`${hwName}`)" public="true" include="true" />
179
180    <ConfigStruct name="`${INST_NAME . &quot;_biquad_config&quot;}`" type="cy_stc_adcmic_biquad_config_t" const="`${inFlash}`" public="true" include="`${micBiquadEnable || pdmBiquadEnable}`" >
181      <Member name="bq0_num1_coeff" value="0x3F27UL" />
182      <Member name="bq0_num2_coeff" value="0x81B2UL" />
183      <Member name="bq0_num3_coeff" value="0x3F27UL" />
184      <Member name="bq0_den2_coeff" value="0x81B5UL" />
185      <Member name="bq0_den3_coeff" value="0x3E51UL" />
186      <Member name="bq1_num1_coeff" value="0x4CCFUL" />
187      <Member name="bq1_num2_coeff" value="0UL" />
188      <Member name="bq1_num3_coeff" value="0UL" />
189      <Member name="bq1_den2_coeff" value="0UL" />
190      <Member name="bq1_den3_coeff" value="0UL" />
191      <Member name="bq2_num1_coeff" value="0x4000UL" />
192      <Member name="bq2_num2_coeff" value="0UL" />
193      <Member name="bq2_num3_coeff" value="0UL" />
194      <Member name="bq2_den2_coeff" value="0UL" />
195      <Member name="bq2_den3_coeff" value="0UL" />
196      <Member name="bq3_num1_coeff" value="0x4000UL" />
197      <Member name="bq3_num2_coeff" value="0UL" />
198      <Member name="bq3_num3_coeff" value="0UL" />
199      <Member name="bq3_den2_coeff" value="0UL" />
200      <Member name="bq3_den3_coeff" value="0UL" />
201      <Member name="bq4_num1_coeff" value="0x4000UL" />
202      <Member name="bq4_num2_coeff" value="0UL" />
203      <Member name="bq4_num3_coeff" value="0UL" />
204      <Member name="bq4_den2_coeff" value="0UL" />
205      <Member name="bq4_den3_coeff" value="0UL" />
206    </ConfigStruct>
207
208    <ConfigStruct name="`${INST_NAME . &quot;_mic_config&quot;}`" type="cy_stc_adcmic_mic_config_t" const="`${inFlash}`" public="true" include="`${micCfg}`" >
209      <Member name="sampleRate" value="`${micSampleRate}`" />
210      <Member name="micBias" value="`${micBias}`" />
211      <Member name="micBiasLz" value="`${micBiasLz}`" />
212      <Member name="micClamp" value="`${clamp}`" />
213      <Member name="pgaGain" value="`${pgaGain}`" />
214      <Member name="pgaInCm" value="`${pgaInCm}`" />
215      <Member name="pgaOutCm" value="`${pgaOutCm}`" />
216      <Member name="biQuadConfig" value="`${micBiquadEnable ? (inFlash ? &quot;(cy_stc_adcmic_biquad_config_t*)&quot; : &quot;&quot;) . &quot;&amp;&quot; . INST_NAME . &quot;_biquad_config&quot; : &quot;NULL&quot;}`" />
217      <Member name="fifoTrigger" value="`${micFifoEnable}`" />
218      <Member name="fifoFull" value="`${micFull}`" />
219      <Member name="fifoEmpty" value="`${micEmpty}`" />
220    </ConfigStruct>
221
222    <ConfigStruct name="`${INST_NAME . &quot;_pdm_config&quot;}`" type="cy_stc_adcmic_pdm_config_t" const="`${inFlash}`" public="true" include="`${pdmCfg}`" >
223      <Member name="sampleRate" value="`${pdmSampleRate}`" />
224      <Member name="clockInv" value="`${clockInv}`" />
225      <Member name="latchDelay" value="`${latchDelay}`" />
226      <Member name="biQuadConfig" value="`${pdmBiquadEnable ? (inFlash ? &quot;(cy_stc_adcmic_biquad_config_t*)&quot; : &quot;&quot;) . &quot;&amp;&quot; . INST_NAME . &quot;_biquad_config&quot; : &quot;NULL&quot;}`" />
227      <Member name="fifoTrigger" value="`${pdmFifoEnable}`" />
228      <Member name="fifoFull" value="`${pdmFull}`" />
229      <Member name="fifoEmpty" value="`${pdmEmpty}`" />
230    </ConfigStruct>
231
232    <ConfigStruct name="`${INST_NAME . &quot;_context&quot;}`" type="cy_stc_adcmic_context_t" const="false" public="true" include="`${dcCfg}`" />
233
234    <ConfigStruct name="`${INST_NAME . &quot;_dc_config&quot;}`" type="cy_stc_adcmic_dc_config_t" const="`${inFlash}`" public="true" include="`${dcCfg}`" >
235      <Member name="range" value="`${range}`" />
236      <Member name="channel" value="`${dcIn}`" />
237      <Member name="timerPeriod" value="`${period}`" />
238      <Member name="timerInput" value="`${tmin}`" />
239      <Member name="context" value="&amp;`${INST_NAME}`_context" />
240    </ConfigStruct>
241
242    <ConfigStruct name="`${INST_NAME . &quot;_config&quot;}`" type="cy_stc_adcmic_config_t" const="`${inFlash}`" public="true" include="true" >
243      <Member name="micConfig" value="`${micCfg ? (inFlash ? &quot;(cy_stc_adcmic_mic_config_t*)&quot; : &quot;&quot;) . &quot;&amp;&quot; . INST_NAME . &quot;_mic_config&quot; : &quot;NULL&quot;}`" />
244      <Member name="pdmConfig" value="`${pdmCfg ? (inFlash ? &quot;(cy_stc_adcmic_pdm_config_t*)&quot; : &quot;&quot;) . &quot;&amp;&quot; . INST_NAME . &quot;_pdm_config&quot; : &quot;NULL&quot;}`" />
245      <Member name="dcConfig" value="`${dcCfg ? (inFlash ? &quot;(cy_stc_adcmic_dc_config_t*)&quot; : &quot;&quot;) . &quot;&amp;&quot; . INST_NAME . &quot;_dc_config&quot; : &quot;NULL&quot;}`" />
246    </ConfigStruct>
247
248    <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)">
249      <Member name="type" value="CYHAL_RSC_ADC" />
250      <Member name="block_num" value="0" />
251      <Member name="channel_num" value="0" />
252    </ConfigStruct>
253
254    <ConfigInstruction value="cyhal_hwmgr_reserve(&amp;`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" />
255
256  </ConfigFirmware>
257</Personality>
258