MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface
Dependencies: USBDevice
Fork of HSP_Release by
This is an example program for the MAX32620HSP (MAXREFDES100 Health Sensor Platform). It demonstrates all the features of the platform and works with a companion graphical user interface (GUI) to help evaluate/configure/monitor the board. Go to the MAXREFDES100 product page and click on "design resources" to download the companion software. The GUI connects to the board through an RPC interface on a virtual serial port over the USB interface.
The RPC interface provides access to all the features of the board and is available to interface with other development environments such Matlab. This firmware provides realtime data streaming through the RPC interface over USB, and also provides the ability to log the data to flash for untethered battery operation. The data logging settings are configured through the GUI, and the GUI also provides the interface to download logged data.
Details on the RPC interface can be found here: HSP RPC Interface Documentation
Windows
With this program loaded, the MAX32620HSP will appear on your computer as a serial port. On Mac and Linux, this will happen by default. For Windows, you need to install a driver: HSP serial port windows driver
For more details about this platform and how to use it, see the MAXREFDES100 product page.
HSP/LoggingService/Logging_RPC.cpp@1:9490836294ea, 2017-04-21 (annotated)
- Committer:
- jbradshaw
- Date:
- Fri Apr 21 12:12:30 2017 -0500
- Revision:
- 1:9490836294ea
- Parent:
- 0:e4a10ed6eb92
- Child:
- 2:d483f896c7a9
Flash device is now fully utilized for datalog of sensor data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbradshaw | 0:e4a10ed6eb92 | 1 | /******************************************************************************* |
jbradshaw | 0:e4a10ed6eb92 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
jbradshaw | 0:e4a10ed6eb92 | 3 | * |
jbradshaw | 0:e4a10ed6eb92 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
jbradshaw | 0:e4a10ed6eb92 | 5 | * copy of this software and associated documentation files (the "Software"), |
jbradshaw | 0:e4a10ed6eb92 | 6 | * to deal in the Software without restriction, including without limitation |
jbradshaw | 0:e4a10ed6eb92 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
jbradshaw | 0:e4a10ed6eb92 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
jbradshaw | 0:e4a10ed6eb92 | 9 | * Software is furnished to do so, subject to the following conditions: |
jbradshaw | 0:e4a10ed6eb92 | 10 | * |
jbradshaw | 0:e4a10ed6eb92 | 11 | * The above copyright notice and this permission notice shall be included |
jbradshaw | 0:e4a10ed6eb92 | 12 | * in all copies or substantial portions of the Software. |
jbradshaw | 0:e4a10ed6eb92 | 13 | * |
jbradshaw | 0:e4a10ed6eb92 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
jbradshaw | 0:e4a10ed6eb92 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
jbradshaw | 0:e4a10ed6eb92 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
jbradshaw | 0:e4a10ed6eb92 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
jbradshaw | 0:e4a10ed6eb92 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
jbradshaw | 0:e4a10ed6eb92 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
jbradshaw | 0:e4a10ed6eb92 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
jbradshaw | 0:e4a10ed6eb92 | 21 | * |
jbradshaw | 0:e4a10ed6eb92 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
jbradshaw | 0:e4a10ed6eb92 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
jbradshaw | 0:e4a10ed6eb92 | 24 | * Products, Inc. Branding Policy. |
jbradshaw | 0:e4a10ed6eb92 | 25 | * |
jbradshaw | 0:e4a10ed6eb92 | 26 | * The mere transfer of this software does not imply any licenses |
jbradshaw | 0:e4a10ed6eb92 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
jbradshaw | 0:e4a10ed6eb92 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
jbradshaw | 0:e4a10ed6eb92 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
jbradshaw | 0:e4a10ed6eb92 | 30 | * ownership rights. |
jbradshaw | 0:e4a10ed6eb92 | 31 | ****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 32 | */ |
jbradshaw | 0:e4a10ed6eb92 | 33 | #include "StringHelper.h" |
jbradshaw | 0:e4a10ed6eb92 | 34 | #include <stdint.h> |
jbradshaw | 0:e4a10ed6eb92 | 35 | #include "Streaming.h" |
jbradshaw | 0:e4a10ed6eb92 | 36 | #include "StringInOut.h" |
jbradshaw | 0:e4a10ed6eb92 | 37 | #include "DataLoggingService.h" |
jbradshaw | 0:e4a10ed6eb92 | 38 | #include "Peripherals.h" |
jbradshaw | 0:e4a10ed6eb92 | 39 | #include "Logging.h" |
jbradshaw | 0:e4a10ed6eb92 | 40 | |
jbradshaw | 0:e4a10ed6eb92 | 41 | extern char loggingMissionCmds[4096]; |
jbradshaw | 0:e4a10ed6eb92 | 42 | uint32_t missionCmdIndex; |
jbradshaw | 0:e4a10ed6eb92 | 43 | |
jbradshaw | 0:e4a10ed6eb92 | 44 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 45 | int Logging_RPC_StartMissionDefine(char argStrs[32][32], |
jbradshaw | 0:e4a10ed6eb92 | 46 | char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 47 | uint32_t i; |
jbradshaw | 0:e4a10ed6eb92 | 48 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 49 | |
jbradshaw | 0:e4a10ed6eb92 | 50 | // reset the missionCmdIndex to the beginning of the cmd buffer |
jbradshaw | 0:e4a10ed6eb92 | 51 | missionCmdIndex = 0; |
jbradshaw | 0:e4a10ed6eb92 | 52 | // clear the mission command buffer, fill with zeros |
jbradshaw | 0:e4a10ed6eb92 | 53 | for (i = 0; i < sizeof(loggingMissionCmds); i++) { |
jbradshaw | 0:e4a10ed6eb92 | 54 | loggingMissionCmds[i] = 0; |
jbradshaw | 0:e4a10ed6eb92 | 55 | } |
jbradshaw | 0:e4a10ed6eb92 | 56 | |
jbradshaw | 0:e4a10ed6eb92 | 57 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 58 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 59 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 60 | } |
jbradshaw | 0:e4a10ed6eb92 | 61 | |
jbradshaw | 0:e4a10ed6eb92 | 62 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 63 | int Logging_RPC_AppendMissionCmd(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 64 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 65 | char *strPtr; |
jbradshaw | 0:e4a10ed6eb92 | 66 | uint32_t count = 0; |
jbradshaw | 0:e4a10ed6eb92 | 67 | uint8_t result = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 68 | // append the string to the mission cmd log |
jbradshaw | 0:e4a10ed6eb92 | 69 | strPtr = argStrs[0]; |
jbradshaw | 0:e4a10ed6eb92 | 70 | while (*strPtr != 0) { |
jbradshaw | 0:e4a10ed6eb92 | 71 | loggingMissionCmds[missionCmdIndex] = *strPtr; |
jbradshaw | 0:e4a10ed6eb92 | 72 | missionCmdIndex++; |
jbradshaw | 0:e4a10ed6eb92 | 73 | strPtr++; |
jbradshaw | 0:e4a10ed6eb92 | 74 | // do not overrun buffer |
jbradshaw | 0:e4a10ed6eb92 | 75 | if (missionCmdIndex > (sizeof(loggingMissionCmds) - 2)) { |
jbradshaw | 0:e4a10ed6eb92 | 76 | result = 0xFF; |
jbradshaw | 0:e4a10ed6eb92 | 77 | break; |
jbradshaw | 0:e4a10ed6eb92 | 78 | } |
jbradshaw | 0:e4a10ed6eb92 | 79 | count++; |
jbradshaw | 0:e4a10ed6eb92 | 80 | // do not read more than max count in incoming string |
jbradshaw | 0:e4a10ed6eb92 | 81 | if (count > (32 * 32)) { |
jbradshaw | 0:e4a10ed6eb92 | 82 | result = 0xFF; |
jbradshaw | 0:e4a10ed6eb92 | 83 | break; |
jbradshaw | 0:e4a10ed6eb92 | 84 | } |
jbradshaw | 0:e4a10ed6eb92 | 85 | } |
jbradshaw | 0:e4a10ed6eb92 | 86 | if (result != 0x80) { |
jbradshaw | 0:e4a10ed6eb92 | 87 | reply[0] = 0xFF; |
jbradshaw | 0:e4a10ed6eb92 | 88 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 89 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 90 | } |
jbradshaw | 0:e4a10ed6eb92 | 91 | // add cr/lf to the end of this cmd string |
jbradshaw | 0:e4a10ed6eb92 | 92 | loggingMissionCmds[missionCmdIndex++] = 13; |
jbradshaw | 0:e4a10ed6eb92 | 93 | loggingMissionCmds[missionCmdIndex++] = 10; |
jbradshaw | 0:e4a10ed6eb92 | 94 | |
jbradshaw | 0:e4a10ed6eb92 | 95 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 96 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 97 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 98 | } |
jbradshaw | 0:e4a10ed6eb92 | 99 | |
jbradshaw | 0:e4a10ed6eb92 | 100 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 101 | int Logging_RPC_EndMissionDefine(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 102 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 103 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 104 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 105 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 106 | } |
jbradshaw | 0:e4a10ed6eb92 | 107 | |
jbradshaw | 0:e4a10ed6eb92 | 108 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 109 | int Logging_RPC_WriteMission(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 110 | uint8_t page; |
jbradshaw | 0:e4a10ed6eb92 | 111 | char *ptr; |
jbradshaw | 0:e4a10ed6eb92 | 112 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 113 | |
jbradshaw | 0:e4a10ed6eb92 | 114 | Peripherals::s25FS512()->parameterSectorErase_Helper(0x0); |
jbradshaw | 0:e4a10ed6eb92 | 115 | ptr = loggingMissionCmds; |
jbradshaw | 0:e4a10ed6eb92 | 116 | for (page = 0; page < 16; page++) { |
jbradshaw | 0:e4a10ed6eb92 | 117 | Peripherals::s25FS512()->writePage_Helper(page, (uint8_t *)ptr, 0); |
jbradshaw | 0:e4a10ed6eb92 | 118 | ptr += 256; |
jbradshaw | 0:e4a10ed6eb92 | 119 | } |
jbradshaw | 0:e4a10ed6eb92 | 120 | |
jbradshaw | 0:e4a10ed6eb92 | 121 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 122 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 123 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 124 | } |
jbradshaw | 0:e4a10ed6eb92 | 125 | |
jbradshaw | 0:e4a10ed6eb92 | 126 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 127 | int Logging_RPC_ReadMission(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 128 | char *ptr; |
jbradshaw | 0:e4a10ed6eb92 | 129 | uint32_t i; |
jbradshaw | 0:e4a10ed6eb92 | 130 | // read sector 0 |
jbradshaw | 0:e4a10ed6eb92 | 131 | ptr = loggingMissionCmds; |
jbradshaw | 0:e4a10ed6eb92 | 132 | for (i = 0; i < 16; i++) { |
jbradshaw | 0:e4a10ed6eb92 | 133 | Peripherals::s25FS512()->readPages_Helper(i, i, (uint8_t *)ptr, 0); |
jbradshaw | 0:e4a10ed6eb92 | 134 | ptr += 256; |
jbradshaw | 0:e4a10ed6eb92 | 135 | } |
jbradshaw | 0:e4a10ed6eb92 | 136 | // strip header by shifting payload left |
jbradshaw | 0:e4a10ed6eb92 | 137 | ptr = loggingMissionCmds; |
jbradshaw | 0:e4a10ed6eb92 | 138 | for (i = 0; i < sizeof(loggingMissionCmds); i++) { |
jbradshaw | 0:e4a10ed6eb92 | 139 | if (*ptr == 13) { |
jbradshaw | 0:e4a10ed6eb92 | 140 | *ptr = ':'; |
jbradshaw | 0:e4a10ed6eb92 | 141 | } else if (*ptr == 10) { |
jbradshaw | 0:e4a10ed6eb92 | 142 | *ptr = ' '; |
jbradshaw | 0:e4a10ed6eb92 | 143 | } |
jbradshaw | 0:e4a10ed6eb92 | 144 | ptr++; |
jbradshaw | 0:e4a10ed6eb92 | 145 | } |
jbradshaw | 0:e4a10ed6eb92 | 146 | if (loggingMissionCmds[0] == 0xFF || loggingMissionCmds[0] == 0x0) { |
jbradshaw | 0:e4a10ed6eb92 | 147 | sprintf(loggingMissionCmds, "%s", "null "); |
jbradshaw | 0:e4a10ed6eb92 | 148 | } |
jbradshaw | 0:e4a10ed6eb92 | 149 | // send it out via uart |
jbradshaw | 0:e4a10ed6eb92 | 150 | putStr(loggingMissionCmds); |
jbradshaw | 0:e4a10ed6eb92 | 151 | replyStrs[0][0] = 0; |
jbradshaw | 0:e4a10ed6eb92 | 152 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 153 | } |
jbradshaw | 0:e4a10ed6eb92 | 154 | |
jbradshaw | 0:e4a10ed6eb92 | 155 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 156 | int Logging_RPC_EraseMission(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 157 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 158 | Peripherals::s25FS512()->parameterSectorErase_Helper(0x0); |
jbradshaw | 0:e4a10ed6eb92 | 159 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 160 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 161 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 162 | } |
jbradshaw | 0:e4a10ed6eb92 | 163 | |
jbradshaw | 0:e4a10ed6eb92 | 164 | #define SECTOR_SIZE_256K 0x10000 |
jbradshaw | 0:e4a10ed6eb92 | 165 | #define PAGE_INC_256K 0x400 |
jbradshaw | 0:e4a10ed6eb92 | 166 | #define SECTOR_SIZE_4K 0x1000 |
jbradshaw | 0:e4a10ed6eb92 | 167 | #define PAGE_INC_4K 0x10 |
jbradshaw | 0:e4a10ed6eb92 | 168 | #define TOTAL_SECTOR_NUMBER 263 |
jbradshaw | 0:e4a10ed6eb92 | 169 | |
jbradshaw | 0:e4a10ed6eb92 | 170 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 171 | int Logging_EraseWrittenSectors(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 172 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 173 | uint8_t data[512]; |
jbradshaw | 0:e4a10ed6eb92 | 174 | uint32_t address; |
jbradshaw | 0:e4a10ed6eb92 | 175 | uint32_t pageNumber; |
jbradshaw | 0:e4a10ed6eb92 | 176 | uint32_t pageEmpty; |
jbradshaw | 0:e4a10ed6eb92 | 177 | uint32_t currentSector; |
jbradshaw | 0:e4a10ed6eb92 | 178 | |
jbradshaw | 0:e4a10ed6eb92 | 179 | pageNumber = PAGE_INC_4K; |
jbradshaw | 0:e4a10ed6eb92 | 180 | address = SECTOR_SIZE_4K; |
jbradshaw | 0:e4a10ed6eb92 | 181 | currentSector = 0; |
jbradshaw | 0:e4a10ed6eb92 | 182 | printf("Logging_EraseWrittenSectors "); |
jbradshaw | 0:e4a10ed6eb92 | 183 | fflush(stdout); |
jbradshaw | 1:9490836294ea | 184 | printf("pageNumber %d 0x%X ", (unsigned int)pageNumber, (unsigned int)pageNumber); |
jbradshaw | 0:e4a10ed6eb92 | 185 | fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 186 | printf("SECTOR_SIZE_4K %d 0x%X ...", SECTOR_SIZE_4K, SECTOR_SIZE_4K); |
jbradshaw | 0:e4a10ed6eb92 | 187 | fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 188 | // always erase this sector... the first part is used for the mission resume |
jbradshaw | 0:e4a10ed6eb92 | 189 | // table |
jbradshaw | 0:e4a10ed6eb92 | 190 | Peripherals::s25FS512()->sectorErase_Helper(address); |
jbradshaw | 0:e4a10ed6eb92 | 191 | address += SECTOR_SIZE_4K; |
jbradshaw | 0:e4a10ed6eb92 | 192 | while (currentSector < TOTAL_SECTOR_NUMBER) { |
jbradshaw | 0:e4a10ed6eb92 | 193 | // sample the page |
jbradshaw | 0:e4a10ed6eb92 | 194 | pageNumber = address >> 8; |
jbradshaw | 0:e4a10ed6eb92 | 195 | Peripherals::s25FS512()->readPages_Helper(pageNumber, pageNumber, data, 0); |
jbradshaw | 0:e4a10ed6eb92 | 196 | pageEmpty = Peripherals::s25FS512()->isPageEmpty(data); |
jbradshaw | 0:e4a10ed6eb92 | 197 | if (pageEmpty == 0) { |
jbradshaw | 0:e4a10ed6eb92 | 198 | Peripherals::s25FS512()->sectorErase_Helper(address); |
jbradshaw | 0:e4a10ed6eb92 | 199 | } else { |
jbradshaw | 0:e4a10ed6eb92 | 200 | // stop processing... all of the sectors from here on out should be empty |
jbradshaw | 0:e4a10ed6eb92 | 201 | // printf("Logging_EraseWrittenSectors break "); fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 202 | // break; |
jbradshaw | 0:e4a10ed6eb92 | 203 | } |
jbradshaw | 0:e4a10ed6eb92 | 204 | currentSector++; |
jbradshaw | 0:e4a10ed6eb92 | 205 | if (currentSector < 8) { |
jbradshaw | 0:e4a10ed6eb92 | 206 | address += SECTOR_SIZE_4K; |
jbradshaw | 0:e4a10ed6eb92 | 207 | } |
jbradshaw | 0:e4a10ed6eb92 | 208 | if (currentSector == 8) { |
jbradshaw | 0:e4a10ed6eb92 | 209 | address = SECTOR_SIZE_256K; |
jbradshaw | 0:e4a10ed6eb92 | 210 | } |
jbradshaw | 0:e4a10ed6eb92 | 211 | if (currentSector > 8) { |
jbradshaw | 0:e4a10ed6eb92 | 212 | address += SECTOR_SIZE_256K; |
jbradshaw | 0:e4a10ed6eb92 | 213 | } |
jbradshaw | 0:e4a10ed6eb92 | 214 | } |
jbradshaw | 0:e4a10ed6eb92 | 215 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 216 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 217 | printf("Logging_EraseWrittenSectors done. \n"); |
jbradshaw | 0:e4a10ed6eb92 | 218 | fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 219 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 220 | } |
jbradshaw | 0:e4a10ed6eb92 | 221 | |
jbradshaw | 0:e4a10ed6eb92 | 222 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 223 | int Logging_Start(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 224 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 225 | Logging_SetStart(true); |
jbradshaw | 0:e4a10ed6eb92 | 226 | reply[0] = 0x80; // indicate success |
jbradshaw | 0:e4a10ed6eb92 | 227 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 228 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 229 | } |
jbradshaw | 0:e4a10ed6eb92 | 230 | |
jbradshaw | 0:e4a10ed6eb92 | 231 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 232 | int Logging_GetLastWrittenPage(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 233 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 234 | |
jbradshaw | 0:e4a10ed6eb92 | 235 | uint32_t page; |
jbradshaw | 0:e4a10ed6eb92 | 236 | uint32_t lastPage; |
jbradshaw | 0:e4a10ed6eb92 | 237 | uint32_t pageEmpty; |
jbradshaw | 0:e4a10ed6eb92 | 238 | uint8_t data[512]; |
jbradshaw | 0:e4a10ed6eb92 | 239 | |
jbradshaw | 0:e4a10ed6eb92 | 240 | printf("Logging_GetLastWrittenPage "); |
jbradshaw | 0:e4a10ed6eb92 | 241 | fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 242 | lastPage = Logging_GetLoggingEndPage(); |
jbradshaw | 0:e4a10ed6eb92 | 243 | for (page = 2; page <= lastPage; page++) { |
jbradshaw | 0:e4a10ed6eb92 | 244 | // Peripherals::serial()->printf("checking page %d ",page); fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 245 | // sample the page |
jbradshaw | 0:e4a10ed6eb92 | 246 | Peripherals::s25FS512()->readPages_Helper(page, page, data, 0); |
jbradshaw | 0:e4a10ed6eb92 | 247 | pageEmpty = Peripherals::s25FS512()->isPageEmpty(data); |
jbradshaw | 0:e4a10ed6eb92 | 248 | if (pageEmpty != 0) { |
jbradshaw | 0:e4a10ed6eb92 | 249 | break; |
jbradshaw | 0:e4a10ed6eb92 | 250 | } |
jbradshaw | 0:e4a10ed6eb92 | 251 | } |
jbradshaw | 0:e4a10ed6eb92 | 252 | if (page > lastPage) |
jbradshaw | 0:e4a10ed6eb92 | 253 | page = lastPage; |
jbradshaw | 1:9490836294ea | 254 | printf("last page %d, 0x%X ", (unsigned int)page, (unsigned int)page); |
jbradshaw | 0:e4a10ed6eb92 | 255 | fflush(stdout); |
jbradshaw | 0:e4a10ed6eb92 | 256 | reply[0] = page; |
jbradshaw | 0:e4a10ed6eb92 | 257 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 258 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 259 | } |
jbradshaw | 0:e4a10ed6eb92 | 260 | |
jbradshaw | 0:e4a10ed6eb92 | 261 | extern int highDataRate; |
jbradshaw | 0:e4a10ed6eb92 | 262 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 263 | int Logging_StartLoggingUsb(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 264 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 265 | // highDataRate = 0; |
jbradshaw | 0:e4a10ed6eb92 | 266 | LoggingService_StartLoggingUsb(); |
jbradshaw | 0:e4a10ed6eb92 | 267 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 268 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 269 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 270 | } |
jbradshaw | 0:e4a10ed6eb92 | 271 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 272 | int Logging_StartLoggingFlash(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 273 | uint32_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 274 | // highDataRate = 0; |
jbradshaw | 0:e4a10ed6eb92 | 275 | LoggingService_StartLoggingFlash(); |
jbradshaw | 0:e4a10ed6eb92 | 276 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 277 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 278 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 279 | } |