NetBurner 3.5.0
PDF Version
sdhc_mcf.h
1
/*NB_REVISION*/
2
3
/*NB_COPYRIGHT*/
4
5
#ifndef _SDHC_H_
6
#define _SDHC_H_
7
8
#include "fat.h"
9
//#include "common.h"
10
#include "effs_fat/common.h"
11
12
#ifdef __cplusplus
13
extern
"C"
14
{
15
#endif
16
17
// Logging levels
18
#define SDHC_LOG_LEVEL_OFF (0)
19
#define SDHC_LOG_LEVEL_INFO (1)
20
#define SDHC_LOG_LEVEL_WARNING (2)
21
#define SDHC_LOG_LEVEL_ERROR (3)
22
#define SDHC_LOG_LEVEL_DEBUG (4)
23
24
#ifdef _DEBUG
25
//#undef SDHC_LOG_LEVEL
26
#define SDHC_LOG_LEVEL SDHC_LOG_LEVEL_DEBUG
// Secify appropriate logging level here if required
27
#else
28
//#define SDHC_LOG_LEVEL SDHC_LOG_LEVEL_DEBUG // Secify appropriate logging level here if required
29
#define SDHC_LOG_LEVEL SDHC_LOG_LEVEL_OFF
// Secify appropriate logging level here if required
30
#endif
31
32
#define IsLogEnabled(x) (SDHC_LOG_LEVEL >= x)
33
34
#if defined(SDHC_LOG_LEVEL) && (SDHC_LOG_LEVEL != SDHC_LOG_LEVEL_OFF)
35
36
#include <stdio.h>
37
38
#if (SDHC_LOG_LEVEL >= SDHC_LOG_LEVEL_INFO)
39
#define SDHC_LOG_INFO(args...) iprintf(args)
40
#else
41
#define SDHC_LOG_INFO(args...)
42
#endif
43
44
#if (SDHC_LOG_LEVEL >= SDHC_LOG_LEVEL_WARNING)
45
#define SDHC_LOG_WARNING(args...) iprintf(args)
46
#else
47
#define SDHC_LOG_WARNING(...)
48
#endif
49
50
#if (SDHC_LOG_LEVEL >= SDHC_LOG_LEVEL_ERROR)
51
#define SDHC_LOG_ERROR(args...) iprintf(args)
52
#else
53
#define SDHC_LOG_ERROR(...)
54
#endif
55
56
#if (SDHC_LOG_LEVEL >= SDHC_LOG_LEVEL_DEBUG)
57
#define SDHC_LOG_DEBUG(args...) iprintf(args)
58
#else
59
#define SDHC_LOG_DEBUG(...)
60
#endif
61
62
#else
63
#define SDHC_LOG_INFO(...)
64
#define SDHC_LOG_WARNING(...)
65
#define SDHC_LOG_ERROR(...)
66
#define SDHC_LOG_DEBUG(...)
67
#endif
68
69
#define SDHC_LOG_LINE SDHC_LOG_DEBUG("Got to line %d in file %s\r\n", __LINE__, __FILE__);
70
#define SDHC_LOG_FUNC(args...) \
71
{ \
72
SDHC_LOG_DEBUG("%s: ", __FUNCTION__); \
73
SDHC_LOG_DEBUG(args); \
74
}
75
#define SDHC_LOG_TICK(args...)
// SDHC_LOG_INFO("%s: %lu, %s\n\r", __FUNCTION__, TimeTick, args);
76
77
#define MAX_SDHC_DRIVES (1)
78
#define F_SDHC_DRIVE0 0
79
//#define F_SDHC_AUTOASSIGN -1
80
81
//#define ENABLE_HIGH_SPEED_MODE (1) // Uncomment to enable High Speed Mode if supported
82
//#define ENABLE_PREERASE (1) // Enables execution of pre-erase command (can increase write speed on some cards)
83
//#define ENABLE_BLOCS_COUNT_CMD (1)
84
#define ESDHC_ENDIAN_CONVERSION (1)
// Must be define to make card format compatible with PC
85
86
#define CMD_RETRIES_COUNT 1
87
#define DAT_RETRIES_COUNT 3
88
#define SECTOR_SIZE ((uint32_t)F_SECTOR_SIZE)
89
#define RW_BUFF_SECTORS (128UL)
90
91
#define INIT_BAUDRATE (100000UL)
// Hz
92
#ifdef __MIMXRT10xx__
93
#define WORK_BAUDRATE (50000000UL)
// Hz
94
#else
95
#define WORK_BAUDRATE (25000000UL)
// Hz
96
#endif
97
#define HIGHSPED_BAUDRATE (31250000)
//(50000000UL)
98
99
#define ESDHC_IRQ_LEVEL (5U)
// Defines the IRQ level of ESDHC interrupt routine 0-6, 0 - auto
100
101
int
sdhc_init(
int
drv);
/* Init SDHC drive */
102
int
sdhc_close(
int
drv);
/* Init SDHC drive */
103
104
int
sdhc_read(
int
drv,
void
*buff,
unsigned
long
sector,
unsigned
int
count);
/* Read data from SDHC device */
105
int
sdhc_write(
int
drv,
void
*buff,
unsigned
long
sector,
unsigned
int
count);
/* Write data to SDHC device*/
106
int
sdhc_get_cd(
int
drv);
/* Get Card Detect state */
107
int
sdhc_get_wp(
int
drv);
/* Get Write Protect state */
108
int
sdhc_check_card_status(
int
drv);
109
void
sdhc_init_card(
int
drv);
110
unsigned
long
sdhc_get_card_size(
int
drv);
111
112
extern
F_DRIVER *sdhc_initfunc(
unsigned
long
driver_param);
113
114
enum
115
{
116
SDHC_NO_ERROR,
117
SDHC_ERR_NOTINITIALIZED = 101,
118
SDHC_ERR_INIT,
119
SDHC_ERROR,
// A general or an unknown error occurred during the operation
120
SDHC_ERR_CMD,
121
SDHC_ERR_TIMEOUT,
122
SDHC_ERR_BUSY,
123
SDHC_ERR_CRC,
124
SDHC_ERR_READ,
125
SDHC_ERR_WRITE,
126
SDHC_ERR_WRITEPROTECT,
127
SDHC_ERR_LOCKED,
128
SDHC_ERR_NOTAVAILABLE
129
};
130
131
#ifdef __cplusplus
132
}
133
#endif
134
135
/******************************************************************************
136
*
137
* end of sdhc_mcf.h
138
*
139
*****************************************************************************/
140
141
#endif
/* _SDHC_H_ */