SDHostCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019, 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  */
32 
33 /*!***************************************************************************
34  * @file SDHostCC32XX.h
35  * @brief SDHost driver implementation for CC32XX devices.
36  *
37  * The SDHost header file should be included in an application as follows:
38  * @code
39  * #include <ti/drivers/SD.h>
40  * #include <ti/drivers/sd/SDHostCC32XX.h>
41  * @endcode
42  *
43  * Refer to @ref SD.h for a complete description of APIs & example of use.
44  *
45  * This SDHost driver implementation is designed to operate on a CC32XX
46  * SD Host controller using a micro DMA controller.
47  *
48  * Note: The driver API's are not thread safe and must not be accessed through
49  * multiple threads without the use of mutexes.
50  *
51  * ## DMA buffer alignment #
52  *
53  * When performing disk operations with a word aligned buffer the driver will
54  * make transfers using the DMA controller. Alternatively, if the buffer is
55  * not aligned, the data will be copied to the internal SD Host controller
56  * buffer using a polling method.
57  *
58  * ## DMA Interrupts #
59  *
60  * When DMA is used, the micro DMA controller generates and IRQ on the
61  * perpheral's interrupt vector. This implementation automatically installs
62  * a DMA interrupt to service the assigned micro DMA channels.
63  *
64  * ## DMA accessible memory #
65  *
66  * When DMA is used, it is the responsibility of the application to ensure
67  * that read/write buffers reside in memory that is accessible by the DMA.
68  *
69  * <hr>
70  */
71 
72 #ifndef ti_drivers_sd_SDHostCC32XX__include
73 #define ti_drivers_sd_SDHostCC32XX__include
74 
75 #include <stdint.h>
76 #include <ti/drivers/SD.h>
77 
78 #include <ti/drivers/dpl/HwiP.h>
79 #include <ti/drivers/dpl/SemaphoreP.h>
80 #include <ti/drivers/Power.h>
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
88 #define SDHostCC32XX_PIN_06_SDCARD_DATA 0x0805
89 #define SDHostCC32XX_PIN_07_SDCARD_CLK 0x0806
90 #define SDHostCC32XX_PIN_08_SDCARD_CMD 0x0807
91 #define SDHostCC32XX_PIN_01_SDCARD_CLK 0x0600
92 #define SDHostCC32XX_PIN_02_SDCARD_CMD 0x0601
93 #define SDHostCC32XX_PIN_64_SDCARD_DATA 0x063f
94 
95 /* SDHost function table */
97 
133 typedef struct {
135  uint_fast32_t clkRate;
136 
138  int_fast32_t intPriority;
139 
141  uint_fast32_t baseAddr;
142 
144  unsigned long rxChIdx;
145 
147  unsigned long txChIdx;
148 
150  uint32_t dataPin;
151 
153  uint32_t cmdPin;
154 
156  uint32_t clkPin;
158 
164 typedef struct {
165  /* Relative Card Address */
166  volatile uint32_t rca;
167  /* Number of sectors written */
168  volatile uint32_t sectorCount;
169  /* Read data pointer */
170  volatile uint32_t *buffer;
171  /*
172  * Semaphore to suspend thread execution when waiting for SD Commands
173  * or data transfers to complete.
174  */
175  SemaphoreP_Handle cmdSem;
176  /* SD Card interrupt handle. */
177  HwiP_Handle hwiHandle;
178  /* UDMA Handle */
180  /* Determined from base address */
181  unsigned int powerMgrId;
182  /* LPDS wake-up notify object */
184  /* Previous park state SDCARD_CLK pin */
186  /* SDCARD_CLK pin */
187  uint16_t clkPin;
188  /* SD Card command state */
189  volatile int_fast8_t stat;
190  /* State of the driver (open or closed) */
191  bool isOpen;
192  /* Indicates if a DMA transfer is in a ping or pong state */
193  bool ping;
194  /* Indicates if a semaphore has been posted for a DMA event */
195  bool dmaPosted;
196  /* SDCard Card Command Class (CCC) */
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* ti_drivers_sd_SDHostCC32XX__include */
volatile int_fast8_t stat
Definition: SDHostCC32XX.h:189
SemaphoreP_Handle cmdSem
Definition: SDHostCC32XX.h:175
uint32_t clkPin
Definition: SDHostCC32XX.h:156
uint_fast32_t baseAddr
Definition: SDHostCC32XX.h:141
int_fast32_t intPriority
Definition: SDHostCC32XX.h:138
Power_NotifyObj postNotify
Definition: SDHostCC32XX.h:183
bool ping
Definition: SDHostCC32XX.h:193
Power Manager.
uint_fast32_t clkRate
Definition: SDHostCC32XX.h:135
SDHostCC32XX Object.
Definition: SDHostCC32XX.h:164
bool dmaPosted
Definition: SDHostCC32XX.h:195
uint32_t dataPin
Definition: SDHostCC32XX.h:150
SD_CardType cardType
Definition: SDHostCC32XX.h:197
uDMA driver implementation for CC32XX.
The definition of a SD function table that contains the required set of functions to control a specif...
Definition: SD.h:285
bool isOpen
Definition: SDHostCC32XX.h:191
UDMACC32XX Global configuration.
Definition: UDMACC32XX.h:125
volatile uint32_t sectorCount
Definition: SDHostCC32XX.h:168
Power manager interface for the CC32XX.
uint32_t cmdPin
Definition: SDHostCC32XX.h:153
Secure Digital (SD) Driver.
unsigned long txChIdx
Definition: SDHostCC32XX.h:147
UDMACC32XX_Handle dmaHandle
Definition: SDHostCC32XX.h:179
volatile uint32_t rca
Definition: SDHostCC32XX.h:166
Power notify object structure.
Definition: Power.h:443
HwiP_Handle hwiHandle
Definition: SDHostCC32XX.h:177
PowerCC32XX_ParkState prevParkCLK
Definition: SDHostCC32XX.h:185
uint16_t clkPin
Definition: SDHostCC32XX.h:187
SD_CardType
SD Card type inserted.
Definition: SD.h:197
volatile uint32_t * buffer
Definition: SDHostCC32XX.h:170
unsigned long rxChIdx
Definition: SDHostCC32XX.h:144
const SD_FxnTable sdHostCC32XX_fxnTable
Definition: SDHostCC32XX.h:133
unsigned int powerMgrId
Definition: SDHostCC32XX.h:181
PowerCC32XX_ParkState
Enumeration of states a pin can be parked in.
Definition: PowerCC32XX.h:385
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale