1
1
/*
2
- 12-3-09
3
- Nathan Seidle
4
- SparkFun Electronics
2
+ 12-3-09
3
+ Nathan Seidle
4
+ SparkFun Electronics
5
5
6
- OpenLog hardware and firmware are released under the Creative Commons Share Alike v3.0 license.
7
- http://creativecommons.org/licenses/by-sa/3.0/
8
- Feel free to use, distribute, and sell varients of OpenLog. All we ask is that you include attribution of 'Based on OpenLog by SparkFun'.
6
+ OpenLog hardware and firmware are released under the Creative Commons Share Alike v3.0 license.
7
+ http://creativecommons.org/licenses/by-sa/3.0/
8
+ Feel free to use, distribute, and sell varients of OpenLog. All we ask is that you include attribution of 'Based on OpenLog by SparkFun'.
9
9
10
- OpenLog is based on the work of Bill Greiman and sdfatlib: https://github.com/greiman/SdFat-beta
10
+ OpenLog is based on the work of Bill Greiman and sdfatlib: https://github.com/greiman/SdFat-beta
11
11
12
- OpenLog is a simple serial logger based on the ATmega328 running at 16MHz. The whole purpose of this
13
- logger was to create a logger that just powered up and worked. OpenLog ships with an Arduino/Optiboot
14
- 115200bps serial bootloader running at 16MHz so you can load new firmware with a simple serial
15
- connection.
12
+ OpenLog is a simple serial logger based on the ATmega328 running at 16MHz. The whole purpose of this
13
+ logger was to create a logger that just powered up and worked. OpenLog ships with an Arduino/Optiboot
14
+ 115200bps serial bootloader running at 16MHz so you can load new firmware with a simple serial
15
+ connection.
16
16
17
- OpenLog has progressed significantly over the past three years. Please see CHANGELOG.md or GitHub commits
18
- for a full trip down memory lane.
17
+ OpenLog has progressed significantly over the past three years. Please see CHANGELOG.md or GitHub commits
18
+ for a full trip down memory lane.
19
19
20
- OpenLog automatically works with 512MB to 64GB micro/SD cards.
20
+ OpenLog automatically works with 512MB to 64GB micro/SD cards.
21
21
22
- OpenLog runs at 9600bps by default. This is configurable to 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200bps. You can alter
23
- all settings including baud rate and escape characters by editing config.txt found on OpenLog.
22
+ OpenLog runs at 9600bps by default. This is configurable to 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200bps. You can alter
23
+ all settings including baud rate and escape characters by editing config.txt found on OpenLog.
24
24
25
- Type '?' to get a list of supported commands.
25
+ Type '?' to get a list of supported commands.
26
26
27
- During power up, you will see '12<'. '1' indicates the serial connection is established. '2' indicates
28
- the SD card has been successfully initialized. '<' indicates OpenLog is ready to receive serial characters.
27
+ During power up, you will see '12<'. '1' indicates the serial connection is established. '2' indicates
28
+ the SD card has been successfully initialized. '<' indicates OpenLog is ready to receive serial characters.
29
29
30
- Recording constant 115200bps datastreams are supported. Throw it everything you've got! To acheive this maximum record rate, please use the
31
- SD card formatter from : http://www.sdcard.org/consumers/formatter/. The fewer files on the card, the faster OpenLog is able to begin logging.
32
- 200 files is ok. 2GB worth of music and pictures is not.
30
+ Recording constant 115200bps datastreams are supported. Throw it everything you've got! To acheive this maximum record rate, please use the
31
+ SD card formatter from : http://www.sdcard.org/consumers/formatter/. The fewer files on the card, the faster OpenLog is able to begin logging.
32
+ 200 files is ok. 2GB worth of music and pictures is not.
33
33
34
- To a lower dir, use 'cd ..' instead of 'cd..'.
34
+ To a lower dir, use 'cd ..' instead of 'cd..'.
35
35
36
- Only standard 8.3 file names are supported. "12345678.123" is acceptable. "123456789.123" is not.
36
+ Only standard 8.3 file names are supported. "12345678.123" is acceptable. "123456789.123" is not.
37
37
38
- All file names are pushed to upper case. "NewLog.txt" will become "NEWLOG.TXT".
38
+ All file names are pushed to upper case. "NewLog.txt" will become "NEWLOG.TXT".
39
39
40
- Type 'set' to enter baud rate configuration menu. Select the baud rate and press enter. You will then
41
- see a message 'Going to 9600bps...' or some such message. You will need to power down OpenLog, change
42
- your system UART settings to match the new OpenLog baud rate and then power OpenLog back up.
40
+ Type 'set' to enter baud rate configuration menu. Select the baud rate and press enter. You will then
41
+ see a message 'Going to 9600bps...' or some such message. You will need to power down OpenLog, change
42
+ your system UART settings to match the new OpenLog baud rate and then power OpenLog back up.
43
43
44
- If you get OpenLog stuck into an unknown baudrate, there is a safety mechanism built-in. Tie the RX pin
45
- to ground and power up OpenLog. You should see the LEDs blink back and forth for 2 seconds, then blink
46
- in unison. Now power down OpenLog and remove the RX/GND jumper. OpenLog is now reset to 9600bps.
44
+ If you get OpenLog stuck into an unknown baudrate, there is a safety mechanism built-in. Tie the RX pin
45
+ to ground and power up OpenLog. You should see the LEDs blink back and forth for 2 seconds, then blink
46
+ in unison. Now power down OpenLog and remove the RX/GND jumper. OpenLog is now reset to 9600bps.
47
47
48
- Please note: The preloaded Optiboot serial bootloader is 0.5k, and begins at 0x7E00 (32,256). If the code is
49
- larger than 32,256 bytes, you will get verification errors during serial bootloading.
48
+ Please note: The preloaded Optiboot serial bootloader is 0.5k, and begins at 0x7E00 (32,256). If the code is
49
+ larger than 32,256 bytes, you will get verification errors during serial bootloading.
50
50
51
- OpenLog regularly shuts down to conserve power. If after 0.5 seconds no characters are received, OpenLog will record
52
- any unsaved characters and go to sleep. OpenLog will automatically wake up and continue logging the instant a
53
- new character is received.
51
+ OpenLog regularly shuts down to conserve power. If after 0.5 seconds no characters are received, OpenLog will record
52
+ any unsaved characters and go to sleep. OpenLog will automatically wake up and continue logging the instant a
53
+ new character is received.
54
54
55
- 1.55mA idle
56
- 15mA actively writing
55
+ 1.55mA idle
56
+ 15mA actively writing
57
57
58
- Input voltage on VCC can be 3.3 to 12V. Input voltage on RX-I pin must not exceed 6V. Output voltage on
59
- TX-O pin will not be greater than 3.3V. This may cause problems with some systems - for example if your
60
- attached microcontroller requires 4V minimum for serial communication (this is rare).
58
+ Input voltage on VCC can be 3.3 to 12V. Input voltage on RX-I pin must not exceed 6V. Output voltage on
59
+ TX-O pin will not be greater than 3.3V. This may cause problems with some systems - for example if your
60
+ attached microcontroller requires 4V minimum for serial communication (this is rare).
61
61
62
- */
62
+ */
63
63
64
64
#define __PROG_TYPES_COMPAT__ // Needed to get SerialPort.h to work in Arduino 1.6.x
65
65
71
71
72
72
SerialPort<0 , 512 , 0 > NewSerial;
73
73
// <port #, RX buffer size, TX buffer size>
74
- // We set the TX buffer to zero because we will be spending most of our
74
+ // We set the TX buffer to zero because we will be spending most of our
75
75
// time needing to buffer the incoming (RX) characters.
76
76
77
77
// This is the array within the append file routine
@@ -311,7 +311,7 @@ char* newLog(void)
311
311
312
312
// There is a weird EEPROM power-up glitch that causes the newFileNumber to advance
313
313
// arbitrarily. This fixes that problem.
314
- if (newFileNumber > 0 ) newFileNumber--;
314
+ if (newFileNumber > 0 ) newFileNumber--;
315
315
316
316
// Search for next available log spot
317
317
static char newFileName[13 ]; // Bug fix from ystark's pull request: https://github.com/sparkfun/OpenLog/pull/189
@@ -322,7 +322,7 @@ char* newLog(void)
322
322
// O_CREAT - create the file if it does not exist
323
323
// O_APPEND - seek to the end of the file prior to each write
324
324
// O_WRITE - open for write
325
- // O_EXCL - if O_CREAT and O_EXCEL are set, open() shall fail if file exists
325
+ // O_EXCL - if O_CREAT and O_EXCEL are set, open() shall fail if file exists
326
326
327
327
// Try to open file, if it opens (file doesn't exist), then break
328
328
if (newFile.open (newFileName, O_CREAT | O_EXCL | O_WRITE)) break ;
@@ -459,6 +459,15 @@ byte appendFile(char* fileName)
459
459
460
460
power_timer0_disable (); // Shut down peripherals we don't need
461
461
power_spi_disable ();
462
+
463
+ // Driving SPI pins low before sleep to attempt to lower microSD card stand-by current
464
+ // Pins: 10, 11, 12, 13
465
+ for (byte x = 10 ; x < 14 ; x++)
466
+ {
467
+ pinMode (x, OUTPUT);
468
+ digitalWrite (x, LOW);
469
+ }
470
+
462
471
sleep_mode (); // Stop everything and go to sleep. Wake up if serial character received
463
472
464
473
power_spi_enable (); // After wake up, power up peripherals
@@ -511,6 +520,15 @@ byte appendFile(char* fileName)
511
520
512
521
power_timer0_disable (); // Shut down peripherals we don't need
513
522
power_spi_disable ();
523
+
524
+ // Driving SPI pins low before sleep to attempt to lower microSD card stand-by current
525
+ // Pins: 10, 11, 12, 13
526
+ for (byte x = 10 ; x < 14 ; x++)
527
+ {
528
+ pinMode (x, OUTPUT);
529
+ digitalWrite (x, LOW);
530
+ }
531
+
514
532
sleep_mode (); // Stop everything and go to sleep. Wake up if serial character received
515
533
516
534
power_spi_enable (); // After wake up, power up peripherals
@@ -525,9 +543,9 @@ byte appendFile(char* fileName)
525
543
workingFile.sync ();
526
544
527
545
// Remove the escape characters from the end of the file
528
- if (setting_max_escape_character > 0 )
546
+ if (setting_max_escape_character > 0 )
529
547
workingFile.truncate (workingFile.fileSize () - setting_max_escape_character);
530
-
548
+
531
549
workingFile.close (); // Done recording, close out the file
532
550
533
551
digitalWrite (stat1, LOW); // Turn off indicator LED
@@ -1708,7 +1726,7 @@ byte readLine(char* buffer, byte bufferLength)
1708
1726
//To capture the escape command and immediately record
1709
1727
//the buffer then stop asking for input from user
1710
1728
//See issue 168: https://github.com/sparkfun/OpenLog/issues/168
1711
- }*/
1729
+ }*/
1712
1730
else {
1713
1731
buffer[readLength] = c;
1714
1732
++readLength;
@@ -2110,33 +2128,33 @@ byte wildcmp(const char* wild, const char* string)
2110
2128
#define DIR_SIZE (sizeof (dir_t ))
2111
2129
2112
2130
/*
2113
- * NAME:
2114
- * void lsPrint(SdFile * theDir, char * cmdStr, byte flags, byte indent)
2115
- *
2116
- * PARAMETERS:
2117
- * SdFile * theDir = the directory to list (assumed opened)
2118
- * char * cmdStr = the command line file/directory string (with possible wildcards)
2119
- * byte flags = the inclusive OR of
2120
- * LS_SIZE - print the file size
2121
- * LS_R - recursively list subdirectories
2122
- * byte indent = amount of space before file name
2123
- * (used for recursive list to indicate subdirectory level)
2124
- *
2125
- * WHAT:
2126
- * List directory contents to serial port.
2127
- *
2128
- * Wildcard support rules:
2129
- * Wildcard characters ('*', '?') only apply to the selection of filenames to
2130
- * list, not to the listing of directory or subdirectory names. All directory
2131
- * and subdirectory names are always listed.
2132
- *
2133
- * RETURN VALUES:
2134
- * None.
2135
- *
2136
- * SPECIAL CONSIDERATIONS:
2137
- * May be called recursively with limited recursion depth (see FOLDER_TRACK_DEPTH).
2138
- * Each recursion uses ~50 bytes of RAM.
2139
- */
2131
+ NAME:
2132
+ void lsPrint(SdFile * theDir, char * cmdStr, byte flags, byte indent)
2133
+
2134
+ PARAMETERS:
2135
+ SdFile * theDir = the directory to list (assumed opened)
2136
+ char * cmdStr = the command line file/directory string (with possible wildcards)
2137
+ byte flags = the inclusive OR of
2138
+ LS_SIZE - print the file size
2139
+ LS_R - recursively list subdirectories
2140
+ byte indent = amount of space before file name
2141
+ (used for recursive list to indicate subdirectory level)
2142
+
2143
+ WHAT:
2144
+ List directory contents to serial port.
2145
+
2146
+ Wildcard support rules:
2147
+ Wildcard characters ('*', '?') only apply to the selection of filenames to
2148
+ list, not to the listing of directory or subdirectory names. All directory
2149
+ and subdirectory names are always listed.
2150
+
2151
+ RETURN VALUES:
2152
+ None.
2153
+
2154
+ SPECIAL CONSIDERATIONS:
2155
+ May be called recursively with limited recursion depth (see FOLDER_TRACK_DEPTH).
2156
+ Each recursion uses ~50 bytes of RAM.
2157
+ */
2140
2158
// void lsPrint(SdFile * theDir, char * cmdStr, byte flags, byte indent)
2141
2159
void lsPrint (FatFile * theDir, char * cmdStr, byte flags, byte indent)
2142
2160
{
@@ -2168,32 +2186,32 @@ void lsPrint(FatFile * theDir, char * cmdStr, byte flags, byte indent)
2168
2186
}
2169
2187
2170
2188
/*
2171
- * NAME:
2172
- * void lsPrintNext(SdFile * theDir, char * cmdStr, byte flags, byte indent)
2173
- *
2174
- * PARAMETERS:
2175
- * SdFile * theDir = the directory to list (assumed opened)
2176
- * char * cmdStr = the command line file/directory string (with possible wildcards)
2177
- * byte flags = the inclusive OR of
2178
- * LS_SIZE - print the file size
2179
- * LS_R - recursively list subdirectories
2180
- * byte indent = amount of space before file name
2181
- * (used for recursive list to indicate subdirectory level)
2182
- *
2183
- * WHAT:
2184
- * List directory's next contents to serial port.
2185
- *
2186
- * Wildcard support rules:
2187
- * Wildcard characters ('*', '?') only apply to the selection of filenames to
2188
- * list, not to the listing of directory or subdirectory names. All directory
2189
- * and subdirectory names are always listed.
2190
- *
2191
- * RETURN VALUES:
2192
- * byte = WAS_EOF - EOF, WAS_FILE - normal file, or WAS_SUBDIR - subdirectory
2193
- *
2194
- * SPECIAL CONSIDERATIONS:
2195
- * None.
2196
- */
2189
+ NAME:
2190
+ void lsPrintNext(SdFile * theDir, char * cmdStr, byte flags, byte indent)
2191
+
2192
+ PARAMETERS:
2193
+ SdFile * theDir = the directory to list (assumed opened)
2194
+ char * cmdStr = the command line file/directory string (with possible wildcards)
2195
+ byte flags = the inclusive OR of
2196
+ LS_SIZE - print the file size
2197
+ LS_R - recursively list subdirectories
2198
+ byte indent = amount of space before file name
2199
+ (used for recursive list to indicate subdirectory level)
2200
+
2201
+ WHAT:
2202
+ List directory's next contents to serial port.
2203
+
2204
+ Wildcard support rules:
2205
+ Wildcard characters ('*', '?') only apply to the selection of filenames to
2206
+ list, not to the listing of directory or subdirectory names. All directory
2207
+ and subdirectory names are always listed.
2208
+
2209
+ RETURN VALUES:
2210
+ byte = WAS_EOF - EOF, WAS_FILE - normal file, or WAS_SUBDIR - subdirectory
2211
+
2212
+ SPECIAL CONSIDERATIONS:
2213
+ None.
2214
+ */
2197
2215
// byte lsPrintNext(SdFile * theDir, char * cmdStr, byte flags, byte indent)
2198
2216
byte lsPrintNext (FatFile * theDir, char * cmdStr, byte flags, byte indent)
2199
2217
{
0 commit comments