Passing Bitsets as parameters in functions

Mr Crusty
 
Avatar
 
Betreff:

Passing Bitsets as parameters in functions

 · 
Gepostet: 29.10.2009 - 20:17 Uhr  ·  #1
Hi,
Probably not much interest for people who have already understood the following concept, but may be useful for newbies.
Taken me a week of nights to realize it's so simple.

I have been working on an Accelerometer unit that uses TWI and has a lot of registers to load, without altering all existing bits in the registers.
There are all 8bit and have reg names and bit names given by the chip maker in their data sheet.
For legibility of code I have made each register a bit set with bits enumerated in line with the makers bit codes.

Getting each register loaded becomes easy when passed as a bitset parameter to the TWI set functions attached. One set bits the other clears bits
If you run this in the emulator and watch the bitsets you will see how the bit true and false states are passed into and processed in the procedure. I have not set the function to clear all vars on entry, so second time through shows how the + - in bitsets works.
If altering be aware that Bitset length must be the same or compile error
Regards
Crusty :P
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 13   32   45 · Page-Gen-Time: 0.06925s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI