1<?xml version="1.0" encoding="utf-8"?>
2
3
4<!--****************************************************************************
5* \file quaddec.cypersonality
6* \version 1.0
7*
8* \brief
9* Quadrature Decoder personality description file.
10*
11********************************************************************************
12* \copyright
13* Copyright 2018-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="mxs40quaddac" name="Quadrature Decoder" version="1.0" xmlns="http://cypress.com/xsd/cyhwpersonality_v7">
30  <Dependencies>
31    <IpBlock name="mxtcpwm" />
32    <Resource name="tcpwm\.cnt" />
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__tcpwm__quaddec.html" linkText="Open Quadrature Decoder (TCPWM) Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />
38
39    <!--General-->
40    <ParamChoice id="CounterSize" name="Quadrature Decoder Resolution" group="General" default="`${(CNT.CNT_WIDTH eq 16) ? &quot;16&quot; : &quot;32&quot;}`" visible="true" editable="false" desc="Sets the resolution of the counter">
41      <Entry name="16-bits" value="16" visible="true" />
42      <Entry name="32-bits" value="32" visible="true" />
43    </ParamChoice>
44    <ParamChoice id="InterruptSource" name="Interrupt Source" group="General" default="CY_TCPWM_INT_NONE" visible="true" editable="true" desc="Selects which events can trigger an interrupt">
45      <Entry name="None" value="CY_TCPWM_INT_NONE" visible="true" />
46      <Entry name="Index" value="CY_TCPWM_INT_ON_TC" visible="true" />
47      <Entry name="TC" value="CY_TCPWM_INT_ON_CC" visible="true" />
48      <Entry name="Index or TC" value="CY_TCPWM_INT_ON_CC_OR_TC" visible="true" />
49    </ParamChoice>
50    <ParamChoice id="Resolution" name="Quadrature Mode" group="General" default="CY_TCPWM_QUADDEC_X1" visible="true" editable="true" desc="Selects the quadrature encoding mode">
51      <Entry name="x1" value="CY_TCPWM_QUADDEC_X1" visible="true" />
52      <Entry name="x2" value="CY_TCPWM_QUADDEC_X2" visible="true" />
53      <Entry name="x4" value="CY_TCPWM_QUADDEC_X4" visible="true" />
54    </ParamChoice>
55
56    <!--Inputs-->
57    <ParamSignal port="clock[0]" name="Clock Signal" group="Inputs" visible="true" desc="The clock input defines the operating frequency." canBeEmpty="false" />
58    <ParamChoice id="IndexInput" name="Index Input" group="Inputs" default="CY_TCPWM_INPUT_DISABLED" visible="true" editable="true" desc="Determines if an index is needed and what edge causes an index to occur">
59      <Entry name="Rising Edge" value="CY_TCPWM_INPUT_RISINGEDGE" visible="true" />
60      <Entry name="Falling Edge" value="CY_TCPWM_INPUT_FALLINGEDGE" visible="true" />
61      <Entry name="Either Edge" value="CY_TCPWM_INPUT_EITHEREDGE" visible="true" />
62      <Entry name="Disabled" value="CY_TCPWM_INPUT_DISABLED" visible="true" />
63    </ParamChoice>
64    <ParamSignal port="reload[0]" name="Index Signal" group="Inputs" visible="`${IndexInput ne CY_TCPWM_INPUT_DISABLED}`" desc="This input causes an index (reload) event to occur (indicates a completed rotation to determine absolute position). This input is only visible if the IndexInput parameter is set to anything other than disabled." canBeEmpty="`${IndexInput eq CY_TCPWM_INPUT_DISABLED}`" >
65      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
66        <Parameter id="DriveModes" severity="DEFAULT" reason="">
67          <Fixed value="CY_GPIO_DM_HIGHZ" />
68        </Parameter>
69      </Constraint>
70      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
71        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
72          <Fixed value="CY_GPIO_DM_HIGHZ" />
73        </Parameter>
74      </Constraint>
75      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
76    </ParamSignal>
77
78    <ParamSignal port="count[0]" name="PhiA Signal" group="Inputs" visible="true" desc="This is the phase A input it is always required." canBeEmpty="false" >
79      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
80        <Parameter id="DriveModes" severity="DEFAULT" reason="">
81          <Fixed value="CY_GPIO_DM_HIGHZ" />
82        </Parameter>
83      </Constraint>
84      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
85        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
86          <Fixed value="CY_GPIO_DM_HIGHZ" />
87        </Parameter>
88      </Constraint>
89      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
90    </ParamSignal>
91    <ParamSignal port="start[0]" name="PhiB Signal" group="Inputs" visible="true" desc="This is the phase B input it is always required." canBeEmpty="false" >
92      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
93        <Parameter id="DriveModes" severity="DEFAULT" reason="">
94          <Fixed value="CY_GPIO_DM_HIGHZ" />
95        </Parameter>
96      </Constraint>
97      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
98        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
99          <Fixed value="CY_GPIO_DM_HIGHZ" />
100        </Parameter>
101      </Constraint>
102      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
103    </ParamSignal>
104
105    <ParamChoice id="StopInput" name="Stop Input" group="Inputs" default="CY_TCPWM_INPUT_DISABLED" visible="true" editable="true" desc="Determines if a stop input is needed and what edges causes a stop to occur">
106      <Entry name="Rising Edge" value="CY_TCPWM_INPUT_RISINGEDGE" visible="true" />
107      <Entry name="Falling Edge" value="CY_TCPWM_INPUT_FALLINGEDGE" visible="true" />
108      <Entry name="Either Edge" value="CY_TCPWM_INPUT_EITHEREDGE" visible="true" />
109      <Entry name="Disabled" value="CY_TCPWM_INPUT_DISABLED" visible="true" />
110    </ParamChoice>
111    <ParamSignal port="stop[0]" name="Stop Signal" group="Inputs" visible="`${StopInput ne CY_TCPWM_INPUT_DISABLED}`" desc="This input causes the Quad Dec to stop Counting. This input is only visible if the StopInput parameter is set to anything other than disabled." canBeEmpty="`${StopInput eq CY_TCPWM_INPUT_DISABLED}`" >
112      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
113        <Parameter id="DriveModes" severity="DEFAULT" reason="">
114          <Fixed value="CY_GPIO_DM_HIGHZ" />
115        </Parameter>
116      </Constraint>
117      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
118        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
119          <Fixed value="CY_GPIO_DM_HIGHZ" />
120        </Parameter>
121      </Constraint>
122      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
123    </ParamSignal>
124
125    <!--Outputs-->
126    <ParamSignal port="tr_compare_match[0]" name="TC (cc_match)" group="Outputs" visible="true" desc="This output goes high on an index event, or when the count equals 0x0000 or `${(CNT.CNT_WIDTH eq 16) ? &quot;0xffff&quot; : &quot;0xffffffff&quot;}`." canBeEmpty="true" >
127      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
128        <Parameter id="DriveModes" severity="DEFAULT" reason="">
129          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
130        </Parameter>
131      </Constraint>
132      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
133        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
134          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
135        </Parameter>
136      </Constraint>
137      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
138    </ParamSignal>
139
140    <!--Config-->
141    <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)." />
142
143    <!-- Peripheral clock divider connection -->
144    <ParamRange id="tcpwmInst" name="TCPWM Number" group="Internal" default="`${getInstNumber(&quot;tcpwm&quot;)}`" min="0" max="127" resolution="1" visible="false" editable="false" desc="" />
145    <ParamRange id="cntInst" name="CNT Number" group="Internal" default="`${getInstNumber(&quot;cnt&quot;)}`" min="0" max="31" resolution="1" visible="false" editable="false" desc="" />
146    <ParamString id="definePrefix" name="Define prefix" group="Internal" default="`${&quot;TCPWM&quot; . tcpwmInst . &quot;_CNT&quot; . cntInst}`" visible="false" editable="false" desc="" />
147    <ParamString id="defineInputDisabled" name="Define input disabled" group="Internal" default="`${INST_NAME . &quot;_INPUT_DISABLED &amp; 0x3U&quot;}`" visible="false" editable="false" desc="" />
148    <ParamString id="pclk" name="PCLK" group="Internal" default="`${getBlockFromSignal(&quot;clock[0]&quot;)}`" visible="false" editable="false" desc="Connected peripheral clock divider (PCLK)" />
149    <ParamBool id="pclkOk" name="PCLK Valid" group="Internal" default="`${hasConnection(&quot;clock&quot;, 0) &amp;&amp; isBlockUsed(pclk)}`" visible="false" editable="false" desc="Checks whether there is a PCLK connected and enabled" />
150    <ParamString id="pclkDst" name="PCLK Destination" group="Internal" default="PCLK_TCPWM`${tcpwmInst}`_CLOCKS`${cntInst}`" visible="false" editable="false" desc="" />
151  </Parameters>
152
153  <DRCs>
154  </DRCs>
155
156  <ConfigFirmware>
157    <ConfigInclude value="cy_tcpwm_quaddec.h" include="true" />
158    <ConfigInclude value="cy_sysclk.h" include="`${pclkOk}`" />
159    <ConfigInclude value="cycfg_routing.h" include="true" />
160    <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" />
161    <ConfigInclude value="cyhal.h" include="true" guard="defined (CY_USING_HAL)" />
162
163    <ConfigDefine name="`${INST_NAME}`_HW" value="TCPWM`${tcpwmInst}`" public="true" include="true" />
164    <ConfigDefine name="`${INST_NAME}`_NUM" value="`${cntInst}`UL" public="true" include="true" />
165    <ConfigDefine name="`${INST_NAME}`_MASK" value="(1UL &lt;&lt; `${cntInst}`)" public="true" include="true" />
166    <ConfigDefine name="`${INST_NAME}`_IRQ" value="tcpwm_`${tcpwmInst}`_interrupts_`${cntInst}`_IRQn" public="true" include="`${InterruptSource ne CY_TCPWM_INT_NONE}`" />
167    <ConfigDefine name="`${INST_NAME}`_INPUT_DISABLED" value="0x7U" public="false" include="true" />
168    <ConfigStruct name="`${INST_NAME . &quot;_config&quot;}`" type="cy_stc_tcpwm_quaddec_config_t" const="`${inFlash}`" public="true" include="true" >
169      <Member name="resolution" value="`${Resolution}`" />
170      <Member name="interruptSources" value="`${InterruptSource}`" />
171      <Member name="indexInputMode" value="`${IndexInput eq CY_TCPWM_INPUT_DISABLED ? defineInputDisabled : IndexInput}`" />
172      <Member name="indexInput" value="`${IndexInput eq CY_TCPWM_INPUT_DISABLED ? &quot;CY_TCPWM_INPUT_0&quot; : (definePrefix . &quot;_RELOAD_VALUE&quot;)}`" />
173      <Member name="stopInputMode" value="`${StopInput eq CY_TCPWM_INPUT_DISABLED ? defineInputDisabled : StopInput}`" />
174      <Member name="stopInput" value="`${StopInput eq CY_TCPWM_INPUT_DISABLED ? &quot;CY_TCPWM_INPUT_0&quot; : (definePrefix . &quot;_STOP_VALUE&quot;)}`" />
175      <Member name="phiAInput" value="`${(definePrefix . &quot;_COUNT_VALUE&quot;)}`" />
176      <Member name="phiBInput" value="`${(definePrefix . &quot;_START_VALUE&quot;)}`" />
177    </ConfigStruct>
178
179    <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)">
180      <Member name="type" value="CYHAL_RSC_TCPWM" />
181      <Member name="block_num" value="`${getInstNumber(&quot;tcpwm&quot;)}`U" />
182      <Member name="channel_num" value="`${getInstNumber(&quot;cnt&quot;)}`U" />
183    </ConfigStruct>
184
185    <ConfigStruct name="`${INST_NAME}`_clock" type="cyhal_clock_t" const="`${inFlash}`" public="true" include="true" guard="defined (CY_USING_HAL)">
186      <Member name="block" value="`${getExposedMember(pclk, &quot;hal_block&quot;)}`" />
187      <Member name="channel" value="`${getExposedMember(pclk, &quot;number&quot;)}`" />
188      <Member name="reserved" value="false" />
189      <Member name="funcs" value="NULL" />
190    </ConfigStruct>
191
192    <ConfigStruct name="`${INST_NAME}`_hal_config" type="cyhal_quaddec_configurator_t" const="`${inFlash}`" public="true" include="true" guard="defined (CY_USING_HAL)">
193      <Member name="resource" value="&amp;`${INST_NAME}`_obj" />
194      <Member name="config" value="&amp;`${INST_NAME}`_config" />
195      <Member name="clock" value="&amp;`${INST_NAME}`_clock" />
196    </ConfigStruct>
197
198    <ConfigInstruction value="Cy_SysClk_PeriphAssignDivider(`${pclkDst}`, `${getExposedMember(pclk, &quot;clockSel&quot;)}`);" include="`${pclkOk}`"  />
199    <ConfigInstruction value="cyhal_hwmgr_reserve(&amp;`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" />
200  </ConfigFirmware>
201</Personality>
202