Skip to content

Commit

Permalink
Merge pull request #50 from carlk3/dev
Browse files Browse the repository at this point in the history
Restore example/hw_config.c to agree with README
  • Loading branch information
carlk3 authored Feb 24, 2023
2 parents df893d1 + 0ac1480 commit 26c77f6
Show file tree
Hide file tree
Showing 63 changed files with 70 additions and 49 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/CMakeLists.txt
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/LICENSE.txt
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/css_e.css
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/res/app1.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/res/app2.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/res/app3.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/res/app4.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/res/app5.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/documents/res/app6.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/00history.txt
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/00readme.txt
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/diskio.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/diskio.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/ff.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/ff.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/ffconf.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/ffsystem.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/ff15/source/ffunicode.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/include/f_util.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/include/ff_stdio.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/include/my_debug.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/include/rtc.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/include/util.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/crc.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/crc.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/demo_logging.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/hw_config.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/sd_card.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/sd_card.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/sd_spi.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/sd_spi.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/spi.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/sd_driver/spi.h
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/src/f_util.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/src/ff_stdio.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/src/glue.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/src/my_debug.c
100644 → 100755
Empty file.
Empty file modified FatFs_SPI/src/rtc.c
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
7 changes: 6 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ On a SanDisk Class 4 16 GB card, I have been able to push the SPI baud rate as f
## Prerequisites:
* Raspberry Pi Pico
* Something like the [Adafruit Micro SD SPI or SDIO Card Breakout Board](https://www.adafruit.com/product/4682)[^3] or [SparkFun microSD Transflash Breakout](https://www.sparkfun.com/products/544)

***Warning***: Stay away from Aduino breakout boards like these: [Micro SD Storage Board Micro SD Card Modules](https://smile.amazon.com/gp/product/B07XF4Q1TT/). They are designed for 5 V Arduino signals. They use simple resistor dividers to drop the signal voltage, and will not work with the 3.3 V Raspberry Pi Pico. There's usually no easy way to bypass the resistors.

Some people have made micro SD card sockets by soldering pins onto old SD Card adapters.

* Breadboard and wires
* Raspberry Pi Pico C/C++ SDK
* (Optional) A couple of ~5-10kΩ resistors for pull-ups
* (Optional) A couple of ~100 pF capacitors for decoupling
* (Optional) A couple of capacitors for decoupling. Ideally, use three capacitors: 10 uF, 0.1 uF (100 nF), and .001 uF (1 nF) on the Vdd line to the of the SD card, located close to the socket. (The Adafruit board already has the 10 uF and 0.1 uF: [Schematic](https://learn.adafruit.com/assets/93596).)

![image](https://github.com/carlk3/FreeRTOS-FAT-CLI-for-RPi-Pico/blob/master/images/IMG_1478.JPG "Prototype")

Expand Down
2 changes: 2 additions & 0 deletions dynamic_config_example/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ target_link_libraries(dynamic_config_example
FatFs_SPI
)

# add_compile_definitions(CARD2)

pico_add_extra_outputs(dynamic_config_example)

Empty file modified dynamic_config_example/dynamic_config_example.cpp
100644 → 100755
Empty file.
Empty file modified dynamic_config_example/hw_config.cpp
100644 → 100755
Empty file.
Empty file modified dynamic_config_example/pico_sdk_import.cmake
100644 → 100755
Empty file.
Empty file modified dynamic_config_example/thing_plus.dynamic_config_example.cpp
100644 → 100755
Empty file.
Empty file modified example/CMakeLists.txt
100644 → 100755
Empty file.
Empty file modified example/FatFS_SPI_example.cpp
100644 → 100755
Empty file.
Empty file modified example/data_log_demo.c
100644 → 100755
Empty file.
63 changes: 35 additions & 28 deletions example/hw_config.c
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* 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
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
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.
*/
/*
Expand All @@ -35,40 +35,47 @@ socket, which SPI it is driven by, and how it is wired.
//
#include "diskio.h" /* Declarations of disk functions */

/*
This example assumes the following hardware configuration:
| | SPI0 | GPIO | Pin | SPI | MicroSD | Description |
| ----- | ---- | ----- | --- | -------- | --------- | ---------------------- |
| MISO | RX | 16 | 21 | DO | DO | Master In, Slave Out |
| MOSI | TX | 19 | 25 | DI | DI | Master Out, Slave In |
| SCK | SCK | 18 | 24 | SCLK | CLK | SPI clock |
| CS0 | CSn | 17 | 22 | SS or CS | CS | Slave (or Chip) Select |
| DET | | 22 | 29 | | CD | Card Detect |
| GND | | | 18,23 | | GND | Ground |
| 3v3 | | | 36 | | 3v3 | 3.3 volt power |
*/

// Hardware Configuration of SPI "objects"
// Note: multiple SD cards can be driven by one SPI if they use different slave
// selects.
static spi_t spis[] = { // One for each SPI.
{
.hw_inst = spi1, // SPI component
.miso_gpio = 12, // GPIO number (not Pico pin number)
.mosi_gpio = 15,
.sck_gpio = 14,
.set_drive_strength = true,
.mosi_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA,
.sck_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA,
.hw_inst = spi0, // SPI component
.miso_gpio = 16, // GPIO number (not Pico pin number)
.mosi_gpio = 19,
.sck_gpio = 18,

// .baud_rate = 1000 * 1000,
//.baud_rate = 12500 * 1000, // The limitation here is SPI slew rate.
.baud_rate = 25 * 1000 * 1000, // Actual frequency: 20833333. Has
// worked for me with SanDisk.
}
};
// .baud_rate = 1000 * 1000
.baud_rate = 12500 * 1000
// .baud_rate = 25 * 1000 * 1000 // Actual frequency: 20833333.
}};

// Hardware Configuration of the SD Card "objects"
static sd_card_t sd_cards[] = { // One for each SD card
{
.pcName = "0:", // Name used to mount device
.spi = &spis[0], // Pointer to the SPI driving this card
.ss_gpio = 9, // The SPI slave select GPIO for this SD card
.set_drive_strength = true,
.ss_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA,
.ss_gpio = 17, // The SPI slave select GPIO for this SD card
.use_card_detect = true,
.card_detect_gpio = 13, // Card detect
.card_detected_true = 1 // What the GPIO read returns when a card is
// present.
}
};
.card_detect_gpio = 22, // Card detect
.card_detected_true = 1 // What the GPIO read returns when a card is
// present.
}};

/* ********************************************************************** */
size_t sd_get_num() { return count_of(sd_cards); }
Expand All @@ -81,7 +88,7 @@ sd_card_t *sd_get_by_num(size_t num) {
}
size_t spi_get_num() { return count_of(spis); }
spi_t *spi_get_by_num(size_t num) {
if (num <= sd_get_num()) {
if (num <= spi_get_num()) {
return &spis[num];
} else {
return NULL;
Expand Down
Empty file modified example/maker_pi_pico.hw_config.c
100644 → 100755
Empty file.
Empty file modified example/pico_sdk_import.cmake
100644 → 100755
Empty file.
Empty file modified example/tests/CreateAndVerifyExampleFiles.c
100644 → 100755
Empty file.
Empty file modified example/tests/app4-IO_module_function_checker.c
100644 → 100755
Empty file.
Empty file modified example/tests/big_file_test.c
100644 → 100755
Empty file.
Empty file modified example/tests/ff_stdio_tests_with_cwd.c
100644 → 100755
Empty file.
Empty file modified example/tests/simple.c
100644 → 100755
Empty file.
47 changes: 27 additions & 20 deletions example/thing_plus.hw_config.c
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* 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
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
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.
*/
/*
Expand All @@ -35,6 +35,20 @@ socket, which SPI it is driven by, and how it is wired.
//
#include "diskio.h" /* Declarations of disk functions */

/* This configuration is for the [SparkFun Thing Plus - RP2040](https://www.sparkfun.com/products/17745),
which has the following hardware configuration:
| | Old | | | | |
| Signal | term | spi0 | GPIO | Description | Controller/Peripheral (NEW) |
| --------------------------------- | ---- | ---- | ---- | -------------------------- | ------------------------------------ |
| DATA 0/CIPO (or Peripheral's SDO) | MISO | RX | 12 | Master In Slave Out (MISO) | Controller In, Peripheral Out (CIPO) |
| CMD/COPI (or Peripheral's SDI) | MOSI | TX | 15 | Master Out Slave In (MOSI) | Controller Out Peripheral In (COPI) |
| CLK/SCK | SCK | SCK | 14 | Serial Clock | |
| DATA 3/CS | SS | CSn | 9 | Slave Select pin (SS) | Chip Select Pin (CS) |
See [RP2040 Thing Plus Hookup Guide](https://learn.sparkfun.com/tutorials/rp2040-thing-plus-hookup-guide/hardware-overview).
*/

// Hardware Configuration of SPI "objects"
// Note: multiple SD cards can be driven by one SPI if they use different slave
// selects.
Expand All @@ -44,25 +58,18 @@ static spi_t spis[] = { // One for each SPI.
.miso_gpio = 12, // GPIO number (not pin number)
.mosi_gpio = 15,
.sck_gpio = 14,
.set_drive_strength = true,
.mosi_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA,
.sck_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA,

// .baud_rate = 1000 * 1000,
//.baud_rate = 12500 * 1000,
.baud_rate = 25 * 1000 * 1000, // Actual frequency: 20833333.
// .baud_rate = 1000 * 1000
//.baud_rate = 12500 * 1000
.baud_rate = 25 * 1000 * 1000 // Actual frequency: 20833333.
}};

// Hardware Configuration of the SD Card "objects"
static sd_card_t sd_cards[] = { // One for each SD card
{
.pcName = "0:", // Name used to mount device
.spi = &spis[0], // Pointer to the SPI driving this card
.ss_gpio = 9, // The SPI slave select GPIO for this SD card
.set_drive_strength = true,
.ss_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA
}
};
.pcName = "0:", // Name used to mount device
.spi = &spis[0], // Pointer to the SPI driving this card
.ss_gpio = 9 // The SPI slave select GPIO for this SD card

/* ********************************************************************** */
size_t sd_get_num() { return count_of(sd_cards); }
Expand All @@ -75,7 +82,7 @@ sd_card_t *sd_get_by_num(size_t num) {
}
size_t spi_get_num() { return count_of(spis); }
spi_t *spi_get_by_num(size_t num) {
if (num <= sd_get_num()) {
if (num <= spi_get_num()) {
return &spis[num];
} else {
return NULL;
Expand Down
Empty file modified simple_example/CMakeLists.txt
100644 → 100755
Empty file.
Empty file modified simple_example/hw_config.c
100644 → 100755
Empty file.
Empty file modified simple_example/pico_sdk_import.cmake
100644 → 100755
Empty file.
Empty file modified simple_example/simple_example.cpp
100644 → 100755
Empty file.
Empty file modified simple_example/thing_plus.hw_config.c
100644 → 100755
Empty file.

0 comments on commit 26c77f6

Please sign in to comment.