%% options copyright owner = Dirk Krause copyright year = 2011-2014 license = bsd %% header #ifdef __cplusplus extern "C" { #endif /** Retrieve one bit. @param i Index of bit (0=lsb, 15=msb). @return The requested bit. */ unsigned short dk3bits_get(size_t i); #ifdef __cplusplus } #endif %% module #include "dk3conf.h" #include "dk3types.h" #include "dk3bits.h" /** Masks to set and retrieve single bits. */ static unsigned short const dk3bits_values[] = { 0x0001U, 0x0002U, 0x0004U, 0x0008U, 0x0010U, 0x0020U, 0x0040U, 0x0080U, 0x0100U, 0x0200U, 0x0400U, 0x0800U, 0x1000U, 0x2000U, 0x4000U, 0x8000U }; unsigned short dk3bits_get(size_t i) { unsigned short back = 0U; if(i < 16) { back = dk3bits_values[i]; } return back; }