Skip to content

EFM32 - change bitfield definitions to be unshifted.#595

Closed
kbob wants to merge 5 commits intolibopencm3:masterfrom
kbob:unshift
Closed

EFM32 - change bitfield definitions to be unshifted.#595
kbob wants to merge 5 commits intolibopencm3:masterfrom
kbob:unshift

Conversation

@kbob
Copy link
Copy Markdown
Contributor

@kbob kbob commented Jan 7, 2016

Change all bitfield constant definitions for EFM32 to use unshifted values. Also fixed three errata in the definitions.

I also have an update for libopencm3-examples pull request #85 that uses the updated definitions. I will submit a pull request for that momentarily.

Rationale

In the comments on Pull Request #581, @karlp and @ChuckM asked that the bitfield definitions be unshifted. E.g., instead of

#define REG_FIELD_SHIFT 2
#define REG_FIELD_MASK 0xC0
#define REG_FIELD(x) (((x) << REG_FIELD_SHIFT) & REG_FIELD_MASK)
#define REG_FIELD_RED REG_FIELD(1)
#define REG_FIELD_BLUE REG_FIELD(2)

   REG = REG_FIELD_RED;

this is the preferred way.

#define REG_FIELD_RED 1
#define REG_FIELD_BLUE 2

    REG = REG_FIELD(REG_FIELD_RED);

@kbob
Copy link
Copy Markdown
Contributor Author

kbob commented Jan 7, 2016

The libopencm3-examples pull request is #116.

Comment thread include/libopencm3/efm32/lg/acmp.h Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you are #defining simply a number do you really need parenthesis around it?

@ChuckM
Copy link
Copy Markdown
Contributor

ChuckM commented Jan 9, 2016

other than the admittedly harmless extra parenthsis it looks good to me @kbob

@kbob
Copy link
Copy Markdown
Contributor Author

kbob commented Jan 9, 2016

I removed the parentheses.

@kbob
Copy link
Copy Markdown
Contributor Author

kbob commented Jan 26, 2016

This is superceded by #606.

@kbob kbob closed this Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants