Skip to content

Commit

Permalink
Merge upstream/master
Browse files Browse the repository at this point in the history
  • Loading branch information
stellar-aria committed Jun 19, 2023
2 parents 7837138 + ee3e337 commit 3f51516
Show file tree
Hide file tree
Showing 20 changed files with 941 additions and 548 deletions.
34 changes: 33 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@
"windows": {
"MIMode": "gdb",
}
},
{
"name": "Debug",
"configFiles": [
"interface/stlink.cfg",
"target/stm32h7x.cfg"
],
"cwd": "${workspaceFolder}",
"debuggerArgs": [
"-d",
"${workspaceRoot}"
],
// Here's where you can put the path to the program you want to debug:
//"executable": "${workspaceRoot}/examples/SDMMC_HelloWorld/build/SDMMC_HelloWorld.elf",
"executable": "${workspaceRoot}/examples/uart/Dma_Receive/build/Dma_Receive.elf",
"interface": "swd",
"openOCDLaunchCommands": [
"init",
"reset init",
"gdb_breakpoint_override hard"
],
"preRestartCommands": [
"load",
"enable breakpoint",
"monitor reset"
],
"request": "launch",
"runToMain": true,
"servertype": "openocd",
"showDevDebugOutput": true,
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
"type": "cortex-debug"
}
]
}
}
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ add_library(${TARGET} STATIC
${MODULE_DIR}/hid/encoder.cpp
${MODULE_DIR}/hid/gatein.cpp
${MODULE_DIR}/hid/led.cpp
${MODULE_DIR}/hid/midi.cpp
${MODULE_DIR}/hid/midi_parser.cpp
${MODULE_DIR}/hid/parameter.cpp
${MODULE_DIR}/hid/rgb_led.cpp
${MODULE_DIR}/hid/switch.cpp
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ hid/ctrl \
hid/encoder \
hid/gatein \
hid/led \
hid/midi \
hid/midi_parser \
hid/parameter \
hid/rgb_led \
hid/switch \
Expand Down Expand Up @@ -85,7 +87,7 @@ BUILD_DIR = build

# manually adding necessary HAL files
# generated by dump_filepath.py
C_SOURCES =
C_SOURCES =
C_SOURCES += \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c \
Expand Down Expand Up @@ -197,7 +199,7 @@ Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_swpmi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_tim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usart.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_utils.c
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_utils.c

# Middleware sources
C_SOURCES += \
Expand Down Expand Up @@ -271,7 +273,7 @@ MCU = -mthumb $(FLOAT-ABI) $(FPU) $(CPU)

# macros for gcc
# AS defines
AS_DEFS =
AS_DEFS =

# C defines
C_DEFS = \
Expand All @@ -283,7 +285,7 @@ C_DEFS = \
-DHSE_VALUE=16000000 \
-DUSE_HAL_DRIVER \
-DUSE_FULL_LL_DRIVER \
-DDATA_IN_D2_SRAM
-DDATA_IN_D2_SRAM
# ^ added for easy startup access


Expand All @@ -302,7 +304,7 @@ C_INCLUDES = \
-IMiddlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc \
-IMiddlewares/Third_Party/FatFs/src \
-I$(MODULE_DIR) \
-I.
-I.

# suppressions for warnings introduced by HAL/FatFS
WARNINGS += -Wall -Wno-attributes -Wno-strict-aliasing -Wno-maybe-uninitialized -Wno-missing-attributes -Wno-stringop-overflow #-Werror
Expand All @@ -328,7 +330,7 @@ CFLAGS += \
CPPFLAGS = $(CFLAGS) $(CPP_WARNINGS)
CPPFLAGS += \
-fno-exceptions \
-fno-rtti
-fno-rtti

C_STANDARD = -std=gnu11
CPP_STANDARD += -std=gnu++14
Expand Down Expand Up @@ -369,7 +371,7 @@ $(BUILD_DIR)/$(TARGET).a: $(SORTED_OBJECTS) Makefile
$(AR) -r $@ $(SORTED_OBJECTS)

$(BUILD_DIR):
mkdir $@
mkdir $@

#######################################
# clean up
Expand Down
8 changes: 7 additions & 1 deletion examples/MIDI_UART_Input/MIDI_UART_Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ int main(void)
{
case NoteOn:
// Do something on Note On events
{
uint8_t bytes[3] = {0x90, 0x00, 0x00};
bytes[1] = msg.data[0];
bytes[2] = msg.data[1];
midi.SendMessage(bytes, 3);
}
break;
default: break;
}
Expand All @@ -91,7 +97,7 @@ int main(void)
if(!event_log.IsEmpty())
{
auto msg = event_log.PopFront();
char outstr[64];
char outstr[128];
char type_str[16];
GetMidiTypeAsString(msg, type_str);
sprintf(outstr,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
/** TODO fix / remove this example
* anticipated issue that it only shows 1 byte every 100ms
* which may be misleading to user
*
* also, it should probably use serial print to pipe out
* data instead of the patch's display.
*/
#include "daisy_patch.h"

using namespace daisy;

/** Consts */
const size_t kUartBufferSize = 512;

/** Globals */
DaisyPatch hw;
UartHandler uart;
uint8_t uart_buffer[kUartBufferSize];
char receive_str[kUartBufferSize];

/** Happens automatically whenever transaction completes */
void uartCallback(uint8_t* data,
size_t size,
void* context,
UartHandler::Result res)
{
/** Clear receive_str */
std::fill(&receive_str[0], &receive_str[kUartBufferSize - 1], 0);
/** Copy new data into the receive str */
std::copy(&data[0], &data[size - 1], &receive_str[0]);
}

int main(void)
{
Expand All @@ -19,21 +44,16 @@ int main(void)

// initialize the UART peripheral, and start reading
uart.Init(uart_conf);
uart.DmaReceiveFifo();
uart.DmaListenStart(uart_buffer, kUartBufferSize, uartCallback, nullptr);

uint8_t pop = 0;
uint8_t pop = 0;
uint8_t send = 0;
while(1)
{
// send the data in a blocking fashion
uart.BlockingTransmit(&send, 1);
send++;

// if there's data, pop it from the FIFO
if(uart.ReadableFifo()){
pop = uart.PopFifo();
}

// clear the display
hw.display.Fill(false);

Expand All @@ -43,10 +63,10 @@ int main(void)
hw.display.SetCursor(0, 0);
hw.display.WriteString(cstr, Font_7x10, true);

// draw the receive buffer contents
sprintf(cstr, "%d", pop);
// draw the latest receive buffer contents
sprintf(receive_str, "%d", pop);
hw.display.SetCursor(0, 12);
hw.display.WriteString(cstr, Font_7x10, true);
hw.display.WriteString(receive_str, Font_7x10, true);

// update the display
hw.display.Update();
Expand Down
88 changes: 50 additions & 38 deletions examples/uart/Dma_Fifo_Receive/Dma_Fifo_Receive.cpp
Original file line number Diff line number Diff line change
@@ -1,57 +1,69 @@
/** TODO fix / remove this example
* anticipated issue that it only shows 1 byte every 100ms
* which may be misleading to user
*
* also, it should probably use serial print to pipe out
* data instead of the patch's display.
*/
#include "daisy_patch.h"

using namespace daisy;

DaisyPatch hw;
/** Consts */
const size_t kUartBufferSize = 512;

DaisyPatch hw;
UartHandler uart;
uint8_t uart_buffer[kUartBufferSize];
char receive_str[kUartBufferSize];

/** Happens automatically whenever transaction completes */
void uartCallback(uint8_t* data,
size_t size,
void* context,
UartHandler::Result res)
{
/** Clear receive_str */
std::fill(&receive_str[0], &receive_str[kUartBufferSize - 1], 0);
/** Copy new data into the receive str */
std::copy(&data[0], &data[size - 1], &receive_str[0]);
}

int main(void)
{
// Initialize the Daisy Patch
hw.Init();

// Configure the Uart Peripheral
UartHandler::Config uart_conf;
uart_conf.periph = UartHandler::Config::Peripheral::USART_1;
uart_conf.mode = UartHandler::Config::Mode::RX;
uart_conf.pin_config.tx = Pin(PORTB, 6);
uart_conf.pin_config.rx = Pin(PORTB, 7);

// Initialize the Uart Peripheral
uart.Init(uart_conf);

// Start the FIFO Receive
uart.DmaReceiveFifo();

uint8_t pop = 0;
while(1) {
// if there's data, pop it from the FIFO
if(uart.ReadableFifo()){
pop = uart.PopFifo();
hw.seed.SetLed(false);
}
else{
hw.seed.SetLed(true);
}

// clear the display
// Initialize the Daisy Patch
hw.Init();

// Configure the Uart Peripheral
UartHandler::Config uart_conf;
uart_conf.periph = UartHandler::Config::Peripheral::USART_1;
uart_conf.mode = UartHandler::Config::Mode::RX;
uart_conf.pin_config.tx = Pin(PORTB, 6);
uart_conf.pin_config.rx = Pin(PORTB, 7);

// Initialize the Uart Peripheral
uart.Init(uart_conf);
uart.DmaListenStart(uart_buffer, kUartBufferSize, uartCallback, nullptr);

while(1)
{
// clear the display
hw.display.Fill(false);

// draw the title text
// draw the title text
char cstr[26];
sprintf(cstr, "Uart DMA Fifo Rx");
hw.display.SetCursor(0, 0);
hw.display.WriteString(cstr, Font_7x10, true);

// draw the last popped data
sprintf(cstr, "%d", pop);
// draw the last popped data
hw.display.SetCursor(0, 12);
hw.display.WriteString(cstr, Font_7x10, true);
// update the display
hw.display.Update();
hw.display.WriteString(receive_str, Font_7x10, true);

// update the display
hw.display.Update();

// wait 100 ms
// wait 100 ms
System::Delay(100);
}
}
}
2 changes: 2 additions & 0 deletions examples/uart/Dma_Receive/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CPP_SOURCES = Dma_Receive.cpp
# Library Locations
LIBDAISY_DIR = ../../..

OPT=-O0

# Core location, and generic Makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
9 changes: 6 additions & 3 deletions src/hid/MidiEvent.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: make this adjustable
#define SYSEX_BUFFER_LEN 128

namespace daisy
{
/** @addtogroup midi MIDI
Expand All @@ -7,7 +10,7 @@ namespace daisy
* @{
*/

/** @defgroup midi_events MIDI_EVENTS
/** @defgroup midi_events MIDI_EVENTS
* @{
*/

Expand Down Expand Up @@ -200,7 +203,7 @@ struct AllNotesOffEvent
{
int channel; /**< & */
};
/** Struct containing OmniModeOffEvent data.
/** Struct containing OmniModeOffEvent data.
* Can be made from MidiEvent
*/
struct OmniModeOffEvent
Expand Down Expand Up @@ -413,4 +416,4 @@ struct MidiEvent
/** @} */ // End midi_events

/** @} */ // End midi
} //namespace daisy
} //namespace daisy
18 changes: 18 additions & 0 deletions src/hid/midi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "midi.h"

namespace daisy
{
static constexpr size_t kDefaultMidiRxBufferSize = 256;

static uint8_t DMA_BUFFER_MEM_SECTION
default_midi_rx_buffer[kDefaultMidiRxBufferSize];

MidiUartTransport::Config::Config()
{
periph = UartHandler::Config::Peripheral::USART_1;
rx = Pin(PORTB, 7);
tx = Pin(PORTB, 6);
rx_buffer = default_midi_rx_buffer;
rx_buffer_size = kDefaultMidiRxBufferSize;
}
} // namespace daisy
Loading

0 comments on commit 3f51516

Please sign in to comment.