1<?xml version="1.0" encoding="utf-8"?>
2
3
4<!--****************************************************************************
5* \file pclk.cypersonality
6* \version 3.0
7*
8* \brief
9* Peripheral Clock personality description file.
10* This supports CAT1A devices.
11********************************************************************************
12* \copyright
13* Copyright (c) (2020-2022), Cypress Semiconductor Corporation (an Infineon company) or
14* an affiliate of Cypress Semiconductor Corporation.
15* SPDX-License-Identifier: Apache-2.0
16*
17* Licensed under the Apache License, Version 2.0 (the "License");
18* you may not use this file except in compliance with the License.
19* You may obtain a copy of the License at
20*
21*     http://www.apache.org/licenses/LICENSE-2.0
22*
23* Unless required by applicable law or agreed to in writing, software
24* distributed under the License is distributed on an "AS IS" BASIS,
25* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26* See the License for the specific language governing permissions and
27* limitations under the License.
28*****************************************************************************-->
29
30<Personality id="pclk" name="Peripheral Clock" version="3.0" xmlns="http://cypress.com/xsd/cyhwpersonality_v7">
31  <Dependencies>
32    <IpBlock name="mxperi,mxperi_ver2" />
33    <Resource name="peri\.div_(8|16|16_5|24_5)" />
34  </Dependencies>
35  <ExposedMembers>
36    <ExposedMember key="type" paramId="typeApiConst" />
37    <ExposedMember key="number" paramId="number" />
38    <ExposedMember key="clockSel" paramId="clockSel" />
39    <ExposedMember key="frequency" paramId="frequency" />
40    <ExposedMember key="divider" paramId="divider" />
41    <ExposedMember key="accuracy" paramId="accuracy" />
42    <ExposedMember key="error" paramId="srcNotUsed" />
43    <ExposedMember key="hal_block" paramId="hal_block" />
44    <ExposedMember key="sourceClockRsc" paramId="sourceClockRsc" />
45  </ExposedMembers>
46  <Parameters>
47    <!-- PDL documentation -->
48    <ParamDoc id="pdlDoc" name="Configuration Help" group="Overview" default="file:///`${cy_libs_path()}`/docs/pdl_api_reference_manual/html/group__group__sysclk__clk__peripheral.html" linkText="Open Peripherals Clock Dividers Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />
49
50    <!-- Get the name of the source clock resource, i.e. CLK_PERI -->
51    <ParamString id="sourceClockRsc" name="Source Clock Resource" group="Internal" default="srss[0].clock[0].periclk[0]" visible="false" editable="false" desc="" />
52
53    <!-- Set an error if the source clock is not enabled or contains an error -->
54    <ParamBool id="srcNotUsed" name="Clock Source Enabled" group="Internal" default="`${!isBlockUsed(sourceClockRsc)}`" visible="false" editable="false" desc="" />
55    <ParamBool id="error" name="Clock Error" group="Internal" default="`${srcNotUsed || getExposedMember(sourceClockRsc, &quot;error&quot;)}`" visible="false" editable="false" desc="" />
56
57    <!-- Source clock frequency -->
58    <ParamRange  id="sourceFreq" name="sourceFrequency" group="Internal" default="`${!error ? getExposedMember(sourceClockRsc, &quot;frequency&quot;) : 0}`" min="0" max="400000000" resolution="1" visible="false" editable="false" desc="" />
59    <ParamString id="accuracy" name="accuracy" group="General" default="`${!error ? getExposedMember(sourceClockRsc, &quot;accuracy&quot;) : 0}`" visible="false" editable="false" desc="" />
60    <ParamString id="sourceFreqInfo" name="Source Clock" group="General" default="CLK_PERI (`${formatFrequency(sourceFreq,accuracy)}`)" visible="true" editable="false" desc="Source clock frequency" />
61
62    <!-- Get the peripheral clock divider type, width and number -->
63    <ParamChoice id="type" name="Divider type" group="Internal" default="`${getBlockType(1)}`" visible="false" editable="false" desc="">
64      <Entry name="div_8"    value="div_8"    visible="true" />
65      <Entry name="div_16"   value="div_16"   visible="true" />
66      <Entry name="div_16_5" value="div_16_5" visible="true" />
67      <Entry name="div_24_5" value="div_24_5" visible="true" />
68    </ParamChoice>
69    <ParamRange  id="width"  name="Divider width" group="Internal" default="`${type eq div_8 ? 8 : type eq div_24_5 ? 24 : 16}`" min="8" max="24" resolution="1" visible="false" editable="false" desc="" />
70    <ParamRange  id="number" name="Divider number" group="Internal" default="`${getInstNumber(getBlockType(1))}`" min="0" max="63" resolution="1" visible="false" editable="false" desc="" />
71
72    <!-- Determine if the divider is fractional -->
73    <ParamBool   id="isFractional" name="isFractional" group="Internal" default="`${(type eq div_16_5) || (type eq div_24_5)}`" visible="false" editable="false" desc="" />
74
75    <!-- Dividers -->
76    <ParamRange  id="intDivider" name="`${isFractional ? &quot;Integer Divider&quot; : &quot;Divider&quot;}`" group="General" default="1" min="1" max="`${pow(2, width)}`" resolution="1" visible="true" editable="true" desc="" />
77    <ParamRange  id="fracDivider" name="Fractional Divider" group="General" default="0" min="0" max="31" resolution="1" visible="`${isFractional}`" editable="true" desc="" />
78    <ParamRange  id="divider" name="Divider" group="Internal" default="`${isFractional ? intDivider + fracDivider / 32.0 : intDivider}`" min="1" max="`${pow(2, width) + 31.0/32.0}`" resolution="0.00001" visible="false" editable="false" desc="" />
79
80    <!-- Output frequency -->
81    <ParamRange id="frequency" name="Frequency" group="General" default="`${cast(int64, ((sourceFreq / cast(float, divider) + 0.0005) * 1000)) / 1000.0}`" min="0" max="400000000" resolution="0.001" visible="false" editable="false" desc="The resulting output clock frequency" />
82
83    <ParamString id="frequencyInfo" name="Frequency" group="General" default="`${formatFrequency(frequency,accuracy)}`" visible="true" editable="false" desc="The resulting output clock frequency" />
84
85    <ParamBool   id="startOnReset" name="Start on Reset" group="General" default="true" visible="true" editable="true" desc="If checked, this option will cause the clock to be enabled by the clock initialization routine" />
86
87    <ParamString id="typeApiConst" name="typeApiConst" group="Internal" default="`${type eq div_8    ? &quot;CY_SYSCLK_DIV_8_BIT&quot;   :
88                                                                                   type eq div_16   ? &quot;CY_SYSCLK_DIV_16_BIT&quot;   :
89                                                                                   type eq div_16_5 ? &quot;CY_SYSCLK_DIV_16_5_BIT&quot; :
90                                                                                                      &quot;CY_SYSCLK_DIV_24_5_BIT&quot;}`" visible="false" editable="false" desc="API constants for the divider type" />
91
92    <ParamString id="clockSel" name="clockSel" group="Internal" default="`${typeApiConst}`, `${number}`U" visible="false" editable="false" desc="Divider type and number" />
93
94    <ParamSignal port="clk[0]" name="Peripherals" group="General" visible="true" desc="This signal can be used to drive peripherals" canBeEmpty="true" />
95
96    <ParamString id="typeApiConstHal" name="typeApiConst" group="Internal" default="`${type eq div_8    ? &quot;8BIT&quot;    :
97                                                                                       type eq div_16   ? &quot;16BIT&quot;   :
98                                                                                       type eq div_16_5 ? &quot;16_5BIT&quot; :
99                                                                                                          &quot;24_5BIT&quot;}`" visible="false" editable="false" desc="API constants for the divider type" />
100
101    <ParamString id="hal_block" name="hal_block" group="Internal" default="CYHAL_CLOCK_BLOCK_PERIPHERAL_`${typeApiConstHal}`" visible="false" editable="false" desc="" />
102  </Parameters>
103
104  <DRCs>
105    <DRC type="ERROR" text="CLK_PERI clock is not enabled" condition="`${srcNotUsed}`" >
106      <FixIt action="ENABLE_BLOCK" target="`${sourceClockRsc}`" value="" valid="true" />
107    </DRC>
108  </DRCs>
109
110  <ConfigFirmware>
111    <ConfigInclude value="cy_sysclk.h" include="true" />
112    <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" />
113
114    <ConfigDefine name="`${INST_NAME}`_HW" value="`${typeApiConst}`" public="true" include="true" />
115    <ConfigDefine name="`${INST_NAME}`_NUM" value="`${number}`U" public="true" include="true" />
116
117    <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)">
118      <Member name="type" value="CYHAL_RSC_CLOCK" />
119      <Member name="block_num" value="`${INST_NAME}`_HW" />
120      <Member name="channel_num" value="`${INST_NAME}`_NUM" />
121    </ConfigStruct>
122
123    <ConfigInstruction value="Cy_SysClk_PeriphDisableDivider(`${clockSel}`);" include="true"  />
124    <ConfigInstruction value="Cy_SysClk_PeriphSetDivider(`${clockSel}`, `${intDivider-1}`U);" include="`${!isFractional}`"  />
125    <ConfigInstruction value="Cy_SysClk_PeriphSetFracDivider(`${clockSel}`, `${intDivider-1}`U, `${fracDivider}`U);" include="`${isFractional}`"  />
126    <ConfigInstruction value="Cy_SysClk_PeriphEnableDivider(`${clockSel}`);" include="`${startOnReset}`"  />
127    <ConfigInstruction value="cyhal_hwmgr_reserve(&amp;`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" />
128  </ConfigFirmware>
129</Personality>
130