2019-12-25 23:07:34 +01:00
|
|
|
#ifndef _SDCARD_H
|
|
|
|
#define _SDCARD_H
|
|
|
|
|
|
|
|
#include <globals.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <SPI.h>
|
2020-05-16 15:30:05 +02:00
|
|
|
|
2020-09-01 11:33:17 +02:00
|
|
|
#if (HAS_SDCARD)
|
2020-05-16 15:30:05 +02:00
|
|
|
#if HAS_SDCARD == 1
|
2019-12-25 23:07:34 +01:00
|
|
|
#include <mySD.h>
|
2020-05-16 15:30:05 +02:00
|
|
|
#elif HAS_SDCARD == 2
|
|
|
|
#include <SD_MMC.h>
|
|
|
|
#else
|
|
|
|
#error HAS_SDCARD unknown card reader value, must be either 1 or 2
|
|
|
|
#endif
|
2020-05-20 12:34:58 +02:00
|
|
|
#endif
|
2019-12-25 23:07:34 +01:00
|
|
|
|
2020-06-06 15:09:12 +02:00
|
|
|
#ifdef HAS_SDS011
|
2020-03-29 18:08:52 +02:00
|
|
|
#include "sds011read.h"
|
2020-06-06 15:09:12 +02:00
|
|
|
#endif
|
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
|
|
|
|
|
2020-10-31 12:05:26 +01:00
|
|
|
// Default config for SDMMC_HOST_DEFAULT (4-bit bus width, slot 1)
|
|
|
|
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sdmmc_host.html
|
|
|
|
|
|
|
|
#ifndef SDCARD_DATA0
|
|
|
|
#define SDCARD_DATA0 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SDCARD_DATA1
|
|
|
|
#define SDCARD_DATA1 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SDCARD_DATA2
|
|
|
|
#define SDCARD_DATA2 12
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SDCARD_DATA3
|
|
|
|
#define SDCARD_DATA3 13
|
|
|
|
#endif
|
|
|
|
|
2020-05-16 15:30:05 +02:00
|
|
|
#define SDCARD_FILE_NAME "/paxcount.%02d"
|
2022-01-28 21:41:55 +01:00
|
|
|
#define SDCARD_FILE_HEADER "timestamp,wifi,ble"
|
2020-09-12 22:39:04 +02:00
|
|
|
|
2022-01-28 21:41:55 +01:00
|
|
|
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
|
|
|
#define SDCARD_FILE_HEADER_VOLTAGE ",voltage"
|
2020-09-01 11:33:17 +02:00
|
|
|
#endif
|
2019-12-25 23:07:34 +01:00
|
|
|
|
2020-09-12 22:39:04 +02:00
|
|
|
bool sdcard_init(void);
|
|
|
|
void sdcardWriteData(uint16_t, uint16_t, uint16_t = 0);
|
2019-12-25 23:07:34 +01:00
|
|
|
|
2020-09-12 22:39:04 +02:00
|
|
|
#endif // _SDCARD_H
|