So I've been writing my Cortex M monitor and using this library, which
eventually I hope to publish to github but in the mean time a question has
come up for me.
So I'm writing SD Card support into my monitor, and its still a bit thin in
the library so I've not too many style suggestions to go by. But this is
the current question.
So in ./include/libopencm3/stm32/sdio.h there is a define:
/* CLKDIV: Clock divide factor */
#define SDIO_CLKCR_CLKDIV_SHIFT 0
#define SDIO_CLKCR_CLKDIV_MSK (0xFF << SDIO_CLKCR_CLKDIV_SHIFT)
And I want to set the Clock Divisor to 0x76. So do I do this ?
tmp = SDIO_CLKCR;
tmp &= ~SDIO_CLKCR_CLKDIV_MSK;
tmp |= (0x76) << SDO_CLKCR_CLKDIV_SHIFT;
Seems a bit verbose.
Not that I'm a huge fan of ST Micro's use of structure construction to
place bits in the field of course, that seems a bit cleaner in their code.
But if that is what is expected in libopencm3 code I'm ok with it.