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.
Dependencies: USBDevice mbed DipCortex-USB-EEProm
main.cpp@10:ba3a28345f76, 2015-09-11 (annotated)
- Committer:
- johnhalfpenny
- Date:
- Fri Sep 11 13:54:03 2015 +0000
- Revision:
- 10:ba3a28345f76
- Parent:
- 9:f37125673b91
Logs to EEPROM & dumps EEPROM from menu
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnhalfpenny | 5:e1eb6bdf10f3 | 1 | // |
johnhalfpenny | 5:e1eb6bdf10f3 | 2 | // Accellerometer project |
johnhalfpenny | 5:e1eb6bdf10f3 | 3 | // |
johnhalfpenny | 5:e1eb6bdf10f3 | 4 | // Laurence Halfpenny |
johnhalfpenny | 5:e1eb6bdf10f3 | 5 | // August 2015 |
SolderSplashLabs | 0:0bce3a738bcb | 6 | |
johnhalfpenny | 9:f37125673b91 | 7 | #include <stdint.h> |
johnhalfpenny | 9:f37125673b91 | 8 | #include <string.h> |
johnhalfpenny | 9:f37125673b91 | 9 | #include "mbed.h" // Needed for MBED library functions |
johnhalfpenny | 9:f37125673b91 | 10 | #include "main.h" // Needed for definitions of things that can be changed |
johnhalfpenny | 9:f37125673b91 | 11 | #include "USBSerial.h" // Needed for USB serial port |
johnhalfpenny | 9:f37125673b91 | 12 | #include "DipCortex-EEprom.h" |
johnhalfpenny | 9:f37125673b91 | 13 | #include "LPC13Uxx.h" |
SolderSplashLabs | 0:0bce3a738bcb | 14 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 15 | // Define the X, Y & Z analogue inputs on ADCs |
johnhalfpenny | 5:e1eb6bdf10f3 | 16 | AnalogIn Z_in(P0_11); // Z accelleration voltage |
johnhalfpenny | 5:e1eb6bdf10f3 | 17 | AnalogIn Y_in(P0_12); // Y accelleration voltage |
johnhalfpenny | 5:e1eb6bdf10f3 | 18 | AnalogIn X_in(P0_13); // X accelleration voltage |
SolderSplashLabs | 4:ce953c80c5b3 | 19 | |
johnhalfpenny | 9:f37125673b91 | 20 | // On-board LED |
johnhalfpenny | 9:f37125673b91 | 21 | DigitalOut LED(P0_1); |
johnhalfpenny | 9:f37125673b91 | 22 | |
johnhalfpenny | 9:f37125673b91 | 23 | // Push button |
johnhalfpenny | 9:f37125673b91 | 24 | // Logic FALSE when pushed, logic TRUE when no pushed |
johnhalfpenny | 9:f37125673b91 | 25 | DigitalIn BUTTON(P0_16); |
johnhalfpenny | 9:f37125673b91 | 26 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 27 | // Acceleration values |
johnhalfpenny | 5:e1eb6bdf10f3 | 28 | int Z_accelleration=0; |
johnhalfpenny | 5:e1eb6bdf10f3 | 29 | int Y_accelleration=0; |
johnhalfpenny | 5:e1eb6bdf10f3 | 30 | int X_accelleration=0; |
SolderSplashLabs | 0:0bce3a738bcb | 31 | |
lh121438 | 8:9a3d2d28e7e5 | 32 | // Storage arrays for X,Y,Z |
johnhalfpenny | 9:f37125673b91 | 33 | // Pack them to save RAM space |
johnhalfpenny | 9:f37125673b91 | 34 | #pragma pack(push,1) |
lh121438 | 8:9a3d2d28e7e5 | 35 | uint16_t Z_store[MAXSAMPLES]={}; |
lh121438 | 8:9a3d2d28e7e5 | 36 | uint16_t Y_store[MAXSAMPLES]={}; |
lh121438 | 8:9a3d2d28e7e5 | 37 | uint16_t X_store[MAXSAMPLES]={}; |
johnhalfpenny | 9:f37125673b91 | 38 | #pragma pack(pop) |
johnhalfpenny | 9:f37125673b91 | 39 | |
lh121438 | 8:9a3d2d28e7e5 | 40 | int Sample_index=0; |
lh121438 | 8:9a3d2d28e7e5 | 41 | int Last_sample=0; |
johnhalfpenny | 9:f37125673b91 | 42 | int EEPROM_index=0; |
lh121438 | 8:9a3d2d28e7e5 | 43 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 44 | // Control variables |
johnhalfpenny | 5:e1eb6bdf10f3 | 45 | bool monitoring=FALSE; // Controls whether monitoring is running or stopped |
johnhalfpenny | 5:e1eb6bdf10f3 | 46 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 47 | // Ticker for monitoring |
johnhalfpenny | 5:e1eb6bdf10f3 | 48 | Ticker monitor_tick; |
SolderSplashLabs | 0:0bce3a738bcb | 49 | |
SolderSplashLabs | 0:0bce3a738bcb | 50 | |
johnhalfpenny | 9:f37125673b91 | 51 | // ------------------------------------------------------------------------------------------------------------ |
johnhalfpenny | 9:f37125673b91 | 52 | // Read and Write the EEPROM |
johnhalfpenny | 9:f37125673b91 | 53 | // ------------------------------------------------------------------------------------------------------------ |
johnhalfpenny | 9:f37125673b91 | 54 | |
SolderSplashLabs | 0:0bce3a738bcb | 55 | |
SolderSplashLabs | 0:0bce3a738bcb | 56 | // ------------------------------------------------------------------------------------------------------------ |
johnhalfpenny | 5:e1eb6bdf10f3 | 57 | // Initialise the LPC1347 processor |
SolderSplashLabs | 0:0bce3a738bcb | 58 | // ------------------------------------------------------------------------------------------------------------ |
SolderSplashLabs | 0:0bce3a738bcb | 59 | void init() |
SolderSplashLabs | 0:0bce3a738bcb | 60 | { |
SolderSplashLabs | 0:0bce3a738bcb | 61 | NVIC_SetPriority(SSP1_IRQn, 0x0); |
SolderSplashLabs | 0:0bce3a738bcb | 62 | NVIC_SetPriority(PIN_INT0_IRQn, 0x1); |
SolderSplashLabs | 0:0bce3a738bcb | 63 | |
SolderSplashLabs | 0:0bce3a738bcb | 64 | // SysTick set to lower priority than Wi-Fi SPI bus interrupt |
SolderSplashLabs | 0:0bce3a738bcb | 65 | NVIC_SetPriority(SysTick_IRQn, 0x2); |
SolderSplashLabs | 3:15828ac052f1 | 66 | |
SolderSplashLabs | 3:15828ac052f1 | 67 | |
SolderSplashLabs | 3:15828ac052f1 | 68 | // Enable RAM1 |
SolderSplashLabs | 3:15828ac052f1 | 69 | LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 26); |
johnhalfpenny | 9:f37125673b91 | 70 | |
johnhalfpenny | 9:f37125673b91 | 71 | // Clear the LED |
johnhalfpenny | 9:f37125673b91 | 72 | LED=FALSE; |
johnhalfpenny | 9:f37125673b91 | 73 | |
johnhalfpenny | 9:f37125673b91 | 74 | // Pull the BUTTON pin up to logic high |
johnhalfpenny | 9:f37125673b91 | 75 | BUTTON.mode(PullUp); |
johnhalfpenny | 10:ba3a28345f76 | 76 | |
johnhalfpenny | 10:ba3a28345f76 | 77 | // Initialise the IAP for EEPROM reading and writing |
johnhalfpenny | 10:ba3a28345f76 | 78 | IAP_Init(); |
SolderSplashLabs | 0:0bce3a738bcb | 79 | } |
SolderSplashLabs | 0:0bce3a738bcb | 80 | |
SolderSplashLabs | 0:0bce3a738bcb | 81 | // ------------------------------------------------------------------------------------------------------------ |
johnhalfpenny | 5:e1eb6bdf10f3 | 82 | // The monitoring software, triggered by the monitoring ticker |
johnhalfpenny | 5:e1eb6bdf10f3 | 83 | // ------------------------------------------------------------------------------------------------------------ |
johnhalfpenny | 5:e1eb6bdf10f3 | 84 | void monitor_accelleration(void) |
johnhalfpenny | 5:e1eb6bdf10f3 | 85 | { |
johnhalfpenny | 9:f37125673b91 | 86 | LED = !LED; // Toggle the LED each sample |
johnhalfpenny | 9:f37125673b91 | 87 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 88 | X_accelleration=X_in.read_u16(); // Read and print X accelleration |
lh121438 | 8:9a3d2d28e7e5 | 89 | X_store[Sample_index]=X_accelleration; |
johnhalfpenny | 5:e1eb6bdf10f3 | 90 | X_accelleration=(X_accelleration-(0xFFFF/2)); // Convert to change in accelleration |
johnhalfpenny | 5:e1eb6bdf10f3 | 91 | X_accelleration=X_accelleration/16; |
johnhalfpenny | 9:f37125673b91 | 92 | //pc.printf("X: %d ",X_accelleration); |
johnhalfpenny | 5:e1eb6bdf10f3 | 93 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 94 | Y_accelleration=Y_in.read_u16(); // Read and print Y accelleration |
lh121438 | 8:9a3d2d28e7e5 | 95 | Y_store[Sample_index]=Y_accelleration; |
johnhalfpenny | 5:e1eb6bdf10f3 | 96 | Y_accelleration=(Y_accelleration-(0xFFFF/2)); // Convert to change in accelleration |
johnhalfpenny | 5:e1eb6bdf10f3 | 97 | Y_accelleration=Y_accelleration/16; |
johnhalfpenny | 9:f37125673b91 | 98 | //pc.printf("Y: %d ",Y_accelleration); |
johnhalfpenny | 5:e1eb6bdf10f3 | 99 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 100 | Z_accelleration=Z_in.read_u16(); // Read and print Z accelleration |
lh121438 | 8:9a3d2d28e7e5 | 101 | Z_store[Sample_index]=Z_accelleration; |
johnhalfpenny | 5:e1eb6bdf10f3 | 102 | Z_accelleration=(Z_accelleration-(0xFFFF/2)); // Convert to change in accelleration |
johnhalfpenny | 5:e1eb6bdf10f3 | 103 | Z_accelleration=Z_accelleration/16; |
johnhalfpenny | 9:f37125673b91 | 104 | //pc.printf("Z: %d \r\n",Z_accelleration); |
lh121438 | 8:9a3d2d28e7e5 | 105 | |
johnhalfpenny | 9:f37125673b91 | 106 | //pc.printf("Sample index: %d \r\n",Sample_index); |
lh121438 | 8:9a3d2d28e7e5 | 107 | Sample_index++; |
lh121438 | 8:9a3d2d28e7e5 | 108 | |
lh121438 | 8:9a3d2d28e7e5 | 109 | if (Sample_index>=MAXSAMPLES) |
lh121438 | 8:9a3d2d28e7e5 | 110 | { |
johnhalfpenny | 9:f37125673b91 | 111 | //pc.printf("Stopping - full!\r\n"); |
lh121438 | 8:9a3d2d28e7e5 | 112 | monitoring=FALSE; |
lh121438 | 8:9a3d2d28e7e5 | 113 | monitor_tick.detach(); |
lh121438 | 8:9a3d2d28e7e5 | 114 | Last_sample=Sample_index; |
lh121438 | 8:9a3d2d28e7e5 | 115 | } |
johnhalfpenny | 5:e1eb6bdf10f3 | 116 | } |
johnhalfpenny | 5:e1eb6bdf10f3 | 117 | |
johnhalfpenny | 5:e1eb6bdf10f3 | 118 | // ------------------------------------------------------------------------------------------------------------ |
johnhalfpenny | 5:e1eb6bdf10f3 | 119 | // main loop |
SolderSplashLabs | 0:0bce3a738bcb | 120 | // ------------------------------------------------------------------------------------------------------------ |
SolderSplashLabs | 0:0bce3a738bcb | 121 | int main( void ) |
SolderSplashLabs | 0:0bce3a738bcb | 122 | { |
johnhalfpenny | 10:ba3a28345f76 | 123 | int i; // For controlling loops |
johnhalfpenny | 10:ba3a28345f76 | 124 | char charIn = 0; |
johnhalfpenny | 10:ba3a28345f76 | 125 | char prevCharIn = 0; |
johnhalfpenny | 10:ba3a28345f76 | 126 | char Command = 0; |
johnhalfpenny | 10:ba3a28345f76 | 127 | char j=0; // For writing to clear EEPROM |
johnhalfpenny | 10:ba3a28345f76 | 128 | |
johnhalfpenny | 9:f37125673b91 | 129 | // Initalise the LPC1347 & WiFiDIPCORTEX board |
SolderSplashLabs | 0:0bce3a738bcb | 130 | init(); |
SolderSplashLabs | 0:0bce3a738bcb | 131 | |
johnhalfpenny | 10:ba3a28345f76 | 132 | // Wait for program to start |
johnhalfpenny | 10:ba3a28345f76 | 133 | wait(1); |
SolderSplashLabs | 0:0bce3a738bcb | 134 | |
johnhalfpenny | 9:f37125673b91 | 135 | // If the BUTTON is pushed (logic FALSE) start logging otherwise go into keyboard menu |
johnhalfpenny | 9:f37125673b91 | 136 | if (BUTTON==FALSE) |
johnhalfpenny | 5:e1eb6bdf10f3 | 137 | { |
johnhalfpenny | 10:ba3a28345f76 | 138 | |
johnhalfpenny | 9:f37125673b91 | 139 | // Start the monitoring |
johnhalfpenny | 9:f37125673b91 | 140 | Sample_index=0; |
johnhalfpenny | 9:f37125673b91 | 141 | monitoring=TRUE; |
johnhalfpenny | 9:f37125673b91 | 142 | monitor_tick.attach(&monitor_accelleration,MONITORINTERVAL); |
johnhalfpenny | 10:ba3a28345f76 | 143 | |
johnhalfpenny | 9:f37125673b91 | 144 | // Wait for the monitoring to finish and then save it to EEPROM |
johnhalfpenny | 9:f37125673b91 | 145 | while (monitoring==TRUE) |
johnhalfpenny | 9:f37125673b91 | 146 | { |
johnhalfpenny | 9:f37125673b91 | 147 | // Just wait for monitoring to finish |
johnhalfpenny | 10:ba3a28345f76 | 148 | wait(1); |
johnhalfpenny | 9:f37125673b91 | 149 | } |
johnhalfpenny | 10:ba3a28345f76 | 150 | |
johnhalfpenny | 9:f37125673b91 | 151 | // Now copy the storage arrays to EEPROM |
johnhalfpenny | 10:ba3a28345f76 | 152 | LED=TRUE; // Turn LED solid on when writing to EEPROM |
johnhalfpenny | 10:ba3a28345f76 | 153 | IAP_Eeprom_Write(EEPROMBASEADDRESS, (uint8_t *)&X_store, sizeof(X_store)); // Write the X array |
johnhalfpenny | 10:ba3a28345f76 | 154 | IAP_Eeprom_Write(EEPROMBASEADDRESS+sizeof(X_store), (uint8_t *)&Y_store, sizeof(Y_store)); // Write the Y array |
johnhalfpenny | 10:ba3a28345f76 | 155 | IAP_Eeprom_Write(EEPROMBASEADDRESS+sizeof(X_store)+sizeof(Y_store), (uint8_t *)&Z_store, sizeof(Z_store)); // Write the Z array |
johnhalfpenny | 9:f37125673b91 | 156 | |
johnhalfpenny | 10:ba3a28345f76 | 157 | // Now wait for ever just flashing LED |
johnhalfpenny | 9:f37125673b91 | 158 | while (TRUE) |
johnhalfpenny | 5:e1eb6bdf10f3 | 159 | { |
johnhalfpenny | 10:ba3a28345f76 | 160 | LED=!LED; // Flash the LED slowly at end |
johnhalfpenny | 10:ba3a28345f76 | 161 | wait(1); |
johnhalfpenny | 9:f37125673b91 | 162 | } |
johnhalfpenny | 9:f37125673b91 | 163 | } |
johnhalfpenny | 9:f37125673b91 | 164 | else |
johnhalfpenny | 9:f37125673b91 | 165 | { |
johnhalfpenny | 10:ba3a28345f76 | 166 | USBSerial pc; // open USB CDC serial port |
johnhalfpenny | 10:ba3a28345f76 | 167 | // Wait for terminal program to start |
johnhalfpenny | 10:ba3a28345f76 | 168 | wait(WAITATSTART); |
johnhalfpenny | 10:ba3a28345f76 | 169 | |
johnhalfpenny | 10:ba3a28345f76 | 170 | // Show the start banner |
johnhalfpenny | 10:ba3a28345f76 | 171 | pc.printf("\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 172 | pc.printf("+-------------------------------------------+\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 173 | pc.printf("| 3-axis accelleration measurer |\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 174 | pc.printf("| Laurence Halfpenny |\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 175 | pc.printf("| Version 1.2 |\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 176 | pc.printf("+-------------------------------------------+\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 177 | |
johnhalfpenny | 9:f37125673b91 | 178 | // Forever check for commands from the keyboard |
johnhalfpenny | 9:f37125673b91 | 179 | while (TRUE) |
johnhalfpenny | 9:f37125673b91 | 180 | { |
johnhalfpenny | 9:f37125673b91 | 181 | pc.printf("+-------------------------------------------+\r\n"); |
johnhalfpenny | 9:f37125673b91 | 182 | pc.printf("| V 1.2 MENU: |\r\n"); |
johnhalfpenny | 9:f37125673b91 | 183 | pc.printf("| 1: Start monitoring |\r\n"); |
johnhalfpenny | 9:f37125673b91 | 184 | pc.printf("| 2: Stop monitoring |\r\n"); |
johnhalfpenny | 9:f37125673b91 | 185 | pc.printf("| 3: Stop / Dump values |\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 186 | pc.printf("| 4: Dump EEPROM values |\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 187 | pc.printf("| 9: Clear EEPROM values |\r\n"); |
johnhalfpenny | 9:f37125673b91 | 188 | pc.printf("+-------------------------------------------+\r\n"); |
johnhalfpenny | 9:f37125673b91 | 189 | |
johnhalfpenny | 10:ba3a28345f76 | 190 | // Get a command from the keyboard |
johnhalfpenny | 10:ba3a28345f76 | 191 | pc.printf("Enter command: "); |
johnhalfpenny | 10:ba3a28345f76 | 192 | while (TRUE) |
johnhalfpenny | 10:ba3a28345f76 | 193 | { |
johnhalfpenny | 10:ba3a28345f76 | 194 | prevCharIn = charIn; |
johnhalfpenny | 10:ba3a28345f76 | 195 | charIn = pc.getc(); |
johnhalfpenny | 10:ba3a28345f76 | 196 | pc.printf("%c", charIn); |
johnhalfpenny | 10:ba3a28345f76 | 197 | if ((charIn == '\n') || (charIn == '\r')) |
johnhalfpenny | 10:ba3a28345f76 | 198 | { |
johnhalfpenny | 10:ba3a28345f76 | 199 | break; |
johnhalfpenny | 10:ba3a28345f76 | 200 | } |
johnhalfpenny | 10:ba3a28345f76 | 201 | } |
johnhalfpenny | 10:ba3a28345f76 | 202 | Command=prevCharIn; |
johnhalfpenny | 10:ba3a28345f76 | 203 | |
johnhalfpenny | 10:ba3a28345f76 | 204 | // Action the command |
johnhalfpenny | 10:ba3a28345f76 | 205 | switch(Command) |
johnhalfpenny | 9:f37125673b91 | 206 | { |
johnhalfpenny | 9:f37125673b91 | 207 | case '1': |
johnhalfpenny | 9:f37125673b91 | 208 | pc.printf("Starting monitor\r\n"); |
johnhalfpenny | 9:f37125673b91 | 209 | Sample_index=0; |
johnhalfpenny | 9:f37125673b91 | 210 | monitoring=TRUE; |
johnhalfpenny | 9:f37125673b91 | 211 | monitor_tick.attach(&monitor_accelleration,MONITORINTERVAL); |
johnhalfpenny | 9:f37125673b91 | 212 | break; |
johnhalfpenny | 9:f37125673b91 | 213 | |
johnhalfpenny | 9:f37125673b91 | 214 | case '2': |
lh121438 | 8:9a3d2d28e7e5 | 215 | pc.printf("Stopping monitoring\r\n"); |
lh121438 | 8:9a3d2d28e7e5 | 216 | monitoring=FALSE; |
johnhalfpenny | 9:f37125673b91 | 217 | LED=FALSE; |
lh121438 | 8:9a3d2d28e7e5 | 218 | monitor_tick.detach(); |
johnhalfpenny | 9:f37125673b91 | 219 | Last_sample=Sample_index; |
johnhalfpenny | 9:f37125673b91 | 220 | break; |
lh121438 | 8:9a3d2d28e7e5 | 221 | |
johnhalfpenny | 9:f37125673b91 | 222 | case '3': |
johnhalfpenny | 9:f37125673b91 | 223 | if (monitoring==TRUE) |
lh121438 | 8:9a3d2d28e7e5 | 224 | { |
johnhalfpenny | 9:f37125673b91 | 225 | pc.printf("Stopping monitoring\r\n"); |
johnhalfpenny | 9:f37125673b91 | 226 | monitoring=FALSE; |
johnhalfpenny | 9:f37125673b91 | 227 | LED=FALSE; |
johnhalfpenny | 9:f37125673b91 | 228 | monitor_tick.detach(); |
johnhalfpenny | 9:f37125673b91 | 229 | Last_sample=Sample_index; |
lh121438 | 8:9a3d2d28e7e5 | 230 | } |
johnhalfpenny | 9:f37125673b91 | 231 | |
johnhalfpenny | 9:f37125673b91 | 232 | if (Last_sample>0) |
johnhalfpenny | 9:f37125673b91 | 233 | { |
johnhalfpenny | 9:f37125673b91 | 234 | for (i=0; i<Last_sample; i++) |
johnhalfpenny | 9:f37125673b91 | 235 | { |
johnhalfpenny | 9:f37125673b91 | 236 | pc.printf("No.: %d ",i); |
johnhalfpenny | 9:f37125673b91 | 237 | pc.printf("X: %d ",X_store[i]); |
johnhalfpenny | 9:f37125673b91 | 238 | pc.printf("Y: %d ",Y_store[i]); |
johnhalfpenny | 9:f37125673b91 | 239 | pc.printf("Z: %d \r\n",Z_store[i]); |
johnhalfpenny | 9:f37125673b91 | 240 | } |
johnhalfpenny | 9:f37125673b91 | 241 | } |
johnhalfpenny | 9:f37125673b91 | 242 | break; |
johnhalfpenny | 9:f37125673b91 | 243 | |
johnhalfpenny | 10:ba3a28345f76 | 244 | case '4': |
johnhalfpenny | 10:ba3a28345f76 | 245 | pc.printf("Dumping EEPROM\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 246 | // Read EEPROM into Storage arrays |
johnhalfpenny | 10:ba3a28345f76 | 247 | IAP_Eeprom_Read(EEPROMBASEADDRESS, (uint8_t *)&X_store, sizeof(X_store)); // Read EEPROM into X array |
johnhalfpenny | 10:ba3a28345f76 | 248 | IAP_Eeprom_Read(EEPROMBASEADDRESS+sizeof(X_store), (uint8_t *)&Y_store, sizeof(Y_store)); // Read EEPROM into Y array |
johnhalfpenny | 10:ba3a28345f76 | 249 | IAP_Eeprom_Read(EEPROMBASEADDRESS+sizeof(X_store)+sizeof(Y_store), (uint8_t *)&Z_store, sizeof(Z_store)); // Read EEPROM into Z array |
johnhalfpenny | 10:ba3a28345f76 | 250 | // Display them |
johnhalfpenny | 10:ba3a28345f76 | 251 | for (i=0; i<MAXSAMPLES; i++) |
johnhalfpenny | 10:ba3a28345f76 | 252 | { |
johnhalfpenny | 10:ba3a28345f76 | 253 | pc.printf("No.: %d ",i); |
johnhalfpenny | 10:ba3a28345f76 | 254 | pc.printf("X: %d ",X_store[i]); |
johnhalfpenny | 10:ba3a28345f76 | 255 | pc.printf("Y: %d ",Y_store[i]); |
johnhalfpenny | 10:ba3a28345f76 | 256 | pc.printf("Z: %d \r\n",Z_store[i]); |
johnhalfpenny | 10:ba3a28345f76 | 257 | } |
johnhalfpenny | 10:ba3a28345f76 | 258 | break; |
johnhalfpenny | 10:ba3a28345f76 | 259 | |
johnhalfpenny | 10:ba3a28345f76 | 260 | case '9': |
johnhalfpenny | 10:ba3a28345f76 | 261 | pc.printf("Clearing EEPROM\r\n"); |
johnhalfpenny | 10:ba3a28345f76 | 262 | // Fill one of the arrays with zeros |
johnhalfpenny | 10:ba3a28345f76 | 263 | for (i=0; i<MAXSAMPLES; i++) |
johnhalfpenny | 10:ba3a28345f76 | 264 | { |
johnhalfpenny | 10:ba3a28345f76 | 265 | X_store[i]=(uint16_t)j; |
johnhalfpenny | 10:ba3a28345f76 | 266 | } |
johnhalfpenny | 10:ba3a28345f76 | 267 | // Write this array to X, Y & Z EEPROM stores |
johnhalfpenny | 10:ba3a28345f76 | 268 | IAP_Eeprom_Write(EEPROMBASEADDRESS, (uint8_t *)&X_store, sizeof(X_store)); |
johnhalfpenny | 10:ba3a28345f76 | 269 | IAP_Eeprom_Write(EEPROMBASEADDRESS+sizeof(X_store), (uint8_t *)&X_store, sizeof(X_store)); |
johnhalfpenny | 10:ba3a28345f76 | 270 | IAP_Eeprom_Write(EEPROMBASEADDRESS+sizeof(X_store)+sizeof(Y_store), (uint8_t *)&X_store, sizeof(X_store)); |
johnhalfpenny | 10:ba3a28345f76 | 271 | break; |
johnhalfpenny | 10:ba3a28345f76 | 272 | |
johnhalfpenny | 9:f37125673b91 | 273 | default: |
johnhalfpenny | 9:f37125673b91 | 274 | pc.printf("Invalid command\r\n"); |
johnhalfpenny | 9:f37125673b91 | 275 | break; |
johnhalfpenny | 9:f37125673b91 | 276 | } |
johnhalfpenny | 5:e1eb6bdf10f3 | 277 | } |
johnhalfpenny | 5:e1eb6bdf10f3 | 278 | } |
johnhalfpenny | 5:e1eb6bdf10f3 | 279 | |
SolderSplashLabs | 0:0bce3a738bcb | 280 | } |
johnhalfpenny | 10:ba3a28345f76 | 281 |