Host software for the MAX30001 ECG, PACE, biopotential, bioimpedance, R-to-R peak sensor. Hosted on the MAX32630FTHR.

Dependencies:   SDFileSystem USBDevice max32630fthr

Fork of MAX30001 SYS EvKit by Emre Eken

MAX30001-MAX32630FTHR ECG Evaluation System

The MAX30001 EVKIT SYS-MBED Evaluation System (EV System) is used to evaluates the MAX30001 sensor, which is an ECG (electrocardiogram), biopotential and bioimpedance analog front end solution for wearable applications. The full evaluation system consists of the MAX32630FTHR board, MAX30001 EVKIT sensor board and the evaluation software. The evaluation kit features ECG, PACE, R-to-R (R-peak timing) detection; bioimpedance (BioZ) AFE; and raw data logging.

The MAX30001 EVKIT evaluation system is assembled, tested and contains the necessary circuitry and connections to evaluate the MAX30001 ECG sensor.

When evaluated as an evaluation system, the MAX32630FTHR board provides the necessary logic rails, master clock, SPI, USB-to-Serial interfaces that are needed to evaluate the MAX30001 sensor board. MAX32630FTHR can be used as an independent development platform.

Communication between the PC and the MAX32630FTHR board is facilitated by a Windows 7, Windows 8 and Windows 10 compatible software that provides a simple and intuitive graphical user interface (GUI).

For more information, visit the wiki pages by clicking the wiki tab above and MAX30001EVSYS product page.

C++ source code, library for the MAX30001 ECG drivers are in the links at the bottom of this page. The sample code includes the ability to log data to the SD card of the MAX32630FTHR.

MAX30001 EVKIT Pinout Connections

/media/uploads/EmreE/max30001_sensor_board_connector_pinout.png

Where to Buy

MAX30001EVSYS-Buy

Committer:
Emre.Eken@IST-LT-35101.maxim-ic.internal
Date:
Thu Apr 05 10:53:26 2018 +0300
Revision:
0:8e4630a71eb1
mbed os 5.8.1 compatible

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 1 /*******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 3 *
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 4 * Permission is hereby granted, free of charge, to any person obtaining a
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 5 * copy of this software and associated documentation files (the "Software"),
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 6 * to deal in the Software without restriction, including without limitation
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 8 * and/or sell copies of the Software, and to permit persons to whom the
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 9 * Software is furnished to do so, subject to the following conditions:
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 10 *
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 11 * The above copyright notice and this permission notice shall be included
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 12 * in all copies or substantial portions of the Software.
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 13 *
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 20 * OTHER DEALINGS IN THE SOFTWARE.
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 21 *
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 22 * Except as contained in this notice, the name of Maxim Integrated
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 24 * Products, Inc. Branding Policy.
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 25 *
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 26 * The mere transfer of this software does not imply any licenses
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 27 * of trade secrets, proprietary technology, copyrights, patents,
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 28 * trademarks, maskwork rights, or any other form of intellectual
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 30 * ownership rights.
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 31 ******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 32 */
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 33 #include "StringHelper.h"
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 34 #include <stdint.h>
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 35 #include "Streaming.h"
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 36 #include "StringInOut.h"
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 37 #include "DataLoggingService.h"
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 38 #include "Peripherals.h"
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 39 #include "Logging.h"
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 40
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 41 extern char loggingMissionCmds[4096];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 42 uint32_t missionCmdIndex;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 43 extern char missionFileName[32];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 44 extern char dataFileName[32];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 45 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 46 int Logging_RPC_StartMissionDefine(char argStrs[32][32],
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 47 char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 48 uint32_t i;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 49 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 50
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 51 // reset the missionCmdIndex to the beginning of the cmd buffer
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 52 missionCmdIndex = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 53 // clear the mission command buffer, fill with zeros
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 54 for (i = 0; i < sizeof(loggingMissionCmds); i++) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 55 loggingMissionCmds[i] = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 56 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 57
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 58 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 59 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 60 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 61 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 62
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 63 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 64 int Logging_RPC_AppendMissionCmd(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 65 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 66 char *strPtr;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 67 uint32_t count = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 68 uint8_t result = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 69 // append the string to the mission cmd log
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 70 strPtr = argStrs[0];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 71 while (*strPtr != 0) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 72 loggingMissionCmds[missionCmdIndex] = *strPtr;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 73 missionCmdIndex++;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 74 strPtr++;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 75 // do not overrun buffer
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 76 if (missionCmdIndex > (sizeof(loggingMissionCmds) - 2)) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 77 result = 0xFF;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 78 break;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 79 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 80 count++;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 81 // do not read more than max count in incoming string
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 82 if (count > (32 * 32)) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 83 result = 0xFF;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 84 break;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 85 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 86 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 87 if (result != 0x80) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 88 reply[0] = 0xFF;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 89 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 90 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 91 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 92 // add cr/lf to the end of this cmd string
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 93 loggingMissionCmds[missionCmdIndex++] = 13;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 94 loggingMissionCmds[missionCmdIndex++] = 10;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 95
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 96 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 97 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 98 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 99 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 100
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 101 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 102 int Logging_RPC_EndMissionDefine(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 103 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 104 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 105 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 106 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 107 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 108
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 109 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 110 int Logging_RPC_WriteMission(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 111 char *ptr;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 112 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 113
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 114 ptr = loggingMissionCmds;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 115 FILE *fp = fopen(missionFileName, "w");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 116 if (fp != NULL){
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 117 fprintf(fp, ptr);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 118 fclose(fp);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 119 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 120
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 121 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 122 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 123 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 124 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 125
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 126 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 127 int Logging_RPC_ReadMission(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 128 char *ptr;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 129 uint32_t i;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 130 FILE *fp;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 131 ptr = loggingMissionCmds;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 132 fp = fopen(missionFileName, "r");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 133 if (fp != NULL) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 134 do
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 135 {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 136 char c = (char)fgetc(fp);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 137 *ptr++ = c;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 138 } while(!feof(fp));
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 139 ptr--;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 140 *ptr = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 141 fclose(fp);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 142 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 143 ptr = loggingMissionCmds;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 144 for (i = 0; i < sizeof(loggingMissionCmds); i++) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 145 if (*ptr == 13) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 146 *ptr = ':';
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 147 } else if (*ptr == 10) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 148 *ptr = ' ';
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 149 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 150 ptr++;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 151 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 152
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 153 // send it out via uart
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 154 putStr(loggingMissionCmds);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 155 replyStrs[0][0] = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 156 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 157 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 158
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 159 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 160 int Logging_RPC_EraseMission(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 161 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 162 FILE *fp = fopen(missionFileName, "w");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 163 if (fp != NULL){
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 164 fprintf(fp, "");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 165 fclose(fp);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 166 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 167 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 168 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 169 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 170 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 171
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 172 #define SECTOR_SIZE_256K 0x10000
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 173 #define PAGE_INC_256K 0x400
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 174 #define SECTOR_SIZE_4K 0x1000
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 175 #define PAGE_INC_4K 0x10
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 176 #define TOTAL_SECTOR_NUMBER 263
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 177
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 178 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 179 int Logging_EraseWrittenSectors(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 180 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 181 uint8_t data[512];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 182
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 183 printf("Logging_EraseWrittenSectors ");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 184 FILE *fp = fopen(missionFileName, "w");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 185 if (fp != NULL){
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 186 fprintf(fp, "");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 187 fclose(fp);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 188 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 189
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 190 fp = fopen(dataFileName, "w");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 191 if (fp != NULL){
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 192 fprintf(fp, "");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 193 fclose(fp);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 194 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 195 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 196 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 197 printf("Logging_EraseWrittenSectors done. \n");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 198 fflush(stdout);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 199 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 200 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 201
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 202 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 203 int Logging_Start(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 204 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 205 Logging_SetStart(true);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 206 reply[0] = 0x80; // indicate success
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 207 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 208 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 209 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 210
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 211 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 212 int Logging_GetLastWrittenPage(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 213 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 214
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 215 uint32_t page;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 216 uint32_t lastPage;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 217 uint32_t pageEmpty;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 218 uint8_t data[512];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 219
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 220 printf("Logging_GetLastWrittenPage ");
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 221 fflush(stdout);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 222 lastPage = Logging_GetLoggingEndPage();
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 223 for (page = 2; page <= lastPage; page++) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 224 // Peripherals::serial()->printf("checking page %d ",page); fflush(stdout);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 225 // sample the page
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 226 Peripherals::s25FS512()->readPages_Helper(page, page, data, 0);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 227 pageEmpty = Peripherals::s25FS512()->isPageEmpty(data);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 228 if (pageEmpty != 0) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 229 break;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 230 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 231 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 232 if (page > lastPage)
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 233 page = lastPage;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 234 printf("last page %d, 0x%X ", page, page);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 235 fflush(stdout);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 236 reply[0] = page;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 237 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 238 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 239 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 240
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 241 extern int highDataRate;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 242 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 243 int Logging_StartLoggingUsb(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 244 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 245 // highDataRate = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 246 LoggingService_StartLoggingUsb();
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 247 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 248 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 249 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 250 }
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 251 //******************************************************************************
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 252 int Logging_StartLoggingFlash(char argStrs[32][32], char replyStrs[32][32]) {
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 253 uint32_t reply[1];
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 254 // highDataRate = 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 255 LoggingService_StartLoggingFlash();
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 256 reply[0] = 0x80;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 257 FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 258 return 0;
Emre.Eken@IST-LT-35101.maxim-ic.internal 0:8e4630a71eb1 259 }