Skip to content

Commit 0100588

Browse files
committed
Merge upstream/master
2 parents 7837138 + ee3e337 commit 0100588

File tree

20 files changed

+941
-548
lines changed

20 files changed

+941
-548
lines changed

.vscode/launch.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,38 @@
2121
"windows": {
2222
"MIMode": "gdb",
2323
}
24+
},
25+
{
26+
"name": "Debug",
27+
"configFiles": [
28+
"interface/stlink.cfg",
29+
"target/stm32h7x.cfg"
30+
],
31+
"cwd": "${workspaceFolder}",
32+
"debuggerArgs": [
33+
"-d",
34+
"${workspaceRoot}"
35+
],
36+
// Here's where you can put the path to the program you want to debug:
37+
//"executable": "${workspaceRoot}/examples/SDMMC_HelloWorld/build/SDMMC_HelloWorld.elf",
38+
"executable": "${workspaceRoot}/examples/uart/Dma_Receive/build/Dma_Receive.elf",
39+
"interface": "swd",
40+
"openOCDLaunchCommands": [
41+
"init",
42+
"reset init",
43+
"gdb_breakpoint_override hard"
44+
],
45+
"preRestartCommands": [
46+
"load",
47+
"enable breakpoint",
48+
"monitor reset"
49+
],
50+
"request": "launch",
51+
"runToMain": true,
52+
"servertype": "openocd",
53+
"showDevDebugOutput": true,
54+
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
55+
"type": "cortex-debug"
2456
}
2557
]
26-
}
58+
}

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ add_library(${TARGET} STATIC
4444
${MODULE_DIR}/hid/encoder.cpp
4545
${MODULE_DIR}/hid/gatein.cpp
4646
${MODULE_DIR}/hid/led.cpp
47+
${MODULE_DIR}/hid/midi.cpp
48+
${MODULE_DIR}/hid/midi_parser.cpp
4749
${MODULE_DIR}/hid/parameter.cpp
4850
${MODULE_DIR}/hid/rgb_led.cpp
4951
${MODULE_DIR}/hid/switch.cpp

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ hid/ctrl \
4141
hid/encoder \
4242
hid/gatein \
4343
hid/led \
44+
hid/midi \
45+
hid/midi_parser \
4446
hid/parameter \
4547
hid/rgb_led \
4648
hid/switch \
@@ -85,7 +87,7 @@ BUILD_DIR = build
8587

8688
# manually adding necessary HAL files
8789
# generated by dump_filepath.py
88-
C_SOURCES =
90+
C_SOURCES =
8991
C_SOURCES += \
9092
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c \
9193
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c \
@@ -197,7 +199,7 @@ Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_swpmi.c \
197199
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_tim.c \
198200
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usart.c \
199201
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c \
200-
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_utils.c
202+
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_utils.c
201203

202204
# Middleware sources
203205
C_SOURCES += \
@@ -271,7 +273,7 @@ MCU = -mthumb $(FLOAT-ABI) $(FPU) $(CPU)
271273

272274
# macros for gcc
273275
# AS defines
274-
AS_DEFS =
276+
AS_DEFS =
275277

276278
# C defines
277279
C_DEFS = \
@@ -283,7 +285,7 @@ C_DEFS = \
283285
-DHSE_VALUE=16000000 \
284286
-DUSE_HAL_DRIVER \
285287
-DUSE_FULL_LL_DRIVER \
286-
-DDATA_IN_D2_SRAM
288+
-DDATA_IN_D2_SRAM
287289
# ^ added for easy startup access
288290

289291

@@ -302,7 +304,7 @@ C_INCLUDES = \
302304
-IMiddlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc \
303305
-IMiddlewares/Third_Party/FatFs/src \
304306
-I$(MODULE_DIR) \
305-
-I.
307+
-I.
306308

307309
# suppressions for warnings introduced by HAL/FatFS
308310
WARNINGS += -Wall -Wno-attributes -Wno-strict-aliasing -Wno-maybe-uninitialized -Wno-missing-attributes -Wno-stringop-overflow #-Werror
@@ -328,7 +330,7 @@ CFLAGS += \
328330
CPPFLAGS = $(CFLAGS) $(CPP_WARNINGS)
329331
CPPFLAGS += \
330332
-fno-exceptions \
331-
-fno-rtti
333+
-fno-rtti
332334

333335
C_STANDARD = -std=gnu11
334336
CPP_STANDARD += -std=gnu++14
@@ -369,7 +371,7 @@ $(BUILD_DIR)/$(TARGET).a: $(SORTED_OBJECTS) Makefile
369371
$(AR) -r $@ $(SORTED_OBJECTS)
370372

371373
$(BUILD_DIR):
372-
mkdir $@
374+
mkdir $@
373375

374376
#######################################
375377
# clean up

examples/MIDI_UART_Input/MIDI_UART_Input.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ int main(void)
7676
{
7777
case NoteOn:
7878
// Do something on Note On events
79+
{
80+
uint8_t bytes[3] = {0x90, 0x00, 0x00};
81+
bytes[1] = msg.data[0];
82+
bytes[2] = msg.data[1];
83+
midi.SendMessage(bytes, 3);
84+
}
7985
break;
8086
default: break;
8187
}
@@ -91,7 +97,7 @@ int main(void)
9197
if(!event_log.IsEmpty())
9298
{
9399
auto msg = event_log.PopFront();
94-
char outstr[64];
100+
char outstr[128];
95101
char type_str[16];
96102
GetMidiTypeAsString(msg, type_str);
97103
sprintf(outstr,

examples/uart/Blocking_Transmit_Fifo_Receive/Blocking_Transmit_Fifo_Receive.cpp

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1+
/** TODO fix / remove this example
2+
* anticipated issue that it only shows 1 byte every 100ms
3+
* which may be misleading to user
4+
*
5+
* also, it should probably use serial print to pipe out
6+
* data instead of the patch's display.
7+
*/
18
#include "daisy_patch.h"
29

310
using namespace daisy;
411

12+
/** Consts */
13+
const size_t kUartBufferSize = 512;
14+
15+
/** Globals */
516
DaisyPatch hw;
617
UartHandler uart;
18+
uint8_t uart_buffer[kUartBufferSize];
19+
char receive_str[kUartBufferSize];
20+
21+
/** Happens automatically whenever transaction completes */
22+
void uartCallback(uint8_t* data,
23+
size_t size,
24+
void* context,
25+
UartHandler::Result res)
26+
{
27+
/** Clear receive_str */
28+
std::fill(&receive_str[0], &receive_str[kUartBufferSize - 1], 0);
29+
/** Copy new data into the receive str */
30+
std::copy(&data[0], &data[size - 1], &receive_str[0]);
31+
}
732

833
int main(void)
934
{
@@ -19,21 +44,16 @@ int main(void)
1944

2045
// initialize the UART peripheral, and start reading
2146
uart.Init(uart_conf);
22-
uart.DmaReceiveFifo();
47+
uart.DmaListenStart(uart_buffer, kUartBufferSize, uartCallback, nullptr);
2348

24-
uint8_t pop = 0;
49+
uint8_t pop = 0;
2550
uint8_t send = 0;
2651
while(1)
2752
{
2853
// send the data in a blocking fashion
2954
uart.BlockingTransmit(&send, 1);
3055
send++;
3156

32-
// if there's data, pop it from the FIFO
33-
if(uart.ReadableFifo()){
34-
pop = uart.PopFifo();
35-
}
36-
3757
// clear the display
3858
hw.display.Fill(false);
3959

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

46-
// draw the receive buffer contents
47-
sprintf(cstr, "%d", pop);
66+
// draw the latest receive buffer contents
67+
sprintf(receive_str, "%d", pop);
4868
hw.display.SetCursor(0, 12);
49-
hw.display.WriteString(cstr, Font_7x10, true);
69+
hw.display.WriteString(receive_str, Font_7x10, true);
5070

5171
// update the display
5272
hw.display.Update();
Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,69 @@
1+
/** TODO fix / remove this example
2+
* anticipated issue that it only shows 1 byte every 100ms
3+
* which may be misleading to user
4+
*
5+
* also, it should probably use serial print to pipe out
6+
* data instead of the patch's display.
7+
*/
18
#include "daisy_patch.h"
29

310
using namespace daisy;
411

5-
DaisyPatch hw;
12+
/** Consts */
13+
const size_t kUartBufferSize = 512;
14+
15+
DaisyPatch hw;
616
UartHandler uart;
17+
uint8_t uart_buffer[kUartBufferSize];
18+
char receive_str[kUartBufferSize];
19+
20+
/** Happens automatically whenever transaction completes */
21+
void uartCallback(uint8_t* data,
22+
size_t size,
23+
void* context,
24+
UartHandler::Result res)
25+
{
26+
/** Clear receive_str */
27+
std::fill(&receive_str[0], &receive_str[kUartBufferSize - 1], 0);
28+
/** Copy new data into the receive str */
29+
std::copy(&data[0], &data[size - 1], &receive_str[0]);
30+
}
731

832
int main(void)
933
{
10-
// Initialize the Daisy Patch
11-
hw.Init();
12-
13-
// Configure the Uart Peripheral
14-
UartHandler::Config uart_conf;
15-
uart_conf.periph = UartHandler::Config::Peripheral::USART_1;
16-
uart_conf.mode = UartHandler::Config::Mode::RX;
17-
uart_conf.pin_config.tx = Pin(PORTB, 6);
18-
uart_conf.pin_config.rx = Pin(PORTB, 7);
19-
20-
// Initialize the Uart Peripheral
21-
uart.Init(uart_conf);
22-
23-
// Start the FIFO Receive
24-
uart.DmaReceiveFifo();
25-
26-
uint8_t pop = 0;
27-
while(1) {
28-
// if there's data, pop it from the FIFO
29-
if(uart.ReadableFifo()){
30-
pop = uart.PopFifo();
31-
hw.seed.SetLed(false);
32-
}
33-
else{
34-
hw.seed.SetLed(true);
35-
}
36-
37-
// clear the display
34+
// Initialize the Daisy Patch
35+
hw.Init();
36+
37+
// Configure the Uart Peripheral
38+
UartHandler::Config uart_conf;
39+
uart_conf.periph = UartHandler::Config::Peripheral::USART_1;
40+
uart_conf.mode = UartHandler::Config::Mode::RX;
41+
uart_conf.pin_config.tx = Pin(PORTB, 6);
42+
uart_conf.pin_config.rx = Pin(PORTB, 7);
43+
44+
// Initialize the Uart Peripheral
45+
uart.Init(uart_conf);
46+
uart.DmaListenStart(uart_buffer, kUartBufferSize, uartCallback, nullptr);
47+
48+
while(1)
49+
{
50+
// clear the display
3851
hw.display.Fill(false);
3952

40-
// draw the title text
53+
// draw the title text
4154
char cstr[26];
4255
sprintf(cstr, "Uart DMA Fifo Rx");
4356
hw.display.SetCursor(0, 0);
4457
hw.display.WriteString(cstr, Font_7x10, true);
4558

46-
// draw the last popped data
47-
sprintf(cstr, "%d", pop);
59+
// draw the last popped data
4860
hw.display.SetCursor(0, 12);
49-
hw.display.WriteString(cstr, Font_7x10, true);
50-
51-
// update the display
52-
hw.display.Update();
61+
hw.display.WriteString(receive_str, Font_7x10, true);
62+
63+
// update the display
64+
hw.display.Update();
5365

54-
// wait 100 ms
66+
// wait 100 ms
5567
System::Delay(100);
56-
}
68+
}
5769
}

examples/uart/Dma_Receive/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ CPP_SOURCES = Dma_Receive.cpp
77
# Library Locations
88
LIBDAISY_DIR = ../../..
99

10+
OPT=-O0
11+
1012
# Core location, and generic Makefile.
1113
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
1214
include $(SYSTEM_FILES_DIR)/Makefile

src/hid/MidiEvent.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// TODO: make this adjustable
2+
#define SYSEX_BUFFER_LEN 128
3+
14
namespace daisy
25
{
36
/** @addtogroup midi MIDI
@@ -7,7 +10,7 @@ namespace daisy
710
* @{
811
*/
912

10-
/** @defgroup midi_events MIDI_EVENTS
13+
/** @defgroup midi_events MIDI_EVENTS
1114
* @{
1215
*/
1316

@@ -200,7 +203,7 @@ struct AllNotesOffEvent
200203
{
201204
int channel; /**< & */
202205
};
203-
/** Struct containing OmniModeOffEvent data.
206+
/** Struct containing OmniModeOffEvent data.
204207
* Can be made from MidiEvent
205208
*/
206209
struct OmniModeOffEvent
@@ -413,4 +416,4 @@ struct MidiEvent
413416
/** @} */ // End midi_events
414417

415418
/** @} */ // End midi
416-
} //namespace daisy
419+
} //namespace daisy

src/hid/midi.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "midi.h"
2+
3+
namespace daisy
4+
{
5+
static constexpr size_t kDefaultMidiRxBufferSize = 256;
6+
7+
static uint8_t DMA_BUFFER_MEM_SECTION
8+
default_midi_rx_buffer[kDefaultMidiRxBufferSize];
9+
10+
MidiUartTransport::Config::Config()
11+
{
12+
periph = UartHandler::Config::Peripheral::USART_1;
13+
rx = Pin(PORTB, 7);
14+
tx = Pin(PORTB, 6);
15+
rx_buffer = default_midi_rx_buffer;
16+
rx_buffer_size = kDefaultMidiRxBufferSize;
17+
}
18+
} // namespace daisy

0 commit comments

Comments
 (0)