PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Memory
SD Minimal.c
1
/*
2
SD Minimal.side
3
4
Create test.txt, write characters in, read back out, display.
5
6
http://learn.parallax.com/propeller-c-simple-devices/sd-card-data
7
*/
8
9
#include "
simpletools.h
"
// Include simpletools header
10
11
int
DO = 22, CLK = 23, DI = 24, CS = 25;
// SD card pins on Propeller BOE
12
13
int
main
(
void
)
// main function
14
{
15
sd_mount
(DO, CLK, DI, CS);
// Mount SD card
16
17
FILE
* fp = fopen(
"test.txt"
,
"w"
);
// Open a file for writing
18
fwrite(
"Testing 123...\n"
, 1, 15, fp);
// Add contents to the file
19
fclose(fp);
// Close the file
20
21
char
s[15];
// Buffer for characters
22
fp = fopen(
"test.txt"
,
"r"
);
// Reopen file for reading
23
fread(s, 1, 15, fp);
// Read 15 characters
24
fclose(fp);
// Close the file
25
26
print
(
"First 15 chars in test.txt:\n"
);
// Display heading
27
print
(
"%s"
, s);
// Display characters
28
print
(
"\n"
);
// With a newline at the end
29
}
30
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
sd_mount
int sd_mount(int doPin, int clkPin, int diPin, int csPin)
Mount an SD card with the minimal 4-pin interface. For Parallax Learn Site examples,...
Definition:
sddriverconfig.c:7
_FILE
Definition:
stdio.h:62
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17