Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Polprzewodnikowy committed Jan 15, 2024
1 parent 7d2ebb8 commit 980d28d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion sw/controller/src/app.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.type loader, %object
loader:
.incbin "build/loader/loader.bin"

.org 0x1000, 0xFF

.section .text.Reset_Handler
.type Reset_Handler, %function
Expand Down
2 changes: 1 addition & 1 deletion sw/controller/src/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions sw/controller/src/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
34 changes: 17 additions & 17 deletions sw/controller/src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions sw/controller/src/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
4 changes: 4 additions & 0 deletions sw/controller/src/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sw/controller/src/lcmxo2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion sw/controller/src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
14 changes: 7 additions & 7 deletions sw/controller/src/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion sw/controller/src/writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 980d28d

Please sign in to comment.