SDSPICC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
52 #ifndef ti_drivers_sdspi_SDSPICC32XX__include
53 #define ti_drivers_sdspi_SDSPICC32XX__include
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #include <stdint.h>
60 #include <ti/drivers/SDSPI.h>
61 #include <ti/drivers/Power.h>
62 
63 #include <third_party/fatfs/ff.h>
64 #include <third_party/fatfs/diskio.h>
65 
66 #define SDSPICC32XX_GPIO0 (0x00 << 16)
67 #define SDSPICC32XX_GPIO1 (0x01 << 16)
68 #define SDSPICC32XX_GPIO2 (0x02 << 16)
69 #define SDSPICC32XX_GPIO3 (0x03 << 16)
70 #define SDSPICC32XX_GPIO4 (0x04 << 16)
71 #define SDSPICC32XX_GPIO5 (0x05 << 16)
72 #define SDSPICC32XX_GPIO6 (0x06 << 16)
73 #define SDSPICC32XX_GPIO7 (0x07 << 16)
74 #define SDSPICC32XX_GPIO8 (0x10 << 16)
75 #define SDSPICC32XX_GPIO9 (0x11 << 16)
76 #define SDSPICC32XX_GPIO10 (0x12 << 16)
77 #define SDSPICC32XX_GPIO11 (0x13 << 16)
78 #define SDSPICC32XX_GPIO12 (0x14 << 16)
79 #define SDSPICC32XX_GPIO13 (0x15 << 16)
80 #define SDSPICC32XX_GPIO14 (0x16 << 16)
81 #define SDSPICC32XX_GPIO15 (0x17 << 16)
82 #define SDSPICC32XX_GPIO16 (0x20 << 16)
83 #define SDSPICC32XX_GPIO17 (0x21 << 16)
84 #define SDSPICC32XX_GPIO18 (0x22 << 16)
85 #define SDSPICC32XX_GPIO19 (0x23 << 16)
86 #define SDSPICC32XX_GPIO20 (0x24 << 16)
87 #define SDSPICC32XX_GPIO21 (0x25 << 16)
88 #define SDSPICC32XX_GPIO22 (0x26 << 16)
89 #define SDSPICC32XX_GPIO23 (0x27 << 16)
90 #define SDSPICC32XX_GPIO24 (0x30 << 16)
91 #define SDSPICC32XX_GPIO25 (0x31 << 16)
92 #define SDSPICC32XX_GPIO26 (0x32 << 16)
93 #define SDSPICC32XX_GPIO27 (0x33 << 16)
94 #define SDSPICC32XX_GPIO28 (0x34 << 16)
95 #define SDSPICC32XX_GPIO29 (0x35 << 16)
96 #define SDSPICC32XX_GPIO30 (0x36 << 16)
97 #define SDSPICC32XX_GPIO31 (0x37 << 16)
98 
99 #define SDSPICC32XX_GPIONONE (0xFF << 16)
100 
101 /*
102  * We need to encode a pin's GPIO function along with the SPI function,
103  * since certain SPI functions need to be handled via manual programming
104  * of a GPIO pin.
105  *
106  * PIN_62 is special for the SDSPI driver when using an SD Boosterpack,
107  * as PIN_62 doesn't have an assigned SPI function yet the SD Boosterpack
108  * has it tied to the CS signal.
109  */
110 #define SDSPICC32XX_PIN_05_CLK 0x0704
111 #define SDSPICC32XX_PIN_06_MISO 0x0705
112 #define SDSPICC32XX_PIN_07_MOSI 0x0706
113 #define SDSPICC32XX_PIN_08_CS (SDSPICC32XX_GPIO17 | 0x0707)
114 #define SDSPICC32XX_PIN_62_GPIO (SDSPICC32XX_GPIO7 | 0x003d)
115 #define SDSPICC32XX_PIN_45_CLK 0x072c
116 #define SDSPICC32XX_PIN_50_CS (SDSPICC32XX_GPIO0 | 0x0931)
117 #define SDSPICC32XX_PIN_52_MOSI 0x0833
118 #define SDSPICC32XX_PIN_53_MISO 0x0734
119 
130 /* Add SDSPICC32XX_STATUS_* macros here */
131 
144 /* Add SDSPICC32XX_CMD_* macros here */
145 
148 typedef unsigned long SDSPIBaseAddrType;
149 typedef unsigned long SDSPIDataType;
150 
151 /* SDSPI function table */
153 
157 typedef enum SDSPICC32XX_CardType {
163 
210 typedef struct SDSPICC32XX_HWAttrsV1 {
212  uint32_t baseAddr;
214  uint32_t spiPRCM;
216  uint32_t clkPin;
218  uint32_t mosiPin;
220  uint32_t misoPin;
222  uint32_t csPin;
224 
230 typedef struct SDSPICC32XX_Object {
231  uint32_t driveNumber; /* Drive number used by FatFs */
232  DSTATUS diskState; /* Disk status */
233  SDSPICC32XX_CardType cardType; /* SDCard Card Command Class (CCC) */
234  uint32_t bitRate; /* SPI bus bit rate (Hz) */
235  FATFS filesystem; /* FATFS data object */
236  uint_fast16_t spiPowerMgrId; /* Determined from base address */
237  uint_fast16_t gpioCsPowerMgrId; /* Determined from base address */
238  Power_NotifyObj postNotify; /* LPDS wake-up notify object */
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 #endif /* ti_drivers_sdspi_SDSPICC32XX__include */
uint32_t mosiPin
Definition: SDSPICC32XX.h:218
uint_fast16_t gpioCsPowerMgrId
Definition: SDSPICC32XX.h:237
uint32_t clkPin
Definition: SDSPICC32XX.h:216
unsigned long SDSPIBaseAddrType
Definition: SDSPICC32XX.h:148
Definition: SDSPICC32XX.h:158
uint32_t baseAddr
Definition: SDSPICC32XX.h:212
Power manager interface.
Power notify object structure.
Definition: Power.h:113
Definition: SDSPICC32XX.h:160
struct SDSPICC32XX_Object SDSPICC32XX_Object
SDSPICC32XX Object.
uint_fast16_t spiPowerMgrId
Definition: SDSPICC32XX.h:236
DSTATUS diskState
Definition: SDSPICC32XX.h:232
Definition: SDSPICC32XX.h:159
Power_NotifyObj postNotify
Definition: SDSPICC32XX.h:238
uint32_t misoPin
Definition: SDSPICC32XX.h:220
SDSPI driver interface.
SDSPICC32XX Object.
Definition: SDSPICC32XX.h:230
struct SDSPICC32XX_HWAttrsV1 SDSPICC32XX_HWAttrsV1
uint32_t csPin
Definition: SDSPICC32XX.h:222
struct SDSPICC32XX_Object * SDSPICC32XX_Handle
uint32_t bitRate
Definition: SDSPICC32XX.h:234
The definition of a SDSPI function table that contains the required set of functions to control a spe...
Definition: SDSPI.h:316
Definition: SDSPICC32XX.h:210
uint32_t driveNumber
Definition: SDSPICC32XX.h:231
SDSPICC32XX_CardType
SD Card type inserted.
Definition: SDSPICC32XX.h:157
SDSPICC32XX_CardType cardType
Definition: SDSPICC32XX.h:233
unsigned long SDSPIDataType
Definition: SDSPICC32XX.h:149
Definition: SDSPICC32XX.h:161
FATFS filesystem
Definition: SDSPICC32XX.h:235
const SDSPI_FxnTable SDSPICC32XX_fxnTable
uint32_t spiPRCM
Definition: SDSPICC32XX.h:214
Copyright 2017, Texas Instruments Incorporated