|
|
|
|
|
by MobiusHorizons
538 days ago
|
|
in microcontrollers it's very common to see code generated that creates structs for the registers. They will typically output fields that are a full machine word in size (or maybe in some cases as small as a byte), and individual bits will be addressed with bitmasking (ie `my_device.some_reg |= SOME_REG_FLAG_NAME` or `my_device.some_reg &= ~SOME_REG_FLAG_NAME` to clear it). It is sometimes necessary to be thoughtful about batching writes so that certain bits are set before the periferal begins some process. A trivial example would be: port_a.data_out |= GPIOA_PIN_1 | GPIOA_PIN_2;
and port_a.pin1 = true;
port_a.pin2 = true;
|
|