-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtf_card.h
47 lines (39 loc) · 1.26 KB
/
tf_card.h
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
#pragma once
#include "hardware/spi.h"
#include "hardware/clocks.h"
#define CLK_SLOW_DEFAULT (100 * KHZ)
#define CLK_FAST_DEFAULT (50 * MHZ)
// CLK_FAST: actually set to clk_peri (= 125.0 MHz) / N,
// which is determined by spi_set_baudrate() in pico-sdk/src/rp2_common/hardware_spi/spi.c
/* SPI pin assignment */
#define PIN_SPI0_MISO_DEFAULT 4 // 0, 4, 16
#define PIN_SPI0_CS_DEFAULT 5 // 1, 5, 17
#define PIN_SPI0_SCK_DEFAULT 2 // 2, 6, 18
#define PIN_SPI0_MOSI_DEFAULT 3 // 3, 7, 19
#define PIN_SPI1_MISO_DEFAULT 8 // 8, 12
#define PIN_SPI1_CS_DEFAULT 9 // 9, 13
#define PIN_SPI1_SCK_DEFAULT 10 // 10, 14
#define PIN_SPI1_MOSI_DEFAULT 11 // 11, 15
typedef struct _pico_fatfs_spi_config_t {
spi_inst_t *spi_inst; // spi0 or spi1
uint clk_slow;
uint clk_fast;
uint pin_miso;
uint pin_cs;
uint pin_sck;
uint pin_mosi;
bool pullup; // miso, mosi pins only
} pico_fatfs_spi_config_t;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Set configuration
*
* @param[in] config the pointer of pico_fatfs_spi_config_t to configure with
*/
void pico_fatfs_set_config(pico_fatfs_spi_config_t *config);
int pico_fatfs_reboot_spi(void);
#ifdef __cplusplus
}
#endif