diff --git a/sw/controller/src/app.S b/sw/controller/src/app.S index 01b6ea0..04076d0 100644 --- a/sw/controller/src/app.S +++ b/sw/controller/src/app.S @@ -8,7 +8,7 @@ .type loader, %object loader: .incbin "build/loader/loader.bin" - + .org 0x1000, 0xFF .section .text.Reset_Handler .type Reset_Handler, %function diff --git a/sw/controller/src/button.c b/sw/controller/src/button.c index 26f811f..9a220ba 100644 --- a/sw/controller/src/button.c +++ b/sw/controller/src/button.c @@ -25,7 +25,7 @@ bool button_get_state (void) { } bool button_set_mode (button_mode_t mode) { - if (mode > BUTTON_MODE_DD_DISK_SWAP) { + if (mode >= __BUTTON_MODE_COUNT) { return true; } p.mode = mode; diff --git a/sw/controller/src/button.h b/sw/controller/src/button.h index 69cb575..bd4cac8 100644 --- a/sw/controller/src/button.h +++ b/sw/controller/src/button.h @@ -6,10 +6,11 @@ typedef enum { - BUTTON_MODE_NONE, - BUTTON_MODE_N64_IRQ, - BUTTON_MODE_USB_PACKET, - BUTTON_MODE_DD_DISK_SWAP, + BUTTON_MODE_NONE = 0, + BUTTON_MODE_N64_IRQ = 1, + BUTTON_MODE_USB_PACKET = 2, + BUTTON_MODE_DD_DISK_SWAP = 3, + __BUTTON_MODE_COUNT } button_mode_t; diff --git a/sw/controller/src/cfg.c b/sw/controller/src/cfg.c index 4a6e805..3a28b2d 100644 --- a/sw/controller/src/cfg.c +++ b/sw/controller/src/cfg.c @@ -18,25 +18,25 @@ typedef enum { - CFG_ID_BOOTLOADER_SWITCH, - CFG_ID_ROM_WRITE_ENABLE, - CFG_ID_ROM_SHADOW_ENABLE, - CFG_ID_DD_MODE, - CFG_ID_ISV_ADDRESS, - CFG_ID_BOOT_MODE, - CFG_ID_SAVE_TYPE, - CFG_ID_CIC_SEED, - CFG_ID_TV_TYPE, - CFG_ID_DD_SD_ENABLE, - CFG_ID_DD_DRIVE_TYPE, - CFG_ID_DD_DISK_STATE, - CFG_ID_BUTTON_STATE, - CFG_ID_BUTTON_MODE, - CFG_ID_ROM_EXTENDED_ENABLE, + CFG_ID_BOOTLOADER_SWITCH = 0, + CFG_ID_ROM_WRITE_ENABLE = 1, + CFG_ID_ROM_SHADOW_ENABLE = 2, + CFG_ID_DD_MODE = 3, + CFG_ID_ISV_ADDRESS = 4, + CFG_ID_BOOT_MODE = 5, + CFG_ID_SAVE_TYPE = 6, + CFG_ID_CIC_SEED = 7, + CFG_ID_TV_TYPE = 8, + CFG_ID_DD_SD_ENABLE = 9, + CFG_ID_DD_DRIVE_TYPE = 10, + CFG_ID_DD_DISK_STATE = 11, + CFG_ID_BUTTON_STATE = 12, + CFG_ID_BUTTON_MODE = 13, + CFG_ID_ROM_EXTENDED_ENABLE = 14, } cfg_id_t; typedef enum { - SETTING_ID_LED_ENABLE, + SETTING_ID_LED_ENABLE = 0, } setting_id_t; typedef enum { @@ -179,7 +179,7 @@ static void cfg_change_scr_bits (uint32_t mask, bool value) { } static bool cfg_set_save_type (save_type_t save_type) { - if (save_type > SAVE_TYPE_SRAM_1M) { + if (save_type >= __SAVE_TYPE_COUNT) { return true; } diff --git a/sw/controller/src/cfg.h b/sw/controller/src/cfg.h index 82038c5..0459fe3 100644 --- a/sw/controller/src/cfg.h +++ b/sw/controller/src/cfg.h @@ -14,6 +14,7 @@ typedef enum { SAVE_TYPE_FLASHRAM = 4, SAVE_TYPE_SRAM_BANKED = 5, SAVE_TYPE_SRAM_1M = 6, + __SAVE_TYPE_COUNT } save_type_t; diff --git a/sw/controller/src/dd.c b/sw/controller/src/dd.c index cafd82e..4b1331a 100644 --- a/sw/controller/src/dd.c +++ b/sw/controller/src/dd.c @@ -136,7 +136,9 @@ static bool dd_block_read_request (void) { if (p.sd_mode) { uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE]; uint32_t sectors = dd_fill_sd_sector_table(index, sector_table, false); + led_activity_on(); bool error = sd_optimize_sectors(buffer_address, sector_table, sectors, sd_read_sectors); + led_activity_off(); dd_set_block_ready(!error); } else { usb_tx_info_t packet_info; @@ -158,7 +160,9 @@ static bool dd_block_write_request (void) { if (p.sd_mode) { uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE]; uint32_t sectors = dd_fill_sd_sector_table(index, sector_table, true); + led_activity_on(); bool error = sd_optimize_sectors(buffer_address, sector_table, sectors, sd_write_sectors); + led_activity_off(); dd_set_block_ready(!error); } else { usb_tx_info_t packet_info; diff --git a/sw/controller/src/lcmxo2.c b/sw/controller/src/lcmxo2.c index d5db5d2..1be5dcd 100644 --- a/sw/controller/src/lcmxo2.c +++ b/sw/controller/src/lcmxo2.c @@ -169,7 +169,7 @@ static bool lcmxo2_wait_busy (void) { uint32_t status; do { status = lcmxo2_read_status(); - } while(status & LSC_STATUS_BUSY); + } while (status & LSC_STATUS_BUSY); return (status & LSC_STATUS_FAIL); } diff --git a/sw/controller/src/timer.c b/sw/controller/src/timer.c index ee50a10..bba0aa9 100644 --- a/sw/controller/src/timer.c +++ b/sw/controller/src/timer.c @@ -21,7 +21,7 @@ static void timer_update (void) { } if (timer[id].pending) { timer[id].pending = false; - } else if(timer[id].value == 0) { + } else if (timer[id].value == 0) { timer[id].running = false; } } diff --git a/sw/controller/src/usb.h b/sw/controller/src/usb.h index 3447e9a..5837f23 100644 --- a/sw/controller/src/usb.h +++ b/sw/controller/src/usb.h @@ -7,13 +7,13 @@ typedef enum packet_cmd { - PACKET_CMD_BUTTON_TRIGGER = 'B', - PACKET_CMD_DATA_FLUSHED = 'G', - PACKET_CMD_DEBUG_OUTPUT = 'U', - PACKET_CMD_DD_REQUEST = 'D', - PACKET_CMD_ISV_OUTPUT = 'I', - PACKET_CMD_SAVE_WRITEBACK = 'S', - PACKET_CMD_UPDATE_STATUS = 'F', + PACKET_CMD_BUTTON_TRIGGER = 'B', + PACKET_CMD_DATA_FLUSHED = 'G', + PACKET_CMD_DEBUG_OUTPUT = 'U', + PACKET_CMD_DD_REQUEST = 'D', + PACKET_CMD_ISV_OUTPUT = 'I', + PACKET_CMD_SAVE_WRITEBACK = 'S', + PACKET_CMD_UPDATE_STATUS = 'F', } usb_packet_cmd_e; diff --git a/sw/controller/src/writeback.c b/sw/controller/src/writeback.c index 05bd31a..d2e4c91 100644 --- a/sw/controller/src/writeback.c +++ b/sw/controller/src/writeback.c @@ -82,7 +82,7 @@ static void writeback_save_to_sd (void) { return; } - bool error = sd_optimize_sectors(address, p.sectors, length / SD_SECTOR_SIZE, sd_write_sectors); + bool error = sd_optimize_sectors(address, p.sectors, (length / SD_SECTOR_SIZE), sd_write_sectors); if (error) { writeback_disable();