Loading...
Searching...
No Matches
mem.c
1/***********************************************************************************
2 * @file launch.c *
3 * @author Matt Ricci *
4 * @addtogroup Shell *
5 * *
6 * @{ *
7 ***********************************************************************************/
8
9#include "mem.h"
10
11static void Flash_exec(Shell *, uint8_t *);
12
13static ShellProgramHandle_t registerShellProgram() {
14 return (ShellProgramHandle_t){
15 .name = "flash",
16 .exec = Flash_exec
17 };
18}
19
20__attribute__((section(".shell_flash"), unused))
21static ShellProgramHandle_t (*registerShellProgram_ptr)() = registerShellProgram;
22
23/* =============================================================================== */
34static void Flash_exec(Shell *shell, uint8_t *flags) {
35 Flash *flash = DeviceHandle_getHandle("Flash").device;
36 UART *usb = DeviceHandle_getHandle("USB").device;
37 // flash erase
38 if (!strcmp(flags, CMD_FLASH_ERASE)) {
39 usb->print(usb, "Clearing flash... ");
40 flash->erase(flash);
41 usb->print(usb, "Done.\n\r");
42 }
43 // flash read all
44 else if (!strcmp(flags, CMD_FLASH_READ_ALL)) {
45 vTaskSuspendAll();
46 volatile uint8_t pageData[256];
47 for (long i = 0; i < flash->pageCount; i++) {
48 flash->readPage(flash, i * 0x100, pageData);
49 for (int j = 0; j < flash->pageSize; j++)
50 usb->send(usb, pageData[j]);
51 }
52 xTaskResumeAll();
53 }
54}
55
Struct definition for UART interface.
Definition uart.h:53
Definition shell.h:34
Definition flash.h:30
DeviceType device
Enum specifier for device type.
Definition spi.h:50