Commit e91eab80 by tatsukiishikawa

updating sd_card_example

parent f407a506
......@@ -15,7 +15,7 @@ endif()
cmake_minimum_required(VERSION 3.13)
set(PICO_BOARD pico_w CACHE STRING "Board type")
set(PROGRAM_NAME imu_data_logger)
set(PROGRAM_NAME sd_card_example)
include(pico_sdk_import.cmake)
......@@ -59,17 +59,30 @@ set_property(TARGET ${PROGRAM_NAME} APPEND_STRING PROPERTY LINK_FLAGS
)
pico_set_program_name(${PROGRAM_NAME} "${PROGRAM_NAME}")
pico_set_program_version(${PROGRAM_NAME} "3.3.1")
pico_set_program_version(${PROGRAM_NAME} "0.1")
pico_enable_stdio_uart(${PROGRAM_NAME} 0)
pico_enable_stdio_usb(${PROGRAM_NAME} 1)
target_include_directories(${PROGRAM_NAME} PUBLIC
include/
)
target_link_libraries(${PROGRAM_NAME}
pico_stdlib
hardware_i2c
pico_multicore
pico_util
sd_custom_driver
hardware_clocks
hardware_adc
hardware_pio
)
# Add the standard include files to the build
target_include_directories(${PROGRAM_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}
)
pico_add_extra_outputs(${PROGRAM_NAME})
#include <stdio.h>
#include <string.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#include "ff.h"
#include "sd_card.h"
#include "f_util.h"
......@@ -167,9 +169,8 @@ static FRESULT check_and_list_files(const char *root_drive) {
}
// ------------------------------ Main -------------------------------------
int main(void) {
stdio_init_all();
sleep_ms(1500);
void core1_entry() {
// 1) Init + mount
if (!sd_init_and_mount()) {
......@@ -178,7 +179,7 @@ int main(void) {
// Build absolute file path: <drive>/test.txt
char path[PATH_MAX_LEN];
join_path(path, sizeof path, g_drive, "test1.txt");
join_path(path, sizeof path, g_drive, "test3.txt");
// 2) Create the file
FIL f;
......@@ -186,7 +187,7 @@ int main(void) {
if (fr != FR_OK) die(fr, "f_open(create)");
// 3) Write data
const char *msg = "data writing test!\n";
const char *msg = "data blahblah test!\n";
UINT bw = 0;
fr = write_to_file(&f, msg, (UINT)strlen(msg), &bw);
if (fr != FR_OK || bw != strlen(msg)) die(fr, "f_write/f_sync");
......@@ -203,5 +204,15 @@ int main(void) {
fr = f_unmount(g_drive);
printf("f_unmount -> %s (%d)\n", FRESULT_str(fr), fr);
while (1) { tight_loop_contents(); }
}
int main(void) {
stdio_init_all();
sleep_ms(3000);
multicore_launch_core1(core1_entry);
while (1) { sleep_ms(1000); }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment