Newer
Older
mbed-os / targets / TARGET_Cypress / TARGET_PSOC6 / mtb-pdl-cat1 / personalities / peripheral / spi-1.0.cypersonality
@Dustin Crossman Dustin Crossman on 4 Jun 2021 41 KB Fix file modes.
<?xml version="1.0" encoding="utf-8"?>


<!--****************************************************************************
* \file spi.cypersonality
* \version 1.0
*
* \brief
* SPI personality description file.
*
********************************************************************************
* \copyright
* Copyright 2018-2019 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************-->

<Personality id="mxs40spi" name="SPI" version="1.0" path="Communications" xmlns="http://cypress.com/xsd/cyhwpersonality_v1">
  <Dependencies>
    <IpBlock name="mxscb">
      <Param name="SPI" value="1" />
    </IpBlock>
    <Resource name="scb" used="true" />
  </Dependencies>
  <ExposedMembers />
  <Parameters>
    <!-- PDL documentation -->
    <ParamDoc id="pdlDoc" name="Configuration Help" group="Peripheral Documentation" default="file:///`${cy_libs_path()}`/docs/pdl_api_reference_manual/html/group__group__scb__spi.html" linkText="Open SPI SCB Documentation" visible="true" desc="Opens the Peripheral Driver Library Documentation" />

    <!-- IP Block property DeepSleepCapable -->
    <ParamBool id="DeepSleepCapable" name="DeepSleepCapable" group="Internal" default="`${DEEPSLEEP eq 1}`" visible="false" editable="false" desc="This parameter specifies the visibility of EnableWakeup parameter." />
    <ParamBool id="SlaveCapable" name="SlaveCapable" group="Internal" default="`${SPI_S eq 1}`" visible="false" editable="false" desc="This parameter specifies if SCB block supports Slave mode." />
    <ParamBool id="MasterCapable" name="MasterCapable" group="Internal" default="`${SPI_M eq 1}`" visible="false" editable="false" desc="This parameter specifies if SCB block supports Master mode." />

    <!--General-->
    <ParamChoice id="ModeUser" name="Mode" group="General" default="`${SlaveCapable ? &quot;CY_SCB_SPI_SLAVE&quot; : &quot;CY_SCB_SPI_MASTER&quot;}`" visible="true" editable="`${SlaveCapable &amp;&amp; MasterCapable}`" desc="This parameter specifies the mode of the SPI operation as: the slave or master.">
      <Entry name="Slave" value="CY_SCB_SPI_SLAVE" visible="`${SlaveCapable}`" />
      <Entry name="Master" value="CY_SCB_SPI_MASTER" visible="`${MasterCapable}`" />
    </ParamChoice>
    <ParamBool id="MasterMode" name="Master Mode" group="Internal" default="`${ModeUser eq CY_SCB_SPI_MASTER}`" visible="false" editable="false" desc="This parameter returns true when the mode is an SPI and it is a master." />

    <ParamChoice id="SubModeUser" name="Sub Mode" group="General" default="CY_SCB_SPI_MOTOROLA" visible="true" editable="`${!DeepSleepCapable}`" desc="This parameter specifies the sub-mode of the SPI as: Motorola, TI (Start Coincides), TI (Start Precedes), or National Semiconductor (Microwire).">
      <Entry name="Motorola" value="CY_SCB_SPI_MOTOROLA" visible="true" />
      <Entry name="TI (Start Coincides)" value="CY_SCB_SPI_TI_COINCIDES" visible="`${!DeepSleepCapable}`" />
      <Entry name="TI (Start Precedes)"  value="CY_SCB_SPI_TI_PRECEDES"  visible="`${!DeepSleepCapable}`" />
      <Entry name="National Semiconductor (Microwire)" value="CY_SCB_SPI_NATIONAL" visible="`${!DeepSleepCapable}`" />
    </ParamChoice>

    <ParamChoice id="SclkModeUser" name="SCLK Mode" group="General" default="CY_SCB_SPI_CPHA0_CPOL0" visible="`${(SubModeUser eq CY_SCB_SPI_MOTOROLA)}`" editable="true" desc="This parameter specifies the serial clock phase (CPHA) and polarity (CPOL) combination.">
      <Entry name="CPHA = 0, CPOL = 0" value="CY_SCB_SPI_CPHA0_CPOL0" visible="true" />
      <Entry name="CPHA = 0, CPOL = 1" value="CY_SCB_SPI_CPHA0_CPOL1" visible="true" />
      <Entry name="CPHA = 1, CPOL = 0" value="CY_SCB_SPI_CPHA1_CPOL0" visible="true" />
      <Entry name="CPHA = 1, CPOL = 1" value="CY_SCB_SPI_CPHA1_CPOL1" visible="true" />
    </ParamChoice>
    <ParamChoice id="SclkMode" name="SCLK Mode" group="General" default="`${(SubModeUser eq CY_SCB_SPI_MOTOROLA) ? SclkModeUser : (SubModeUser eq CY_SCB_SPI_NATIONAL) ? &quot;CY_SCB_SPI_CPHA0_CPOL0&quot; : &quot;CY_SCB_SPI_CPHA1_CPOL0&quot;}`" visible="`${!(SubModeUser eq CY_SCB_SPI_MOTOROLA)}`" editable="false" desc="This parameter specifies the serial clock phase (CPHA) and polarity (CPOL) combination.">
      <Entry name="CPHA = 0, CPOL = 0" value="CY_SCB_SPI_CPHA0_CPOL0" visible="true" />
      <Entry name="CPHA = 0, CPOL = 1" value="CY_SCB_SPI_CPHA0_CPOL1" visible="true" />
      <Entry name="CPHA = 1, CPOL = 0" value="CY_SCB_SPI_CPHA1_CPOL0" visible="true" />
      <Entry name="CPHA = 1, CPOL = 1" value="CY_SCB_SPI_CPHA1_CPOL1" visible="true" />
    </ParamChoice> 
    <ParamRange id="DataRate" name="Data Rate (kbps)" group="General" default="1000" min="1" max="`${hasConnection(&quot;spi_miso&quot;, 0) ? 25000 : 50000}`" resolution="1" visible="true" editable="true" desc="Data rate that SPI operates. The actual data rate may differ based on the available clock frequency and SPI settings. The range: 1-25000 kbps." />
    <!--Oversample-->
    <ParamRange id="OvsFactor" name="Oversample" group="General" default="16" min="`${hasConnection(&quot;spi_miso&quot;, 0) ? 4 : 2}`" max="16" resolution="1" visible="`${MasterMode}`" editable="true" desc="This parameter defines how many SCB clocks are used to generate the SCLK period (only applicable for the master mode). When the oversample is even the first and second phase of the clock period are the same. Otherwise the first phase of the clock signal period is one SCB clock cycle longer than the second phase. The range: 4-16 (MISO utilized) and 2-16 (MISO is not utilized)." />

    <ParamBool id="EnableInputFilter" name="Enable Input Glitch Filter" group="General" default="false" visible="true" editable="true" desc="This parameter applies a digital 3-tap median filter to the SPI input lines." />
    <ParamBool id="EnableLateMisoSample" name="Enable MISO Late Sampling" group="General" default="true" visible="`${MasterMode}`" editable="true" desc="This option allows the master to sample the MISO signal by half of the SCLK period later (on the alternate serial clock edge). Late sampling addresses the round-trip delay associated with transmitting SCLK from the master to the slave and transmitting MISO from the slave to the master." />
    <ParamBool id="EnableFreeRunSclk" name="SCLK Free Running" group="General" default="false" visible="`${MasterMode}`" editable="true" desc="This parameter allows the master to generate SCLK continually. It is useful when the master SCLK is connected to the slave device which uses it for functional operation rather than only the SPI functionality." />

    <ParamBool id="EnableWakeup" name="Enable Wakeup from Deep Sleep Mode" group="General" default="false" visible="`${DeepSleepCapable}`" editable="true" desc="This parameter enables wake-up from Deep Sleep on an SPI slave-select event." />  
    
    <!--Data Configuration-->
    <ParamChoice id="BitsOrder" name="Bit Order" group="Data Configuration" default="MSB_FIRST" visible="true" editable="true" desc="This parameter defines the direction in which the serial data is transmitted. When set to the MSB first, the most-significant bit is transmitted first. When set to the LSB first, the least-significant bit is transmitted first.">
      <Entry name="MSB First" value="MSB_FIRST" visible="true" />
      <Entry name="LSB First" value="LSB_FIRST" visible="true" />
    </ParamChoice>
    <ParamRange id="RxDataWidth" name="RX Data Width" group="Data Configuration" default="8" min="4" max="16" resolution="1" visible="true" editable="true" desc="This option defines the width of a single data element for the RX direction in bits. This number must match with TX Word Width for all SPI sub-modes except National Semiconductor (Microwire). The range: 4-16." />
    <ParamRange id="TxDataWidth" name="TX Data Width" group="Data Configuration" default="8" min="4" max="16" resolution="1" visible="true" editable="true" desc="This option defines the width of a single data element for the TX direction in bits. This number must match with RX Word Width for all SPI sub-modes except National Semiconductor (Microwire). The range: 4-16." />
    <ParamRange id="DataWidth" name="Data Width" group="Internal" default="`${(RxDataWidth &gt; TxDataWidth) ? RxDataWidth : TxDataWidth}`" min="4" max="16" resolution="1" visible="false" editable="false" desc="This option defines the data width. The range: 4-16." />   

    <!--Slave Select-->
    <ParamBool id="DeassertSelectLine" name="Deassert SS Between Data Element" group="Slave Select" default="false" visible="`${MasterMode}`" editable="true" desc="This parameter determines if individual data transfers are separated by the slave select de-selection." />

    <!-- SS visible options -->
    <ParamBool id="isConnectableSel0" name="isConnectableSel0" group="Internal" default="`${hasVisibleOption(&quot;spi_select0[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if SS0 has valid connections." />
    <ParamBool id="isConnectableSel1" name="isConnectableSel1" group="Internal" default="`${hasVisibleOption(&quot;spi_select1[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if SS1 has valid connections." />
    <ParamBool id="isConnectableSel2" name="isConnectableSel2" group="Internal" default="`${hasVisibleOption(&quot;spi_select2[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if SS2 has valid connections." />    
    <ParamBool id="isConnectableSel3" name="isConnectableSel3" group="Internal" default="`${hasVisibleOption(&quot;spi_select3[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if SS3 has valid connections." />

    <!-- Slave Select polarities -->
    <ParamChoice id="Ss0Polarity" name="SS0 Polarity" group="Slave Select" default="CY_SCB_SPI_ACTIVE_LOW" visible="`${isConnectableSel0}`" editable="true" desc="This parameter defines the active polarity of the slave-select 0 signal as Active Low or Active High.">
      <Entry name="Active Low"  value="CY_SCB_SPI_ACTIVE_LOW"  visible="true" />
      <Entry name="Active High" value="CY_SCB_SPI_ACTIVE_HIGH" visible="true" />
    </ParamChoice>
    <ParamChoice id="Ss1Polarity" name="SS1 Polarity" group="Slave Select" default="CY_SCB_SPI_ACTIVE_LOW" visible="`${isConnectableSel1}`" editable="true" desc="This parameter defines the active polarity of the slave-select 1 signal as Active Low or Active High.">
      <Entry name="Active Low"  value="CY_SCB_SPI_ACTIVE_LOW"  visible="true" />
      <Entry name="Active High" value="CY_SCB_SPI_ACTIVE_HIGH" visible="true" />
    </ParamChoice>
    <ParamChoice id="Ss2Polarity" name="SS2 Polarity" group="Slave Select" default="CY_SCB_SPI_ACTIVE_LOW" visible="`${isConnectableSel2}`" editable="true" desc="This parameter defines the active polarity of the slave-select 2 signal as Active Low or Active High.">
      <Entry name="Active Low"  value="CY_SCB_SPI_ACTIVE_LOW"  visible="true" />
      <Entry name="Active High" value="CY_SCB_SPI_ACTIVE_HIGH" visible="true" />
    </ParamChoice>
    <ParamChoice id="Ss3Polarity" name="SS3 Polarity" group="Slave Select" default="CY_SCB_SPI_ACTIVE_LOW" visible="`${isConnectableSel3}`" editable="true" desc="This parameter defines the active polarity of the slave-select 3 signal as Active Low or Active High.">
      <Entry name="Active Low"  value="CY_SCB_SPI_ACTIVE_LOW"  visible="true" />
      <Entry name="Active High" value="CY_SCB_SPI_ACTIVE_HIGH" visible="true" />
    </ParamChoice>  

    <!-- SPI Slave data rate calculation parameters -->
    <ParamRange id="TDSO" name="TDSO" group="Internal" default="50" min="0" max="255" resolution="1" visible="false" editable="false" desc="TDSO, 002-10490 Rev. *C: SID171 (units ns)." />
    <ParamRange id="F_SPI_SLAVE_IC" name="F_SPI_SLAVE_IC" group="Internal" default="15" min="0" max="255" resolution="1" visible="false" editable="false" desc="002-10490 Rev. *C: SID166A (units MHz)." />
    <ParamRange id="T_DSO_INTERNAL" name="T_DSO_INTERNAL" group="Internal" default="`${TDSO - 3 * 10}`" min="0" max="255" resolution="1" visible="false" editable="true" desc="Tdso = Tdso_internal + (3 * Tscbclk), where Tscbclk = 10ns (units ns)." />
    <ParamRange id="T_MASTER_DELAYS" name="T_MASTER_DELAYS" group="Internal" default="`${(1000.0 / F_SPI_SLAVE_IC) - TDSO}`" min="0" max="1000" resolution="0.000001" visible="false" editable="false" desc="Calculate time left for master delays to meet SID166A FSPI_IC." />
    <ParamRange id="scbClocksToOutput" name="scbClocksToOutput" group="Internal" default="`${EnableInputFilter ? 4 : 3}`" min="0" max="255" resolution="1" visible="false" editable="false" desc="The number of scb clocks to output." /> 
    <ParamRange id="spiClkPeriod" name="spiClkPeriod" group="Internal" default="`${1000000 / DataRate}`" min="0" max="1000000" resolution="1" visible="false" editable="false" desc="SPI SCLK period (units ns)." />
    
    <!-- Get SPI Slave desired clock -->
    <ParamRange id="ClkPeriHz" name="ClkPeriHz" group="Internal" default="`${getExposedMember(&quot;srss[0].clock[0].periclk[0]&quot;, &quot;frequency&quot;)}`" min="1" max="200000000" resolution="1" visible="false" editable="false" desc="ClkPeri frequency in Hz." />
    <ParamRange id="spiTdso" name="spiTdso" group="Internal" default="`${(spiClkPeriod / 2) - T_DSO_INTERNAL - T_MASTER_DELAYS}`" min="-67" max="1000000" resolution="0.000001" visible="false" editable="false" desc="Time left for tDSO (units ns) that is function of SCB clock." />
    <ParamRange id="SlaveClkHzTmp" name="SlaveClkHzTmp" group="Internal" default="`${(spiTdso &gt; 0) ? ((1000000000 * scbClocksToOutput) / spiTdso) : ClkPeriHz}`" min="1" max="4294967295" resolution="1" visible="false" editable="false" desc="Slave clock to operate with desired baud rate in Hz (not adjuested)." />
    <ParamRange id="SlaveClkHz" name="SlaveClkHz" group="Internal" default="`${(SlaveClkHzTmp &gt; ClkPeriHz) ? ClkPeriHz : SlaveClkHzTmp}`" min="1" max="200000000" resolution="1" visible="false" editable="false" desc="Slave SCB clock to operate with desired baud rate in Hz." />
    
    <!-- Get SPI Master desired clock -->
    <ParamRange id="MasterClkHz" name="MasterClkHz" group="Internal" default="`${DataRate * OvsFactor * 1000}`" min="1" max="400000000" resolution="1" visible="false" editable="false" desc="Master clock to operate with desired baud rate in kHz." />

    <!-- Connections -->
    <ParamSignal port="clock[0]" name="Clock" group="Connections" visible="true" desc="Clock that operates this block." canBeEmpty="false" >
      <Constraint type="REQUIRE" targetLocation="peri\[\d+\]\.div_.*" valid="`${!MasterMode}`" >
        <Parameter id="intDivider" severity="ERROR" reason="The clock frequency must be `${SlaveClkHz / 1000}` kHz to operate with data rate `${DataRate}` kbps." valid="true">
          <Fixed 
            value= "`${floor(getExposedMember(&quot;REF_LOCATION&quot;, &quot;frequency&quot;) * getExposedMember(&quot;REF_LOCATION&quot;, &quot;divider&quot;) / SlaveClkHz)}`" />
        </Parameter>
      </Constraint>
      <Constraint type="REQUIRE" targetLocation="peri\[\d+\]\.div_.*" valid="`${MasterMode}`" >
        <Parameter id="intDivider" severity="ERROR" reason="The clock frequency must be `${MasterClkHz / 1000}` kHz to operate with data rate `${DataRate}` kbps." valid="true">
          <Fixed 
            value= "`${ceil(getExposedMember(&quot;REF_LOCATION&quot;, &quot;frequency&quot;) * getExposedMember(&quot;REF_LOCATION&quot;, &quot;divider&quot;) / MasterClkHz)}`" />
        </Parameter>
      </Constraint> 
      <Constraint type="ACCEPT" targetLocation="peri\[\d+\]\.div_(16.5|24.5).*" valid="true" >
        <Parameter id="fracDivider" severity="ERROR" reason="Fractional divider must be 0 for SPI interface.">
          <Fixed value= "0" />
        </Parameter>
      </Constraint>     
    </ParamSignal>

    <!-- Drive mode selection -->
    <ParamString id="DmMOSI" name="DmMOSI" group="Internal" default="`${MasterMode ? &quot;CY_GPIO_DM_STRONG_IN_OFF&quot; : &quot;CY_GPIO_DM_HIGHZ&quot;}`" visible="false" editable="false" desc="Drive mode " />
    <ParamString id="DmMOSIMsg" name="sourceClock" group="Internal" default="Drive Mode must be set to '`${MasterMode ? &quot;Strong Drive. Input buffer off&quot; : &quot;Digital High-Z. Input buffer on&quot;}`'" visible="false" editable="false" desc="Drive mode erorr message." />
    <ParamString id="DmMISO" name="DmMOSI" group="Internal" default="`${!MasterMode ? &quot;CY_GPIO_DM_STRONG_IN_OFF&quot; : &quot;CY_GPIO_DM_HIGHZ&quot;}`" visible="false" editable="false" desc="Drive mode " />
    <ParamString id="DmMISOMsg" name="sourceClock" group="Internal" default="Drive Mode must be set to '`${!MasterMode ? &quot;Strong Drive. Input buffer off&quot; : &quot;Digital High-Z. Input buffer on&quot;}`'" visible="false" editable="false" desc="Drive mode erorr message." />

    <!-- SCLK, MOSI and MISO connections -->
    <ParamBool id="hasConnectionSclk" name="hasConnectionSclk" group="Internal" default="`${hasVisibleOption(&quot;spi_clk[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if SCLK has valid connections." />
    <ParamBool id="hasConnectionMosi" name="hasConnectionMosi" group="Internal" default="`${hasVisibleOption(&quot;spi_mosi[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if MOSI has valid connections." />
    <ParamBool id="hasConnectionMiso" name="hasConnectionMiso" group="Internal" default="`${hasVisibleOption(&quot;spi_miso[0]&quot;)}`" visible="false" editable="false" desc="This parameter determines if MISO has valid connections." />

    <ParamSignal port="spi_clk[0]"  name="SCLK" group="Connections" visible="`${MasterMode ? hasConnectionSclk : true}`" desc="The Serial Clock (SCLK) from the master to slave device." canBeEmpty="`${MasterMode}`">
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>

    <ParamSignal port="spi_mosi[0]" name="MOSI" group="Connections" visible="`${hasConnectionMosi}`" desc="The Master Output Slave Input (MOSI) signal between the master and slave devices." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>
    
    <ParamSignal port="spi_miso[0]" name="MISO" group="Connections" visible="`${hasConnectionMiso}`" desc="The Master Input Slave Output (MOSI) signal between the slave and master devices." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMISO}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMISO}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>
    
    <ParamSignal port="spi_select0[0]" name="SS0" group="Connections" visible="`${isConnectableSel0}`" desc="The Master Output / Slave Input Slave Select (SS) signal. The master uses SS signal to enable Slave for the following communication." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>

    <ParamSignal port="spi_select1[0]" name="SS1" group="Connections" visible="`${isConnectableSel1}`" desc="The Master Output / Slave Input Slave Select (SS) signal. The master uses SS signal to enable Slave for the following communication." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>

    <ParamSignal port="spi_select2[0]" name="SS2" group="Connections" visible="`${isConnectableSel2}`" desc="The Master Output / Slave Input Slave Select (SS) signal. The master uses SS signal to enable Slave for the following communication." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>

    <ParamSignal port="spi_select3[0]" name="SS3" group="Connections" visible="`${isConnectableSel3}`" desc="The Master Output / Slave Input Slave Select (SS) signal. The master uses SS signal to enable Slave for the following communication." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="`${DmMOSI}`" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>

    <ParamSignal port="tr_rx_req[0]" name="RX Trigger Output" group="Connections" visible="`${MasterMode ? hasConnectionMiso : hasConnectionMosi}`" desc="Connects SCB RX trigger output to the DMA. Configure RX FIFO Level to define this output behavior." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>
    <ParamSignal port="tr_tx_req[0]" name="TX Trigger Output" group="Connections" visible="`${MasterMode ? hasConnectionMosi : hasConnectionMiso}`" desc="Connects SCB TX trigger output to the DMA. Configure RX FIFO Level to define this output behavior." canBeEmpty="true" >
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="DEFAULT" reason="">
          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation="ioss\[\d+\]\.port\[\d+\]\.pin.*" valid="true" >
        <Parameter id="DriveModes" severity="INFO" reason="The pin Drive Mode parameter does not match expected.">
          <Fixed value="CY_GPIO_DM_STRONG_IN_OFF" />
        </Parameter>
      </Constraint>
      <Constraint type="ACCEPT" targetLocation=".*" valid="true" />
    </ParamSignal>

    <!-- Clock Frequency -->
    <ParamString id="sourceClock" name="sourceClock" group="Internal" default="`${getBlockFromSignal(&quot;clock[0]&quot;)}`" visible="false" editable="false" desc="Source Clock Resource" />
    <ParamRange  id="scbClkHz" name="scbClkHz" group="Internal" default="`${getExposedMember(sourceClock, &quot;frequency&quot;)}`" min="1" max="200000000" resolution="1" visible="false" editable="false" desc="SCB clock frequency in kHz" />

    <!-- Actual data rate notes -->
    <ParamString id="SlaveActDataRateNote" name="ActualDataRateNoteSlave" group="Internal" default="This is the theoretical data rate calculated with the assumption that the master captures data on a half SCLK period after the driving edge (normal sample). If the master captures data a half SCLK period later (late sampling) then the actual data rate is twice what is displayed. To determine the data rate for your system, consult the selected device TRM." visible="false" editable="false" desc="Actual Data Rate Note Slave" />
    <ParamString id="MasterActDataRateNote" name="ActualDataRateNoteMaster" group="Internal" default="The actual data rate is calculated based only on the master configuration. To determine the data rate for your system, consult the selected device TRM." visible="false" editable="false" desc="Actual Data Rate Note Master." />

    <!-- Slave actual data rate calculations -->
    <ParamRange id="tDSO_SCB" name="tDSO" group="Internal" default="`${scbClocksToOutput * (1000000000 / scbClkHz)}`" min="0" max="4294967295" resolution="0.000001" visible="false" editable="false" desc="Get tDSO based on SCB clock (units ns)." />
    <ParamRange id="spiRoundTripDelay" name="spiRoundTripDelay" group="Internal" default="`${tDSO_SCB + T_DSO_INTERNAL + T_MASTER_DELAYS}`" min="0" max="4294967295" resolution="0.000001" visible="false" editable="false" desc="Get SCL to MISO round trip delay (units ns)." />
    
    <ParamRange id="SlaveActualDataRate" name="Actual Slave data rate (kbps)" group="Internal" default="`${1000000 / (2 * spiRoundTripDelay)}`" min="0" max="4294967295" resolution="0.001" visible="false" editable="false" desc="Actual Slave data rate (kbps)." />

    <!-- Master actual data rate calculations -->
    <ParamRange id="MasterActualDataRate" name="MasterActualDataRate" group="Internal" default="`${(scbClkHz / OvsFactor) / 1000.0}`" min="0" max="4294967295" resolution="0.001" visible="false" editable="false" desc="Actual Master data rate (kbps)." />

    <!-- Data Rate and Clock output-->
    <ParamRange id="actualDataRate" name="Actual Data Rate (kbps)" group="Data Rate" default="`${MasterMode ? MasterActualDataRate : SlaveActualDataRate}`" min="1" max="4294967295" resolution="0.001" visible="true" editable="false" desc="`${MasterMode ? MasterActDataRateNote : SlaveActDataRateNote}`" />
    
    <ParamString id="ClkFreq" name="Clock Frequency" group="Data Rate" default="`${(scbClkHz &lt; 1000000) ? (scbClkHz / 1000.0) . &quot; kHz&quot; : (scbClkHz / 1000000.0) . &quot; MHz&quot;}`" visible="true" editable="false" desc="Frequency of the connected clock" />

    <!-- Hardware buffer size (defines FIFO size) -->
    <ParamRange id="hwBufferSize" name="Hardware Buffer Size" group="Internal" default="`${lookupExpression(&quot;EZ_DATA_NR&quot;)}`" min="0" max="512" resolution="1" visible="false" editable="false" desc="Hardware buffer size." />
    <ParamRange id="FifoLevelByte" name="FIFO Level (Byte)" group="Internal" default="`${(hwBufferSize / 2) - 1}`" min="1" max="512" resolution="1" visible="false" editable="false" desc="FIFO Level for byte entry." />
    <ParamRange id="FifoLevelHalfword" name="FIFO Level (Halfword)" group="Internal" default="`${(hwBufferSize / 4) - 1}`" min="1" max="512" resolution="1" visible="false" editable="false" desc="FIFO Level for byte entry." />
    <ParamRange id="FifoLevelMax" name="FIFO Level Max" group="Internal" default="`${(DataWidth &lt;= 8) ? FifoLevelByte : FifoLevelHalfword}`" min="1" max="512" resolution="1" visible="false" editable="false" desc="FIFO Level for byte entry." />

    <!--Trigger Level-->
    <ParamRange id="RxTriggerLevel" name="RX FIFO Level" group="Trigger Level" default="63" min="0" max="`${FifoLevelMax}`" resolution="1" visible="true" editable="true" desc="This parameter determines behavior of signal which drives the RX FIFO Above Level interrupt source and RX trigger output as follows: the signal remains active until the number of data elements in the RX FIFO is greater than the value of RX FIFO Level. For example, the RX FIFO has 8 data elements and the RX FIFO level is 0. The signal remains active until all data elements are read from the RX FIFO. The range: 0 – `${FifoLevelByte}` (when TX/RX Data Width less or equal 8), and 0 - `${FifoLevelHalfword}` otherwise." />

    <ParamRange id="TxTriggerLevel" name="TX FIFO Level" group="Trigger Level" default="63" min="0" max="`${FifoLevelMax}`" resolution="1" visible="true" editable="true" desc="This parameter determines the behavior of the signal which drives the TX FIFO Below Level interrupt source and TX trigger output as follows: until the number of data elements in the TX FIFO is less than the value of the TX FIFO level. For example, the TX FIFO has 0 data elements (empty) and the TX FIFO level is 7. The signal remains active until TX FIFO has 7 data elements. The range: 0 – `${FifoLevelByte}` (when TX/RX Data Width less or equal 8), and 0 - `${FifoLevelHalfword}` otherwise." /> 

    <!-- API Mode -->
    <ParamChoice id="ApiMode" name="API Mode" group="API Mode" default="HIGH_LEVEL" visible="true" editable="true" desc="This parameter defines which API set will be used during driver operation. High Level means driver controls interrupt sources and Cy_SCB_SPI_Interrupt function must be called in the interrupt handler hooked to NVIC. Low Level means that the user configures interrupt sources and implements own interrupt handler or do not use interrupt at all.">
      <Entry name="High Level" value="HIGH_LEVEL" visible="true" />      
      <Entry name="Low Level"  value="LOW_LEVEL"  visible="true" />
    </ParamChoice>
    <ParamBool id="ConfigIntr" name="ConfigIntr" group="Internal" default="`${ApiMode eq LOW_LEVEL}`" visible="false" editable="false" desc="This parameter specifies the visibility of all RX Interrupt Sources parameter." />

    <!--RX Interrupt Sources-->
    <ParamBool id="IntrRxNotEmpty" name="RX FIFO not Empty" group="RX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the RX FIFO not-empty interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrRxTrigger" name="RX FIFO Above Level" group="RX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the RX FIFO above-level interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrRxFull" name="RX FIFO Full" group="RX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the RX FIFO full interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrRxOverflow" name="RX FIFO Overflow" group="RX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the RX FIFO overflow interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrRxUnderflow" name="RX FIFO Underflow" group="RX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the RX FIFO underflow interrupt source to trigger the interrupt output." />  
  
    <ParamRange id="IntrRxMask" name="INTR_RX_MASK" group="Internal" default="`${ConfigIntr ? (IntrRxTrigger ? 0x1 : 0) + (IntrRxNotEmpty ? 0x4 : 0) + (IntrRxFull ? 0x8 : 0) + (IntrRxOverflow ? 0x20 : 0) + (IntrRxUnderflow ? 0x40 : 0) : 0}`" min="0" max="4294967295" resolution="1" visible="false" editable="false" desc="This parameter defines the SPI RX interrupt mask to be written into the SCB.INTR_RX_MASK register." />

    <!--TX Interrupt Sources-->
    <ParamBool id="IntrTxEmpty" name="TX FIFO Empty" group="TX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the TX FIFO empty interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrTxTrigger" name="TX FIFO Below Level" group="TX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the TX FIFO below-level interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrTxNotFull" name="TX FIFO not Full" group="TX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the TX FIFO not-full interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrTxOverflow" name="TX FIFO Overflow" group="TX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the TX FIFO overflow interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrTxUnderflow" name="TX FIFO Underflow" group="TX Interrupt Sources" default="false" visible="`${ConfigIntr}`" editable="true" desc="This parameter enables the TX FIFO underflow interrupt source to trigger the interrupt output." />

    <ParamRange id="IntrTxMask" name="INTR_TX_MASK" group="Internal" default="`${ConfigIntr ? (IntrTxTrigger ?  0x1 : 0) + (IntrTxNotFull ? 0x2 : 0) + (IntrTxEmpty ? 0x10 : 0) + (IntrTxOverflow ? 0x20 : 0) + (IntrTxUnderflow ? 0x40 : 0) : 0}`" min="0" max="4294967295" resolution="1" visible="false" editable="false" desc="This parameter defines the SPI TX interrupt mask to be written into the SCB.INTR_TX_MASK register." />

    <!--Master / Slave Interrupt Source-->
    <ParamBool id="IntrMasterSpiDone" name="SPI Done" group="Master Interrupt Source" default="false" visible="`${ConfigIntr &amp;&amp; MasterMode}`" editable="true" desc="This parameter enables the SPI done interrupt source to trigger the interrupt output." />
    <ParamBool id="IntrSlaveBusError" name="SPI Bus Error" group="Slave Interrupt Source" default="false" visible="`${ConfigIntr &amp;&amp; !MasterMode}`" editable="true" desc="This parameter enables the SPI bus error interrupt source to trigger the interrupt output." />

    <ParamRange id="IntrMasterSlaveMask" name="INTR_MS_MASK" group="Internal" default="`${ConfigIntr ? (((MasterMode &amp;&amp; IntrMasterSpiDone) ? 0x200 : 0) + ((!MasterMode &amp;&amp; IntrSlaveBusError) ? 0x800 : 0)) : 0}`" min="0" max="4294967295" resolution="1" visible="false" editable="false" desc="This parameter defines the SPI slave or master interrupt mask to be written into the SCB.INTR_M_MASK or SCB.INTR_S_MASK register." />

    <!-- Advanced -->
    <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)." />

    <!-- SCB instance number -->
    <ParamString id="InstNumber" name="InstNumber" group="Internal" default="`${getInstNumber(&quot;scb&quot;)}`" visible="false" editable="false" desc="SCB Instance name number." />
    
    <!-- Peripheral clock divider connection -->
    <ParamBool id="pclkOk" name="PCLK Valid" group="Internal" default="`${hasConnection(&quot;clock&quot;, 0) &amp;&amp; isBlockUsed(sourceClock)}`" visible="false" editable="false" desc="Checks whether there is a PCLK connected and enabled." />
    <ParamString id="pclkDst" name="PCLK Destination" group="Internal" default="PCLK_SCB`${InstNumber}`_CLOCK" visible="false" editable="false" desc="Generates PCLK connection define." />
  </Parameters>
  
  <DRCs>  
    <!--RxDataWidth and $TxDataWidth DRCs-->
    <DRC type="ERROR" text="The RX and TX Data Width must be equal for the selected Sub Mode." paramId="TxDataWidth" condition="`${((SubModeUser ne CY_SCB_SPI_NATIONAL) &amp;&amp; (RxDataWidth ne TxDataWidth)) ? true : false}`" />

    <!--EnableWakeup DRCs-->
    <DRC type="ERROR" text="The API Mode must be High Level to support wakeup capability (the Cy_SCB_SPI_Interrupt function must be called in the interrupt handler hooked to NVIC)." paramId="ApiMode" condition="`${(DeepSleepCapable &amp;&amp; EnableWakeup) ? ConfigIntr : false}`" />

    <!-- Check Master valid connections -->
    <DRC type="ERROR" text="The SCLK and MOSI connections are not available for the selected device. The SPI Master can not operate on this SCB." paramId="ModeUser" condition="`${MasterMode &amp;&amp; !hasConnectionSclk &amp;&amp; !hasConnectionMosi}`" />

    <!-- Check data rate value -->
    <DRC type="ERROR" text="Data rate upto 50000 kbps is allowed only if MISO is not used. Otherwise only upto 25000 kbps data rate is allowed." paramId="DataRate" condition="`${MasterMode ? ((!hasConnection(&quot;spi_miso&quot;, 0)) ? ((DataRate &lt; 50001) ? false : true) : ((DataRate &lt; 25001) ? false : true)) : false}`" />

    <!-- Check oversample value -->
    <DRC type="ERROR" text="Oversample between 2-16 is allowed only if MISO is not used. Otherwise oversample only between 4-16 is allowed." paramId="OvsFactor" condition="`${MasterMode ? ((!hasConnection(&quot;spi_miso&quot;, 0)) ? ((OvsFactor &lt; 2) ? true : false) : ((OvsFactor &lt; 4) ? true : false)) : false}`" />

  </DRCs>
  
  <ConfigFirmware>
    <ConfigInclude value="cy_scb_spi.h" include="true" />
    <ConfigInclude value="cy_sysclk.h" include="`${pclkOk}`" />
    <ConfigInclude value="cyhal_hwmgr.h" include="true" guard="defined (CY_USING_HAL)" />
    
    <ConfigDefine name="`${INST_NAME}`_HW" value="SCB`${InstNumber}`" public="true" include="true" />
    <ConfigDefine name="`${INST_NAME}`_IRQ" value="scb_`${InstNumber}`_interrupt_IRQn" public="true" include="true" />
    <ConfigStruct name="`${INST_NAME}`_config" type="cy_stc_scb_spi_config_t" const="`${inFlash}`" public="true" include="true">
      <Member name="spiMode" value="`${ModeUser}`" />
      <Member name="subMode" value="`${SubModeUser}`" />
      <Member name="sclkMode" value="`${SclkMode}`" />
      
      <Member name="oversample" value="`${MasterMode ? OvsFactor : &quot;0UL&quot;}`" />
      
      <Member name="rxDataWidth" value="`${RxDataWidth}`UL" />
      <Member name="txDataWidth" value="`${TxDataWidth}`UL" />
      <Member name="enableMsbFirst" value="`${(BitsOrder eq MSB_FIRST) ? &quot;true&quot; : &quot;false&quot;}`" />
      <Member name="enableInputFilter" value="`${EnableInputFilter}`" />
      
      <Member name="enableFreeRunSclk" value="`${(MasterMode &amp;&amp; EnableFreeRunSclk) ? &quot;true&quot; : &quot;false&quot;}`" />
      <Member name="enableMisoLateSample" value="`${(MasterMode &amp;&amp; EnableLateMisoSample) ? &quot;true&quot; : &quot;false&quot;}`" />
      <Member name="enableTransferSeperation" value="`${(MasterMode &amp;&amp; DeassertSelectLine) ? &quot;true&quot; : &quot;false&quot;}`" />
      
      <Member name="ssPolarity" value="(`${&quot;(&quot; . Ss0Polarity}` &lt;&lt; CY_SCB_SPI_SLAVE_SELECT0) | \&#xA;
                                        `${&quot;(&quot; . Ss1Polarity}` &lt;&lt; CY_SCB_SPI_SLAVE_SELECT1) | \&#xA;
                                        `${&quot;(&quot; . Ss2Polarity}` &lt;&lt; CY_SCB_SPI_SLAVE_SELECT2) | \&#xA;
                                        `${&quot;(&quot; . Ss3Polarity}` &lt;&lt; CY_SCB_SPI_SLAVE_SELECT3))"/>

      <Member name="enableWakeFromSleep" value="`${EnableWakeup}`" />
      
      <Member name="rxFifoTriggerLevel"  value="`${RxTriggerLevel}`UL" />
      <Member name="rxFifoIntEnableMask" value="`${IntrRxMask}`UL" />
      
      <Member name="txFifoTriggerLevel"  value="`${TxTriggerLevel}`UL" />
      <Member name="txFifoIntEnableMask" value="`${IntrTxMask}`UL" />
      
      <Member name="masterSlaveIntEnableMask" value="`${IntrMasterSlaveMask}`UL" />
    </ConfigStruct>
    
    <ConfigStruct name="`${INST_NAME}`_obj" type="cyhal_resource_inst_t" const="true" public="true" include="true" guard="defined (CY_USING_HAL)">
      <Member name="type" value="CYHAL_RSC_SCB" />
      <Member name="block_num" value="`${getInstNumber(&quot;scb&quot;)}`U" />
      <Member name="channel_num" value="0U" />
    </ConfigStruct>
    
    <ConfigInstruction value="Cy_SysClk_PeriphAssignDivider(`${pclkDst}`, `${getExposedMember(sourceClock, &quot;clockSel&quot;)}`);" include="`${pclkOk}`" />
    <ConfigInstruction value="cyhal_hwmgr_reserve(&amp;`${INST_NAME}`_obj);" include="true" guard="defined (CY_USING_HAL)" />
  </ConfigFirmware>
</Personality>