Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of d7a_1x by
Diff: src/d7a_fs.cpp
- Revision:
- 77:8c792719a1fc
- Parent:
- 76:fda2e34ff19d
- Child:
- 78:f1c0affd99e7
--- a/src/d7a_fs.cpp Tue Dec 20 09:30:14 2016 +0000
+++ b/src/d7a_fs.cpp Wed Dec 21 10:47:29 2016 +0000
@@ -35,18 +35,10 @@
void* data;
} d7a_fs_com_t;
-typedef struct {
- Thread* thread;
- Queue<void, 8> fs_done;
- WriteFileFunction write_file;
- ReadFileFunction read_file;
- Queue<d7a_com_rx_msg_t, 16> pkt_queue;
- uint8_t hdr_map[FS_MAX_FILE_QTY];
- uint8_t nb_files;
- d7a_fs_com_t com[FS_MAX_CONCURRENCY];
-} d7a_fs_ctx_t;
-
-d7a_fs_ctx_t g_fs_ctx;
+static Thread g_fs_thread(osPriorityHigh, DEFAULT_STACK_SIZE, NULL);
+static WriteFileFunction g_fs_write_file;
+static ReadFileFunction g_fs_read_file;
+static Queue<d7a_com_rx_msg_t, 8> g_fs_pkt_queue;
void d7a_fs_thread();
@@ -54,11 +46,10 @@
{
FPRINT("\r\n");
- g_fs_ctx.write_file = wf;
- g_fs_ctx.read_file = rf;
- g_fs_ctx.thread = new Thread(osPriorityHigh, DEFAULT_STACK_SIZE*2);
+ g_fs_write_file = wf;
+ g_fs_read_file = rf;
- osStatus err = g_fs_ctx.thread->start(d7a_fs_thread);
+ osStatus err = g_fs_thread.start(d7a_fs_thread);
ASSERT(err == osOK, "Failed to start d7a_fs_thread (err: %d)\r\n", err);
return D7A_ERR_NONE;
@@ -68,7 +59,7 @@
{
FPRINT("\r\n");
- g_fs_ctx.thread->terminate();
+ g_fs_thread.terminate();
return D7A_ERR_NONE;
}
@@ -87,13 +78,13 @@
void d7a_fs_new_pkt(d7a_com_rx_msg_t* pkt)
{
FPRINT("\r\n");
- ASSERT(g_fs_ctx.pkt_queue.put(pkt) == osOK, "FS queue full!\r\n");
+ ASSERT(g_fs_pkt_queue.put(pkt) == osOK, "FS queue full!\r\n");
}
d7a_com_rx_msg_t* d7a_fs_wait_pkt( uint32_t millisec )
{
FPRINT("(millisec:%d)\r\n", millisec);
- osEvent evt = g_fs_ctx.pkt_queue.get(millisec);
+ osEvent evt = g_fs_pkt_queue.get(millisec);
return (evt.status == osEventMessage)? (d7a_com_rx_msg_t*)evt.value.p : NULL;
}
@@ -169,8 +160,8 @@
else if (req->cmd == FS_OP_RD)
{
d7a_fs_com_resp_t* b = (d7a_fs_com_resp_t*)MALLOC(OP_SIZE_RETDATA + req->length);
- ASSERT(g_fs_ctx.read_file != NULL, "FS Read callback not implemented!\r\n");
- uint32_t len = g_fs_ctx.read_file(req->fid, req->offset, req->length, &b->data[0]);
+ ASSERT(g_fs_read_file != NULL, "FS Read callback not implemented!\r\n");
+ uint32_t len = g_fs_read_file(req->fid, req->offset, req->length, &b->data[0]);
b->id = req->id;
b->cmd = FS_OP_RETDATA;
@@ -191,14 +182,14 @@
}
else if (req->cmd == FS_OP_WR)
{
- ASSERT(g_fs_ctx.write_file != NULL, "FS Write callback not implemented!\r\n");
- buf.length = g_fs_ctx.write_file(req->fid, req->offset, req->length, &pkt->buffer[OP_SIZE_WR]);
+ ASSERT(g_fs_write_file != NULL, "FS Write callback not implemented!\r\n");
+ buf.length = g_fs_write_file(req->fid, req->offset, req->length, &pkt->buffer[OP_SIZE_WR]);
d7a_fs_msg((uint8_t*)&buf, OP_SIZE_RETSTAT, KAL_COM_FLOW_FS_RESP);
}
else if (req->cmd == FS_OP_TOUCH)
{
DPRINT("PS Touch f:%d o:%d s:%d\r\n", req->fid, req->offset, req->length);
- //buf.length = g_fs_ctx.callback->touch_file(req->fid, req->offset, req->length);
+ //buf.length = g_fs_callback->touch_file(req->fid, req->offset, req->length);
d7a_fs_msg((uint8_t*)&buf, OP_SIZE_RETSTAT, KAL_COM_FLOW_FS_RESP);
}
else
