File tree Expand file tree Collapse file tree 6 files changed +59
-6
lines changed Expand file tree Collapse file tree 6 files changed +59
-6
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ File::File(SdFile f, const char *n) {
22
22
// oh man you are kidding me, new() doesn't exist? Ok we do it by hand!
23
23
_file = (SdFile *)malloc (sizeof (SdFile));
24
24
if (_file) {
25
- memcpy (_file, &f, sizeof (SdFile));
25
+ memcpy (( void *) _file, ( void *) &f, sizeof (SdFile));
26
26
27
27
strncpy (_name, n, 12 );
28
28
_name[12 ] = 0 ;
Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ namespace SDLib {
53
53
void rewindDirectory (void );
54
54
55
55
using Print::write;
56
+ #ifdef ARDUINO_CI
57
+ int getWriteError () { return writeError; }
58
+ void setWriteError (int value = 1 ) { writeError = value; }
59
+ void clearWriteError () { writeError = 0 ; }
60
+ private:
61
+ int writeError;
62
+ #endif
56
63
};
57
64
58
65
class SDClass {
Original file line number Diff line number Diff line change
1
+ #ifdef ARDUINO_CI
2
+
3
+ #include " Sd2PinMap.h"
4
+
5
+ uint8_t avr_io_registers[RAMSTART];
6
+
7
+ #endif
Original file line number Diff line number Diff line change 17
17
along with the Arduino SdFat Library. If not, see
18
18
<http://www.gnu.org/licenses/>.
19
19
*/
20
+
21
+ #ifdef ARDUINO_CI
22
+ #include <inttypes.h>
23
+ #ifdef _SFR_IO8
24
+ #undef _SFR_IO8
25
+ #define _AVR_IO_REG (type , mem_addr ) (*(type*)(&avr_io_registers[mem_addr]))
26
+ #define __SFR_OFFSET 0x20
27
+ #define _SFR_IO8 (io_addr ) _AVR_IO_REG(uint8_t, io_addr + __SFR_OFFSET)
28
+ #define _SFR_IO16 (io_addr ) _AVR_IO_REG(uint16_t, io_addr + __SFR_OFFSET)
29
+ #define _SFR_MEM8 (mem_addr ) _AVR_IO_REG(uint8_t, mem_addr)
30
+ #define _SFR_MEM16 (mem_addr ) _AVR_IO_REG(uint16_t, mem_addr)
31
+ #define _SFR_MEM32 (mem_addr ) _AVR_IO_REG(uint32_t, mem_addr)
32
+
33
+ extern uint8_t avr_io_registers [RAMSTART ];
34
+ #endif
35
+ #define SDCARD_SS_PIN 4
36
+ #define SDCARD_MOSI_PIN 11
37
+ #define SDCARD_MISO_PIN 12
38
+ #define SDCARD_SCK_PIN 13
39
+ #endif
40
+
20
41
#if defined(__arm__ ) // Arduino Due Board follows
21
42
22
43
#ifndef Sd2PinMap_h
Original file line number Diff line number Diff line change @@ -454,6 +454,13 @@ class SdFile : public Print {
454
454
static uint8_t make83Name (const char * str, uint8_t * name);
455
455
uint8_t openCachedEntry (uint8_t cacheIndex, uint8_t oflags);
456
456
dir_t * readDirCache (void );
457
+ #ifdef ARDUINO_CI
458
+ int writeError;
459
+ public:
460
+ int getWriteError () { return writeError; }
461
+ void setWriteError (int value = 1 ) { writeError = value; }
462
+ void clearWriteError () { writeError = 0 ; }
463
+ #endif
457
464
};
458
465
// ==============================================================================
459
466
// SdVolume class
Original file line number Diff line number Diff line change 34
34
#endif
35
35
#define NOINLINE __attribute__((noinline,unused))
36
36
#define UNUSEDOK __attribute__((unused))
37
+
38
+ #if UINTPTR_MAX == 0xFFFF
39
+ typedef int16_t ptr_as_int ;
40
+ #elif UINTPTR_MAX == 0xFFFFFFFF
41
+ typedef int32_t ptr_as_int ;
42
+ #elif UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu
43
+ typedef int64_t ptr_as_int ;
44
+ #else
45
+ #error unrecognized pointer size!
46
+ #endif
47
+
37
48
//------------------------------------------------------------------------------
38
49
/** Return the number of bytes currently free in RAM. */
39
50
static UNUSEDOK int FreeRam (void ) {
40
51
extern int __bss_end ;
41
52
extern int * __brkval ;
42
53
int free_memory ;
43
- if (reinterpret_cast < int > (__brkval ) == 0 ) {
54
+ if (reinterpret_cast < ptr_as_int > (__brkval ) == 0 ) {
44
55
// if no heap use from end of bss section
45
- free_memory = reinterpret_cast < int > (& free_memory )
46
- - reinterpret_cast < int > (& __bss_end );
56
+ free_memory = reinterpret_cast < ptr_as_int > (& free_memory )
57
+ - reinterpret_cast < ptr_as_int > (& __bss_end );
47
58
} else {
48
59
// use from top of stack to heap
49
- free_memory = reinterpret_cast < int > (& free_memory )
50
- - reinterpret_cast < int > (__brkval );
60
+ free_memory = reinterpret_cast < ptr_as_int > (& free_memory )
61
+ - reinterpret_cast < ptr_as_int > (__brkval );
51
62
}
52
63
return free_memory ;
53
64
}
You can’t perform that action at this time.
0 commit comments