From bb2cb0dd9e8299b506f60eaab83c016507fde60d Mon Sep 17 00:00:00 2001 From: CNLohr Date: Wed, 5 Aug 2020 13:28:14 -0400 Subject: [PATCH] Update colorchord on the STM32f303 --- embeddedstm32f303/Makefile | 4 ++-- embeddedstm32f303/README.md | 16 ++++++++++++++++ embeddedstm32f303/ccconfig.h | 17 ++++++++--------- embeddedstm32f303/main.c | 16 +++++++++------- 4 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 embeddedstm32f303/README.md diff --git a/embeddedstm32f303/Makefile b/embeddedstm32f303/Makefile index 461f890..b46c39d 100644 --- a/embeddedstm32f303/Makefile +++ b/embeddedstm32f303/Makefile @@ -32,10 +32,10 @@ CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) \ CFLAGS+=-DDEBUG -#If you use a TQFP STM32F303. +#If you use a TQFP STM32F303. (x6, x8) CFLAGS+=-I. -DTQFP32 -DHSE_VALUE=8000000 -#From the nucleos(sp?) +#From the nucleos(sp?) (STM32F303xB/xC) #CFLAGS+=-I. -DHSE_VALUE=25000000 AFLAGS = $(MCFLAGS) diff --git a/embeddedstm32f303/README.md b/embeddedstm32f303/README.md new file mode 100644 index 0000000..06ee710 --- /dev/null +++ b/embeddedstm32f303/README.md @@ -0,0 +1,16 @@ +# ColorChord running on an STM32F303 + + +## Step 1: Get the necessiary build enivronment + +``` +sudo apt-get install build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi openocd +``` + +## Step 2: Build + +``` +make +``` + +Note: Step 2 being called "build" is a misnomer. If you have your board plugged in, it will also flash. diff --git a/embeddedstm32f303/ccconfig.h b/embeddedstm32f303/ccconfig.h index ae93cd4..d7bd2d6 100644 --- a/embeddedstm32f303/ccconfig.h +++ b/embeddedstm32f303/ccconfig.h @@ -3,15 +3,14 @@ #define CCEMBEDDED -#ifdef TQFP32 -#define NUM_LIN_LEDS 20 -#define USE_NUM_LIN_LEDS 20 -#define DFREQ 12500 //XXX Incorrect. -#else -#define NUM_LIN_LEDS 24 -#define USE_NUM_LIN_LEDS 24 -#define DFREQ 12500 -#endif +#include + +extern uint8_t RootNoteOffset; //From embeddedout.c +extern int UseNumLinLeds; + +#define NUM_LIN_LEDS 100 +#define USE_NUM_LIN_LEDS UseNumLinLeds +#define DFREQ 12500 //Unsure. #endif diff --git a/embeddedstm32f303/main.c b/embeddedstm32f303/main.c index c13f986..fb174d3 100644 --- a/embeddedstm32f303/main.c +++ b/embeddedstm32f303/main.c @@ -8,7 +8,8 @@ #include #include #include - +#include "spi2812.h" +#include "adc.h" gpio freepin; @@ -23,10 +24,15 @@ int16_t sampbuff[CIRCBUFSIZE]; volatile int samples; -void ADCCallback( uint16_t adcval ) + + +int UseNumLinLeds = 20; +int Gain = 10; + +void ADCCallback( int16_t adcval ) { #ifdef TQFP32 - sampbuff[last_samp_pos] = adcval*2.0; + sampbuff[last_samp_pos] = adcval*Gain; #else sampbuff[last_samp_pos] = adcval; #endif @@ -102,10 +108,6 @@ int main(void) wf++; if( wf == 128 ) { - //uint8_t rdat[20] = { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff }; - //static int countup; - //rdat[5] = sampbuff[last_samp_pos] ;//countup++; - //SendSPI2812( rdat, 4 ); NewFrame(); wf = 0; }