<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックSPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1416062#M47938</link>
    <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;On my custom LPC55xx based board I'm trying to communicate via a single SPI interface with several slaves (SSEL0 - SSEL2).&amp;nbsp;&lt;/P&gt;&lt;P&gt;The MCU obviously supports this as&amp;nbsp;the FIFO Write register contains bits to select the slave for a transfer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="danielholala_0-1645196071221.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/171069iE4F0FF60297D7EA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="danielholala_0-1645196071221.png" alt="danielholala_0-1645196071221.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;FIFOWR provides the possibility of altering some SPI controls at the same time as&lt;BR /&gt;sending new data.&lt;/P&gt;&lt;P&gt;Do the SDK drivers support this and how?&lt;/P&gt;&lt;P&gt;I checked SDK examples but could not find an anwer to my question. Further, SDK documentation is &lt;A href="https://community.nxp.com/t5/MCUXpresso-SDK/Documentation-of-SDK-components-drivers-middleware-abstraction/td-p/1349217" target="_self"&gt;lacking&lt;/A&gt;. There's no information about, e.g.,&amp;nbsp;&lt;EM&gt;SPI_MasterInit()&lt;/EM&gt; or&amp;nbsp;&lt;EM&gt;SPI_MasterTransferNonBlocking()&lt;/EM&gt; in the &lt;A href="https://mcuxpresso.nxp.com/api_doc/dev/2656/a00049.html" target="_self"&gt;SDK doxygen doc&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I gleaned from the source code &lt;EM&gt;fsl_spi.h&lt;/EM&gt; that the slave number is encoded in a struct&amp;nbsp;&lt;EM&gt;spi_master_config_t&lt;/EM&gt; and this struct is used when calling&amp;nbsp;&lt;EM&gt;SPI_MasterInit()&lt;/EM&gt;. According to &lt;EM&gt;fsl_spi.h&lt;/EM&gt;, the slave number is not used when doing a transfer. So it seems it is not possible to easily switch between slaves from one transfer to another.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Feb 2022 14:59:48 GMT</pubDate>
    <dc:creator>danielholala</dc:creator>
    <dc:date>2022-02-18T14:59:48Z</dc:date>
    <item>
      <title>SPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1416062#M47938</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;On my custom LPC55xx based board I'm trying to communicate via a single SPI interface with several slaves (SSEL0 - SSEL2).&amp;nbsp;&lt;/P&gt;&lt;P&gt;The MCU obviously supports this as&amp;nbsp;the FIFO Write register contains bits to select the slave for a transfer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="danielholala_0-1645196071221.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/171069iE4F0FF60297D7EA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="danielholala_0-1645196071221.png" alt="danielholala_0-1645196071221.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;FIFOWR provides the possibility of altering some SPI controls at the same time as&lt;BR /&gt;sending new data.&lt;/P&gt;&lt;P&gt;Do the SDK drivers support this and how?&lt;/P&gt;&lt;P&gt;I checked SDK examples but could not find an anwer to my question. Further, SDK documentation is &lt;A href="https://community.nxp.com/t5/MCUXpresso-SDK/Documentation-of-SDK-components-drivers-middleware-abstraction/td-p/1349217" target="_self"&gt;lacking&lt;/A&gt;. There's no information about, e.g.,&amp;nbsp;&lt;EM&gt;SPI_MasterInit()&lt;/EM&gt; or&amp;nbsp;&lt;EM&gt;SPI_MasterTransferNonBlocking()&lt;/EM&gt; in the &lt;A href="https://mcuxpresso.nxp.com/api_doc/dev/2656/a00049.html" target="_self"&gt;SDK doxygen doc&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I gleaned from the source code &lt;EM&gt;fsl_spi.h&lt;/EM&gt; that the slave number is encoded in a struct&amp;nbsp;&lt;EM&gt;spi_master_config_t&lt;/EM&gt; and this struct is used when calling&amp;nbsp;&lt;EM&gt;SPI_MasterInit()&lt;/EM&gt;. According to &lt;EM&gt;fsl_spi.h&lt;/EM&gt;, the slave number is not used when doing a transfer. So it seems it is not possible to easily switch between slaves from one transfer to another.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 14:59:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1416062#M47938</guid>
      <dc:creator>danielholala</dc:creator>
      <dc:date>2022-02-18T14:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: SPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1417922#M47973</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;A id="link_12" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/139806" target="_self" aria-label="View Profile of danielholala"&gt;&lt;SPAN class=""&gt;danielholala&lt;/SPAN&gt;&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;The slave number is used in&amp;nbsp;SPI_WriteData() function:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alice_Yang_0-1645594664706.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/171464iEAB1E5989C539187/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alice_Yang_0-1645594664706.png" alt="Alice_Yang_0-1645594664706.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to use more than one slave, you need change the number for call this data write function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 05:41:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1417922#M47973</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2022-02-23T05:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: SPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1422662#M48106</link>
      <description>&lt;P&gt;Dear Alice,&lt;/P&gt;&lt;P&gt;Thanks, I appreciate your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You seem to be confirming that the SDK SPI driver does not support more than one slave per SPI interface.&lt;/P&gt;&lt;P&gt;In that case I'd say that the&amp;nbsp;SDK is utterly lacking as it misses basic functions and that&amp;nbsp;NXP has done a bad job regarding SDK.&lt;/P&gt;&lt;P&gt;I hope that NXP is working on the shortcomings of the SDK (documentation and functionality).&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 11:48:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1422662#M48106</guid>
      <dc:creator>danielholala</dc:creator>
      <dc:date>2022-03-03T11:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: SPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1422731#M48108</link>
      <description>&lt;P&gt;Dear Alice,&lt;/P&gt;&lt;P&gt;as you know the Peripherals Tool generates code based on the CMSIS API. I used Peripherals Tool to configure Flexcomm interfaces, e.g., Flexcomm3 for SPI. For the SPI component this code in "peripherals.c" looks like:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;static void FLEXCOMM3_init(void) {
  /* Interrupt vector FLEXCOMM3_IRQn priority settings in the NVIC. */
  NVIC_SetPriority(FLEXCOMM3_IRQN, FLEXCOMM3_IRQ_PRIORITY);
  /* Initialize CMSIS SPI */
  FLEXCOMM3_PERIPHERAL.Initialize(SPI_SignalEvent);
  /* Power control of CMSIS SPI */
  FLEXCOMM3_PERIPHERAL.PowerControl(ARM_POWER_FULL);
  /* Control of CMSIS SPI */
  FLEXCOMM3_PERIPHERAL.Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL0_CPHA0 | ARM_SPI_DATA_BITS(8) | ARM_SPI_MSB_LSB | ARM_SPI_SS_MASTER_HW_OUTPUT, 500000);
  /* Control of CMSIS SPI */
  FLEXCOMM3_PERIPHERAL.Control(ARM_SPI_SET_DEFAULT_TX_VALUE, 0);
}&lt;/LI-CODE&gt;&lt;P&gt;Further, I have to add the SPI callback function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With that said and referring to your suggestion to use calls from the standard SDK SPI driver:&lt;/P&gt;&lt;P&gt;how do I continue/move from here (CMSIS based driver code and initialized SPI interface) to the standard SDK driver?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 13:51:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1422731#M48108</guid>
      <dc:creator>danielholala</dc:creator>
      <dc:date>2022-03-03T13:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: SPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1424261#M48139</link>
      <description>&lt;P&gt;Hello Daniel,&lt;/P&gt;
&lt;P&gt;The SDK SPI driver support multiple slaves. I have reply you on your private case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 04:25:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1424261#M48139</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2022-03-08T04:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPI: slave select using SDK, e.g.,  SPI_MasterTransferNonBlocking()?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1426843#M48187</link>
      <description>&lt;P&gt;Dear Alice,&lt;/P&gt;&lt;P&gt;I appreciate your reply. However, I have to disagree. I can not find any API functions to select a different slave for each transaction short of calling the init function again (as I mentioned before).&lt;/P&gt;&lt;P&gt;I'm using Peripherals Tool and selected "Universal Driver" for Flexcomm. This generates initialization code based on the CMSIS driver. The CMSIS driver is not using &lt;FONT face="courier new,courier"&gt;SPI_WriteData()&lt;/FONT&gt; but&amp;nbsp;&lt;FONT face="courier new,courier"&gt;SPI_MasterTransferNonBlocking()&lt;/FONT&gt; and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;SPI_TransferHandleIRQInternal()&lt;/FONT&gt; in &lt;EM&gt;fsl_spi.c&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;The latter includes this piece of code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    /* select slave to talk with */
    tx_ctrl |= ((uint32_t)SPI_DEASSERT_ALL &amp;amp; (uint32_t)SPI_ASSERTNUM_SSEL(handle-&amp;gt;sselNum));
    /* set width of data */
    tx_ctrl |= SPI_FIFOWR_LEN(handle-&amp;gt;dataWidth);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is, in each interrupt request, the slave is selected according to&amp;nbsp;&lt;FONT face="courier new,courier"&gt;handle-&amp;gt;sselNum&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A quick solution is to add an API call (to &lt;EM&gt;fsl_spi_cmsis.c&lt;/EM&gt;) in order to change &lt;FONT face="courier new,courier"&gt;sselNum&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;uint8_t SPI3_getSSEL() {
    return SPI3_InterruptDriverState.handle-&amp;gt;masterHandle.sselNum;
}

void SPI3_setSSEL(uint8_t slave) {
    SPI3_InterruptDriverState.handle-&amp;gt;masterHandle.sselNum = slave;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This sets &lt;FONT face="courier new,courier"&gt;sselNum&lt;/FONT&gt; of Flexcomm3. Should be called before a call to &lt;FONT face="courier new,courier"&gt;Transfer()&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;Further resource locking is recommended.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 08:58:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPI-slave-select-using-SDK-e-g-SPI-MasterTransferNonBlocking/m-p/1426843#M48187</guid>
      <dc:creator>danielholala</dc:creator>
      <dc:date>2023-11-23T08:58:26Z</dc:date>
    </item>
  </channel>
</rss>

