Skip to content

Instantly share code, notes, and snippets.

@nadavmatalon
Created November 8, 2016 16:47
Show Gist options
  • Save nadavmatalon/bfc85529c5afaf214ca08d7d7e7f49d1 to your computer and use it in GitHub Desktop.
Save nadavmatalon/bfc85529c5afaf214ca08d7d7e7f49d1 to your computer and use it in GitHub Desktop.
Union & Struct Example
typedef struct Scr_t {
union {
u16 data;
struct {
u16 tile : 10;
u16 hflip : 1;
u16 vflip : 1;
u16 pal : 4;
};
};
} scr_t;
scr_t se;
void setup() {
se.pal= 1; // Set via C bitfields
se.data= 0x1000; // Set manually (overwrites all fields)
}
void loop() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment