PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
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
main
int main(void)
Definition:
GraphicsTest.c:20
CS
const PropWare::Port::Mask CS
Definition:
L3G_Demo.cpp:38
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12