<?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>LPCXpresso IDEのトピックUnused variables in LPCOpen library</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654434#M32747</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;lpc_chip_43xx/src/spi_43xx.c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;/* Clean all data in RX FIFO of SPI */&lt;BR /&gt;void Chip_SPI_Int_FlushData(LPC_SPI_T *pSPI)&lt;BR /&gt;{&lt;BR /&gt; volatile uint32_t tmp; &lt;STRONG&gt;// &amp;lt;----- Not used&lt;/STRONG&gt;&lt;BR /&gt; Chip_SPI_GetStatus(pSPI);&lt;BR /&gt; tmp = Chip_SPI_ReceiveFrame(pSPI);&lt;BR /&gt; Chip_SPI_Int_ClearStatus(pSPI, SPI_INT_SPIF);&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lpc_chip_43xx/src/uart_18xx_43xx.c&lt;/STRONG&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;/* Initializes the pUART peripheral */&lt;BR /&gt;void Chip_UART_Init(LPC_USART_T *pUART)&lt;BR /&gt;{&lt;BR /&gt; volatile uint32_t tmp; &lt;STRONG&gt;// &amp;lt;----- Not used&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* Enable UART clocking. UART base clock(s) must already be enabled */&lt;BR /&gt; Chip_Clock_EnableOpts(UART_PClock[Chip_UART_GetIndex(pUART)], true, true, 1);&lt;/P&gt;&lt;P&gt;/* Enable FIFOs by default, reset them */&lt;BR /&gt; Chip_UART_SetupFIFOS(pUART, (UART_FCR_FIFO_EN | UART_FCR_RX_RS | UART_FCR_TX_RS));&lt;/P&gt;&lt;P&gt;//...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2017 00:00:43 GMT</pubDate>
    <dc:creator>hmyoong</dc:creator>
    <dc:date>2017-02-21T00:00:43Z</dc:date>
    <item>
      <title>Unused variables in LPCOpen library</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654434#M32747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;lpc_chip_43xx/src/spi_43xx.c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;/* Clean all data in RX FIFO of SPI */&lt;BR /&gt;void Chip_SPI_Int_FlushData(LPC_SPI_T *pSPI)&lt;BR /&gt;{&lt;BR /&gt; volatile uint32_t tmp; &lt;STRONG&gt;// &amp;lt;----- Not used&lt;/STRONG&gt;&lt;BR /&gt; Chip_SPI_GetStatus(pSPI);&lt;BR /&gt; tmp = Chip_SPI_ReceiveFrame(pSPI);&lt;BR /&gt; Chip_SPI_Int_ClearStatus(pSPI, SPI_INT_SPIF);&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lpc_chip_43xx/src/uart_18xx_43xx.c&lt;/STRONG&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;/* Initializes the pUART peripheral */&lt;BR /&gt;void Chip_UART_Init(LPC_USART_T *pUART)&lt;BR /&gt;{&lt;BR /&gt; volatile uint32_t tmp; &lt;STRONG&gt;// &amp;lt;----- Not used&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* Enable UART clocking. UART base clock(s) must already be enabled */&lt;BR /&gt; Chip_Clock_EnableOpts(UART_PClock[Chip_UART_GetIndex(pUART)], true, true, 1);&lt;/P&gt;&lt;P&gt;/* Enable FIFOs by default, reset them */&lt;BR /&gt; Chip_UART_SetupFIFOS(pUART, (UART_FCR_FIFO_EN | UART_FCR_RX_RS | UART_FCR_TX_RS));&lt;/P&gt;&lt;P&gt;//...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 00:00:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654434#M32747</guid>
      <dc:creator>hmyoong</dc:creator>
      <dc:date>2017-02-21T00:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Unused variables in LPCOpen library</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654435#M32748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;/* Clean all data in RX FIFO of SPI */&lt;BR /&gt;void Chip_SPI_Int_FlushData(LPC_SPI_T *pSPI)&lt;BR /&gt;{&lt;BR /&gt; volatile uint32_t tmp; &lt;BR /&gt; Chip_SPI_GetStatus(pSPI);&lt;BR /&gt; tmp = Chip_SPI_ReceiveFrame(pSPI);&amp;nbsp; &lt;STRONG&gt;// &amp;lt;----- used here&lt;/STRONG&gt;&lt;BR /&gt; Chip_SPI_Int_ClearStatus(pSPI, SPI_INT_SPIF);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would expect it has sth to do with a compiler/an optimization but I might be completely wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2017 16:49:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654435#M32748</guid>
      <dc:creator>adamrakam</dc:creator>
      <dc:date>2017-02-22T16:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unused variables in LPCOpen library</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654436#M32749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not look down of the lines. You are right, the default optimization removes it. Need to dissambly the code to see the differences.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2017 12:50:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654436#M32749</guid>
      <dc:creator>hmyoong</dc:creator>
      <dc:date>2017-02-23T12:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unused variables in LPCOpen library</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654437#M32750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;You are right, the default optimization removes it.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Removes what ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how "Chip_SPI_ReceiveFrame()" is defined :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;STATIC INLINE uint16_t Chip_SPI_ReceiveFrame(LPC_SPI_T *pSPI)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return SPI_DR_DATA(pSPI-&amp;gt;DR);&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose :&lt;/P&gt;&lt;P&gt;The volatile&amp;nbsp;keyword is used to force a compiler to call the function "Chip_SPI_ReceiveFrame()". If the variable tmp was defined without volatile keyword i.e. just "uint32_t tmp", calling of the "Chip_SPI_ReceiveFrame()" would not be guaranteed. In this case a compiler might think: "hm, return value from "Chip_SPI_ReceiveFrame()" is stored in the non-volatile "tmp" variable on the stack and "tmp" is not used till the end of the "Chip_SPI_Int_FlushData()" so i will not call(inline) it and save time/memory."&lt;/P&gt;&lt;P&gt;But the volatile keyword does not give a compiler any chance to be ambiguous about calling "Chip_SPI_ReceiveFrame()"&amp;nbsp; - keyword volatile guarantees that calling "Chip_SPI_ReceiveFrame()" will not be optimized away.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2017 15:32:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Unused-variables-in-LPCOpen-library/m-p/654437#M32750</guid>
      <dc:creator>adamrakam</dc:creator>
      <dc:date>2017-02-23T15:32:22Z</dc:date>
    </item>
  </channel>
</rss>

