PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
propgcc
propeller-elf
include
sys
sd.h
1
//
2
// To tell the library how your SD card is attached to the Propeller,
3
// fill in a _SD_Params structure and pass its address to LoadSDDriver.
4
//
5
// The SD Driver has 3 modes: Single SPI, C3/Serial deMUX, and Parallel deMUX.
6
//
7
// For all modes, MISO, CLK, MOSI, and CS are required. For these parameters, the
8
// library user specifies an PIO and LoadSDDriver() converts the pin to a mask
9
// and sends to the driver.
10
//
11
// It should be obvious, but specify logical pin numbers (The P#) instead of
12
// physical pin numbers. For example, if you attached the SD card's MISO
13
// to the Propeller pin 23, that's P20 so you, specify MISO=20.
14
//
15
// Use Single SPI mode if your SD card is the only thing on your SPI bus.
16
// To use this mode:
17
// - Initialize all structure elements to 0
18
// - Set MISO, CLK, MOSI, and CS to the appropriate pin numbers
19
// - Set the attachment type to SingleSPI
20
//
21
// Use Serial deMUX mode for the C3 or any other board where the SPI bus is
22
// controlled by a serial counter attached to an inverting deMUX. Two pins
23
// and a count control the counter and deMUX:
24
//
25
// - CLR connects to the reset/clear pin of the serial counter (hence "CLR"
26
// stands for "Clear"; like CS, this is an active low signal).
27
// - INC connects to the clock/count pin of the serial counter (hence "INC"
28
// stands for "Increment")
29
// - ADDR is the address of the SD card; it is the count of clocks needed
30
// on the INC pin so that the SD card becomes selected on the SPI bus.
31
//
32
// To use this mode:
33
// - Initialize all structure elements to 0
34
// - Set MISO, CLK, MOSI, CLR, and INC to the appropriate pin numbers
35
// - Set the ADDR to the appropriate number
36
// - Set the attachment type to SerialDeMUX
37
//
38
// Use Parallel deMUX mode for Bill Henning's boards or any other board where the
39
// SPI bus is controlled by an inverting deMUX; one pin connects to the deMUX's
40
// active-low enable, and two or more Propeller pins connect to the deMUX's
41
// address lines. You specify the active-low enable as a pin number:
42
//
43
// - CS the pin number that connects to the deMUX's active-low enable.
44
//
45
// However, because more than one pin could be used to address the deMUX,
46
// so you specify the address connections as masks:
47
//
48
// - MSK is a mask with a bit set for each pin connected to the address
49
// deMUX; the driver clears all these pins from OUTA when addressing the
50
// SD card.
51
// - SEL is a mask of the deMUX address bits for the SD card; the driver ORs
52
// this mask into OUTA when addressing the SD card. Note that the code does
53
// not enforce that the bits specified in SEL are a subset of the bits
54
// specified in MSK (i.e. SEL & MSK == SEL).
55
//
56
// To use this mode:
57
// - Initialize all structure elements to 0
58
// - Set MISO, CLK, MOSI, and CS to the appropriate pin numbers
59
// - Set SEL, MSK to the appropriate masks
60
// - Set the attachment type to ParallelDeMUX
61
//
62
63
#ifndef _SYS_SD_H
64
#define _SYS_SD_H
65
66
#include <time.h>
/* for struct tm */
67
68
typedef
enum
{ _SDA_SingleSPI, _SDA_SerialDeMUX, _SDA_ParallelDeMUX, _SDA_ConfigWords } _SDAttachType;
69
70
typedef
struct
71
{
72
uint32_t MISO;
// The pin attached to the SD card's MISO or DO output
73
uint32_t CLK;
// The pin attached to the SD card's CLK or SCLK input
74
uint32_t MOSI;
// The pin attached to the SD card's MOSI or DI input
75
uint32_t CS;
// The pin attached to the SD card's CS input
76
}
_SD_SingleSPI
;
77
78
typedef
struct
79
{
80
uint32_t MISO;
// The pin attached to the SD card's MISO or DO output
81
uint32_t CLK;
// The pin attached to the SD card's CLK or SCLK input
82
uint32_t MOSI;
// The pin attached to the SD card's MOSI or DI input
83
uint32_t CLR;
// The pin attached to the counter's reset/clear pin
84
uint32_t INC;
// The pin attached to the counter's clock/count pin
85
uint32_t ADDR;
// The SD card's demux address (the counter's count)
86
}
_SD_SerialDeMUX
;
87
88
typedef
struct
89
{
90
uint32_t MISO;
// The pin attached to the SD card's MISO or DO output
91
uint32_t CLK;
// The pin attached to the SD card's CLK or SCLK input
92
uint32_t MOSI;
// The pin attached to the SD card's MOSI or DI input
93
uint32_t CS;
// The pin attached to the inverting deMUX's active-low enable
94
uint32_t START;
// The starting pin of the mask for selecting the SD card's deMUX address
95
uint32_t WIDTH;
// The width of the mask for selecting the SD card's deMUX address
96
uint32_t ADDR;
// The SD card's demux address
97
}
_SD_ParallelDeMUX
;
98
99
typedef
struct
100
{
101
uint32_t CONFIG1;
// The value of the loader patched variable _sdspi_config1
102
uint32_t CONFIG2;
// The value of the loader patched variable _sdspi_config2
103
}
_SD_ConfigWords
;
104
105
typedef
struct
106
{
107
_SDAttachType AttachmentType;
108
109
union
110
{
111
_SD_SingleSPI
SingleSPI;
112
_SD_SerialDeMUX
SerialDeMUX;
113
_SD_ParallelDeMUX
ParallelDeMUX;
114
_SD_ConfigWords
ConfigWords;
115
} pins;
116
}
_SD_Params
;
117
118
uint32_t dfs_mount(
_SD_Params
* params);
119
uint32_t dfs_mount_defaults(
void
);
120
void
dfs_use_lock(uint32_t lockId);
121
void
dfs_setDefaultFileDateTime(
struct
tm
*
tm
);
122
123
#endif
_SD_Params
Definition:
sd.h:105
_SD_ParallelDeMUX
Definition:
sd.h:88
tm
Definition:
thread.h:39
_SD_ConfigWords
Definition:
sd.h:99
_SD_SerialDeMUX
Definition:
sd.h:78
_SD_SingleSPI
Definition:
sd.h:70
Generated on Fri May 20 2022 16:48:01 for PropWare by
1.8.17