diff --git a/firmware/applications/cbitset.h b/firmware/applications/cbitset.h new file mode 100644 index 0000000..4e76b82 --- /dev/null +++ b/firmware/applications/cbitset.h @@ -0,0 +1,53 @@ +#ifndef CBITFIELD_H +#define CBITFIELD_H + +#define BITSETCHUNKSIZE 32 + +#define one ((uint32_t)1) + +struct bitset { + uint16_t size; + uint32_t bits[BITSET_SIZE/BITSETCHUNKSIZE+1]; +}; + +static inline void bitset_set(struct bitset *bs,uint16_t index, uint8_t value) { + uint16_t base=index/BITSETCHUNKSIZE; + uint16_t offset=index%BITSETCHUNKSIZE; + if(value) { + bs->bits[base]|=(one<bits[base]&=~(one<bits[base]^=(one<bits[base]&(one<