Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erbui sdmmc support #693

Merged
merged 11 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/windows_2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ jobs:
- name: test/micropatch
run: erbb configure && erbb build && erbb build simulator
working-directory: test/micropatch
- name: test/seed2-dfm-eval-euro
run: erbb configure && erbb build firmware && erbb build simulator
working-directory: test/seed2-dfm-eval-euro
- name: test/display-context
run: erbb configure && erbb build firmware && erbb build simulator
working-directory: test/display-context
Expand Down
5 changes: 5 additions & 0 deletions boards/seed2_dfm_eval_euro/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,10 @@
'accept': ['Display'],
'bind': 'oled()',
},

'SDMMC1': {
'accept': ['SdMmc'],
'bind': 'fatfs()',
},
}
}
9 changes: 9 additions & 0 deletions boards/seed2_dfm_eval_euro/firmware/BoardSeed2DfmEvalEuro.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class BoardSeed2DfmEvalEuro
inline typename erb::FormatSsd130x <128, 64>::Storage &
oled () { return _oled_buffer; }

// SdMmc
#if defined (erb_USE_FATFS) && erb_USE_FATFS
inline FATFS & fatfs () { return *_fat_fs_ptr; }
#else
inline int fatfs () { return 0; }
#endif

// Clock
inline const uint64_t &
clock () { return _clock.ms (); }
Expand Down Expand Up @@ -156,6 +163,7 @@ class BoardSeed2DfmEvalEuro
private:

inline void init_qspi ();
inline void init_sdmmc ();
inline void init_audio ();
inline void init_display ();

Expand All @@ -172,6 +180,7 @@ class BoardSeed2DfmEvalEuro

daisy::QSPIHandle
_qspi;
FATFS * _fat_fs_ptr = nullptr;
daisy::AudioHandle
_audio;
daisy::AdcHandle
Expand Down
27 changes: 27 additions & 0 deletions boards/seed2_dfm_eval_euro/firmware/BoardSeed2DfmEvalEuro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ BoardSeed2DfmEvalEuro::BoardSeed2DfmEvalEuro ()
_this_ptr = this;

init_qspi ();
init_sdmmc ();
init_audio ();
init_display ();
}
Expand Down Expand Up @@ -288,6 +289,32 @@ void BoardSeed2DfmEvalEuro::init_qspi ()



/*
==============================================================================
Name : init_sdmmc
==============================================================================
*/

void BoardSeed2DfmEvalEuro::init_sdmmc ()
{
// Since this involves DMA transfers, the structures need to be stored
// in AXI SRAM.
static __attribute__((section(".text"))) daisy::SdmmcHandler sdmmc;
static __attribute__((section(".text"))) daisy::FatFSInterface fsi;

sdmmc.Init (daisy::SdmmcHandler::Config {
.speed = daisy::SdmmcHandler::Speed::FAST,
.width = daisy::SdmmcHandler::BusWidth::BITS_4,
.clock_powersave = false
});

fsi.Init (daisy::FatFSInterface::Config::MEDIA_SD);

_fat_fs_ptr = &fsi.GetSDFileSystem ();
}



/*
==============================================================================
Name : init_audio
Expand Down
7 changes: 7 additions & 0 deletions boards/seed2_dfm_eval_euro/layout.erbui
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ module seed2_dfm_eval_euro {
pin OLED1
}

//--- Micro SD ------------------------------------------------------------

control sdmmc SdMmc {
position 210.2mm, 96.0mm
pin SDMMC1
}

//--- Gates ---------------------------------------------------------------

control gate_in GateIn {
Expand Down
67 changes: 62 additions & 5 deletions boards/seed2_dfm_eval_euro/simulator/BoardSeed2DfmEvalEuro.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

#include "erb/vcvrack/BoardGeneric.h"

#if defined (erb_USE_FATFS) && erb_USE_FATFS
#include "ff.h"
#include "ff_gen_drv.h"
#endif



namespace erb
Expand All @@ -29,11 +34,8 @@ class BoardSeed2DfmEvalEuro
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

public:
inline BoardSeed2DfmEvalEuro () : BoardGeneric (
7, 7, 4, // digital/analog/audio inputs
0, 2, 4 // digital/analog/audio outputs
) {}
virtual ~BoardSeed2DfmEvalEuro () override = default;
inline BoardSeed2DfmEvalEuro ();
inline virtual ~BoardSeed2DfmEvalEuro () override;

// Digital Inputs
inline const uint8_t &
Expand Down Expand Up @@ -62,6 +64,17 @@ class BoardSeed2DfmEvalEuro
inline typename erb::FormatSsd130x <128, 64>::Storage &
oled () { return _oled; }

// SdMmc
#if defined (erb_USE_FATFS) && erb_USE_FATFS
inline FATFS & fatfs () { return _ff; }
inline bool set_sd (const char * path_0);
inline void reset_sd ();

#else
inline int fatfs () { return 0; }

#endif



/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
Expand All @@ -74,9 +87,49 @@ class BoardSeed2DfmEvalEuro

private:

#if defined (erb_USE_FATFS) && erb_USE_FATFS
static inline DSTATUS
ff_init (BYTE pdrv);
static inline DSTATUS
ff_status (BYTE pdrv);
static inline DRESULT
ff_read (BYTE pdrv, BYTE * buf, DWORD sector, UINT count);
#if _USE_WRITE == 1
static inline DRESULT
ff_write (BYTE pdrv, const BYTE * buf, DWORD sector, UINT count);
#endif
#if _USE_IOCTL == 1
static inline DRESULT
ff_ioctl (BYTE pdrv, BYTE cmd, void * buf);
#endif
#endif

erb::FormatSsd130x <128, 64>::Storage
_oled;

#if defined (erb_USE_FATFS) && erb_USE_FATFS
FATFS _ff;
char _ff_path [4];
inline static std::FILE *
_ff_file_ptr = nullptr;
inline static std::size_t
_ff_sector_cnt = 0;
static constexpr std::size_t
_ff_sector_size = 512;

const Diskio_drvTypeDef
_ff_driver = {
ff_init,
ff_status,
ff_read,
#if _USE_WRITE == 1
ff_write,
#endif
#if _USE_IOCTL == 1
ff_ioctl,
#endif
};
#endif


/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
Expand All @@ -101,4 +154,8 @@ class BoardSeed2DfmEvalEuro



#include "BoardSeed2DfmEvalEuro.hpp"



/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
Loading