Skip to content

Commit

Permalink
mio168 comm
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Dec 26, 2020
1 parent 22b7f70 commit 1b64653
Show file tree
Hide file tree
Showing 25 changed files with 54,226 additions and 53,749 deletions.
48 changes: 48 additions & 0 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,11 @@
"name": "dlog_item_is_available",
"type": "boolean",
"defaultValue": "1"
},
{
"name": "module_is_resync_supported",
"type": "boolean",
"defaultValue": "1"
}
],
"actions": [
Expand Down Expand Up @@ -3088,6 +3093,9 @@
},
{
"name": "select_mass_storage_device"
},
{
"name": "module_resync"
}
],
"gui": {
Expand Down Expand Up @@ -9987,6 +9995,46 @@
"hangingIndent": 24
}
]
},
{
"type": "Select",
"style": {
"inheritFrom": "default"
},
"data": "module_is_resync_supported",
"left": 226,
"top": 162,
"width": 114,
"height": 50,
"widgets": [
{
"type": "Rectangle",
"style": {
"inheritFrom": "default"
},
"left": 0,
"top": 0,
"width": 114,
"height": 50,
"invertColors": true
},
{
"type": "MultilineText",
"style": {
"inheritFrom": "edit_value_active_S_center",
"alignHorizontal": "center",
"alignVertical": "center"
},
"action": "module_resync",
"left": 0,
"top": 0,
"width": 114,
"height": 50,
"text": "Resync",
"firstLineIndent": 0,
"hangingIndent": 0
}
]
}
]
},
Expand Down
11 changes: 10 additions & 1 deletion src/eez/action_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,12 @@ void action_show_edit_mode_slider_help() {

void action_show_slot_settings() {
hmi::selectSlot(getFoundWidgetAtDown().cursor);
showPage(g_slots[hmi::g_selectedSlotIndex]->getSlotSettingsPageId());

showPage(
g_slots[hmi::g_selectedSlotIndex]->getTestResult() == TEST_OK ?
g_slots[hmi::g_selectedSlotIndex]->getSlotSettingsPageId() :
PAGE_ID_SLOT_SETTINGS
);
}

void action_show_ch_settings() {
Expand Down Expand Up @@ -1305,6 +1310,10 @@ void action_edit_ntp_refresh_frequency() {
NumericKeypad::start(0, Value(page->ntpRefreshFrequency, VALUE_TYPE_UINT32), options, onSetNtpRefreshFrequency, 0, 0);
}

void action_module_resync() {
sendMessageToPsu(PSU_MESSAGE_MODULE_RESYNC, hmi::g_selectedSlotIndex);
}

} // namespace gui
} // namespace eez

Expand Down
121 changes: 19 additions & 102 deletions src/eez/fs_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void LinkDriver(int slotIndex) {
path[2] = '/';
auto result = f_mount(&g_fatFS[slotIndex], path, 1);
if (result != FR_OK) {
disk.drv[driverIndex] = 0;
DebugTrace("Slot %d disk mount failed\n", slotIndex + 1);
return;
}
Expand Down Expand Up @@ -198,74 +199,35 @@ int getDiskDriveIndex(int iterationIndex, bool includeUsbMassStorageDevice) {
#if defined(EEZ_PLATFORM_STM32)

DSTATUS DiskDriver_initialize(BYTE lun) {
ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_INITIALIZE;

g_slots[lun]->executeDiskDriveOperation(&params);

return (DSTATUS)params.result;
return (DSTATUS)g_slots[lun]->diskDriveInitialize();
}

DSTATUS DiskDriver_status(BYTE lun) {
ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_STATUS;

g_slots[lun]->executeDiskDriveOperation(&params);

return (DSTATUS)params.result;
return (DSTATUS)g_slots[lun]->diskDriveStatus();
}

DRESULT DiskDriver_read(BYTE lun, BYTE* buff, DWORD sector, UINT count) {
ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_READ;

for (UINT i = 0; i < count; i++) {
params.buff = buff + i * 512;
params.sector = sector + i;

g_slots[lun]->executeDiskDriveOperation(&params);

if (params.result != RES_OK) {
return (DRESULT)params.result;
auto result = (DRESULT)g_slots[lun]->diskDriveRead(buff + i * 512, sector + i);
if (result != RES_OK) {
return result;
}
}

return RES_OK;
}

DRESULT DiskDriver_write(BYTE lun, const BYTE* buff, DWORD sector, UINT count) {
ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_WRITE;

for (UINT i = 0; i < count; i++) {
params.buff = (BYTE *)buff + i * 512;
params.sector = sector + i;

g_slots[lun]->executeDiskDriveOperation(&params);

if (params.result != RES_OK) {
return (DRESULT)params.result;
auto result = (DRESULT)g_slots[lun]->diskDriveWrite((BYTE *)buff + i * 512, sector + i);
if (result != RES_OK) {
return result;
}
}

return RES_OK;
}

DRESULT DiskDriver_ioctl(BYTE lun, BYTE cmd, void *buff) {
ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_IOCTL;

params.cmd = cmd;
params.buff = (BYTE *)buff;

g_slots[lun]->executeDiskDriveOperation(&params);

return (DRESULT)params.result;
return (DRESULT)g_slots[lun]->diskDriveIoctl(cmd, (BYTE *)buff);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -277,27 +239,15 @@ static int8_t UsbStorageFS_Init(uint8_t lun) {
static int8_t UsbStorageFS_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size) {
int slotIndex = g_selectedMassStorageDevice - 1;

ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_IOCTL;

// get block_num
params.cmd = GET_SECTOR_COUNT;
params.buff = (uint8_t *)block_num;

g_slots[slotIndex]->executeDiskDriveOperation(&params);

if ((DRESULT)params.result != RES_OK) {
auto result = DiskDriver_ioctl(slotIndex, GET_SECTOR_COUNT, block_num);
if (result != RES_OK) {
return -1;
}

// get block_size
params.cmd = GET_SECTOR_SIZE;
params.buff = (uint8_t *)block_size;

g_slots[slotIndex]->executeDiskDriveOperation(&params);

if ((DRESULT)params.result != RES_OK) {
result = DiskDriver_ioctl(slotIndex, GET_SECTOR_SIZE, block_size);
if (result != RES_OK) {
return -1;
}

Expand All @@ -306,56 +256,23 @@ static int8_t UsbStorageFS_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_

static int8_t UsbStorageFS_IsReady(uint8_t lun) {
int slotIndex = g_selectedMassStorageDevice - 1;

ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_STATUS;

g_slots[slotIndex]->executeDiskDriveOperation(&params);

return (DSTATUS)params.result & STA_NOINIT ? -1 : USBD_OK;
return DiskDriver_status(slotIndex) & STA_NOINIT ? -1 : USBD_OK;
}

static int8_t UsbStorageFS_IsWriteProtected(uint8_t lun) {
return USBD_OK;
}

static int8_t UsbStorageFS_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
if (blk_len > 1) {
return -1;
}

int slotIndex = g_selectedMassStorageDevice - 1;

ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_READ;

params.buff = buf;
params.sector = blk_addr;

g_slots[slotIndex]->executeDiskDriveOperation(&params);

return (DRESULT)params.result == RES_OK ? USBD_OK : -1;
auto result = DiskDriver_read(slotIndex, buf, blk_addr, blk_len);
return result == RES_OK ? USBD_OK : -1;
}

static int8_t UsbStorageFS_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
if (blk_len > 1) {
return -1;
}

int slotIndex = g_selectedMassStorageDevice - 1;

ExecuteDiskDriveOperationParams params;

params.operation = DISK_DRIVER_OPERATION_WRITE;

params.buff = buf;
params.sector = blk_addr;

g_slots[slotIndex]->executeDiskDriveOperation(&params);

return (DRESULT)params.result == RES_OK ? USBD_OK : -1;
auto result = DiskDriver_write(slotIndex, buf, blk_addr, blk_len);
return result == RES_OK ? USBD_OK : -1;
}

static int8_t UsbStorageFS_GetMaxLun() {
Expand Down
Loading

0 comments on commit 1b64653

Please sign in to comment.