<?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のトピックRe: How do the SPI driver bitfield macros work?</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572565#M21063</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Sat May 21 17:34:04 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That's a common way to define values in registers and not restricted to set single bits.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this case Serial Clock Rate. So if I my SCR calculation results in 7, I define: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#define SSPCR0_SCR (0x7&amp;lt;&amp;lt;8)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and can assemble my CR0 with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;CR0 = ... | SSPCR0_SCR;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:51:52 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:51:52Z</dc:date>
    <item>
      <title>How do the SPI driver bitfield macros work?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572564#M21062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by justyn on Sat May 21 17:16:11 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;spi.h (and perhaps others) in the driver files (for the LPC111x at least) contains various macros like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#define SSPCR0_SCR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x1&amp;lt;&amp;lt;8)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm perfectly familiar with using notation like the above to set individual bit flags.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But SCR isn't a single bit flag, it is an 8-bit value&amp;nbsp; set in bits 15:8 of the CR0 register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So since the macro resolves as 0x10 or 0b0000000100000000, how is it useful? Surely the macro needs to be 0xFF00, or perhaps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#define SSPCR0_SCR(x)&amp;nbsp;&amp;nbsp;&amp;nbsp; (x&amp;lt;&amp;lt;8)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or something like that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:51:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572564#M21062</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do the SPI driver bitfield macros work?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572565#M21063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Sat May 21 17:34:04 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That's a common way to define values in registers and not restricted to set single bits.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this case Serial Clock Rate. So if I my SCR calculation results in 7, I define: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#define SSPCR0_SCR (0x7&amp;lt;&amp;lt;8)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and can assemble my CR0 with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SSP0-&amp;gt;CR0 = ... | SSPCR0_SCR;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:51:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572565#M21063</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do the SPI driver bitfield macros work?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572566#M21064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Rob65 on Sat May 21 23:56:18 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Justyn,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you got that perfectly well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You even suggest an alternate macro to be able to program the serial clock rate in our own programs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;#define SSPCR0_SCR(x)&amp;nbsp;&amp;nbsp;&amp;nbsp; (x&amp;lt;&amp;lt;8)&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;What I am concerned about is the fact that you name these files [B][I]driver files[/I][/B].&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;These files are called [I][B]example projects[/B][/I] by NXP and are in no way meant to be driver files that are of general use. The older versions of the example projects were simple: the ssp directory contained ssp.c and ssp.h and the program ssptest.c.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the new version of the example projects the ssp.c and ssp.h files have just been moved to a common/driver directory which makes this less readable as an example (since now there is no SSP sample code in the SSP project, it's all 'hidden' in the common/driver project).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These files are, again, in no way ever meant to be used as general purpose drivers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The documentation is a bit sparse:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;LPCXpresso examples common files
================================
Welcome to the LPCXpresso examples common files project. This project
does not build. It is used together with the template project to
create other projects.

See template_readme.txt in the template project for a complete
explanation.
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;:eek:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I have no clue what the [I]drivers[/I]&amp;nbsp; do or what they don't do - how would this make these files usable in my own projects?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The next thing is that there are errors and funny things in the code telling me it was not properly tested or even reviewed. At one time I got a chearfull email from someone within NXP in San Jose telling me they were going to write a general driver library and he asked me if I'd be willing to review specifications, documentation and code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you are using these [I]driver files[/I] exactly the way they should be: the code in one hand, the user manual in the other and intelligently look at it and change it to your own needs (use the force Luke) &lt;SPAN class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;&lt;LI-EMOJI id="lia_grinning-face-with-smiling-eyes" title=":grinning_face_with_smiling_eyes:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it is hard to create general purpose drivers and for some components this may even be out of bounds: a general SPI driver which is able to be both master and slave may not be what you want (I mostly only act as a master). I2C slave/master is even worse: this will make your code grow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:51:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572566#M21064</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do the SPI driver bitfield macros work?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572567#M21065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by justyn on Sun May 22 09:31:10 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Rob65&lt;/STRONG&gt;&lt;BR /&gt;What I am concerned about is the fact that you name these files [B][I]driver files[/I][/B].&lt;BR /&gt;These files are called [I][B]example projects[/B][/I] by NXP and are in no way meant to be driver files that are of general use. The older versions of the example projects were simple: the ssp directory contained ssp.c and ssp.h and the program ssptest.c.&lt;BR /&gt;In the new version of the example projects the ssp.c and ssp.h files have just been moved to a common/driver directory which makes this less readable as an example (since now there is no SSP sample code in the SSP project, it's all 'hidden' in the common/driver project).&lt;BR /&gt;&lt;BR /&gt;These files are, again, in no way ever meant to be used as general purpose drivers.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ah OK, thank you, yes it is clear I was misunderstanding the purpose of these files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Rob65&lt;/STRONG&gt;&lt;BR /&gt; I think it is hard to create general purpose drivers and for some components this may even be out of bounds: a general SPI driver which is able to be both master and slave may not be what you want (I mostly only act as a master). I2C slave/master is even worse: this will make your code grow.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I understand what you're saying but I can't help feeling that with the use of #define and #ifdef statements we could create some more general purpose drivers for the peripherals that are no larger than custom or hand-modified code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this would be fine for the initialization of the peripherals at least - actual data transfer and such is more likely to be dependent on how you're using interrupts etc.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:51:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/How-do-the-SPI-driver-bitfield-macros-work/m-p/572567#M21065</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:51:54Z</dc:date>
    </item>
  </channel>
</rss>

