-
Notifications
You must be signed in to change notification settings - Fork 12
/
hw_config.c
83 lines (70 loc) · 2.5 KB
/
hw_config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* hw_config.c
Copyright 2021 Carl John Kugler III
Licensed under the Apache License, Version 2.0 (the License); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
*/
/*
This file should be tailored to match the hardware design.
See
https://github.com/carlk3/FreeRTOS-FAT-CLI-for-RPi-Pico#customizing-for-the-hardware-configuration */
/* Hardware configuration for Expansion Module Type A
See https://oshwlab.com/carlk3/rpi-pico-sd-card-expansion-module-1
*/
#include "hw_config.h"
/* SDIO Interface */
static sd_sdio_if_t sdio_if = {
/*
Pins CLK_gpio, D1_gpio, D2_gpio, and D3_gpio are at offsets from pin D0_gpio.
The offsets are determined by sd_driver\SDIO\rp2040_sdio.pio.
CLK_gpio = (D0_gpio + SDIO_CLK_PIN_D0_OFFSET) % 32;
As of this writing, SDIO_CLK_PIN_D0_OFFSET is 30,
which is -2 in mod32 arithmetic, so:
CLK_gpio = D0_gpio -2.
D1_gpio = D0_gpio + 1;
D2_gpio = D0_gpio + 2;
D3_gpio = D0_gpio + 3;
*/
.CMD_gpio = 3,
.D0_gpio = 4
};
// Hardware Configuration of the SD Card socket "object"
static sd_card_t sd_card = {
// "device_name" is arbitrary:
.device_name = "sd0",
// "mount_point" must be a directory off the file system's root directory and must be an
// absolute path:
.mount_point = "/sd0",
.type = SD_IF_SDIO,
.sdio_if_p = &sdio_if,
// SD Card detect:
.use_card_detect = true,
.card_detect_gpio = 9,
.card_detected_true = 0 // What the GPIO read returns when a card is present.
};
/* ********************************************************************** */
/**
* @brief Returns the number of sd_card_t objects that are available.
* @return The number of sd_card_t objects.
*/
size_t sd_get_num(void) {
return 1;
}
/**
* @brief Return the sd_card_t object at the given index (0-based).
* @param num The index of the sd_card_t object.
* @return Pointer to the sd_card_t object at the given index if it exists, NULL otherwise.
*/
sd_card_t *sd_get_by_num(size_t num) {
if (0 == num) {
return &sd_card;
} else {
return NULL;
}
}
/* [] END OF FILE */