static void flash_write(FlashIO* io, FlashWrite* fc) { FlashWritten info; info.cmd = FLASH_WRITTEN; info.req_id = fc->req_id; info.addr = fc->addr; info.bytes = 0; // Do the write info.bytes = flash_save(io, fc->addr, fc->bytes, fc->data); #if defined(ALLOW_VERBOSE) if (debug_fn) { char buff[24]; snprintf(buff, sizeof(buff), "flash_write(r=%d,%ld,%d)\r\n", (int) info.req_id, info.addr, info.bytes); debug(buff); } #endif // ALLOW_VERBOSE // CRC the EEPROM that we've just written info.crc = get_crc(io, fc->addr, fc->bytes); send_flash_message(& info, sizeof(info)); }
static void flash_slot(FlashIO* io, FlashSlot* fc) { #if defined(ALLOW_VERBOSE) if (debug_fn) { char buff[32]; snprintf(buff, sizeof(buff), "flash_record(r=%d,%d)\r\n", (int) fc->req_id, fc->slot); debug(buff); } #endif // ALLOW_VERBOSE // Write Record const uint16_t size = sizeof(fc->entry); const uint32_t offset = fc->slot * size; FlashWritten info; info.cmd = FLASH_WRITTEN; info.req_id = fc->req_id; info.addr = offset; info.bytes = 0; // Do the write if (fc->slot <= MAX_SLOTS) { info.bytes = flash_save(io, offset, size, (uint8_t*) & fc->entry); // CRC the EEPROM that we've just written info.crc = get_crc(io, offset, size); } send_flash_message(& info, sizeof(info)); }
bool asic_save(emu_image *s) { s->deviceType = asic.deviceType; return backlight_save(s) && control_save(s) && cpu_save(s) && flash_save(s) && intrpt_save(s) && keypad_save(s) && lcd_save(s) && mem_save(s) && watchdog_save(s) && protect_save(s) && rtc_save(s) && sha256_save(s) && gpt_save(s) && usb_save(s) && cxxx_save(s) && dxxx_save(s) && exxx_save(s) && sched_save(s); }
static void i2c_rx_irq(enum sys_message msg) { uint8_t *flash_addr = FLASH_ADDR; uint8_t cmd = i2c_rx_buff[0]; uint8_t arg = i2c_rx_buff[1]; uint8_t mute_st = i2c_rx_buff[2]; uint8_t vol_r = i2c_rx_buff[3]; uint8_t vol_l = i2c_rx_buff[4]; switch (cmd) { case M_CMD_WRITE: if (arg == 2) { flash_addr = SEGMENT_C; } else if (arg == 3) { flash_addr = SEGMENT_D; } else { flash_addr = SEGMENT_B; } flash_save(flash_addr, (void *)&s, sizeof(s)); break; case M_CMD_READ: if (arg == 2) { flash_addr = SEGMENT_C; } else if (arg == 3) { flash_addr = SEGMENT_D; } else { flash_addr = SEGMENT_B; } settings_init(flash_addr); break; case M_CMD_VOL: if ((0 < arg) && (arg < 7) && ((mute_st == MUTE) || (mute_st == UNMUTE))) { pga_set_volume(arg, vol_r, vol_l, 1, 1); if (mute_st != mixer_get_mute_struct(arg)) { if (mute_st == MUTE) { pga_set_mute_st(arg, MUTE, 1); } else { pga_set_mute_st(arg, UNMUTE, 1); } } } break; case M_CMD_MUTE: if ((0 < arg) && (arg < 7)) { pga_set_mute_st(arg, MUTE, 1); } break; case M_CMD_UNMUTE: if ((0 < arg) && (arg < 7)) { pga_set_mute_st(arg, UNMUTE, 1); } break; } i2c_rx_rdy = 1; }
static void uart1_rx_irq(enum sys_message msg) { uint16_t u16; uint8_t p; uint8_t pga, ch, left = 0, right = 0; uint8_t *flash_addr = FLASH_ADDR; char *input; uint8_t *ptr; uint8_t allfine = 0; input = (char *)uart1_rx_buf; p = input[0]; if (p > 97) { p -= 32; } if ((p == 63) || (p == M_CMD_HELP)) { // [h?] display_help(); } else if (p == M_CMD_SHOW) { // [s]how settings show_settings(); uart1_tx_str("ok\r\n", 4); } else if (p == M_CMD_WRITE) { // [w]rite to flash if (str_to_uint16(input, &u16, 1, 1, 1, 3)) { if (u16 == 1) { flash_addr = SEGMENT_B; } else if (u16 == 2) { flash_addr = SEGMENT_C; } else if (u16 == 3) { flash_addr = SEGMENT_D; } flash_save(flash_addr, (void *)&s, sizeof(s)); uart1_tx_str("ok\r\n", 4); } } else if (p == M_CMD_READ) { // [r]ead from flash if (str_to_uint16(input, &u16, 1, 1, 1, 3)) { if (u16 == 1) { flash_addr = SEGMENT_B; } else if (u16 == 2) { flash_addr = SEGMENT_C; } else if (u16 == 3) { flash_addr = SEGMENT_D; } settings_init(flash_addr); uart1_tx_str("ok\r\n", 4); } } else if (p == M_CMD_MUTE) { // [m]ute pga if (str_to_uint16(input, &u16, 1, 1, 1, 6)) { pga = u16; pga_set_mute_st(pga, MUTE, 1); uart1_tx_str("ok\r\n", 4); } } else if (p == M_CMD_UNMUTE) { // [u]nmute pga if (str_to_uint16(input, &u16, 1, 1, 1, 6)) { pga = u16; pga_set_mute_st(pga, UNMUTE, 1); uart1_tx_str("ok\r\n", 4); } } else if (p == M_CMD_VOL) { // [v]olume set if (str_to_uint16(input, &u16, 1, 1, 1, 6)) { pga = u16; ch = input[2]; if (str_to_uint16(input, &u16, 3, strlen(input) - 3, 0, 255)) { ptr = (uint8_t *) & s.v1_r; if (ch == 98) { // 'b' - change both channels right = u16; left = u16; allfine = 1; } else if (ch == 114) { // 'r' - only change the right channel right = u16; left = *(ptr + (pga * 2 - 2) + 1); allfine = 1; } else if (ch == 108) { // 'l' - only change the left channel right = *(ptr + (pga * 2 - 2)); left = u16; allfine = 1; } if (allfine) { pga_set_volume(pga, right, left, 1, 1); uart1_tx_str("ok\r\n", 4); } } } } //snprintf(str_temp, TEMP_LEN, "D 0x%x 0x%x 0x%x\r\n", input[0], input[1], input[2]); //uart1_tx_str(str_temp, strlen(str_temp)); uart1_p = 0; uart1_rx_enable = 1; }