Skip to content

Commit

Permalink
Merge pull request #693 from ohmtech-rdi/erbui-sdmmc-support
Browse files Browse the repository at this point in the history
Erbui sdmmc support
  • Loading branch information
ohmtech-rdi authored Feb 6, 2025
2 parents 2ddb19c + a2525bd commit abca6b4
Show file tree
Hide file tree
Showing 42 changed files with 3,208 additions and 22 deletions.
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

0 comments on commit abca6b4

Please sign in to comment.