Hallo, Zum speichern einzelner Bits habe ich mir folgende Funktion geschrieben, ich finde allerdings das ständige multiplizieren und dividieren nicht sonderlich gut gelöste evtl. hat jemand eine bessere und schnellere Lösung. Gruß Thomas
1 | #define BINTABELSIZE 128 |
2 | volatile uint8_t BinTabel[BINTABELSIZE]; |
3 | volatile uint16_t BinTabelPos =0; |
4 | volatile uint8_t BinTabelSize =0; |
5 | |
6 | |
7 | |
8 | |
9 | void AddBitBuffer(uint8_t bit) |
10 | { |
11 | |
12 | if( BinTabelPos < (BINTABELSIZE*8) ) |
13 | { |
14 | if ( bit ) |
15 | { |
16 | BinTabel[BinTabelPos/8] |= 1<<(7-(BinTabelPos%8)); //high |
17 | BinTabelPos++; |
18 | } |
19 | else |
20 | { |
21 | BinTabel[BinTabelPos/8] &= ~(1<<(7-(BinTabelPos%8))); //Low |
22 | BinTabelPos++; |
23 | } |
24 | } |
25 | } |