ESP32-PaxCounter/include/sdcard.h

71 lines
1.2 KiB
C
Raw Permalink Normal View History

2019-12-25 23:07:34 +01:00
#ifndef _SDCARD_H
#define _SDCARD_H
2022-02-22 13:11:46 +01:00
#if (HAS_SDCARD)
2022-01-30 15:25:46 +01:00
#include "globals.h"
2019-12-25 23:07:34 +01:00
#include <stdio.h>
#include <SPI.h>
2022-02-26 17:30:23 +01:00
#include "esp_vfs_fat.h"
#include "sdmmc_cmd.h"
#define MOUNT_POINT "/sdcard"
2020-05-16 15:30:05 +02:00
2022-02-28 22:39:25 +01:00
#if HAS_SDCARD == 1 // SPI interface
2022-02-26 17:30:23 +01:00
#include "driver/sdspi_host.h"
2020-03-29 18:08:52 +02:00
2020-05-16 15:30:05 +02:00
#ifndef SDCARD_CS
#define SDCARD_CS SS
#endif
#ifndef SDCARD_MOSI
#define SDCARD_MOSI MOSI
#endif
#ifndef SDCARD_MISO
#define SDCARD_MISO MISO
#endif
#ifndef SDCARD_SCLK
#define SDCARD_SCLK SCK
#endif
2022-02-28 22:39:25 +01:00
#elif HAS_SDCARD == 2 // MMC interface
#include "driver/sdmmc_host.h"
2022-10-31 16:19:56 +01:00
#ifndef SDCARD_SLOTCONFIG
#define SDCARD_SLOTCONFIG SDMMC_SLOT_CONFIG_DEFAULT()
#endif
2022-02-28 22:39:25 +01:00
#ifndef SDCARD_SLOTWIDTH
#define SDCARD_SLOTWIDTH 1
#endif
#ifndef SDCARD_PULLUP
#define SDCARD_PULLUP SDMMC_SLOT_FLAG_INTERNAL_PULLUP
#endif
#else
#error HAS_SDCARD unknown card reader value, must be either 1 or 2
#endif
#ifdef HAS_SDS011
#include "sds011read.h"
#endif
2022-01-30 15:25:46 +01:00
#define SDCARD_FILE_NAME clientId
#define SDCARD_FILE_HEADER "timestamp,wifi,ble"
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
#define SDCARD_FILE_HEADER_VOLTAGE ",voltage"
#endif
2019-12-25 23:07:34 +01:00
2022-01-29 13:47:59 +01:00
bool sdcard_init(bool create = true);
2022-02-26 17:30:23 +01:00
void sdcard_flush(void);
2022-01-30 15:25:46 +01:00
void sdcard_close(void);
void sdcardWriteData(uint16_t, uint16_t, uint16_t = 0);
2019-12-25 23:07:34 +01:00
2022-02-22 13:11:46 +01:00
#endif
#endif // _SDCARD_H