From 47eca77733a717180f7bfe8c45a2825a44127fba Mon Sep 17 00:00:00 2001 From: brian crabtree Date: Thu, 3 Jun 2021 08:29:23 -0400 Subject: [PATCH] cdc grid support (#96) * cdc setup and detection * libavr32 * libavr32 * zeroflood * it works * works * restore * lights * working * remove test * libavr32 to main --- libavr32 | 2 +- src/config.mk | 3 +++ src/main.c | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libavr32 b/libavr32 index 85f0ea1..98d6b60 160000 --- a/libavr32 +++ b/libavr32 @@ -1 +1 @@ -Subproject commit 85f0ea1943a302b42da53647988244605dc705ed +Subproject commit 98d6b6002e0708b6524ace3c692451c2c4bf349d diff --git a/src/config.mk b/src/config.mk index 0ab16e7..a8826ba 100644 --- a/src/config.mk +++ b/src/config.mk @@ -102,6 +102,8 @@ CSRCS = \ ../libavr32/src/usb/midi/uhi_midi.c \ ../libavr32/src/usb/midi/midi.c \ ../libavr32/src/usb/msc/msc.c \ + ../libavr32/src/usb/cdc/cdc.c \ + ../libavr32/src/usb/cdc/uhi_cdc.c \ ../libavr32/asf/common/services/storage/ctrl_access/ctrl_access.c \ avr32/drivers/adc/adc.c \ avr32/drivers/flashc/flashc.c \ @@ -137,6 +139,7 @@ INC_PATH = \ ../../src \ ../src \ ../src/usb \ + ../src/usb/cdc \ ../src/usb/ftdi \ ../src/usb/hid \ ../src/usb/midi \ diff --git a/src/main.c b/src/main.c index a81e330..1fe5c40 100644 --- a/src/main.c +++ b/src/main.c @@ -54,6 +54,7 @@ usb flash #include "ftdi.h" #include "ii.h" #include "dac.h" +#include "cdc.h" #include "conf_board.h" @@ -153,7 +154,7 @@ static void cvTimer_callback(void* o) { } static void monome_poll_timer_callback(void* obj) { - ftdi_read(); + serial_read(); } static void monome_refresh_timer_callback(void* obj) { @@ -221,6 +222,10 @@ static void handler_FtdiConnect(s32 data) { ftdi_setup(); } +static void handler_SerialConnect(s32 data) { + monome_setup_mext(); +} + static void handler_FtdiDisconnect(s32 data) { timers_unset_monome(); app_event_handlers[ kEventFrontShort ] = &handler_FrontShort; @@ -414,6 +419,8 @@ static inline void assign_main_event_handlers(void) { app_event_handlers[ kEventMidiConnect ] = &handler_MidiConnect ; app_event_handlers[ kEventMidiDisconnect ] = &handler_MidiDisconnect ; app_event_handlers[ kEventMidiPacket ] = &handler_None; + app_event_handlers[ kEventSerialConnect ] = &handler_SerialConnect ; + app_event_handlers[ kEventSerialDisconnect ] = &handler_FtdiDisconnect ; } // app event loop @@ -795,6 +802,7 @@ int main(void) print_dbg("\r\n== FLASH struct size: "); print_dbg_ulong(sizeof(f)); + if(flash_is_fresh()) { // store flash defaults print_dbg("\r\nfirst run."); @@ -851,7 +859,7 @@ int main(void) init_usb_host(); init_monome(); - while (true) { - check_events(); - } + while (true) { + check_events(); + } }