MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
sdhc.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  *************************************************************************** */
38 
39 /* Define to prevent redundant inclusion */
40 #ifndef _SDHC_H_
41 #define _SDHC_H_
42 
43 /* **** Includes **** */
44 #include "mxc_device.h"
45 #include "sdhc_regs.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
57 /* **** Definitions **** */
58 #define MXC_SDHC_Bus_Voltage_1_8 5
59 #define MXC_SDHC_Bus_Voltage_3_0 6
60 #define MXC_SDHC_Bus_Voltage_3_3 7
61 
62 #define MXC_SDHC_DIRECTION_CFG 0
63 #define MXC_SDHC_DIRECTION_READ 1
64 #define MXC_SDHC_DIRECTION_WRITE 2
65 
70 typedef struct {
71  unsigned int bus_voltage;
72  unsigned int block_gap;
73  unsigned int clk_div;
75 
86 typedef void (*mxc_sdhc_callback_fn) (int error_code);
87 
92 typedef struct {
93  uint32_t sdma;
94  uint32_t block_size;
95  uint32_t block_count;
96  uint32_t arg_1;
97  unsigned int dma;
98  unsigned int direction;
99  uint32_t command;
100  uint32_t host_control_1;
103 
104 /* **** Function Prototypes **** */
105 
113 int MXC_SDHC_Init (const mxc_sdhc_cfg_t *cfg);
114 
118 void MXC_SDHC_PowerUp (void);
119 
123 void MXC_SDHC_PowerDown (void);
124 
131 int MXC_SDHC_Shutdown (void);
132 
137 void MXC_SDHC_Set_Clock_Config (unsigned int clk_div);
138 
146 unsigned int MXC_SDHC_Get_Clock_Config (void);
147 
166 
176 void MXC_SDHC_Handler (void);
177 
184 
191 void MXC_SDHC_ClearFlags (uint32_t mask);
192 
199 unsigned MXC_SDHC_GetFlags (void);
200 
205 void MXC_SDHC_Reset (void);
206 
212 
219 
225 unsigned int MXC_SDHC_Get_Host_Cn_1 (void);
226 
233 uint32_t MXC_SDHC_Get_Response32 (void);
234 
242 
249 void MXC_SDHC_Get_Response128 (unsigned char *response);
250 
253 #ifdef __cplusplus
254 }
255 #endif
256 
257 #endif /* _SDHC_H_ */
MXC_SDHC_Get_Host_Cn_1
unsigned int MXC_SDHC_Get_Host_Cn_1(void)
Retrieve host control 1 register.
MXC_SDHC_Get_Response32
uint32_t MXC_SDHC_Get_Response32(void)
Read a 32-bit command response.
MXC_SDHC_Init
int MXC_SDHC_Init(const mxc_sdhc_cfg_t *cfg)
Initialize and enable SDHC module.
mxc_sdhc_cmd_cfg_t::arg_1
uint32_t arg_1
Definition: sdhc.h:96
MXC_SDHC_PowerUp
void MXC_SDHC_PowerUp(void)
Enable SDHC Bus Power.
mxc_sdhc_cmd_cfg_t::command
uint32_t command
Definition: sdhc.h:99
MXC_SDHC_Reset_CMD_DAT
void MXC_SDHC_Reset_CMD_DAT(void)
Abort any command or data transaction in progress on controller.
mxc_sdhc_callback_fn
void(* mxc_sdhc_callback_fn)(int error_code)
Callback function type used in asynchromous SDHC communications requests.
Definition: sdhc.h:86
mxc_sdhc_cmd_cfg_t::block_count
uint32_t block_count
Definition: sdhc.h:95
MXC_SDHC_ClearFlags
void MXC_SDHC_ClearFlags(uint32_t mask)
Clear interrupt flags.
MXC_SDHC_Get_Response32_Auto
uint32_t MXC_SDHC_Get_Response32_Auto(void)
Read a 32-bit command response for Auto commands.
MXC_SDHC_PowerDown
void MXC_SDHC_PowerDown(void)
Disable SDHC Bus Power.
mxc_sdhc_cfg_t::bus_voltage
unsigned int bus_voltage
Definition: sdhc.h:71
mxc_sdhc_cfg_t::clk_div
unsigned int clk_div
Definition: sdhc.h:73
MXC_SDHC_SendCommand
int MXC_SDHC_SendCommand(mxc_sdhc_cmd_cfg_t *sd_cmd_cfg)
Send Command, blocking.
mxc_sdhc_cfg_t
Used to configure voltage and clock for sdhc interface.
Definition: sdhc.h:70
mxc_sdhc_cmd_cfg_t::host_control_1
uint32_t host_control_1
Definition: sdhc.h:100
MXC_SDHC_Card_Busy
int MXC_SDHC_Card_Busy(void)
Check if Card is busy.
mxc_sdhc_cmd_cfg_t::direction
unsigned int direction
Definition: sdhc.h:98
MXC_SDHC_Set_Clock_Config
void MXC_SDHC_Set_Clock_Config(unsigned int clk_div)
Set clock divider.
mxc_sdhc_cfg_t::block_gap
unsigned int block_gap
Definition: sdhc.h:72
mxc_sdhc_cmd_cfg_t::sdma
uint32_t sdma
Definition: sdhc.h:93
MXC_SDHC_SendCommandAsync
int MXC_SDHC_SendCommandAsync(mxc_sdhc_cmd_cfg_t *sd_cmd_cfg)
Send SDHC command Async.
MXC_SDHC_Shutdown
int MXC_SDHC_Shutdown(void)
Shutdown SDHC module.
MXC_SDHC_Get_Clock_Config
unsigned int MXC_SDHC_Get_Clock_Config(void)
Get clock divider.
MXC_SDHC_Card_Inserted
int MXC_SDHC_Card_Inserted(void)
See if card is inserted.
mxc_sdhc_cmd_cfg_t::callback
mxc_sdhc_callback_fn callback
Definition: sdhc.h:101
mxc_sdhc_cmd_cfg_t::dma
unsigned int dma
Definition: sdhc.h:97
MXC_SDHC_Get_Response128
void MXC_SDHC_Get_Response128(unsigned char *response)
Read a 128-bit command response.
MXC_SDHC_Handler
void MXC_SDHC_Handler(void)
SDHC interrupt handler.
MXC_SDHC_Reset
void MXC_SDHC_Reset(void)
Resets SDHC back to default settings.
mxc_sdhc_cmd_cfg_t::block_size
uint32_t block_size
Definition: sdhc.h:94
mxc_sdhc_cmd_cfg_t
Used to configure sdhc interface.
Definition: sdhc.h:92
MXC_SDHC_GetFlags
unsigned MXC_SDHC_GetFlags(void)
Get interrupt flags.