Skip to content

Commit f44b3ab

Browse files
committed
Merge pull request #2 from mbedmicro/master
Update 2
2 parents e4419e7 + 4e54e07 commit f44b3ab

File tree

193 files changed

+385
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+385
-308
lines changed

libraries/USBDevice/USBMSD/USBMSD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void USBMSD::memoryWrite (uint8_t * buf, uint16_t size) {
232232
// if the array is filled, write it in memory
233233
if (!((addr + size)%BlockSize)) {
234234
if (!(disk_status() & WRITE_PROTECT)) {
235-
disk_write(page, addr/BlockSize);
235+
disk_write(page, addr/BlockSize, 1);
236236
}
237237
}
238238

@@ -257,7 +257,7 @@ void USBMSD::memoryVerify (uint8_t * buf, uint16_t size) {
257257

258258
// beginning of a new block -> load a whole block in RAM
259259
if (!(addr%BlockSize))
260-
disk_read(page, addr/BlockSize);
260+
disk_read(page, addr/BlockSize, 1);
261261

262262
// info are in RAM -> no need to re-read memory
263263
for (n = 0; n < size; n++) {
@@ -505,7 +505,7 @@ void USBMSD::memoryRead (void) {
505505

506506
// we read an entire block
507507
if (!(addr%BlockSize))
508-
disk_read(page, addr/BlockSize);
508+
disk_read(page, addr/BlockSize, 1);
509509

510510
// write data which are in RAM
511511
writeNB(EPBULK_IN, &page[addr%BlockSize], n, MAX_PACKET_SIZE_EPBULK);

libraries/USBDevice/USBMSD/USBMSD.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,24 @@ class USBMSD: public USBDevice {
8888
protected:
8989

9090
/*
91-
* read a block on a storage chip
91+
* read one or more blocks on a storage chip
9292
*
9393
* @param data pointer where will be stored read data
94-
* @param block block number
94+
* @param block starting block number
95+
* @param count number of blocks to read
9596
* @returns 0 if successful
9697
*/
97-
virtual int disk_read(uint8_t * data, uint64_t block) = 0;
98+
virtual int disk_read(uint8_t* data, uint64_t block, uint8_t count) = 0;
9899

99100
/*
100-
* write a block on a storage chip
101+
* write one or more blocks on a storage chip
101102
*
102103
* @param data data to write
103-
* @param block block number
104+
* @param block starting block number
105+
* @param count number of blocks to write
104106
* @returns 0 if successful
105107
*/
106-
virtual int disk_write(const uint8_t * data, uint64_t block) = 0;
108+
virtual int disk_write(const uint8_t* data, uint64_t block, uint8_t count) = 0;
107109

108110
/*
109111
* Disk initilization

libraries/USBHost/USBHostMSD/USBHostMSD.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,24 +323,34 @@ int USBHostMSD::disk_initialize() {
323323
return readCapacity();
324324
}
325325

326-
int USBHostMSD::disk_write(const uint8_t *buffer, uint64_t block_number) {
327-
USB_DBG("FILESYSTEM: write block: %lld", block_number);
326+
int USBHostMSD::disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count) {
327+
USB_DBG("FILESYSTEM: write block: %lld, count: %d", block_number, count);
328328
if (!disk_init) {
329329
disk_initialize();
330330
}
331331
if (!disk_init)
332332
return -1;
333-
return dataTransfer((uint8_t *)buffer, block_number, 1, HOST_TO_DEVICE);
333+
for (uint64_t b = block_number; b < block_number + count; b++) {
334+
if (dataTransfer((uint8_t*)buffer, b, 1, HOST_TO_DEVICE))
335+
return -1;
336+
buffer += 512;
337+
}
338+
return 0;
334339
}
335340

336-
int USBHostMSD::disk_read(uint8_t * buffer, uint64_t block_number) {
337-
USB_DBG("FILESYSTEM: read block %lld", block_number);
341+
int USBHostMSD::disk_read(uint8_t* buffer, uint64_t block_number, uint8_t count) {
342+
USB_DBG("FILESYSTEM: read block: %lld, count: %d", block_number, count);
338343
if (!disk_init) {
339344
disk_initialize();
340345
}
341346
if (!disk_init)
342347
return -1;
343-
return dataTransfer((uint8_t *)buffer, block_number, 1, DEVICE_TO_HOST);
348+
for (uint64_t b = block_number; b < block_number + count; b++) {
349+
if (dataTransfer((uint8_t*)buffer, b, 1, DEVICE_TO_HOST))
350+
return -1;
351+
buffer += 512;
352+
}
353+
return 0;
344354
}
345355

346356
uint64_t USBHostMSD::disk_sectors() {

libraries/USBHost/USBHostMSD/USBHostMSD.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class USBHostMSD : public IUSBEnumerator, public FATFileSystem {
5959
// From FATFileSystem
6060
virtual int disk_initialize();
6161
virtual int disk_status() {return 0;};
62-
virtual int disk_read(uint8_t * buffer, uint64_t sector);
63-
virtual int disk_write(const uint8_t * buffer, uint64_t sector);
62+
virtual int disk_read(uint8_t* buffer, uint64_t sector, uint8_t count);
63+
virtual int disk_write(const uint8_t* buffer, uint64_t sector, uint8_t count);
6464
virtual int disk_sync() {return 0;};
6565
virtual uint64_t disk_sectors();
6666

libraries/fs/fat/ChaN/diskio.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,10 @@ DRESULT disk_read (
3636
)
3737
{
3838
debug_if(FFS_DBG, "disk_read(sector %d, count %d) on drv [%d]\n", sector, count, drv);
39-
for(DWORD s=sector; s<sector+count; s++) {
40-
debug_if(FFS_DBG, " disk_read(sector %d)\n", s);
41-
int res = FATFileSystem::_ffs[drv]->disk_read((uint8_t*)buff, s);
42-
if(res) {
43-
return RES_PARERR;
44-
}
45-
buff += 512;
46-
}
47-
return RES_OK;
39+
if (FATFileSystem::_ffs[drv]->disk_read((uint8_t*)buff, sector, count))
40+
return RES_PARERR;
41+
else
42+
return RES_OK;
4843
}
4944

5045
#if _READONLY == 0
@@ -56,15 +51,10 @@ DRESULT disk_write (
5651
)
5752
{
5853
debug_if(FFS_DBG, "disk_write(sector %d, count %d) on drv [%d]\n", sector, count, drv);
59-
for(DWORD s = sector; s < sector + count; s++) {
60-
debug_if(FFS_DBG, " disk_write(sector %d)\n", s);
61-
int res = FATFileSystem::_ffs[drv]->disk_write((uint8_t*)buff, s);
62-
if(res) {
63-
return RES_PARERR;
64-
}
65-
buff += 512;
66-
}
67-
return RES_OK;
54+
if (FATFileSystem::_ffs[drv]->disk_write((uint8_t*)buff, sector, count))
55+
return RES_PARERR;
56+
else
57+
return RES_OK;
6858
}
6959
#endif /* _READONLY */
7060

libraries/fs/fat/FATFileSystem.h

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
using namespace mbed;
3131

32+
/**
33+
* FATFileSystem based on ChaN's Fat Filesystem library v0.8
34+
*/
3235
class FATFileSystem : public FileSystemLike {
3336
public:
3437

@@ -39,19 +42,50 @@ class FATFileSystem : public FileSystemLike {
3942
FATFS _fs; // Work area (file system object) for logical drive
4043
int _fsid;
4144

45+
/**
46+
* Opens a file on the filesystem
47+
*/
4248
virtual FileHandle *open(const char* name, int flags);
49+
50+
/**
51+
* Removes a file path
52+
*/
4353
virtual int remove(const char *filename);
54+
55+
/**
56+
* Renames a file
57+
*/
4458
virtual int rename(const char *oldname, const char *newname);
59+
60+
/**
61+
* Formats a logical drive, FDISK artitioning rule, 512 bytes per cluster
62+
*/
4563
virtual int format();
64+
65+
/**
66+
* Opens a directory on the filesystem
67+
*/
4668
virtual DirHandle *opendir(const char *name);
69+
70+
/**
71+
* Creates a directory path
72+
*/
4773
virtual int mkdir(const char *name, mode_t mode);
74+
75+
/**
76+
* Mounts the filesystem
77+
*/
4878
virtual int mount();
79+
80+
/**
81+
* Unmounts the filesystem
82+
*/
4983
virtual int unmount();
5084

5185
virtual int disk_initialize() { return 0; }
5286
virtual int disk_status() { return 0; }
53-
virtual int disk_read(uint8_t * buffer, uint64_t sector) = 0;
54-
virtual int disk_write(const uint8_t * buffer, uint64_t sector) = 0;
87+
virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count) = 0;
88+
virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count) = 0;
5589
virtual int disk_sync() { return 0; }
5690
virtual uint64_t disk_sectors() = 0;
5791

libraries/fs/sd/SDFileSystem.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,33 +223,41 @@ int SDFileSystem::disk_initialize() {
223223
return 0;
224224
}
225225

226-
int SDFileSystem::disk_write(const uint8_t *buffer, uint64_t block_number) {
226+
int SDFileSystem::disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count) {
227227
if (!_is_initialized) {
228228
return -1;
229229
}
230-
231-
// set write address for single block (CMD24)
232-
if (_cmd(24, block_number * cdv) != 0) {
233-
return 1;
230+
231+
for (uint64_t b = block_number; b < block_number + count; b++) {
232+
// set write address for single block (CMD24)
233+
if (_cmd(24, b * cdv) != 0) {
234+
return 1;
235+
}
236+
237+
// send the data block
238+
_write(buffer, 512);
239+
buffer += 512;
234240
}
235-
236-
// send the data block
237-
_write(buffer, 512);
241+
238242
return 0;
239243
}
240244

241-
int SDFileSystem::disk_read(uint8_t *buffer, uint64_t block_number) {
245+
int SDFileSystem::disk_read(uint8_t* buffer, uint64_t block_number, uint8_t count) {
242246
if (!_is_initialized) {
243247
return -1;
244248
}
245-
246-
// set read address for single block (CMD17)
247-
if (_cmd(17, block_number * cdv) != 0) {
248-
return 1;
249+
250+
for (uint64_t b = block_number; b < block_number + count; b++) {
251+
// set read address for single block (CMD17)
252+
if (_cmd(17, b * cdv) != 0) {
253+
return 1;
254+
}
255+
256+
// receive the data
257+
_read(buffer, 512);
258+
buffer += 512;
249259
}
250260

251-
// receive the data
252-
_read(buffer, 512);
253261
return 0;
254262
}
255263

libraries/fs/sd/SDFileSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class SDFileSystem : public FATFileSystem {
5454
SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
5555
virtual int disk_initialize();
5656
virtual int disk_status();
57-
virtual int disk_read(uint8_t * buffer, uint64_t block_number);
58-
virtual int disk_write(const uint8_t * buffer, uint64_t block_number);
57+
virtual int disk_read(uint8_t* buffer, uint64_t block_number, uint8_t count);
58+
virtual int disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count);
5959
virtual int disk_sync();
6060
virtual uint64_t disk_sectors();
6161

libraries/mbed/api/mbed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef MBED_H
1717
#define MBED_H
1818

19-
#define MBED_LIBRARY_VERSION 86
19+
#define MBED_LIBRARY_VERSION 88
2020

2121
#include "platform.h"
2222

@@ -25,7 +25,7 @@
2525
#include <time.h>
2626

2727
// mbed Debug libraries
28-
#include "error.h"
28+
#include "mbed_error.h"
2929
#include "mbed_interface.h"
3030

3131
// mbed Peripheral components
File renamed without changes.

libraries/mbed/common/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <stdarg.h>
1818
#include "device.h"
1919
#include "toolchain.h"
20-
#include "error.h"
20+
#include "mbed_error.h"
2121
#if DEVICE_STDIO_MESSAGES
2222
#include <stdio.h>
2323
#endif

libraries/mbed/common/mbed_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "gpio_api.h"
2020
#include "wait_api.h"
2121
#include "semihost_api.h"
22-
#include "error.h"
22+
#include "mbed_error.h"
2323
#include "toolchain.h"
2424

2525
#if DEVICE_SEMIHOST

libraries/mbed/common/pinmap_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
#include "pinmap.h"
17-
#include "error.h"
17+
#include "mbed_error.h"
1818

1919
void pinmap_pinout(PinName pin, const PinMap *map) {
2020
if (pin == NC)

libraries/mbed/common/retarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ extern "C" int mkdir(const char *path, mode_t mode) {
392392

393393
#if defined(TOOLCHAIN_GCC)
394394
/* prevents the exception handling name demangling code getting pulled in */
395-
#include "error.h"
395+
#include "mbed_error.h"
396396
namespace __gnu_cxx {
397397
void __verbose_terminate_handler() {
398398
error("Exception");

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/TOOLCHAIN_ARM_MICRO/startup_stm32f030.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ __initial_sp EQU 0x20002000 ; Top of RAM (8 KB for STM32F030R8)
4646
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
4747
; </h>
4848

49-
Heap_Size EQU 0x00000000
49+
Heap_Size EQU 0x00000400
5050

5151
AREA HEAP, NOINIT, READWRITE, ALIGN=3
5252
EXPORT __heap_base

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F072RB/TOOLCHAIN_ARM_MICRO/startup_stm32f072xb.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __initial_sp EQU 0x20004000 ; Top of RAM (16KB)
5858
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
5959
; </h>
6060

61-
Heap_Size EQU 0x00000200
61+
Heap_Size EQU 0x00000400
6262

6363
AREA HEAP, NOINIT, READWRITE, ALIGN=3
6464
EXPORT __heap_base

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/TOOLCHAIN_ARM_MICRO/startup_stm32f10x_md.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ __initial_sp EQU 0x20005000 ; Top of RAM
4646
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
4747
; </h>
4848

49-
Heap_Size EQU 0x00000000
49+
Heap_Size EQU 0x00000400
5050

5151
AREA HEAP, NOINIT, READWRITE, ALIGN=3
5252
EXPORT __heap_base

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/TOOLCHAIN_ARM_MICRO/startup_stm32f302x8.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ __initial_sp EQU 0x20004000 ; Top of RAM
4848
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
4949
; </h>
5050

51-
Heap_Size EQU 0x00000000
51+
Heap_Size EQU 0x00000400
5252

5353
AREA HEAP, NOINIT, READWRITE, ALIGN=3
5454
EXPORT __heap_base

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/TOOLCHAIN_ARM_MICRO/startup_stm32f334x8.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __initial_sp EQU 0x20003000 ; Top of RAM
5858
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
5959
; </h>
6060

61-
Heap_Size EQU 0x00000000
61+
Heap_Size EQU 0x00000400
6262

6363
AREA HEAP, NOINIT, READWRITE, ALIGN=3
6464
EXPORT __heap_base

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/TOOLCHAIN_ARM_MICRO/startup_stm32f411xe.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __initial_sp EQU 0x20020000 ; Top of RAM
5858
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
5959
; </h>
6060

61-
Heap_Size EQU 0x00000000
61+
Heap_Size EQU 0x00000400
6262

6363
AREA HEAP, NOINIT, READWRITE, ALIGN=3
6464
EXPORT __heap_base

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/TOOLCHAIN_ARM_MICRO/startup_stm32l053xx.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __initial_sp EQU 0x20002000 ; Top of RAM
5858
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
5959
; </h>
6060

61-
Heap_Size EQU 0x00000000
61+
Heap_Size EQU 0x00000400
6262

6363
AREA HEAP, NOINIT, READWRITE, ALIGN=3
6464
EXPORT __heap_base

0 commit comments

Comments
 (0)