Skip to content

Commit

Permalink
Fix GPIO settings in F7's QSPI FLASH driver, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kwarc93 committed Nov 22, 2024
1 parent 22e41e4 commit 317edf3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Digital Multi Effect

A concept of digital multi-effect for guitar running on STM32F746-DISCO board
A concept of digital multi-effect for guitar running on STM32F746G-DISCO or STM32H745I-DISCO board

![screenshot](guitar_mfx.png)

Expand All @@ -21,14 +21,23 @@ The vocoder effect needs an additional signal input as modulator, which can be:
- right channel of the line-in, labeled as AUX (default)
- signal form the onboard digital microphone


This signal can be selected from the audio settings screen.

Audio quality is set to 24bit 48kHz. Audio latency is determined by the size of audio buffer, which by default is 128 samples that gives around 6ms in-out delay.

## Demo
https://soundcloud.com/kwarc-1/sets/gmfx
https://soundcloud.com/kwarc-1/sets/gmfx
https://youtu.be/xXm61wA0C68?feature=shared

## Supported boards

- STM32F746G-DISCO
- STM32H745I-DISCO

*Note 1: On STM32H745I-DISCO board, the application runs on single core (Cortex-M7) and the second core (Cortex-M4) should be put in stop mode.*
*Note 2: To use digital microphone on STM32H745I-DISCO board, some solder bridges need to be changed (open: SB41 & SB42, close: SB40 & SB32).*

## How to build

Project was created using **Eclipse IDE for Embedded C/C++ Developers**
Expand All @@ -38,7 +47,13 @@ Follow these steps:
2. Clone repo: `git clone --recurse-submodules https://github.com/kwarc93/audio-multieffect.git`
3. In Eclipse go to: **File->Import->Existing projects into workspace**, select folder with cloned repo and check **Copy projects into workspace**. Click **Finish**.

Now the project should have two build configurations: **Debug** and **Release**, it should be possible to build each one with no errors.
Now the project should have four build configurations:
- **STM32F746G-DISCO-Debug**
- **STM32F746G-DISCO-Release**
- **STM32H745I-DISCO-CM7-Debug**
- **STM32H745I-DISCO-CM7-Release**

it should be possible to build each one with no errors.

## How to add new effect

Expand All @@ -51,3 +66,4 @@ Here is a brief description of how to add new effect to the system:
5. Go to **app/view/lcd_view/lcd_view.hpp** module and add new effect controls to the **effect_controls_changed** event. Add another **set_effect_attr** method overload to the **lcd_view** class and define it in the source file. Also, in method **change_effect_screen** add new case for handling new effect screen.

After completing these steps it should be possible to compile the project. However this instruction is not very detailed so there may be compilation errors if something is missing. If so, follow the compiler error messages.

13 changes: 6 additions & 7 deletions drivers/qspi_n25q128a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,17 @@ qspi_n25q128a::qspi_n25q128a()
/* Initialize QSPI GPIOs */
static constexpr std::array<const gpio::io, 6> gpios =
{{
{gpio::port::portg, gpio::pin::pin6}, // QSPI_NCS
{gpio::port::portf, gpio::pin::pin10}, // QSPI_CLK
{gpio::port::portb, gpio::pin::pin6}, // QSPI_NCS
{gpio::port::portb, gpio::pin::pin2}, // QSPI_CLK
{gpio::port::portd, gpio::pin::pin11}, // QSPI_D0
{gpio::port::portf, gpio::pin::pin9}, // QSPI_D1
{gpio::port::portf, gpio::pin::pin7}, // QSPI_D2
{gpio::port::portf, gpio::pin::pin6}, // QSPI_D3
{gpio::port::portd, gpio::pin::pin12}, // QSPI_D1
{gpio::port::porte, gpio::pin::pin2}, // QSPI_D2
{gpio::port::portd, gpio::pin::pin13}, // QSPI_D3
}};

for (const auto &pin : gpios)
gpio::configure(pin, gpio::mode::af, gpio::af::af9);
gpio::configure(gpios[0], gpio::mode::af, gpio::af::af10);
gpio::configure(gpios[3], gpio::mode::af, gpio::af::af10);
gpio::configure(gpios.front(), gpio::mode::af, gpio::af::af10);

/* Configure QSPI peripheral */
static constexpr qspi::config cfg
Expand Down
11 changes: 7 additions & 4 deletions middlewares/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ inline void test(void)
hal::buttons::blue_btn button;
hal::nvms::qspi_flash storage;

// FLASH erase
if (button.is_pressed())
{
printf("Erasing QSPI FLASH...\r\n");
Expand All @@ -43,18 +44,20 @@ inline void test(void)
printf("Starting file system test...\r\n");

// random subsector test
constexpr size_t subsector_size = 4096;
uint32_t address = hal::random::get() % storage.total_size();
if (storage.erase(address, storage.erase_size()))
address = address & ~(subsector_size - 1);
if (storage.erase(address, subsector_size))
{
static std::array<std::byte, 4096> data;
static std::array<std::byte, subsector_size> data;
std::generate(data.begin(), data.end(), [](){ return (std::byte)(hal::random::get() % 256); });

if (storage.write(data.data(), address, data.size()))
{
static std::array<std::byte, 4096> readback;
static std::array<std::byte, subsector_size> readback;
if (storage.read(readback.data(), address, readback.size()))
{
for (unsigned i = 0; i < 4096; i++)
for (unsigned i = 0; i < subsector_size; i++)
assert(data[i] == readback[i]);

printf("QSPI FLASH write & read at 0x%lx successful\r\n", address);
Expand Down

0 comments on commit 317edf3

Please sign in to comment.