Files
tonberry-pico/software/modules/rp2_sd/sd.h
Matthias Blankertz aa41334ba7
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m45s
Check code formatting / Check-C-Format (push) Successful in 6s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
feat: Add SD multiblock write support
Add support for CMD25 to write multiple sequential blocks in one go, in
an attempt to speed up uploads. It still needs to be benchmarked if this
actually results in a meaningful speedup.

Also fix logging from SD driver to be visible even when running under
micropython.

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
2026-01-13 22:41:34 +01:00

28 lines
928 B
C

#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define SD_SECTOR_SIZE 512
struct sd_context {
size_t blocks;
size_t blocksize;
bool initialized;
bool old_card;
bool sdhc_sdxc;
};
bool sd_init(struct sd_context *context, int mosi, int miso, int sck, int ss, int rate);
bool sd_deinit(struct sd_context *sd_context);
bool sd_readblock(struct sd_context *context, size_t sector_num, uint8_t buffer[static SD_SECTOR_SIZE]);
bool sd_readblock_start(struct sd_context *context, size_t sector_num, uint8_t buffer[static SD_SECTOR_SIZE]);
bool sd_readblock_complete(struct sd_context *context);
bool sd_readblock_is_complete(struct sd_context *context);
bool sd_writeblock(struct sd_context *context, size_t sector_num, uint8_t buffer[const static SD_SECTOR_SIZE]);
bool sd_writeblocks(struct sd_context *sd_context, const size_t sector_num, const size_t sectors, uint8_t *buffer);