+
+void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *max_blk, uint8_t *app_areas, 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;
+ *app_areas = 2;
+ *max_blk = 31;
+ } else if(isset(chip_cfg, 0x10) && isset(mem_cfg, 0x80) && notset(mem_cfg, 0x20)) {
+ *kb = 16;
+ *app_areas = 2;
+ *max_blk = 255; //16kb
+ } else if(notset(chip_cfg, 0x10) && notset(mem_cfg, 0x80) && notset(mem_cfg, 0x20)) {
+ *kb = 16;
+ *app_areas = 16;
+ *max_blk = 255; //16kb
+ } else if(isset(chip_cfg, 0x10) && isset(mem_cfg, 0x80) && isset(mem_cfg, 0x20)) {
+ *kb = 32;
+ *app_areas = 3;
+ *max_blk = 255; //16kb
+ } else if(notset(chip_cfg, 0x10) && notset(mem_cfg, 0x80) && isset(mem_cfg, 0x20)) {
+ *kb = 32;
+ *app_areas = 17;
+ *max_blk = 255; //16kb
+ } else {
+ *kb = 32;
+ *app_areas = 2;
+ *max_blk = 255;
+ }
+}
+
+void mem_app_config(const picopass_hdr *hdr) {