+
+void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *max_blk, uint8_t *books, uint8_t *kb) {
+ // mem-bit 5, mem-bit 7, chip-bit 4: defines chip type
+ if(isset(chip_cfg, 0x10) && notset(mem_cfg, 0x80) && notset(mem_cfg, 0x20)) {
+ kb = 2;
+ books = 1;
+ max_blk = 31;
+ } else if(isset(chip_cfg, 0x10) && isset(mem_cfg, 0x80) && notset(mem_cfg, 0x20)) {
+ kb = 16;
+ books = 2;
+ max_blk = 255; //16kb
+ } else if(notset(chip_cfg, 0x10) && notset(mem_cfg, 0x80) && notset(mem_cfg, 0x20)) {
+ kb = 16;
+ books = 16;
+ max_blk = 255; //16kb
+ } else if(isset(chip_cfg, 0x10) && isset(mem_cfg, 0x80) && isset(mem_cfg, 0x20)) {
+ kb = 32;
+ books = 2;
+ max_blk = 255; //16kb
+ } else if(notset(chip_cfg, 0x10) && notset(mem_cfg, 0x80) && isset(mem_cfg, 0x20)) {
+ kb = 32;
+ books = 16;
+ max_blk = 255; //16kb
+ } else {
+ kb = 32;
+ max_blk = 255;
+ }
+}
+