From 19eb8652e73fba1a2af9b54bfc11f2fab96e5a08 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 20 Jun 2018 17:03:38 +0700 Subject: [PATCH] function rename --- src/main.c | 6 +++--- src/usb/msc_uf2.c | 25 ++++++++++++++----------- src/usb/msc_uf2.h | 6 +++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main.c b/src/main.c index 56f0299..7c35838 100644 --- a/src/main.c +++ b/src/main.c @@ -337,7 +337,7 @@ int main(void) (void) bootloader_init(); // Init msc flash, must be after bootloader_init(), before SD init - msc_flash_init(); + msc_uf2_init(); if (bootloader_dfu_sd_in_progress()) { @@ -541,13 +541,13 @@ void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) void tud_mount_cb(uint8_t rhport) { (void) rhport; - msc_flash_mount(); + msc_uf2_mount(); } void tud_umount_cb(uint8_t rhport) { (void) rhport; - msc_flash_umount(); + msc_uf2_umount(); } uint32_t tusb_hal_millis(void) diff --git a/src/usb/msc_uf2.c b/src/usb/msc_uf2.c index 1e7d4fd..fd89bdb 100644 --- a/src/usb/msc_uf2.c +++ b/src/usb/msc_uf2.c @@ -267,13 +267,13 @@ static void fat_pstorage_cb(pstorage_handle_t * p_handle, uint8_t op_code, uint3 /*------------------------------------------------------------------*/ /* API *------------------------------------------------------------------*/ -void msc_flash_init(void) +void msc_uf2_init(void) { pstorage_module_param_t fat_psp = { .cb = fat_pstorage_cb}; pstorage_register(&fat_psp, &_fat_psh); } -void msc_flash_mount(void) +void msc_uf2_mount(void) { _wr10_state = WRITE10_IDLE; @@ -281,7 +281,7 @@ void msc_flash_mount(void) fat12_mkfs(); } -void msc_flash_umount(void) +void msc_uf2_umount(void) { } @@ -389,17 +389,20 @@ int32_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t o { memcpy(buffer, ((uint8_t*) &_disk_ram) + lba*MSC_FLASH_BLOCK_SIZE, bufsize); } - else if ( lba < SECTOR_DATA + arrcount_(info)) - { - // INFO_UF2.TXT & INDEX.HTM contents - strcpy(buffer, info[lba-SECTOR_DATA].content); - -// uint32_t addr = lba2addr(lba) + offset; -// memcpy(buffer, (uint8_t*) addr, bufsize); - } else { + lba -= SECTOR_DATA; + if ( lba < arrcount_(info) - 1 ) + { + strcpy(buffer, info[lba].content); // INFO_UF2.TXT & INDEX.HTM contents + } + else + { + lba -= (arrcount_(info) - 1); + + + } } return bufsize; diff --git a/src/usb/msc_uf2.h b/src/usb/msc_uf2.h index 9f0a20f..c325d21 100644 --- a/src/usb/msc_uf2.h +++ b/src/usb/msc_uf2.h @@ -63,9 +63,9 @@ VERIFY_STATIC( MSC_FLASH_ADDR_START+MSC_FLASH_SIZE == BOOTLOADER_REGION_START-DF /* Note ATTR_WEAK is used when CFG_TUD_MSC = 0 *------------------------------------------------------------------*/ -ATTR_WEAK void msc_flash_init(void); -ATTR_WEAK void msc_flash_mount(void); -ATTR_WEAK void msc_flash_umount(void); +ATTR_WEAK void msc_uf2_init(void); +ATTR_WEAK void msc_uf2_mount(void); +ATTR_WEAK void msc_uf2_umount(void); #ifdef __cplusplus