lpcware

How do the SPI driver bitfield macros work?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by justyn on Sat May 21 17:16:11 MST 2011
Hi all,

spi.h (and perhaps others) in the driver files (for the LPC111x at least) contains various macros like this:

#define SSPCR0_SCR      (0x1<<8)

I'm perfectly familiar with using notation like the above to set individual bit flags.

But SCR isn't a single bit flag, it is an 8-bit value  set in bits 15:8 of the CR0 register.

So since the macro resolves as 0x10 or 0b0000000100000000, how is it useful? Surely the macro needs to be 0xFF00, or perhaps:
#define SSPCR0_SCR(x)    (x<<8)
or something like that?

What am I missing?

Outcomes