1<?xml version="1.0" encoding="utf-8"?>
2
3
4<!--****************************************************************************
5* \file seglcd.cypersonality
6* \version 1.1.1
7*
8* \brief
9* LCD personality description file.
10*
11********************************************************************************
12* \copyright
13* Copyright 2019-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="seglcd" name="Segment LCD" version="1.1" xmlns="http://cypress.com/xsd/cyhwpersonality_v7">
30  <Dependencies>
31    <IpBlock name="mxlcd,mxlcd_ver2" />
32    <Resource name="lcd\.drive" />
33  </Dependencies>
34  <ExposedMembers>
35    <ExposedMember key="configured" paramId="configured" />
36  </ExposedMembers>
37  <Parameters>
38    <!-- PDL documentation -->
39    <ParamDoc id="pdlDoc" name="Configuration Help" group="Overview" default="file:///`${cy_libs_path()}`/docs/pdl_api_reference_manual/html/group__group__seglcd.html" linkText="Open SegLCD Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />
40
41    <ParamRange id="maxComNum" name="maxComNum" group="Internal" default="`${CHIP_TOP.COM_NR}`" min="0" max="100" resolution="1" visible="false" editable="false" desc="" />
42    <ParamRange id="maxPinNum" name="maxPinNum" group="Internal" default="`${CHIP_TOP.PIN_NR}`" min="0" max="100" resolution="1" visible="false" editable="false" desc="" />
43    <ParamRange id="comNum" name="Commons" group="Internal" default="0" min="0" max="`${CHIP_TOP.COM_NR}`" resolution="1" visible="false" editable="true" desc="" />
44    <ParamRange id="segNum" name="Segments" group="Internal" default="0" min="0" max="`${CHIP_TOP.PIN_NR}`" resolution="1" visible="false" editable="true" desc="" />
45    <ParamBool id="configured" name="configured" group="Internal" default="`${1 &lt; comNum}`" visible="false" editable="false" desc="" />
46    <ParamString id="cfgFileName" name="cfgFileName" group="External Tools" default="design.cyseglcd" visible="false" editable="false" desc="" />
47    <ParamString id="cfgFilePath" name="cfgFilePath" group="External Tools" default="`${cy_design_path() . &quot;/&quot; . cfgFileName}`" visible="false" editable="false" desc="" />
48
49    <ParamCustom id="configurator" name="SegLCD Configurator" group="External Tools" default="0" path="`${cy_tools_path(&quot;seglcd-configurator&quot;) . &quot;/seglcd-configurator&quot;}`" modal="true" visible="true" editable="true" desc="Launch SegLCD Configurator.">
50      <Arg value="`${&quot;--config=&quot; . cfgFilePath}`" />
51      <Arg value="`${&quot;--output-dir=&quot; . cy_codegen_path()}`" />
52      <Arg value="`${&quot;--design=&quot; . cy_design_file()}`" />
53      <Arg value="`${&quot;--library=&quot; . cy_libs_file()}`" />
54      <Arg value="`${&quot;-n=&quot; . INST_NAME}`" />
55    </ParamCustom>
56
57    <ParamChoice id="speed" name="Speed Mode" group="General" default="CY_SEGLCD_SPEED_LOW" visible="true" editable="true" desc="The Speed Mode: Low Speed or High Speed.">
58      <Entry name="Low Speed" value="CY_SEGLCD_SPEED_LOW" visible="true" />
59      <Entry name="High Speed" value="CY_SEGLCD_SPEED_HIGH" visible="true" />
60    </ParamChoice>
61    <ParamBool id="speedLow" name="speedLow" group="Internal" default="`${speed eq CY_SEGLCD_SPEED_LOW}`" visible="false" editable="false" desc="" />
62    <ParamSignal port="clock[0]" name="Clock" group="General" visible="true" desc="High speed clock source" canBeEmpty="`${speed eq CY_SEGLCD_SPEED_LOW}`" />
63
64    <ParamBool id="ipver1" name="IP Version 1" group="Internal" default="`${1 eq getVersion()}`" visible="false" editable="false" desc="" />
65    <ParamBool id="ipver2" name="IP Version 2" group="Internal" default="`${2 eq getVersion()}`" visible="false" editable="false" desc="" />
66
67    <ParamChoice id="lsClk" name="Low Speed Clock Input" group="General" default="CY_SEGLCD_LSCLK_LF" visible="`${speedLow &amp;&amp; ipver2}`" editable="true" desc="The Low Speed Clock Source selection.">
68      <Entry name="Low Frequency"    value="CY_SEGLCD_LSCLK_LF" visible="true" />
69      <Entry name="Medium Frequency" value="CY_SEGLCD_LSCLK_MF" visible="true" />
70    </ParamChoice>
71
72    <ParamSignal port="clk_mf[0]" name="MF Clock" group="General" visible="`${ipver2}`" desc="Low speed medium frequency slock source" canBeEmpty="`${ipver1 || (lsClk eq CY_SEGLCD_LSCLK_LF)}`" />
73
74    <ParamChoice id="drive" name="Driving Mode" group="General" default="CY_SEGLCD_CORRELATION" visible="true" editable="true" desc="Driving mode configuration">
75      <Entry name="Digital Correlation" value="CY_SEGLCD_CORRELATION" visible="true" />
76      <Entry name="PWM" value="CY_SEGLCD_PWM" visible="true" />
77    </ParamChoice>
78
79    <ParamChoice id="bias" name="PWM Bias" group="General" default="CY_SEGLCD_BIAS_HALF" visible="`${drive eq CY_SEGLCD_PWM}`" editable="true" desc="PWM bias selection">
80      <Entry name="1/2 Bias" value="CY_SEGLCD_BIAS_HALF" visible="true" />
81      <Entry name="1/3 Bias" value="CY_SEGLCD_BIAS_THIRD" visible="true" />
82      <Entry name="1/4 Bias" value="CY_SEGLCD_BIAS_FOURTH" visible="`${(speed eq CY_SEGLCD_SPEED_HIGH) || ipver2}`" />
83      <Entry name="1/5 Bias" value="CY_SEGLCD_BIAS_FIFTH" visible="`${(speed eq CY_SEGLCD_SPEED_HIGH) || ipver2}`" />
84    </ParamChoice>
85
86    <ParamChoice id="wave" name="Waveform Type" group="General" default="CY_SEGLCD_TYPE_A" visible="true" editable="true" desc="Type A - Each frame addresses each COM pin only once with a balanced (DC=0) waveform. Type B - Each frame addresses each COM pin twice in sequence with a positive and negative waveform that together are balanced (DC=0).">
87      <Entry name="Type A" value="CY_SEGLCD_TYPE_A" visible="true"/>
88      <Entry name="Type B" value="CY_SEGLCD_TYPE_B" visible="true"/>
89    </ParamChoice>
90
91    <ParamChoice id="frRate" name="Frame Rate (Hz)" group="General" default="60" visible="true" editable="true" desc="The desired LCD frame rate">
92      <Entry name="30" value="30" visible="true" />
93      <Entry name="40" value="40" visible="true" />
94      <Entry name="50" value="50" visible="true" />
95      <Entry name="60" value="60" visible="true" />
96      <Entry name="70" value="70" visible="true" />
97      <Entry name="80" value="80" visible="true" />
98      <Entry name="90" value="90" visible="true" />
99      <Entry name="100" value="100" visible="true" />
100      <Entry name="110" value="110" visible="true" />
101      <Entry name="120" value="120" visible="true" />
102      <Entry name="130" value="130" visible="true" />
103      <Entry name="140" value="140" visible="true" />
104      <Entry name="150" value="150" visible="true" />
105    </ParamChoice>
106
107    <ParamRange id="contrast" name="Contrast (%)" group="General" default="60" min="0" max="100" resolution="1" visible="true" editable="true" desc="The desired LCD contrast" />
108
109    <Repeat count="16">
110        <ParamSignal port="comP[$idx]" name="Com[$idx]" group="Connections" visible="`${$idx &lt; comNum}`" desc="The LCD common line" canBeEmpty="`${$idx &gt; comNum - 1}`" multiSelect="false">
111          <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
112            <Parameter id="DriveModes" severity="DEFAULT" reason="">
113              <Fixed value="CY_GPIO_DM_PULLUP_DOWN_IN_OFF" />
114            </Parameter>
115            <Parameter id="driveStrength" severity="DEFAULT" reason="">
116              <Fixed value="CY_GPIO_DRIVE_1_8" />
117            </Parameter>
118          </Constraint>
119          <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
120        </ParamSignal>
121    </Repeat>
122
123    <Repeat count="62">
124        <ParamSignal port="segP[$idx]" name="Seg[$idx]" group="Connections" visible="`${$idx &lt; segNum}`" desc="The LCD segment line" canBeEmpty="`${$idx &gt; segNum - 1}`" multiSelect="false">
125          <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
126            <Parameter id="DriveModes" severity="DEFAULT" reason="">
127              <Fixed value="CY_GPIO_DM_PULLUP_DOWN_IN_OFF" />
128            </Parameter>
129            <Parameter id="driveStrength" severity="DEFAULT" reason="">
130              <Fixed value="CY_GPIO_DRIVE_1_8" />
131            </Parameter>
132          </Constraint>
133          <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
134        </ParamSignal>
135    </Repeat>
136
137    <ParamString id="clkLf" name="clkLf" group="Internal" default="srss[0].clock[0].lfclk[0]" visible="false" editable="false" desc="" />
138    <ParamString id="clkMf" name="clkMf" group="Internal" default="srss[0].clock[0].mfclk[0]" visible="false" editable="false" desc="" />
139    <ParamString id="clkHsRsc" name="clkHsRsc" group="Internal" default="`${getBlockFromSignal(&quot;clock[0]&quot;)}`" visible="false" editable="false" desc="" />
140    <ParamString id="clkLsRsc" name="clkLsRsc" group="Internal" default="`${(lsClk eq CY_SEGLCD_LSCLK_MF) ? clkMf : clkLf}`" visible="false" editable="false" desc="" />
141    <ParamBool id="clkHsOk" name="clkHsOk" group="Internal" default="`${hasConnection(&quot;clock&quot;, 0) &amp;&amp; isBlockUsed(clkHsRsc)}`" visible="false" editable="false" desc="" />
142    <ParamBool id="clkLsOk" name="clkLsOk" group="Internal" default="`${isBlockUsed(clkLsRsc)}`" visible="false" editable="false" desc="" />
143    <ParamBool id="clkOk" name="clkOk" group="Internal" default="`${speedLow ? clkLsOk : clkHsOk}`" visible="false" editable="false" desc="" />
144    <ParamRange  id="frqHs" name="frqHs" group="Internal" default="`${(clkHsOk) ? getExposedMember(clkHsRsc, &quot;frequency&quot;) : 0}`" min="0" max="200000000" resolution="1" visible="false" editable="false" desc="" />
145    <ParamRange  id="frqLs" name="frqLs" group="Internal" default="`${(clkLsOk) ? getExposedMember(clkLsRsc, &quot;frequency&quot;) : 0}`" min="0" max="200000000" resolution="1" visible="false" editable="false" desc="" />
146    <ParamString id="accHs" name="AccHs" group="Internal" default="`${(clkHsOk) ? getExposedMember(clkHsRsc, &quot;accuracy&quot;) : 0}`" visible="false" editable="false" desc="" />
147    <ParamString id="accLs" name="AccLs" group="Internal" default="`${(clkLsOk) ? getExposedMember(clkLsRsc, &quot;accuracy&quot;) : 0}`" visible="false" editable="false" desc="" />
148    <ParamRange  id="frequency" name="frequency" group="Internal" default="`${speedLow ? frqLs : frqHs}`" min="0" max="200000000" resolution="1" visible="false" editable="false" desc="" />
149    <ParamString id="accuracy"  name="accuracy"  group="Internal" default="`${speedLow ? accLs : accHs}`" visible="false" editable="false" desc="" />
150    <ParamString id="frequencyInfo" name="Clock Frequency" group="General" default="`${formatFrequency(frequency,accuracy)}`" visible="true" editable="false" desc="The input clocking frequency" />
151    <ParamRange id="instance" name="instance" group="Internal" default="`${getInstNumber(&quot;lcd&quot;)}`" min="0" max="10" resolution="1" visible="false" editable="false" desc="" />
152    <ParamRange id="subfrDiv" name="Sub-Frame Divider" group="General" default="`${clkOk &amp;&amp; configured ? ((frequency / (frRate * 4.0 * comNum) - 1.0) * contrast / 100.0) : 0}`" min="0" max="1000000000" resolution="1" visible="true" editable="false" desc="The LCD signal generator divider for sub-frame timing generation, depends on the number of common lines, input clocking frequency and the desired contrast and frame rate" />
153    <ParamRange id="deadDiv" name="Dead Divider" group="General" default="`${clkOk &amp;&amp; configured ? ((frequency / frRate) * (1.0 - (contrast / 100.0))) : 0}`" min="0" max="1000000000" resolution="1" visible="true" editable="false" desc="The LCD signal generator divider for dead time period generation, depends on the input clocking frequency and the desired contrast and frame rate" />
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  <DRCs>
158    <DRC type="ERROR" text="The Sub-Frame Divider should not exceed 16-bit in High Speed Mode, please decrease the input clock frequency or increase the contrast or frame rate or number of common lines using SegLCD Configurator" condition="`${(subfrDiv &gt; 65535) &amp;&amp; ((speed eq CY_SEGLCD_SPEED_HIGH) || ipver2)}`" />
159    <DRC type="ERROR" text="The Dead Divider should not exceed 16-bit in High Speed Mode, please decrease the contrast or input clock frequency or increase the frame rate" condition="`${(deadDiv &gt; 65535) &amp;&amp; ((speed eq CY_SEGLCD_SPEED_HIGH) || ipver2)}`" />
160
161    <DRC type="ERROR" text="The Sub-Frame Divider should not exceed 8-bit in Low Speed Mode, please decrease the input clock frequency or increase the contrast or frame rate or number of common lines using SegLCD Configurator" condition="`${(subfrDiv &gt; 255) &amp;&amp; speedLow &amp;&amp; ipver1}`" />
162    <DRC type="ERROR" text="The Dead Divider should not exceed 8-bit in Low Speed Mode, please decrease the contrast or input clock frequency or increase the frame rate" condition="`${(deadDiv &gt; 255) &amp;&amp; speedLow &amp;&amp; ipver1}`" />
163
164    <DRC type="ERROR" text="The Low Frequency Clock Source (CLK_LF) should be enabled" condition="`${speedLow &amp;&amp; (lsClk eq CY_SEGLCD_LSCLK_LF) &amp;&amp; !isBlockUsed(clkLf)}`" />
165    <DRC type="ERROR" text="The Medium Frequency Clock Source (typically CLK_MF) should be enabled" condition="`${speedLow &amp;&amp; (lsClk eq CY_SEGLCD_LSCLK_MF) &amp;&amp; !isBlockUsed(clkMf)}`" />
166
167    <DRC type="INFO" text="Launch the SegLCD Configurator to configure your displays" condition="`${!configured}`" />
168  </DRCs>
169  <ConfigFirmware>
170    <!-- External tools -->
171    <ConfigTool value="`${cy_tools_path(&quot;seglcd-configurator&quot;) . &quot;/seglcd-configurator-cli&quot;}`" include="`${configured}`">
172      <Arg value="`${&quot;--config=&quot; . cfgFilePath}`" />
173      <Arg value="`${&quot;--output-dir=&quot; . cy_codegen_path()}`" />
174      <Arg value="`${&quot;-n=&quot; . INST_NAME}`" />
175    </ConfigTool>
176
177    <ConfigInclude value="cy_seglcd.h" include="true" />
178    <ConfigInclude value="cy_sysclk.h" include="`${clkHsOk}`" />
179    <ConfigInclude value="cycfg_routing.h" include="true" />
180    <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" />
181
182    <ConfigDefine name="`${INST_NAME}`_HW" value="LCD0" public="true" include="true" />
183    <ConfigDefine name="`${INST_NAME}`_COM_NUM" value="`${comNum}`" public="true" include="`${configured}`" />
184    <ConfigDefine name="`${INST_NAME}`_SEG_NUM" value="`${segNum}`" public="true" include="`${configured}`" />
185    <ConfigDefine name="`${INST_NAME}`_FRAME_RATE" value="`${frRate}`" public="true" include="true" />
186    <ConfigDefine name="`${INST_NAME}`_CONTRAST" value="`${contrast}`" public="true" include="true" />
187    <ConfigDefine name="`${INST_NAME}`_CLOCK_FREQ" value="`${frequency}`" public="true" include="true" />
188    <ConfigDefine name="`${INST_NAME}`_CONST_MODIFIER" value="`${inFlash ? &quot;const&quot; : &quot;&quot;}`" public="true" include="true" />
189
190    <ConfigDefine name="`${INST_NAME . &quot;_COM_&quot; . $idx}`" value="`${&quot;LCD&quot; . instance . &quot;_DRIVE0_COM&quot; . $idx}`" public="true" include="`${$idx &lt; comNum}`" repeatCount="16"/>
191    <ConfigDefine name="`${INST_NAME . &quot;_SEG_&quot; . $idx}`" value="`${&quot;LCD&quot; . instance . &quot;_DRIVE0_SEG&quot; . $idx}`" public="true" include="`${$idx &lt; segNum}`" repeatCount="62"/>
192
193    <!--ConfigStruct name="`${INST_NAME}`_commons" type="uint32_t" const="true" isArray="true" public="true" include="true">
194      <Member name="`${##}`"
195             value="`${&quot;CY_SEGLCD_COMMON(&quot; . INST_NAME . &quot;_COM_&quot; . ## . &quot;,&quot; . ## . &quot;UL)&quot;}`"
196           include="`${## &lt; comNum}`"
197             count="16"/>
198    </ConfigStruct-->
199
200    <ConfigStruct name="`${INST_NAME . &quot;_config&quot;}`" type="cy_stc_seglcd_config_t" const="`${inFlash}`" public="true" include="`${configured}`" >
201      <Member name="speed"    value="`${speed}`" />
202      <Member name="wave"     value="`${wave}`"  />
203      <Member name="drive"    value="`${drive}`" />
204      <Member name="bias"     value="`${bias}`"  />
205      <Member name="lsClk"    value="`${lsClk}`"  />
206      <Member name="comNum"   value="`${INST_NAME}`_COM_NUM"    />
207      <Member name="frRate"   value="`${INST_NAME}`_FRAME_RATE" />
208      <Member name="contrast" value="`${INST_NAME}`_CONTRAST"   />
209      <Member name="clkFreq"  value="`${INST_NAME}`_CLOCK_FREQ" />
210    </ConfigStruct>
211
212    <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)">
213      <Member name="type" value="CYHAL_RSC_LCD" />
214      <Member name="block_num" value="`${getInstNumber(&quot;lcd&quot;)}`U" />
215      <Member name="channel_num" value="0" />
216    </ConfigStruct>
217
218    <ConfigInstruction value="Cy_SysClk_PeriphAssignDivider(PCLK_LCD_CLOCK, `${getExposedMember(clkHsRsc, &quot;clockSel&quot;)}`);" include="`${clkHsOk &amp;&amp; configured}`" />
219    <ConfigInstruction value="cyhal_hwmgr_reserve(&amp;`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" />
220  </ConfigFirmware>
221</Personality>
222