6 #ifndef __CHANNELLIST_H__
7 #define __CHANNELLIST_H__
20 uint16_t address ()
const {
return addr; }
22 bool valid ()
const {
return addr != 0; }
24 uint8_t getByte (uint8_t offset)
const {
25 return storage().getByte(addr + offset);
28 uint8_t getByte (uint8_t offset, uint8_t mask, uint8_t shift)
const {
29 return (getByte(offset) & mask) >> shift;
32 bool setByte (uint8_t offset, uint8_t data)
const {
33 return storage().setByte(addr + offset, data);
36 bool setByte (uint8_t offset, uint8_t data, uint8_t mask, uint8_t shift)
const {
37 uint8_t tmp = getByte(offset) & ~mask;
38 tmp |= (data << shift) & mask;
39 return setByte(offset, tmp);
42 bool isBitSet (uint8_t offset, uint8_t bit)
const {
43 return (storage().getByte(addr + offset) & bit) == bit;
46 bool setBit (uint8_t offset, uint8_t bit,
bool value)
const {
48 return storage().setBits(addr + offset, bit);
50 return storage().clearBits(addr + offset, bit);
53 bool setData (uint8_t offset,uint8_t* buf,uint16_t size)
const {
54 return storage().setData(addr + offset,buf,size);
57 bool getData (uint8_t offset,uint8_t* buf,uint16_t size)
const {
58 return storage().getData(addr + offset,buf,size);
61 void clear (uint8_t offset,uint16_t size) {
62 storage().clearData(addr + offset,size);
65 void init (
const uint8_t* data,uint16_t size) {
66 for(uint16_t idx=0; idx<size; ++idx) {
67 storage().setByte(addr + idx,pgm_read_byte(data + idx));
74 uint8_t (*getregister) (uint8_t off);
75 uint8_t (*getoffset) (uint8_t reg);
78 GenericList (uint16_t a,uint8_t s,uint8_t (*getreg) (uint8_t off), uint8_t (*getoff) (uint8_t reg)) :
BaseList(a), size(s), getregister(getreg), getoffset(getoff) {}
80 uint8_t getOffset (uint8_t reg)
const {
81 return getoffset(reg);
84 uint8_t getRegister (uint8_t offset)
const {
85 return getregister(offset);
88 bool writeRegister (uint8_t reg, uint8_t value)
const {
90 uint8_t offset = getOffset(reg);
91 if( offset != 0xff ) {
92 result = setByte(offset,value);
97 uint8_t readRegister (uint8_t reg)
const {
99 uint8_t offset = getOffset(reg);
100 if( offset != 0xff ) {
101 value = getByte(offset);
106 uint8_t getSize ()
const {
113 storage().dump(address(),getSize());
119 template<
class DataType>
126 static uint8_t getOffset (uint8_t reg) {
127 return DataType::getOffset(reg);
130 static uint8_t getRegister (uint8_t offset) {
131 return DataType::getRegister(offset);
134 static uint8_t size () {
135 return sizeof(DataType);
138 bool writeRegister (uint8_t reg, uint8_t value)
const {
140 uint8_t offset = getOffset(reg);
141 if( offset != 0xff ) {
142 result = setByte(offset,value);
147 uint8_t readRegister (uint8_t reg)
const {
149 uint8_t offset = getOffset(reg);
150 if( offset != 0xff ) {
151 value = getByte(offset);
159 storage().dump(address(),size());
163 return GenericList(address(),size(),getRegister,getOffset);
170 static uint8_t getOffset(__attribute__((unused)) uint8_t reg) {
return 0xff; }
171 static uint8_t getRegister(__attribute__((unused)) uint8_t reg) {
return 0xff; }
192 static uint8_t getOffset(uint8_t reg) {
203 static uint8_t getRegister(uint8_t offset) {
219 HMID masterid () {
return HMID(getByte(1),getByte(2),getByte(3)); }
220 void masterid (
const HMID& mid) {
221 setByte(1,mid.id0());
222 setByte(2,mid.id1());
223 setByte(3,mid.id2());
225 bool aesActive ()
const {
return false; }
226 bool sabotageMsg ()
const {
return false; }
227 bool localResetDisable ()
const {
return false; }
228 uint8_t ledMode ()
const {
return 0x01; }
238 uint8_t transmitDevTryMax ()
const {
return 6; }
245 uint8_t AesActive :1;
248 static uint8_t getOffset(uint8_t reg) {
256 static uint8_t getRegister(uint8_t offset) {
269 bool aesActive ()
const {
return isBitSet(0,0x01); }
270 bool aesActive (
bool s)
const {
return setBit(0,0x01,s); }
283 static uint8_t getOffset(uint8_t reg) {
291 static uint8_t getRegister(uint8_t offset) {
304 bool burst ()
const {
return isBitSet(0,0x01); }
305 bool burst (
bool s)
const {
return setBit(0,0x01,s); }