fixed really nasty write bug
This commit is contained in:
parent
84433bb1d6
commit
c966b71e5b
|
@ -117,7 +117,8 @@ DRESULT dataflash_random_write(const BYTE *buff, DWORD offset, DWORD length) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
wait_for_ready();
|
wait_for_ready();
|
||||||
DWORD pageaddr = ((offset/256) << 9) | (offset%256);
|
DWORD pageaddr = (offset/256) << 9;
|
||||||
|
DWORD buffaddr = (offset%256);
|
||||||
DWORD remaining = 256 - offset%256;
|
DWORD remaining = 256 - offset%256;
|
||||||
if (remaining > length) {
|
if (remaining > length) {
|
||||||
remaining = length;
|
remaining = length;
|
||||||
|
@ -137,9 +138,9 @@ DRESULT dataflash_random_write(const BYTE *buff, DWORD offset, DWORD length) {
|
||||||
// write bytes into the dataflash buffer
|
// write bytes into the dataflash buffer
|
||||||
CS_LOW();
|
CS_LOW();
|
||||||
xmit_spi(OP_BUFFER1WRITE);
|
xmit_spi(OP_BUFFER1WRITE);
|
||||||
xmit_spi(0x00);
|
xmit_spi((BYTE)(buffaddr >> 16));
|
||||||
xmit_spi(0x00);
|
xmit_spi((BYTE)(buffaddr >> 8));
|
||||||
xmit_spi(0x00);
|
xmit_spi((BYTE)buffaddr);
|
||||||
do {
|
do {
|
||||||
xmit_spi(*buff++);
|
xmit_spi(*buff++);
|
||||||
} while (--remaining);
|
} while (--remaining);
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "filesystem/ff.h"
|
#include "filesystem/ff.h"
|
||||||
#include "filesystem/diskio.h"
|
#include "filesystem/diskio.h"
|
||||||
|
|
||||||
|
#include "usb/usbmsc.h"
|
||||||
|
|
||||||
#include "core/ssp/ssp.h"
|
#include "core/ssp/ssp.h"
|
||||||
|
|
||||||
void incBacklight(void);
|
void incBacklight(void);
|
||||||
|
@ -44,6 +46,7 @@ const struct MENU_DEF menu_list = {"FS List", &fs_list};
|
||||||
const struct MENU_DEF menu_create = {"FS Create", &fs_create};
|
const struct MENU_DEF menu_create = {"FS Create", &fs_create};
|
||||||
const struct MENU_DEF menu_format = {"FS format", &fs_format};
|
const struct MENU_DEF menu_format = {"FS format", &fs_format};
|
||||||
const struct MENU_DEF menu_read = {"FS read", &fs_read};
|
const struct MENU_DEF menu_read = {"FS read", &fs_read};
|
||||||
|
const struct MENU_DEF menu_usb = {"USB mount", &usbMSCInit};
|
||||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||||
|
|
||||||
static menuentry menu[] = {
|
static menuentry menu[] = {
|
||||||
|
@ -55,6 +58,8 @@ static menuentry menu[] = {
|
||||||
&menu_nop,
|
&menu_nop,
|
||||||
&menu_format,
|
&menu_format,
|
||||||
&menu_nop,
|
&menu_nop,
|
||||||
|
&menu_usb,
|
||||||
|
&menu_nop,
|
||||||
&menu_ISP,
|
&menu_ISP,
|
||||||
&menu_incBL,
|
&menu_incBL,
|
||||||
&menu_decBL,
|
&menu_decBL,
|
||||||
|
|
|
@ -14,11 +14,11 @@ MSC_DEVICE_INFO MscDevInfo;
|
||||||
ROM ** rom = (ROM **)0x1fff1ff8;
|
ROM ** rom = (ROM **)0x1fff1ff8;
|
||||||
|
|
||||||
void usbMSCWrite(uint32_t offset, uint8_t src[], uint32_t length) {
|
void usbMSCWrite(uint32_t offset, uint8_t src[], uint32_t length) {
|
||||||
dataflash_random_write(src, offset+1, length);
|
dataflash_random_write(src, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbMSCRead(uint32_t offset, uint8_t dst[], uint32_t length) {
|
void usbMSCRead(uint32_t offset, uint8_t dst[], uint32_t length) {
|
||||||
dataflash_random_read(dst, offset+1, length);
|
dataflash_random_read(dst, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbMSCInit(void) {
|
void usbMSCInit(void) {
|
||||||
|
|
Loading…
Reference in New Issue