diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc new file mode 100644 index 00000000..1f8cc8c3 --- /dev/null +++ b/ACDC/ACDC.ioc @@ -0,0 +1,882 @@ +#MicroXplorer Configuration settings - do not modify +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_11 +ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_14 +ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_3 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 +ADC1.ContinuousConvMode=ENABLE +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR +ADC1.EOCSelection=ADC_EOC_SEQ_CONV +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,ConversionDataManagement,Overrun,master +ADC1.NbrOfConversion=4 +ADC1.NbrOfConversionFlag=1 +ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE +ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE +ADC1.OffsetSignedSaturation-2\#ChannelRegularConversion=DISABLE +ADC1.OffsetSignedSaturation-3\#ChannelRegularConversion=DISABLE +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN +ADC1.OversamplingMode=DISABLE +ADC1.Rank-0\#ChannelRegularConversion=1 +ADC1.Rank-1\#ChannelRegularConversion=2 +ADC1.Rank-2\#ChannelRegularConversion=3 +ADC1.Rank-3\#ChannelRegularConversion=4 +ADC1.Resolution=ADC_RESOLUTION_12B +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.master=1 +Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC1.3.EventEnable=DISABLE +Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC1.3.Instance=DMA1_Stream3 +Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC1.3.MemInc=DMA_MINC_ENABLE +Dma.ADC1.3.Mode=DMA_CIRCULAR +Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE +Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.ADC1.3.Priority=DMA_PRIORITY_LOW +Dma.ADC1.3.RequestNumber=1 +Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.ADC1.3.SignalID=NONE +Dma.ADC1.3.SyncEnable=DISABLE +Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.ADC1.3.SyncRequestNumber=1 +Dma.ADC1.3.SyncSignalID=NONE +Dma.Request0=SAI1_A +Dma.Request1=SAI1_B +Dma.Request2=SPI3_TX +Dma.Request3=ADC1 +Dma.RequestsNb=4 +Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_A.0.EventEnable=DISABLE +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.0.Instance=DMA1_Stream0 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.0.RequestNumber=1 +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_A.0.SignalID=NONE +Dma.SAI1_A.0.SyncEnable=DISABLE +Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_A.0.SyncRequestNumber=1 +Dma.SAI1_A.0.SyncSignalID=NONE +Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_B.1.EventEnable=DISABLE +Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.1.Instance=DMA1_Stream1 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.1.RequestNumber=1 +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_B.1.SignalID=NONE +Dma.SAI1_B.1.SyncEnable=DISABLE +Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_B.1.SyncRequestNumber=1 +Dma.SAI1_B.1.SyncSignalID=NONE +Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI3_TX.2.EventEnable=DISABLE +Dma.SPI3_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI3_TX.2.Instance=DMA1_Stream2 +Dma.SPI3_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.SPI3_TX.2.MemInc=DMA_MINC_ENABLE +Dma.SPI3_TX.2.Mode=DMA_NORMAL +Dma.SPI3_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.SPI3_TX.2.PeriphInc=DMA_PINC_DISABLE +Dma.SPI3_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SPI3_TX.2.Priority=DMA_PRIORITY_LOW +Dma.SPI3_TX.2.RequestNumber=1 +Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SPI3_TX.2.SignalID=NONE +Dma.SPI3_TX.2.SyncEnable=DISABLE +Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SPI3_TX.2.SyncRequestNumber=1 +Dma.SPI3_TX.2.SyncSignalID=NONE +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ColumnBitsNumber1=FMC_SDRAM_COLUMN_BITS_NUM_9 +FMC.ExitSelfRefreshDelay1=7 +FMC.IPParameters=ColumnBitsNumber1,CASLatency1,SDClockPeriod1,SDClockPeriod2,ReadBurst1,ReadBurst2,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=10 +FMC.RPDelay1=1 +FMC.RPDelay2=1 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.RowCycleDelay1=8 +FMC.RowCycleDelay2=8 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=3 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configUSE_IDLE_HOOK=0 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +FREERTOS.configUSE_TICK_HOOK=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32H7 +Mcu.IP0=ADC1 +Mcu.IP1=CORTEX_M7 +Mcu.IP10=SPI2 +Mcu.IP11=SPI3 +Mcu.IP12=SYS +Mcu.IP13=TIM2 +Mcu.IP14=TIM3 +Mcu.IP15=TIM4 +Mcu.IP16=TIM8 +Mcu.IP17=UART5 +Mcu.IP18=UART7 +Mcu.IP19=USB_DEVICE +Mcu.IP2=DEBUG +Mcu.IP20=USB_OTG_FS +Mcu.IP3=DMA +Mcu.IP4=FMC +Mcu.IP5=FREERTOS +Mcu.IP6=NVIC +Mcu.IP7=QUADSPI +Mcu.IP8=RCC +Mcu.IP9=SAI1 +Mcu.IPNb=21 +Mcu.Name=STM32H743IIKx +Mcu.Package=UFBGA176 +Mcu.Pin0=PE3 +Mcu.Pin1=PE2 +Mcu.Pin10=PE4 +Mcu.Pin100=PB0 +Mcu.Pin101=PF11 +Mcu.Pin102=PF14 +Mcu.Pin103=PE7 +Mcu.Pin104=PE10 +Mcu.Pin105=PE12 +Mcu.Pin106=PE15 +Mcu.Pin107=PB10 +Mcu.Pin108=PB11 +Mcu.Pin109=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin11=PE5 +Mcu.Pin110=VP_SYS_VS_Systick +Mcu.Pin111=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin12=PE6 +Mcu.Pin13=PB7 +Mcu.Pin14=PB6 +Mcu.Pin15=PG15 +Mcu.Pin16=PG10 +Mcu.Pin17=PD0 +Mcu.Pin18=PC10 +Mcu.Pin19=PA12 +Mcu.Pin2=PE1 +Mcu.Pin20=PI7 +Mcu.Pin21=PI6 +Mcu.Pin22=PI5 +Mcu.Pin23=PD1 +Mcu.Pin24=PI3 +Mcu.Pin25=PI2 +Mcu.Pin26=PA11 +Mcu.Pin27=PC13 +Mcu.Pin28=PI9 +Mcu.Pin29=PI4 +Mcu.Pin3=PE0 +Mcu.Pin30=PH15 +Mcu.Pin31=PI1 +Mcu.Pin32=PF0 +Mcu.Pin33=PI10 +Mcu.Pin34=PH13 +Mcu.Pin35=PH14 +Mcu.Pin36=PI0 +Mcu.Pin37=PA9 +Mcu.Pin38=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin39=PH2 +Mcu.Pin4=PB5 +Mcu.Pin40=PC9 +Mcu.Pin41=PA8 +Mcu.Pin42=PH0-OSC_IN (PH0) +Mcu.Pin43=PH3 +Mcu.Pin44=PC7 +Mcu.Pin45=PH1-OSC_OUT (PH1) +Mcu.Pin46=PF2 +Mcu.Pin47=PF1 +Mcu.Pin48=PH4 +Mcu.Pin49=PG8 +Mcu.Pin5=PB3 (JTDO/TRACESWO) +Mcu.Pin50=PC6 +Mcu.Pin51=PF3 +Mcu.Pin52=PF4 +Mcu.Pin53=PH5 +Mcu.Pin54=PG7 +Mcu.Pin55=PG6 +Mcu.Pin56=PF7 +Mcu.Pin57=PF6 +Mcu.Pin58=PF5 +Mcu.Pin59=PH12 +Mcu.Pin6=PC12 +Mcu.Pin60=PG5 +Mcu.Pin61=PG4 +Mcu.Pin62=PG3 +Mcu.Pin63=PF10 +Mcu.Pin64=PF9 +Mcu.Pin65=PF8 +Mcu.Pin66=PH11 +Mcu.Pin67=PH10 +Mcu.Pin68=PD15 +Mcu.Pin69=PG2 +Mcu.Pin7=PA15 (JTDI) +Mcu.Pin70=PC0 +Mcu.Pin71=PC1 +Mcu.Pin72=PC2_C +Mcu.Pin73=PC3_C +Mcu.Pin74=PG1 +Mcu.Pin75=PH8 +Mcu.Pin76=PH9 +Mcu.Pin77=PD14 +Mcu.Pin78=PD13 +Mcu.Pin79=PA1 +Mcu.Pin8=PA14 (JTCK/SWCLK) +Mcu.Pin80=PA0 +Mcu.Pin81=PF13 +Mcu.Pin82=PG0 +Mcu.Pin83=PE13 +Mcu.Pin84=PD12 +Mcu.Pin85=PD10 +Mcu.Pin86=PA2 +Mcu.Pin87=PA6 +Mcu.Pin88=PC5 +Mcu.Pin89=PF12 +Mcu.Pin9=PA13 (JTMS/SWDIO) +Mcu.Pin90=PF15 +Mcu.Pin91=PE8 +Mcu.Pin92=PE9 +Mcu.Pin93=PE11 +Mcu.Pin94=PE14 +Mcu.Pin95=PD9 +Mcu.Pin96=PD8 +Mcu.Pin97=PA3 +Mcu.Pin98=PA7 +Mcu.Pin99=PB1 +Mcu.PinsNb=112 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32H743IIKx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.QUADSPI_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SAI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SPI3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +PA0.Locked=true +PA0.Signal=GPIO_Output +PA1.Signal=S_TIM2_CH2 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13\ (JTMS/SWDIO).Mode=Trace_Asynchronous_SW +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +PA14\ (JTCK/SWCLK).Mode=Trace_Asynchronous_SW +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PA15\ (JTDI).Signal=S_TIM2_CH1 +PA2.GPIOParameters=GPIO_Label +PA2.GPIO_Label=ADC2 +PA2.Signal=ADCx_INP14 +PA3.Signal=S_TIM2_CH4 +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=ADC6 +PA6.Locked=true +PA6.Signal=ADCx_INP3 +PA7.Signal=S_TIM3_CH2 +PA8.Mode=Asynchronous +PA8.Signal=UART7_RX +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=ADC7 +PB0.Signal=ADCx_INP9 +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=ADC3 +PB1.Signal=ADCx_INP5 +PB10.GPIOParameters=GPIO_Speed,GPIO_Label +PB10.GPIO_Label=ADC_SPI_CLK +PB10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB10.Locked=true +PB10.Mode=Full_Duplex_Master +PB10.Signal=SPI2_SCK +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=ADC_SPI_NCS +PB11.Locked=true +PB11.Signal=GPIO_Output +PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW +PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO +PB5.Mode=Asynchronous +PB5.Signal=UART5_RX +PB6.Mode=Asynchronous +PB6.Signal=UART5_TX +PB7.Locked=true +PB7.Signal=I2C1_SDA +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=ADC1 +PC0.Signal=ADCx_INP10 +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC5 +PC1.Signal=ADCx_INP11 +PC10.GPIOParameters=GPIO_Speed +PC10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PC10.Locked=true +PC10.Signal=SharedStack_PC10 +PC10.Stacked=true +PC12.GPIOParameters=GPIO_Speed +PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PC12.Locked=true +PC12.Signal=SharedStack_PC12 +PC12.Stacked=true +PC13.Locked=true +PC13.Signal=GPIO_Output +PC15-OSC32_OUT\ (OSC32_OUT).Locked=true +PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPIO_Input +PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label +PC2_C.GPIO_Label=ADC_SPI_MISO +PC2_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PC2_C.Mode=Full_Duplex_Master +PC2_C.Signal=SPI2_MISO +PC3_C.GPIOParameters=GPIO_Speed,GPIO_Label +PC3_C.GPIO_Label=ADC_SPI_MOSI +PC3_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PC3_C.Mode=Full_Duplex_Master +PC3_C.Signal=SPI2_MOSI +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=ADC4 +PC5.Signal=ADCx_INP8 +PC6.Signal=S_TIM8_CH1 +PC7.Signal=S_TIM8_CH2 +PC9.GPIOParameters=GPIO_Label +PC9.GPIO_Label=EXTI9 +PC9.Locked=true +PC9.Signal=SharedStack_PC9 +PC9.Stacked=true +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD12.Signal=S_TIM4_CH1 +PD13.Signal=S_TIM4_CH2 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Speed,GPIO_Label +PE2.GPIO_Label=FLASH_DQ2 +PE2.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE2.Mode=Single Bank 1 +PE2.Signal=QUADSPI_BK1_IO2 +PE3.GPIOParameters=GPIO_Speed +PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Speed +PE4.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE4.Mode=SAI_A_MasterWithClock +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Speed +PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE5.Mode=SAI_A_MasterWithClock +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Speed +PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE6.Mode=SAI_A_MasterWithClock +PE6.Signal=SAI1_SD_A +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Speed,GPIO_Label +PF10.GPIO_Label=FLASH_CLK +PF10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF10.Mode=Single Bank 1 +PF10.Signal=QUADSPI_CLK +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF6.GPIOParameters=GPIO_Speed,GPIO_Label +PF6.GPIO_Label=FLASH_DQ3 +PF6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF6.Mode=Single Bank 1 +PF6.Signal=QUADSPI_BK1_IO3 +PF7.Mode=Asynchronous +PF7.Signal=UART7_TX +PF8.GPIOParameters=GPIO_Speed,GPIO_Label +PF8.GPIO_Label=FLASH_DQ0 +PF8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF8.Mode=Single Bank 1 +PF8.Signal=QUADSPI_BK1_IO0 +PF9.GPIOParameters=GPIO_Speed,GPIO_Label +PF9.GPIO_Label=FLASH_DQ1 +PF9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF9.Mode=Single Bank 1 +PF9.Signal=QUADSPI_BK1_IO1 +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG10.Locked=true +PG10.Signal=GPIO_Input +PG15.Signal=FMC_SDNCAS +PG2.Signal=FMC_A12 +PG3.GPIOParameters=GPIO_Label +PG3.GPIO_Label=ADC_RST +PG3.Locked=true +PG3.Signal=GPIO_Output +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG6.GPIOParameters=GPIO_Speed,GPIO_Label +PG6.GPIO_Label=FLASH_NCS +PG6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PG6.Mode=Single Bank 1 +PG6.Signal=QUADSPI_BK1_NCS +PG7.GPIOParameters=GPIO_Speed +PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PG7.Mode=SAI_A_MasterWithClock +PG7.Signal=SAI1_MCLK_A +PG8.Signal=FMC_SDCLK +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +PH10.Signal=FMC_D18 +PH11.Signal=FMC_D19 +PH12.Signal=FMC_D20 +PH13.Signal=FMC_D21 +PH14.Signal=FMC_D22 +PH15.Signal=FMC_D23 +PH2.Mode=SdramChipSelect1_1 +PH2.Signal=FMC_SDCKE0 +PH3.Mode=SdramChipSelect1_1 +PH3.Signal=FMC_SDNE0 +PH4.Locked=true +PH4.Signal=GPIO_Output +PH5.Signal=FMC_SDNWE +PH8.Signal=FMC_D16 +PH9.Signal=FMC_D17 +PI0.Signal=FMC_D24 +PI1.Signal=FMC_D25 +PI10.Signal=FMC_D31 +PI2.Signal=FMC_D26 +PI3.Signal=FMC_D27 +PI4.Signal=FMC_NBL2 +PI5.Signal=FMC_NBL3 +PI6.Signal=FMC_D28 +PI7.Signal=FMC_D29 +PI9.Signal=FMC_D30 +PinOutPanel.CurrentBGAView=Top +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32H743IIKx +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=1 +ProjectManager.MainLocation=Core/Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=ACDC.ioc +ProjectManager.ProjectName=ACDC +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM4_Init-TIM4-false-HAL-true,12-MX_UART5_Init-UART5-false-HAL-true,13-MX_UART7_Init-UART7-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM8_Init-TIM8-false-HAL-true,16-MX_TIM3_Init-TIM3-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +QUADSPI.ClockPrescaler=9 +QUADSPI.FifoThreshold=4 +QUADSPI.FlashSize=22 +QUADSPI.IPParameters=ClockPrescaler,FifoThreshold,FlashSize +RCC.ADCFreq_Value=25000000 +RCC.AHB12Freq_Value=240000000 +RCC.AHB4Freq_Value=240000000 +RCC.APB1Freq_Value=120000000 +RCC.APB2Freq_Value=120000000 +RCC.APB3Freq_Value=120000000 +RCC.APB4Freq_Value=120000000 +RCC.AXIClockFreq_Value=240000000 +RCC.CECFreq_Value=32000 +RCC.CKPERFreq_Value=64000000 +RCC.CortexFreq_Value=480000000 +RCC.CpuClockFreq_Value=480000000 +RCC.D1CPREFreq_Value=480000000 +RCC.D1PPRE=RCC_APB3_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D3PPRE=RCC_APB4_DIV2 +RCC.DFSDMACLkFreq_Value=98285714.2857143 +RCC.DFSDMFreq_Value=120000000 +RCC.DIVM1=1 +RCC.DIVM2=1 +RCC.DIVM3=7 +RCC.DIVN1=120 +RCC.DIVN2=18 +RCC.DIVN3=172 +RCC.DIVP1Freq_Value=480000000 +RCC.DIVP2=6 +RCC.DIVP2Freq_Value=25000000 +RCC.DIVP3Freq_Value=98285714.2857143 +RCC.DIVQ1=5 +RCC.DIVQ1Freq_Value=192000000 +RCC.DIVQ2Freq_Value=75000000 +RCC.DIVQ3Freq_Value=98285714.2857143 +RCC.DIVR1Freq_Value=480000000 +RCC.DIVR2Freq_Value=75000000 +RCC.DIVR3Freq_Value=98285714.2857143 +RCC.FDCANFreq_Value=192000000 +RCC.FMCFreq_Value=240000000 +RCC.FamilyName=M +RCC.HCLK3ClockFreq_Value=240000000 +RCC.HCLKFreq_Value=240000000 +RCC.HPRE=RCC_HCLK_DIV2 +RCC.HRTIMFreq_Value=240000000 +RCC.HSE_VALUE=8000000 +RCC.I2C123Freq_Value=120000000 +RCC.I2C4Freq_Value=120000000 +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVM3,DIVN1,DIVN2,DIVN3,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +RCC.LPTIM1Freq_Value=120000000 +RCC.LPTIM2Freq_Value=120000000 +RCC.LPTIM345Freq_Value=120000000 +RCC.LPUART1Freq_Value=120000000 +RCC.LTDCFreq_Value=98285714.2857143 +RCC.MCO1PinFreq_Value=64000000 +RCC.MCO2PinFreq_Value=480000000 +RCC.PLL2FRACN=6144 +RCC.PLL3FRACN=0 +RCC.PLLFRACN=0 +RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE +RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 +RCC.QSPIFreq_Value=240000000 +RCC.RNGFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL3 +RCC.SAI1Freq_Value=98285714.2857143 +RCC.SAI23Freq_Value=192000000 +RCC.SAI4AFreq_Value=192000000 +RCC.SAI4BFreq_Value=192000000 +RCC.SDMMCFreq_Value=192000000 +RCC.SPDIFRXFreq_Value=192000000 +RCC.SPI123CLockSelection=RCC_SPI123CLKSOURCE_PLL2 +RCC.SPI123Freq_Value=25000000 +RCC.SPI45Freq_Value=120000000 +RCC.SPI6Freq_Value=120000000 +RCC.SWPMI1Freq_Value=120000000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.Tim1OutputFreq_Value=240000000 +RCC.Tim2OutputFreq_Value=240000000 +RCC.TraceFreq_Value=480000000 +RCC.USART16Freq_Value=120000000 +RCC.USART234578Freq_Value=120000000 +RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 +RCC.USBFreq_Value=48000000 +RCC.VCO1OutputFreq_Value=960000000 +RCC.VCO2OutputFreq_Value=150000000 +RCC.VCO3OutputFreq_Value=196571428.5714286 +RCC.VCOInput1Freq_Value=8000000 +RCC.VCOInput2Freq_Value=8000000 +RCC.VCOInput3Freq_Value=1142857.142857143 +SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 +SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 +SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K +SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX +SAI1.ClockStrobing-SAI_A_MasterWithClock=SAI_CLOCKSTROBING_RISINGEDGE +SAI1.DataSize-SAI_A_MasterWithClock=SAI_DATASIZE_24 +SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 +SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=-0.01 % +SAI1.FSDefinition-SAI_A_MasterWithClock=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSOffset-SAI_A_MasterWithClock=SAI_FS_BEFOREFIRSTBIT +SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT +SAI1.FSPolarity-SAI_A_MasterWithClock=SAI_FS_ACTIVE_HIGH +SAI1.FSPolarity-SAI_B_SyncSlave=SAI_FS_ACTIVE_HIGH +SAI1.FrameLength-SAI_A_MasterWithClock=256 +SAI1.FrameLength-SAI_B_SyncSlave=256 +SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave,FSDefinition-SAI_A_MasterWithClock,FSDefinition-SAI_B_SyncSlave,ActiveFrameLength-SAI_A_MasterWithClock,ActiveFrameLength-SAI_B_SyncSlave +SAI1.Instance-SAI_A_MasterWithClock=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE +SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE +SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE +SAI1.OutputDrive-SAI_B_SyncSlave=SAI_OUTPUTDRIVE_ENABLE +SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz +SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF +SAI1.SlotActive-SAI_B_SyncSlave=0x0000FFFF +SAI1.SlotNumber-SAI_A_MasterWithClock=8 +SAI1.SlotNumber-SAI_B_SyncSlave=8 +SAI1.SlotSize-SAI_A_MasterWithClock=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SAI1.VirtualSlotActive-SAI_A_MasterWithClock=SAI_SLOTACTIVE_ALL +SAI1.VirtualSlotActive-SAI_B_SyncSlave=SAI_SLOTACTIVE_ALL +SH.ADCx_INP10.0=ADC1_INP10,IN10-Single-Ended +SH.ADCx_INP10.ConfNb=1 +SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended +SH.ADCx_INP11.ConfNb=1 +SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended +SH.ADCx_INP14.ConfNb=1 +SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended +SH.ADCx_INP3.ConfNb=1 +SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended +SH.ADCx_INP5.ConfNb=1 +SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended +SH.ADCx_INP8.ConfNb=1 +SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended +SH.ADCx_INP9.ConfNb=1 +SH.FMC_A0.0=FMC_A0,13b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,13b-sda1 +SH.FMC_A1.ConfNb=1 +SH.FMC_A10.0=FMC_A10,13b-sda1 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,13b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A12.0=FMC_A12,13b-sda1 +SH.FMC_A12.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,13b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,13b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,13b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,13b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,13b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,13b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,13b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,13b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-32b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D16.0=FMC_D16,sd-32b-d1 +SH.FMC_D16.ConfNb=1 +SH.FMC_D17.0=FMC_D17,sd-32b-d1 +SH.FMC_D17.ConfNb=1 +SH.FMC_D18.0=FMC_D18,sd-32b-d1 +SH.FMC_D18.ConfNb=1 +SH.FMC_D19.0=FMC_D19,sd-32b-d1 +SH.FMC_D19.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D20.0=FMC_D20,sd-32b-d1 +SH.FMC_D20.ConfNb=1 +SH.FMC_D21.0=FMC_D21,sd-32b-d1 +SH.FMC_D21.ConfNb=1 +SH.FMC_D22.0=FMC_D22,sd-32b-d1 +SH.FMC_D22.ConfNb=1 +SH.FMC_D23.0=FMC_D23,sd-32b-d1 +SH.FMC_D23.ConfNb=1 +SH.FMC_D24.0=FMC_D24,sd-32b-d1 +SH.FMC_D24.ConfNb=1 +SH.FMC_D25.0=FMC_D25,sd-32b-d1 +SH.FMC_D25.ConfNb=1 +SH.FMC_D26.0=FMC_D26,sd-32b-d1 +SH.FMC_D26.ConfNb=1 +SH.FMC_D27.0=FMC_D27,sd-32b-d1 +SH.FMC_D27.ConfNb=1 +SH.FMC_D28.0=FMC_D28,sd-32b-d1 +SH.FMC_D28.ConfNb=1 +SH.FMC_D29.0=FMC_D29,sd-32b-d1 +SH.FMC_D29.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 +SH.FMC_D2_DA2.ConfNb=1 +SH.FMC_D30.0=FMC_D30,sd-32b-d1 +SH.FMC_D30.ConfNb=1 +SH.FMC_D31.0=FMC_D31,sd-32b-d1 +SH.FMC_D31.ConfNb=1 +SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 +SH.FMC_NBL2.ConfNb=1 +SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 +SH.FMC_NBL3.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,13b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 +SH.S_TIM2_CH1.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM2_CH4.0=TIM2_CH4,PWM Generation4 CH4 +SH.S_TIM2_CH4.ConfNb=1 +SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2 +SH.S_TIM3_CH2.ConfNb=1 +SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1 +SH.S_TIM4_CH1.ConfNb=1 +SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2 +SH.S_TIM4_CH2.ConfNb=1 +SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1 +SH.S_TIM8_CH1.ConfNb=1 +SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2 +SH.S_TIM8_CH2.ConfNb=1 +SH.SharedStack_PC10.0=SDMMC1_D2 +SH.SharedStack_PC10.1=SPI3_SCK,TX_Only_Simplex_Unidirect_Master +SH.SharedStack_PC10.ConfNb=2 +SH.SharedStack_PC12.0=SDMMC1_CK +SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master +SH.SharedStack_PC12.ConfNb=2 +SH.SharedStack_PC9.0=SDMMC1_D1 +SH.SharedStack_PC9.1=TIM3_CH4 +SH.SharedStack_PC9.2=TIM8_CH4 +SH.SharedStack_PC9.3=GPIO_EXTI9 +SH.SharedStack_PC9.ConfNb=4 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256 +SPI2.CLKPhase=SPI_PHASE_2EDGE +SPI2.CLKPolarity=SPI_POLARITY_HIGH +SPI2.CalculateBaudRate=97.656 KBits/s +SPI2.DataSize=SPI_DATASIZE_8BIT +SPI2.Direction=SPI_DIRECTION_2LINES +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase +SPI2.Mode=SPI_MODE_MASTER +SPI2.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI2.VirtualType=VM_MASTER +SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +SPI3.CalculateBaudRate=1.5625 MBits/s +SPI3.DataSize=SPI_DATASIZE_8BIT +SPI3.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,NSSPMode +SPI3.Mode=SPI_MODE_MASTER +SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI3.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM2.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM2.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Prescaler,Period,Channel-PWM Generation4 CH4 +TIM2.Period=1023 +TIM2.Prescaler=100 +TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM3.IPParameters=Channel-PWM Generation2 CH2,Prescaler,Period +TIM3.Period=1023 +TIM3.Prescaler=100 +TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM4.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Period,Prescaler +TIM4.Period=1023 +TIM4.Prescaler=100 +TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM8.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Period,Prescaler +TIM8.Period=1023 +TIM8.Prescaler=100 +USB_DEVICE.CLASS_NAME_FS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +USB_DEVICE.PID_AUDIO_FS=0xDADA +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-ACDC +USB_DEVICE.VID-AUDIO_FS=0x1209 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +USB_DEVICE.VirtualModeFS=Audio_FS +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +board=custom diff --git a/ACDC/Core/Inc/FreeRTOSConfig.h b/ACDC/Core/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..36d0599c --- /dev/null +++ b/ACDC/Core/Inc/FreeRTOSConfig.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/* + * FreeRTOS Kernel V10.2.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configENABLE_FPU 0 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h new file mode 100644 index 00000000..cc5eefcb --- /dev/null +++ b/ACDC/Core/Inc/hardware.h @@ -0,0 +1,64 @@ +#include "main.h" +#include "stm32h7xx_hal.h" + +#define OWL_XIBECA +#define HARDWARE_ID XIBECA_HARDWARE +#define HARDWARE_VERSION "Xibeca" +/* #define NO_EXTERNAL_RAM */ +/* #define NO_CCM_RAM */ +#define DMA_RAM __attribute__ ((section (".dmadata"))) +#define USE_PLUS_RAM + +#ifdef NDEBUG +#define USE_ICACHE +#define USE_DCACHE +#endif + +#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ + +// todo: quad SPI +/* #define USE_SPI_FLASH */ +/* #define SPI_FLASH_HSPI hqspi */ + +/* #define AUDIO_INPUT_GAIN 114 */ +#define AUDIO_OUTPUT_GAIN 114 + +#define USE_CODEC +#define USE_PCM3168A +#define CODEC_ADC_INVERT +#define CODEC_DAC_INVERT +/* #define CODEC_HP_FILTER */ +#define CODEC_SPI hspi2 + +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 4 +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_RX_FB +#define USE_USBD_FS +#define USBD_HANDLE hUsbDeviceFS + +/* #define USE_UART_MIDI_RX */ +/* #define USE_UART_MIDI_TX */ +/* #define UART_MIDI_HANDLE huart2 */ +/* #define UART_MIDI_RX_BUFFER_SIZE 256 */ + +#define AUDIO_SAMPLINGRATE 48000 + +#define USE_ADC +#define ADC_PERIPH hadc1 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 + +#define NOF_ADC_VALUES 4 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (0+4) diff --git a/ACDC/Core/Inc/main.h b/ACDC/Core/Inc/main.h new file mode 100644 index 00000000..760d6690 --- /dev/null +++ b/ACDC/Core/Inc/main.h @@ -0,0 +1,124 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define FLASH_DQ2_Pin GPIO_PIN_2 +#define FLASH_DQ2_GPIO_Port GPIOE +#define FLASH_NCS_Pin GPIO_PIN_6 +#define FLASH_NCS_GPIO_Port GPIOG +#define FLASH_DQ3_Pin GPIO_PIN_6 +#define FLASH_DQ3_GPIO_Port GPIOF +#define ADC_RST_Pin GPIO_PIN_3 +#define ADC_RST_GPIO_Port GPIOG +#define FLASH_CLK_Pin GPIO_PIN_10 +#define FLASH_CLK_GPIO_Port GPIOF +#define FLASH_DQ1_Pin GPIO_PIN_9 +#define FLASH_DQ1_GPIO_Port GPIOF +#define FLASH_DQ0_Pin GPIO_PIN_8 +#define FLASH_DQ0_GPIO_Port GPIOF +#define ADC1_Pin GPIO_PIN_0 +#define ADC1_GPIO_Port GPIOC +#define ADC5_Pin GPIO_PIN_1 +#define ADC5_GPIO_Port GPIOC +#define ADC_SPI_MISO_Pin GPIO_PIN_2 +#define ADC_SPI_MISO_GPIO_Port GPIOC +#define ADC_SPI_MOSI_Pin GPIO_PIN_3 +#define ADC_SPI_MOSI_GPIO_Port GPIOC +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOA +#define ADC6_Pin GPIO_PIN_6 +#define ADC6_GPIO_Port GPIOA +#define ADC4_Pin GPIO_PIN_5 +#define ADC4_GPIO_Port GPIOC +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOB +#define ADC7_Pin GPIO_PIN_0 +#define ADC7_GPIO_Port GPIOB +#define ADC_SPI_CLK_Pin GPIO_PIN_10 +#define ADC_SPI_CLK_GPIO_Port GPIOB +#define ADC_SPI_NCS_Pin GPIO_PIN_11 +#define ADC_SPI_NCS_GPIO_Port GPIOB +/* USER CODE BEGIN Private defines */ + +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC + +#define ADC_NCS_Pin ADC_SPI_NCS_Pin +#define ADC_NCS_GPIO_Port ADC_SPI_NCS_GPIO_Port +#define ADC_RESET_Pin ADC_RST_Pin +#define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port + +#define FLASH_nCS_Pin FLASH_NCS_Pin +#define FLASH_nCS_GPIO_Port FLASH_NCS_GPIO_Port +#define FLASH_WP_Pin FLASH_DQ2_Pin +#define FLASH_WP_GPIO_Port FLASH_DQ2_GPIO_Port +#define FLASH_HOLD_Pin FLASH_DQ3_Pin +#define FLASH_HOLD_GPIO_Port FLASH_DQ3_GPIO_Port + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Inc/stm32h7xx_hal_conf.h b/ACDC/Core/Inc/stm32h7xx_hal_conf.h new file mode 100644 index 00000000..1a9f1d21 --- /dev/null +++ b/ACDC/Core/Inc/stm32h7xx_hal_conf.h @@ -0,0 +1,512 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_CONF_H +#define STM32H7xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_FDCAN_MODULE_ENABLED */ +/* #define HAL_FMAC_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +/* #define HAL_CORDIC_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_OTFDEC_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_HRTIM_MODULE_ENABLED */ +/* #define HAL_HSEM_MODULE_ENABLED */ +/* #define HAL_GFXMMU_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_OPAMP_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +#define HAL_QSPI_MODULE_ENABLED +/* #define HAL_RAMECC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/* #define HAL_SWPMI_MODULE_ENABLED */ +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_MDIOS_MODULE_ENABLED */ +/* #define HAL_PSSI_MODULE_ENABLED */ +/* #define HAL_DTS_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_MDMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_HSEM_MODULE_ENABLED + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal oscillator (CSI) default value. + * This value is the default CSI value after Reset. + */ +#if !defined (CSI_VALUE) + #define CSI_VALUE (4000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (64000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSI_VALUE) + #define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000UL /*!< Value of the External clock in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define USE_SD_TRANSCEIVER 0U /*!< use uSD Transceiver */ +#define USE_SPI_CRC 0U /*!< use CRC in SPI */ + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U /* CORDIC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_DTS_REGISTER_CALLBACKS 0U /* DTS register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ +#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U /* FMAC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U /* GFXMMU register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U /* OSPI register callback disabled */ +#define USE_HAL_OTFDEC_REGISTER_CALLBACKS 0U /* OTFDEC register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################### Ethernet Configuration ######################### */ +#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ +#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ + +#define ETH_MAC_ADDR0 (0x02UL) +#define ETH_MAC_ADDR1 (0x00UL) +#define ETH_MAC_ADDR2 (0x00UL) +#define ETH_MAC_ADDR3 (0x00UL) +#define ETH_MAC_ADDR4 (0x00UL) +#define ETH_MAC_ADDR5 (0x00UL) + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32h7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32h7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32h7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_MDMA_MODULE_ENABLED + #include "stm32h7xx_hal_mdma.h" +#endif /* HAL_MDMA_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32h7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32h7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32h7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32h7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32h7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DTS_MODULE_ENABLED + #include "stm32h7xx_hal_dts.h" +#endif /* HAL_DTS_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32h7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32h7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32h7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32h7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED + #include "stm32h7xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32h7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32h7xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CORDIC_MODULE_ENABLED + #include "stm32h7xx_hal_cordic.h" +#endif /* HAL_CORDIC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32h7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32h7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32h7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32h7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32h7xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FMAC_MODULE_ENABLED + #include "stm32h7xx_hal_fmac.h" +#endif /* HAL_FMAC_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32h7xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_HSEM_MODULE_ENABLED + #include "stm32h7xx_hal_hsem.h" +#endif /* HAL_HSEM_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32h7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32h7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32h7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32h7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32h7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED + #include "stm32h7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED + #include "stm32h7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32h7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32h7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32h7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32h7xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32h7xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_OTFDEC_MODULE_ENABLED +#include "stm32h7xx_hal_otfdec.h" +#endif /* HAL_OTFDEC_MODULE_ENABLED */ + +#ifdef HAL_PSSI_MODULE_ENABLED + #include "stm32h7xx_hal_pssi.h" +#endif /* HAL_PSSI_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32h7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32h7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RAMECC_MODULE_ENABLED + #include "stm32h7xx_hal_ramecc.h" +#endif /* HAL_RAMECC_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32h7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32h7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32h7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32h7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32h7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32h7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32h7xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32h7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32h7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32h7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32h7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32h7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32h7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32h7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32h7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32h7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Inc/stm32h7xx_it.h b/ACDC/Core/Inc/stm32h7xx_it.h new file mode 100644 index 00000000..ef57fd7d --- /dev/null +++ b/ACDC/Core/Inc/stm32h7xx_it.h @@ -0,0 +1,70 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32H7xx_IT_H +#define __STM32H7xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void SysTick_Handler(void); +void DMA1_Stream0_IRQHandler(void); +void DMA1_Stream1_IRQHandler(void); +void DMA1_Stream2_IRQHandler(void); +void DMA1_Stream3_IRQHandler(void); +void ADC_IRQHandler(void); +void SPI3_IRQHandler(void); +void SAI1_IRQHandler(void); +void QUADSPI_IRQHandler(void); +void OTG_FS_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32H7xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp new file mode 100644 index 00000000..f4c568af --- /dev/null +++ b/ACDC/Core/Src/ACDC.cpp @@ -0,0 +1,146 @@ +#include "Owl.h" +#include "device.h" +#include "errorhandlers.h" +#include "Pin.h" +#include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" +#include "message.h" +#include "Codec.h" + +#define XIBECA_PIN3 GPIOD, GPIO_PIN_2 +#define XIBECA_PIN4 GPIOG, GPIO_PIN_10 +#define XIBECA_PIN5 GPIOC, GPIO_PIN_9 +#define XIBECA_PIN6 GPIOC, GPIO_PIN_8 +#define XIBECA_PIN7 GPIOC, GPIO_PIN_13 +#define XIBECA_PIN8 GPIOI, GPIO_PIN_11 +#define XIBECA_PIN9 GPIOC, GPIO_PIN_14 +#define XIBECA_PIN10 GPIOA, GPIO_PIN_0 +#define XIBECA_PIN11 GPIOH, GPIO_PIN_4 +#define XIBECA_PIN12 GPIOC, GPIO_PIN_15 +#define XIBECA_PIN13 GPIOA, GPIO_PIN_7 +#define XIBECA_PIN14 GPIOA, GPIO_PIN_3 + +#define XIBECA_PIN17 GPIOG, GPIO_PIN_12 +#define XIBECA_PIN18 GPIOG, GPIO_PIN_11 +#define XIBECA_PIN19 GPIOA, GPIO_PIN_15 +#define XIBECA_PIN20 GPIOA, GPIO_PIN_1 + +#define XIBECA_PIN21 GPIOC, GPIO_PIN_6 +#define XIBECA_PIN22 GPIOC, GPIO_PIN_7 +#define XIBECA_PIN23 GPIOD, GPIO_PIN_12 +#define XIBECA_PIN24 GPIOD, GPIO_PIN_13 + +// Pin led_in1(XIBECA_PIN13); +// Pin led_in2(XIBECA_PIN14); +// Pin led_in3(XIBECA_PIN19); +// Pin led_in4(XIBECA_PIN20); + +Pin led_clip1(XIBECA_PIN10); +Pin led_clip2(XIBECA_PIN7); +Pin led_clip3(XIBECA_PIN8); +Pin led_clip4(XIBECA_PIN5); + +// Pin led_out1(XIBECA_PIN21); +// Pin led_out2(XIBECA_PIN22); +// Pin led_out3(XIBECA_PIN23); +// Pin led_out4(XIBECA_PIN24); + +void setLed(uint8_t led, uint32_t rgb){ + uint32_t pwm = 1023 - (__USAT(rgb>>2, 10)); // expects 12-bit parameter value + switch(led){ + case 1: + if(rgb == RED_COLOUR){ + led_clip1.low(); + TIM2->CCR1 = 0xFFFFFFFFU; + }else{ + led_clip1.high(); + TIM2->CCR1 = pwm; + } + break; + case 2: + if(rgb == RED_COLOUR){ + led_clip2.low(); + TIM2->CCR4 = 0xFFFFFFFFU; + }else{ + led_clip2.high(); + TIM2->CCR4 = pwm; + } + break; + case 3: + if(rgb == RED_COLOUR){ + led_clip3.low(); + TIM3->CCR2 = 0xFFFFFFFFU; + }else{ + led_clip3.high(); + TIM3->CCR2 = pwm; + } + break; + case 4: + if(rgb == RED_COLOUR){ + led_clip4.low(); + TIM2->CCR2 = 0xFFFFFFFFU; + }else{ + led_clip4.high(); + TIM2->CCR2 = pwm; + } + break; + case 5: + TIM8->CCR1 = pwm; + break; + case 6: + TIM8->CCR2 = pwm; + break; + case 7: + TIM4->CCR1 = pwm; + break; + case 8: + TIM4->CCR2 = pwm; + break; + } +} + +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; +} + +void initLed(){ + extern TIM_HandleTypeDef htim2; + extern TIM_HandleTypeDef htim3; + extern TIM_HandleTypeDef htim4; + extern TIM_HandleTypeDef htim8; + HAL_TIM_Base_Start(&htim2); + HAL_TIM_Base_Start(&htim3); + HAL_TIM_Base_Start(&htim4); + HAL_TIM_Base_Start(&htim8); + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // in1 + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); // in4 + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4); // in2 + HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2); // in3 + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1); // out3 + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2); // out4 + HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out1 + HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2); // out2 + + led_clip1.outputMode(); + led_clip2.outputMode(); + led_clip3.outputMode(); + led_clip4.outputMode(); +} + +void onSetup(){ + initLed(); + for(size_t i=1; i<=8; ++i) + setLed(i, NO_COLOUR); + // codec.set((1<<22)-1); +} + +void onLoop(void){ + for(size_t i=0; i<4; ++i){ + int16_t value = getParameterValue(PARAMETER_AA+i); + setLed(i+1, value >= 4000 ? RED_COLOUR : value); + setLed(i+5, getParameterValue(PARAMETER_BA+i)); + } +} diff --git a/ACDC/Core/Src/freertos.c b/ACDC/Core/Src/freertos.c new file mode 100644 index 00000000..4a5debed --- /dev/null +++ b/ACDC/Core/Src/freertos.c @@ -0,0 +1,106 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c new file mode 100644 index 00000000..fb0b0157 --- /dev/null +++ b/ACDC/Core/Src/main.c @@ -0,0 +1,1228 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" +#include "usb_device.h" +#include "usb_device.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "device.h" +#include "errorhandlers.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc1; +DMA_HandleTypeDef hdma_adc1; + +QSPI_HandleTypeDef hqspi; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi2; +SPI_HandleTypeDef hspi3; +DMA_HandleTypeDef hdma_spi3_tx; + +TIM_HandleTypeDef htim2; +TIM_HandleTypeDef htim3; +TIM_HandleTypeDef htim4; +TIM_HandleTypeDef htim8; + +UART_HandleTypeDef huart5; +UART_HandleTypeDef huart7; + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +void PeriphCommonClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_QUADSPI_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_ADC1_Init(void); +static void MX_SPI2_Init(void); +static void MX_SPI3_Init(void); +static void MX_TIM2_Init(void); +static void MX_TIM4_Init(void); +static void MX_UART5_Init(void); +static void MX_UART7_Init(void); +static void MX_TIM8_Init(void); +static void MX_TIM3_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +void setup(void); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif +#ifdef USE_ICACHE + /* Enable I-Cache-------------------------------------------------------------*/ + /* After reset, you must invalidate each cache before enabling (SCB_EnableICache) it. */ + SCB_InvalidateICache(); + SCB_EnableICache(); +#endif +#ifdef USE_DCACHE + /* Enable D-Cache-------------------------------------------------------------*/ + /* Before enabling the data cache, you must invalidate the entire data cache (SCB_InvalidateDCache), because external memory might have changed from when the cache was disabled. */ + SCB_InvalidateDCache(); + SCB_EnableDCache(); +#endif + + /* Enable D2 domain SRAM Clocks */ + /* presumably done in SystemInit by setting DATA_IN_D2_SRAM ? */ + /* should be started before libc_init_array and LoopCopyData in startup.s */ + /* __HAL_RCC_D2SRAM1_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM2_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM3_CLK_ENABLE(); */ + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_QUADSPI_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_ADC1_Init(); + MX_SPI2_Init(); + MX_SPI3_Init(); + MX_TIM2_Init(); + MX_TIM4_Init(); + MX_UART5_Init(); + MX_UART7_Init(); + MX_TIM8_Init(); + MX_TIM3_Init(); + /* USER CODE BEGIN 2 */ + +#ifdef USE_EXTERNAL_RAM + SDRAM_Initialization_Sequence(&hsdram1); +#endif + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 1024); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Supply configuration update enable + */ + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); + + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Macro to configure the PLL clock source + */ + __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 1; + RCC_OscInitStruct.PLL.PLLN = 120; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 5; + RCC_OscInitStruct.PLL.PLLR = 2; + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 + |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1|RCC_PERIPHCLK_SPI3 + |RCC_PERIPHCLK_SPI2; + PeriphClkInitStruct.PLL2.PLL2M = 1; + PeriphClkInitStruct.PLL2.PLL2N = 18; + PeriphClkInitStruct.PLL2.PLL2P = 6; + PeriphClkInitStruct.PLL2.PLL2Q = 2; + PeriphClkInitStruct.PLL2.PLL2R = 2; + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 6144; + PeriphClkInitStruct.PLL3.PLL3M = 7; + PeriphClkInitStruct.PLL3.PLL3N = 172; + PeriphClkInitStruct.PLL3.PLL3P = 2; + PeriphClkInitStruct.PLL3.PLL3Q = 2; + PeriphClkInitStruct.PLL3.PLL3R = 2; + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC1 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC1_Init(void) +{ + + /* USER CODE BEGIN ADC1_Init 0 */ + + /* USER CODE END ADC1_Init 0 */ + + ADC_MultiModeTypeDef multimode = {0}; + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC1_Init 1 */ + + /* USER CODE END ADC1_Init 1 */ + /** Common config + */ + hadc1.Instance = ADC1; + hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; + hadc1.Init.LowPowerAutoWait = DISABLE; + hadc1.Init.ContinuousConvMode = ENABLE; + hadc1.Init.NbrOfConversion = 4; + hadc1.Init.DiscontinuousConvMode = DISABLE; + hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR; + hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; + hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; + hadc1.Init.OversamplingMode = DISABLE; + if (HAL_ADC_Init(&hadc1) != HAL_OK) + { + Error_Handler(); + } + /** Configure the ADC multi-mode + */ + multimode.Mode = ADC_MODE_INDEPENDENT; + if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_10; + sConfig.Rank = ADC_REGULAR_RANK_1; + sConfig.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; + sConfig.SingleDiff = ADC_SINGLE_ENDED; + sConfig.OffsetNumber = ADC_OFFSET_NONE; + sConfig.Offset = 0; + sConfig.OffsetSignedSaturation = DISABLE; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_11; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_14; + sConfig.Rank = ADC_REGULAR_RANK_3; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_3; + sConfig.Rank = ADC_REGULAR_RANK_4; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC1_Init 2 */ + + /* USER CODE END ADC1_Init 2 */ + +} + +/** + * @brief QUADSPI Initialization Function + * @param None + * @retval None + */ +static void MX_QUADSPI_Init(void) +{ + + /* USER CODE BEGIN QUADSPI_Init 0 */ + + /* USER CODE END QUADSPI_Init 0 */ + + /* USER CODE BEGIN QUADSPI_Init 1 */ + + /* USER CODE END QUADSPI_Init 1 */ + /* QUADSPI parameter configuration*/ + hqspi.Instance = QUADSPI; + hqspi.Init.ClockPrescaler = 9; + hqspi.Init.FifoThreshold = 4; + hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; + hqspi.Init.FlashSize = 22; + hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; + hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; + hqspi.Init.FlashID = QSPI_FLASH_ID_1; + hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; + if (HAL_QSPI_Init(&hqspi) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN QUADSPI_Init 2 */ + + /* USER CODE END QUADSPI_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_RX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; + hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.PdmInit.Activation = DISABLE; + hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockA1.FrameInit.FrameLength = 256; + hsai_BlockA1.FrameInit.ActiveFrameLength = 128; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 8; + hsai_BlockA1.SlotInit.SlotActive = 0x0000FFFF; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + hsai_BlockB1.Init.PdmInit.Activation = DISABLE; + hsai_BlockB1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockB1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockB1.FrameInit.FrameLength = 256; + hsai_BlockB1.FrameInit.ActiveFrameLength = 128; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 8; + hsai_BlockB1.SlotInit.SlotActive = 0x0000FFFF; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI2 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI2_Init(void) +{ + + /* USER CODE BEGIN SPI2_Init 0 */ + + /* USER CODE END SPI2_Init 0 */ + + /* USER CODE BEGIN SPI2_Init 1 */ + + /* USER CODE END SPI2_Init 1 */ + /* SPI2 parameter configuration*/ + hspi2.Instance = SPI2; + hspi2.Init.Mode = SPI_MODE_MASTER; + hspi2.Init.Direction = SPI_DIRECTION_2LINES; + hspi2.Init.DataSize = SPI_DATASIZE_8BIT; + hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH; + hspi2.Init.CLKPhase = SPI_PHASE_2EDGE; + hspi2.Init.NSS = SPI_NSS_SOFT; + hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; + hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi2.Init.TIMode = SPI_TIMODE_DISABLE; + hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi2.Init.CRCPolynomial = 0x0; + hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI2_Init 2 */ + + /* USER CODE END SPI2_Init 2 */ + +} + +/** + * @brief SPI3 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI3_Init(void) +{ + + /* USER CODE BEGIN SPI3_Init 0 */ + + /* USER CODE END SPI3_Init 0 */ + + /* USER CODE BEGIN SPI3_Init 1 */ + + /* USER CODE END SPI3_Init 1 */ + /* SPI3 parameter configuration*/ + hspi3.Instance = SPI3; + hspi3.Init.Mode = SPI_MODE_MASTER; + hspi3.Init.Direction = SPI_DIRECTION_2LINES_TXONLY; + hspi3.Init.DataSize = SPI_DATASIZE_8BIT; + hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi3.Init.NSS = SPI_NSS_SOFT; + hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; + hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi3.Init.TIMode = SPI_TIMODE_DISABLE; + hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi3.Init.CRCPolynomial = 0x0; + hspi3.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi3) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI3_Init 2 */ + + /* USER CODE END SPI3_Init 2 */ + +} + +/** + * @brief TIM2 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM2_Init(void) +{ + + /* USER CODE BEGIN TIM2_Init 0 */ + + /* USER CODE END TIM2_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM2_Init 1 */ + + /* USER CODE END TIM2_Init 1 */ + htim2.Instance = TIM2; + htim2.Init.Prescaler = 100; + htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + htim2.Init.Period = 1023; + htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM2_Init 2 */ + + /* USER CODE END TIM2_Init 2 */ + HAL_TIM_MspPostInit(&htim2); + +} + +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 100; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 1023; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + HAL_TIM_MspPostInit(&htim3); + +} + +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 100; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 1023; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim4) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + HAL_TIM_MspPostInit(&htim4); + +} + +/** + * @brief TIM8 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM8_Init(void) +{ + + /* USER CODE BEGIN TIM8_Init 0 */ + + /* USER CODE END TIM8_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; + + /* USER CODE BEGIN TIM8_Init 1 */ + + /* USER CODE END TIM8_Init 1 */ + htim8.Instance = TIM8; + htim8.Init.Prescaler = 100; + htim8.Init.CounterMode = TIM_COUNTERMODE_UP; + htim8.Init.Period = 1023; + htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim8.Init.RepetitionCounter = 0; + htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim8) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; + sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; + if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; + sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; + sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; + sBreakDeadTimeConfig.DeadTime = 0; + sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; + sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; + sBreakDeadTimeConfig.BreakFilter = 0; + sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE; + sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH; + sBreakDeadTimeConfig.Break2Filter = 0; + sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; + if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM8_Init 2 */ + + /* USER CODE END TIM8_Init 2 */ + HAL_TIM_MspPostInit(&htim8); + +} + +/** + * @brief UART5 Initialization Function + * @param None + * @retval None + */ +static void MX_UART5_Init(void) +{ + + /* USER CODE BEGIN UART5_Init 0 */ + + /* USER CODE END UART5_Init 0 */ + + /* USER CODE BEGIN UART5_Init 1 */ + + /* USER CODE END UART5_Init 1 */ + huart5.Instance = UART5; + huart5.Init.BaudRate = 115200; + huart5.Init.WordLength = UART_WORDLENGTH_8B; + huart5.Init.StopBits = UART_STOPBITS_1; + huart5.Init.Parity = UART_PARITY_NONE; + huart5.Init.Mode = UART_MODE_TX_RX; + huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart5.Init.OverSampling = UART_OVERSAMPLING_16; + huart5.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart5.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart5.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart5) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart5, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart5, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart5) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART5_Init 2 */ + + /* USER CODE END UART5_Init 2 */ + +} + +/** + * @brief UART7 Initialization Function + * @param None + * @retval None + */ +static void MX_UART7_Init(void) +{ + + /* USER CODE BEGIN UART7_Init 0 */ + + /* USER CODE END UART7_Init 0 */ + + /* USER CODE BEGIN UART7_Init 1 */ + + /* USER CODE END UART7_Init 1 */ + huart7.Instance = UART7; + huart7.Init.BaudRate = 115200; + huart7.Init.WordLength = UART_WORDLENGTH_8B; + huart7.Init.StopBits = UART_STOPBITS_1; + huart7.Init.Parity = UART_PARITY_NONE; + huart7.Init.Mode = UART_MODE_TX_RX; + huart7.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart7.Init.OverSampling = UART_OVERSAMPLING_16; + huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart7.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart7) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart7, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart7, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart7) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART7_Init 2 */ + + /* USER CODE END UART7_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA1_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA1_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn); + /* DMA1_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); + /* DMA1_Stream2_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); + /* DMA1_Stream3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK1; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; + SdramTiming.ExitSelfRefreshDelay = 7; + SdramTiming.SelfRefreshTime = 4; + SdramTiming.RowCycleDelay = 8; + SdramTiming.WriteRecoveryTime = 3; + SdramTiming.RPDelay = 1; + SdramTiming.RCDDelay = 10; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOI_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(ADC_RST_GPIO_Port, ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PB8 PB4 PB9 PB2 + PB12 PB13 PB14 PB15 */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : PG14 PG13 PG12 PG11 + PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pins : PD7 PD6 PD5 PD4 + PD3 PD2 PD11 */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_3|GPIO_PIN_2|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pin : PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : PG10 */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pins : PC11 PC14 PC8 PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_8|GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PC13 */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PI8 PI11 */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /*Configure GPIO pins : PA10 PA4 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_4|GPIO_PIN_5; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : PC15 */ + GPIO_InitStruct.Pin = GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PC9 */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PH4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_RST_Pin */ + GPIO_InitStruct.Pin = ADC_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PH6 PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pin : PA0 */ + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_SPI_NCS_Pin */ + GPIO_InitStruct.Pin = ADC_SPI_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_SPI_NCS_GPIO_Port, &GPIO_InitStruct); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + /* USER CODE BEGIN 5 */ + + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + } + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/startup_stm32h743xx.s b/ACDC/Core/Src/startup_stm32h743xx.s new file mode 100644 index 00000000..2b1034a6 --- /dev/null +++ b/ACDC/Core/Src/startup_stm32h743xx.s @@ -0,0 +1,749 @@ +/** + ****************************************************************************** + * @file startup_stm32h743xx.s + * @author MCD Application Team + * @brief STM32H743xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Call the clock system intitialization function.*/ + bl SystemInit + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word RNG_IRQHandler /* Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word SAI2_IRQHandler /* SAI2 */ + .word QUADSPI_IRQHandler /* QUADSPI */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word OTG_FS_EP1_OUT_IRQHandler /* USB OTG FS End Point 1 Out */ + .word OTG_FS_EP1_IN_IRQHandler /* USB OTG FS End Point 1 In */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word HRTIM1_Master_IRQHandler /* HRTIM Master Timer global Interrupt */ + .word HRTIM1_TIMA_IRQHandler /* HRTIM Timer A global Interrupt */ + .word HRTIM1_TIMB_IRQHandler /* HRTIM Timer B global Interrupt */ + .word HRTIM1_TIMC_IRQHandler /* HRTIM Timer C global Interrupt */ + .word HRTIM1_TIMD_IRQHandler /* HRTIM Timer D global Interrupt */ + .word HRTIM1_TIME_IRQHandler /* HRTIM Timer E global Interrupt */ + .word HRTIM1_FLT_IRQHandler /* HRTIM Fault global Interrupt */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word SAI3_IRQHandler /* SAI3 global Interrupt */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word JPEG_IRQHandler /* JPEG global Interrupt */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak RNG_IRQHandler + .thumb_set RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak SAI2_IRQHandler + .thumb_set SAI2_IRQHandler,Default_Handler + + .weak QUADSPI_IRQHandler + .thumb_set QUADSPI_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_OUT_IRQHandler + .thumb_set OTG_FS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_IN_IRQHandler + .thumb_set OTG_FS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak HRTIM1_Master_IRQHandler + .thumb_set HRTIM1_Master_IRQHandler,Default_Handler + + .weak HRTIM1_TIMA_IRQHandler + .thumb_set HRTIM1_TIMA_IRQHandler,Default_Handler + + .weak HRTIM1_TIMB_IRQHandler + .thumb_set HRTIM1_TIMB_IRQHandler,Default_Handler + + .weak HRTIM1_TIMC_IRQHandler + .thumb_set HRTIM1_TIMC_IRQHandler,Default_Handler + + .weak HRTIM1_TIMD_IRQHandler + .thumb_set HRTIM1_TIMD_IRQHandler,Default_Handler + + .weak HRTIM1_TIME_IRQHandler + .thumb_set HRTIM1_TIME_IRQHandler,Default_Handler + + .weak HRTIM1_FLT_IRQHandler + .thumb_set HRTIM1_FLT_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SAI3_IRQHandler + .thumb_set SAI3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak JPEG_IRQHandler + .thumb_set JPEG_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/ACDC/Core/Src/stm32h7xx_hal_msp.c b/ACDC/Core/Src/stm32h7xx_hal_msp.c new file mode 100644 index 00000000..f3d67835 --- /dev/null +++ b/ACDC/Core/Src/stm32h7xx_hal_msp.c @@ -0,0 +1,1231 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_hal_msp.c + * @brief This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc1; + +extern DMA_HandleTypeDef hdma_spi3_tx; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspInit 0 */ + + /* USER CODE END ADC1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC12_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PA2 ------> ADC1_INP14 + PA6 ------> ADC1_INP3 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + GPIO_InitStruct.Pin = ADC1_Pin|ADC5_Pin|ADC4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC2_Pin|ADC6_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC3_Pin|ADC7_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* ADC1 DMA Init */ + /* ADC1 Init */ + hdma_adc1.Instance = DMA1_Stream3; + hdma_adc1.Init.Request = DMA_REQUEST_ADC1; + hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc1.Init.Mode = DMA_CIRCULAR; + hdma_adc1.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC1_MspInit 1 */ + + /* USER CODE END ADC1_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ + + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC12_CLK_DISABLE(); + + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PA2 ------> ADC1_INP14 + PA6 ------> ADC1_INP3 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC5_Pin|ADC4_Pin); + + HAL_GPIO_DeInit(GPIOA, ADC2_Pin|ADC6_Pin); + + HAL_GPIO_DeInit(GPIOB, ADC3_Pin|ADC7_Pin); + + /* ADC1 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ + } + +} + +/** +* @brief QSPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspInit 0 */ + + /* USER CODE END QUADSPI_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_QSPI; + PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_QSPI_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + GPIO_InitStruct.Pin = FLASH_DQ2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(FLASH_DQ2_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(FLASH_NCS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ3_Pin|FLASH_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ1_Pin|FLASH_DQ0_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* QUADSPI interrupt Init */ + HAL_NVIC_SetPriority(QUADSPI_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(QUADSPI_IRQn); + /* USER CODE BEGIN QUADSPI_MspInit 1 */ + + /* USER CODE END QUADSPI_MspInit 1 */ + } + +} + +/** +* @brief QSPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi) +{ + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspDeInit 0 */ + + /* USER CODE END QUADSPI_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_QSPI_CLK_DISABLE(); + + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + HAL_GPIO_DeInit(FLASH_DQ2_GPIO_Port, FLASH_DQ2_Pin); + + HAL_GPIO_DeInit(FLASH_NCS_GPIO_Port, FLASH_NCS_Pin); + + HAL_GPIO_DeInit(GPIOF, FLASH_DQ3_Pin|FLASH_CLK_Pin|FLASH_DQ1_Pin|FLASH_DQ0_Pin); + + /* QUADSPI interrupt DeInit */ + HAL_NVIC_DisableIRQ(QUADSPI_IRQn); + /* USER CODE BEGIN QUADSPI_MspDeInit 1 */ + + /* USER CODE END QUADSPI_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspInit 0 */ + + /* USER CODE END SPI2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI2_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + GPIO_InitStruct.Pin = ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC_SPI_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(ADC_SPI_CLK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI2_MspInit 1 */ + + /* USER CODE END SPI2_MspInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspInit 0 */ + + /* USER CODE END SPI3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC10 ------> SPI3_SCK + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* SPI3 DMA Init */ + /* SPI3_TX Init */ + hdma_spi3_tx.Instance = DMA1_Stream2; + hdma_spi3_tx.Init.Request = DMA_REQUEST_SPI3_TX; + hdma_spi3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_spi3_tx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_spi3_tx.Init.MemInc = DMA_MINC_ENABLE; + hdma_spi3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_spi3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_spi3_tx.Init.Mode = DMA_NORMAL; + hdma_spi3_tx.Init.Priority = DMA_PRIORITY_LOW; + hdma_spi3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_spi3_tx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hspi,hdmatx,hdma_spi3_tx); + + /* SPI3 interrupt Init */ + HAL_NVIC_SetPriority(SPI3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspInit 1 */ + + /* USER CODE END SPI3_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspDeInit 0 */ + + /* USER CODE END SPI2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI2_CLK_DISABLE(); + + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + HAL_GPIO_DeInit(GPIOC, ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin); + + HAL_GPIO_DeInit(ADC_SPI_CLK_GPIO_Port, ADC_SPI_CLK_Pin); + + /* USER CODE BEGIN SPI2_MspDeInit 1 */ + + /* USER CODE END SPI2_MspDeInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspDeInit 0 */ + + /* USER CODE END SPI3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI3_CLK_DISABLE(); + + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC10 ------> SPI3_SCK + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_10); + + /* SPI3 DMA DeInit */ + HAL_DMA_DeInit(hspi->hdmatx); + + /* SPI3 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspDeInit 1 */ + + /* USER CODE END SPI3_MspDeInit 1 */ + } + +} + +/** +* @brief TIM_PWM MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspInit 0 */ + + /* USER CODE END TIM2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM2_CLK_ENABLE(); + /* USER CODE BEGIN TIM2_MspInit 1 */ + + /* USER CODE END TIM2_MspInit 1 */ + } + else if(htim_pwm->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspInit 0 */ + + /* USER CODE END TIM3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM3_CLK_ENABLE(); + /* USER CODE BEGIN TIM3_MspInit 1 */ + + /* USER CODE END TIM3_MspInit 1 */ + } + else if(htim_pwm->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } + else if(htim_pwm->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspInit 0 */ + + /* USER CODE END TIM8_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM8_CLK_ENABLE(); + /* USER CODE BEGIN TIM8_MspInit 1 */ + + /* USER CODE END TIM8_MspInit 1 */ + } + +} + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspPostInit 0 */ + + /* USER CODE END TIM2_MspPostInit 0 */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + PA3 ------> TIM2_CH4 + */ + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1|GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM2_MspPostInit 1 */ + + /* USER CODE END TIM2_MspPostInit 1 */ + } + else if(htim->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspPostInit 0 */ + + /* USER CODE END TIM3_MspPostInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM3 GPIO Configuration + PA7 ------> TIM3_CH2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM3_MspPostInit 1 */ + + /* USER CODE END TIM3_MspPostInit 1 */ + } + else if(htim->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspPostInit 0 */ + + /* USER CODE END TIM4_MspPostInit 0 */ + + __HAL_RCC_GPIOD_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM4_MspPostInit 1 */ + + /* USER CODE END TIM4_MspPostInit 1 */ + } + else if(htim->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspPostInit 0 */ + + /* USER CODE END TIM8_MspPostInit 0 */ + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**TIM8 GPIO Configuration + PC7 ------> TIM8_CH2 + PC6 ------> TIM8_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM8_MspPostInit 1 */ + + /* USER CODE END TIM8_MspPostInit 1 */ + } + +} +/** +* @brief TIM_PWM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspDeInit 0 */ + + /* USER CODE END TIM2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM2_CLK_DISABLE(); + /* USER CODE BEGIN TIM2_MspDeInit 1 */ + + /* USER CODE END TIM2_MspDeInit 1 */ + } + else if(htim_pwm->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspDeInit 0 */ + + /* USER CODE END TIM3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM3_CLK_DISABLE(); + /* USER CODE BEGIN TIM3_MspDeInit 1 */ + + /* USER CODE END TIM3_MspDeInit 1 */ + } + else if(htim_pwm->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } + else if(htim_pwm->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspDeInit 0 */ + + /* USER CODE END TIM8_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM8_CLK_DISABLE(); + /* USER CODE BEGIN TIM8_MspDeInit 1 */ + + /* USER CODE END TIM8_MspDeInit 1 */ + } + +} + +/** +* @brief UART MSP Initialization +* This function configures the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspInit 0 */ + + /* USER CODE END UART5_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART5; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART5_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF14_UART5; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN UART5_MspInit 1 */ + + /* USER CODE END UART5_MspInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspInit 0 */ + + /* USER CODE END UART7_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART7; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART7_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF11_UART7; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF7_UART7; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN UART7_MspInit 1 */ + + /* USER CODE END UART7_MspInit 1 */ + } + +} + +/** +* @brief UART MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspDeInit 0 */ + + /* USER CODE END UART5_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART5_CLK_DISABLE(); + + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN UART5_MspDeInit 1 */ + + /* USER CODE END UART5_MspDeInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspDeInit 0 */ + + /* USER CODE END UART7_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART7_CLK_DISABLE(); + + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7); + + /* USER CODE BEGIN UART7_MspDeInit 1 */ + + /* USER CODE END UART7_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC; + PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOI, GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOH, GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA1_Stream0; + hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; + hdma_sai1_a.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA1_Stream1; + hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; + hdma_sai1_b.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_7); + + /* SAI1 DMA Deinit */ + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3); + + /* SAI1 DMA Deinit */ + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/stm32h7xx_it.c b/ACDC/Core/Src/stm32h7xx_it.c new file mode 100644 index 00000000..aedaacf9 --- /dev/null +++ b/ACDC/Core/Src/stm32h7xx_it.c @@ -0,0 +1,237 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32h7xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; +extern QSPI_HandleTypeDef hqspi; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; +extern DMA_HandleTypeDef hdma_spi3_tx; +extern SPI_HandleTypeDef hspi3; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32H7xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32h7xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles DMA1 stream0 global interrupt. + */ +void DMA1_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream0_IRQn 0 */ + + /* USER CODE END DMA1_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA1_Stream0_IRQn 1 */ + + /* USER CODE END DMA1_Stream0_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream1 global interrupt. + */ +void DMA1_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream1_IRQn 0 */ + + /* USER CODE END DMA1_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA1_Stream1_IRQn 1 */ + + /* USER CODE END DMA1_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream2 global interrupt. + */ +void DMA1_Stream2_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ + + /* USER CODE END DMA1_Stream2_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_spi3_tx); + /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ + + /* USER CODE END DMA1_Stream2_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream3 global interrupt. + */ +void DMA1_Stream3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream3_IRQn 0 */ + + /* USER CODE END DMA1_Stream3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc1); + /* USER CODE BEGIN DMA1_Stream3_IRQn 1 */ + + /* USER CODE END DMA1_Stream3_IRQn 1 */ +} + +/** + * @brief This function handles ADC1 and ADC2 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + +/** + * @brief This function handles SPI3 global interrupt. + */ +void SPI3_IRQHandler(void) +{ + /* USER CODE BEGIN SPI3_IRQn 0 */ + + /* USER CODE END SPI3_IRQn 0 */ + HAL_SPI_IRQHandler(&hspi3); + /* USER CODE BEGIN SPI3_IRQn 1 */ + + /* USER CODE END SPI3_IRQn 1 */ +} + +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + +/** + * @brief This function handles QUADSPI global interrupt. + */ +void QUADSPI_IRQHandler(void) +{ + /* USER CODE BEGIN QUADSPI_IRQn 0 */ + + /* USER CODE END QUADSPI_IRQn 0 */ + HAL_QSPI_IRQHandler(&hqspi); + /* USER CODE BEGIN QUADSPI_IRQn 1 */ + + /* USER CODE END QUADSPI_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/system_stm32h7xx.c b/ACDC/Core/Src/system_stm32h7xx.c new file mode 100644 index 00000000..9ae8b842 --- /dev/null +++ b/ACDC/Core/Src/system_stm32h7xx.c @@ -0,0 +1,402 @@ +/** + ****************************************************************************** + * @file system_stm32h7xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32h7xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock, it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx_system + * @{ + */ + +/** @addtogroup STM32H7xx_System_Private_Includes + * @{ + */ + +#include "stm32h7xx.h" +#include +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (CSI_VALUE) + #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ +#define DATA_IN_D2_SRAM + +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 64000000; + uint32_t SystemD2Clock = 64000000; + const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting and vector table location + * configuration. + * @param None + * @retval None + */ +void SystemInit (void) +{ +#if defined (DATA_IN_D2_SRAM) + __IO uint32_t tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + + /* Increasing the CPU frequency */ + if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + + /* Set HSION bit */ + RCC->CR |= RCC_CR_HSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */ + RCC->CR &= 0xEAF6ED7FU; + + /* Decreasing the number of wait states because of lower CPU frequency */ + if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + +#if defined(D3_SRAM_BASE) + /* Reset D1CFGR register */ + RCC->D1CFGR = 0x00000000; + + /* Reset D2CFGR register */ + RCC->D2CFGR = 0x00000000; + + /* Reset D3CFGR register */ + RCC->D3CFGR = 0x00000000; +#else + /* Reset CDCFGR1 register */ + RCC->CDCFGR1 = 0x00000000; + + /* Reset CDCFGR2 register */ + RCC->CDCFGR2 = 0x00000000; + + /* Reset SRDCFGR register */ + RCC->SRDCFGR = 0x00000000; +#endif + /* Reset PLLCKSELR register */ + RCC->PLLCKSELR = 0x02020200; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x01FF0000; + /* Reset PLL1DIVR register */ + RCC->PLL1DIVR = 0x01010280; + /* Reset PLL1FRACR register */ + RCC->PLL1FRACR = 0x00000000; + + /* Reset PLL2DIVR register */ + RCC->PLL2DIVR = 0x01010280; + + /* Reset PLL2FRACR register */ + + RCC->PLL2FRACR = 0x00000000; + /* Reset PLL3DIVR register */ + RCC->PLL3DIVR = 0x01010280; + + /* Reset PLL3FRACR register */ + RCC->PLL3FRACR = 0x00000000; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000; + +#if (STM32H7_DEV_ID == 0x450UL) + /* dual core CM7 or single core line */ + if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) + { + /* if stm32h7 revY*/ + /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ + *((__IO uint32_t*)0x51008108) = 0x000000001U; + } +#endif + +#if defined (DATA_IN_D2_SRAM) + /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock (AHB SRAM clock) */ +#if defined(RCC_AHB2ENR_D2SRAM3EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); +#elif defined(RCC_AHB2ENR_D2SRAM2EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN); +#else + RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); +#endif /* RCC_AHB2ENR_D2SRAM3EN */ + + tmpreg = RCC->AHB2ENR; + (void) tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* + * Disable the FMC bank1 (enabled after reset). + * This, prevents CPU speculation access on this bank which blocks the use of FMC during + * 24us. During this time the others FMC master (such as LTDC) cannot use it! + */ + FMC_Bank1_R->BTCR[0] = 0x000030D2; + + /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ + extern char _ISR_VECTOR; + SCB->VTOR = (uint32_t)&_ISR_VECTOR; + +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock , it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*) + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*), + * HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors. + * + * (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 64 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 25 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; + uint32_t common_system_clock; + float_t fracn1, pllvco; + + + /* Get SYSCLK source -------------------------------------------------------*/ + + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */ + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + + case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */ + common_system_clock = CSI_VALUE; + break; + + case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */ + common_system_clock = HSE_VALUE; + break; + + case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC); + pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ; + pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos); + fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3)); + + if (pllm != 0U) + { + switch (pllsource) + { + case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ + + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + + break; + + case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ + pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ + pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + default: + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + } + pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ; + common_system_clock = (uint32_t)(float_t)(pllvco/(float_t)pllp); + } + else + { + common_system_clock = 0U; + } + break; + + default: + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + } + + /* Compute SystemClock frequency --------------------------------------------------*/ +#if defined (RCC_D1CFGR_D1CPRE) + tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); + +#else + tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU)); + +#endif + +#if defined(DUAL_CORE) && defined(CORE_CM4) + SystemCoreClock = SystemD2Clock; +#else + SystemCoreClock = common_system_clock; +#endif /* DUAL_CORE && CORE_CM4 */ +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Makefile b/ACDC/Makefile new file mode 100644 index 00000000..07a099a6 --- /dev/null +++ b/ACDC/Makefile @@ -0,0 +1,48 @@ +PROJECT = ACDC +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +LDSCRIPT = $(OPENWARE)/Hardware/xibeca.ld +include $(OPENWARE)/Hardware/owl3.mk + +C_SRC = $(wildcard Core/Src/*.c) +CPP_SRC = $(wildcard Core/Src/*.cpp) +C_SRC += $(OPENWARE)/Source/pcm3168a.c +C_SRC += $(OPENWARE)/Source/usbd_audio.c +# C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/sdram-as4cXm32.c + +# CPP_SRC += $(OPENWARE)/Source/uart.cpp +# CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp + +S_SRC = $(BUILDROOT)/Core/Src/startup_stm32h743xx.s + +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usb_device.c +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usbd_desc.c +C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c + +# CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp +# C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c +# C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c + +C_SRC += $(OPENWARE)/Source/flash.c + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_SAI) +# C_SRC += $(C_SRC_DAC) +C_SRC += $(C_SRC_SDRAM) +C_SRC += $(C_SRC_USBD) +# C_SRC += $(C_SRC_USBH) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_I2C) +C_SRC += $(C_SRC_QSPI) +C_SRC += $(C_SRC_MDMA) + +include $(OPENWARE)/Hardware/h7.mk + +dfu: Build/${PROJECT}.bin + $(DFUUTIL) -d 0483:df11 -c 1 -i 0 -a 0 -s 0x8000000 -D $< + @echo Uploaded $< to Xibeca bootsector diff --git a/ACDC/USB_DEVICE/App/usb_device.c b/ACDC/USB_DEVICE/App/usb_device.c new file mode 100644 index 00000000..9b34c972 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usb_device.c @@ -0,0 +1,100 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" + +/* USER CODE BEGIN Includes */ +#include "usbd_audio.h" +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef hUsbDeviceFS; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/App/usb_device.h b/ACDC/USB_DEVICE/App/usb_device.h new file mode 100644 index 00000000..7c91b657 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/App/usbd_desc.c b/ACDC/USB_DEVICE/App/usbd_desc.c new file mode 100644 index 00000000..976791a4 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usbd_desc.c @@ -0,0 +1,394 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : App/usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_FS 0xDADA +#define USBD_PRODUCT_STRING_FS "OWL-ACDC" +#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" +#define USBD_INTERFACE_STRING_FS "AUDIO Interface" + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for FS. + * @{ + */ + +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef FS_Desc = +{ + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/* USB_DeviceDescriptor */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang identifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ + + /* USER CODE END USBD_FS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/App/usbd_desc.h b/ACDC/USB_DEVICE/App/usbd_desc.h new file mode 100644 index 00000000..51de9706 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef FS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/Target/usbd_conf.c b/ACDC/USB_DEVICE/Target/usbd_conf.c new file mode 100644 index 00000000..073b6145 --- /dev/null +++ b/ACDC/USB_DEVICE/Target/usbd_conf.c @@ -0,0 +1,680 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : Target/usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +/* USER CODE BEGIN Includes */ +#include "device.h" +uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_FS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 9; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +/* void *USBD_static_malloc(uint32_t size) */ +/* { */ +/* static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/\* On 32-bit boundary *\/ */ +/* return mem; */ +/* } */ + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + +/** + * @brief Delays routine for the USB device library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/Target/usbd_conf.h b/ACDC/USB_DEVICE/Target/usbd_conf.h new file mode 100644 index 00000000..7fb0f34a --- /dev/null +++ b/ACDC/USB_DEVICE/Target/usbd_conf.h @@ -0,0 +1,176 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 5U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 1U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL 0U +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U +/*---------- -----------*/ +#define USBD_AUDIO_FREQ 22100U + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros make sure to use static memory allocation */ +/** Alias for memory allocation. */ +#define USBD_malloc (void *)USBD_static_malloc + +/** Alias for memory release. */ +#define USBD_free USBD_static_free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Alchemist/Alchemist.ioc b/Alchemist/Alchemist.ioc index 249821e6..a9431db5 100644 --- a/Alchemist/Alchemist.ioc +++ b/Alchemist/Alchemist.ioc @@ -1,641 +1,653 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -USB_DEVICE.PID_AUDIO_HS=0xDADA -Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D0_DA0.ConfNb=1 -RCC.USART1Freq_Value=108000000 -Dma.ADC3.0.Priority=DMA_PRIORITY_LOW -USART2.IPParameters=VirtualMode -SH.FMC_A8.ConfNb=1 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SH.FMC_A0.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.RCDDelay1=2 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -SPI1.VirtualType=VM_MASTER -Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.GPXTI9.0=GPIO_EXTI9 -PG4.Signal=FMC_A14_BA0 -PG8.Signal=FMC_SDCLK -RCC.PLLCLKFreq_Value=168000000 -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -FMC.LoadToActiveDelay1=2 -VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled -PC3.Locked=true -RCC.RTCFreq_Value=32000 -PA6.GPIO_Label=FLASH_MISO -Dma.SAI1_A.1.Mode=DMA_CIRCULAR -SH.FMC_SDNWE.ConfNb=1 -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB13.Signal=USB_OTG_HS_VBUS -Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PD6.GPIO_Label=CS_SDIN -Dma.SAI1_B.2.Mode=DMA_CIRCULAR -PinOutPanel.RotationAngle=0 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -PE6.GPIO_Label=CS_SDA -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=54000000 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -PF7.Signal=SPI5_SCK -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -Dma.SAI1_A.1.Instance=DMA2_Stream1 -RCC.I2C4Freq_Value=54000000 -PE2.Mode=TX_Only_Simplex_Unidirect_Master -TIM2.IPParameters=Period,Prescaler,Pulse-PWM Generation1 CH1,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Pulse-PWM Generation2 CH2 -RCC.APB2TimFreq_Value=168000000 -PB2/BOOT1.GPIO_Label=SW2 -PB6.Signal=FMC_SDNE1 -Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D10_DA10.ConfNb=1 -PH1/OSC_OUT.Signal=RCC_OSC_OUT -PB6.Mode=SdramChipSelect2_1 -SPI1.CalculateBaudRate=42.0 MBits/s -PC3.Signal=ADCx_IN13 -PD0.Signal=FMC_D2_DA2 -ADC3.ScanConvMode=ENABLE -RCC.SAI2Freq_Value=50000000 -PD8.Signal=FMC_D13_DA13 -PE5.Signal=SAI1_SCK_A -Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE -PE1.Signal=FMC_NBL1 -PF10.GPIO_Label=ADC4 -Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE -RCC.USART3Freq_Value=54000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Full_Duplex_Master -Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.0 -MxDb.Version=DB.5.0.60 -PA1.GPIOParameters=GPIO_Label -ProjectManager.BackupPrevious=false -SAI1.SlotNumber-SAI_A_AsyncSlave=2 -PC4.GPIO_Label=FLASH_HOLD -PE9.Signal=FMC_D6_DA6 -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Device_Only_FS -PB1.GPIO_Label=PWM3 -SH.FMC_D15_DA15.ConfNb=1 -ADC3.ContinuousConvMode=ENABLE -PE4.GPIO_Label=CS_LRCK -PF10.Locked=true -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge -SH.ADCx_IN11.ConfNb=1 -PE2.Signal=SPI4_SCK -PF8.Mode=Full_Duplex_Master +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -PC15/OSC32_OUT.Locked=true -PF3.Signal=FMC_A3 -USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -PE10.Signal=FMC_D7_DA7 -ProjectManager.HalAssertFull=true -USB_DEVICE.MANUFACTURER_STRING-AUDIO_HS=Rebel Technology -RCC.MCO2PinFreq_Value=168000000 -Mcu.Package=LQFP144 -PB9.Signal=GPXTI9 -TIM2.Prescaler=16 -PF8.GPIOParameters=GPIO_Label -PB1.Signal=S_TIM3_CH4 -SH.GPXTI8.0=GPIO_EXTI8 -Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 -SH.GPXTI8.ConfNb=1 -PB9.GPIO_PuPd=GPIO_PULLUP -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -TIM2.Pulse-PWM\ Generation2\ CH2=1023 -SH.FMC_A1.0=FMC_A1,12b-sda1 -SPI5.CalculateBaudRate=42.0 MBits/s +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.CECFreq_Value=32786.88524590164 -PF14.Signal=FMC_A8 +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -RCC.APB1TimFreq_Value=84000000 -Dma.ADC3.0.Instance=DMA2_Stream0 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FMC.RowCycleDelay2=6 -PF10.Mode=IN8 -FMC.RowCycleDelay1=6 -PB10.GPIOParameters=GPIO_Label -PB13.Mode=Activate_VBUS_FS +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=4 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 ADC3.Rank-34\#ChannelRegularConversion=4 -SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -PD15.Signal=FMC_D1_DA1 -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -SPI5.VirtualType=VM_MASTER -ProjectManager.CustomerFirmwarePackage= -PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -RCC.PLLSAIQCLKFreq_Value=50000000 -SH.FMC_D3_DA3.ConfNb=1 -PA6.GPIOParameters=GPIO_Label -PD6.GPIOParameters=GPIO_Label -SH.FMC_A4.0=FMC_A4,12b-sda1 -PA0/WKUP.GPIOParameters=GPIO_Label -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -ProjectManager.ProjectFileName=Alchemist.ioc -SH.FMC_A5.ConfNb=1 -SH.FMC_A1.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL -Mcu.PinsNb=78 -Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Mcu.Pin73=PE1 -Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin71=PB9 -Mcu.Pin72=PE0 -Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS -PG5.Signal=FMC_A15_BA1 -Mcu.Pin75=VP_RTC_VS_RTC_Activate -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=VP_SYS_VS_Systick -FREERTOS.INCLUDE_vTaskDelayUntil=1 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -Mcu.Pin70=PB8 -PB8.GPIO_PuPd=GPIO_PULLUP -PC2.Signal=ADCx_IN12 -PB11.GPIO_Label=CS_nRST -PD1.Signal=FMC_D3_DA3 -RCC.VCOSAIOutputFreq_ValueQ=25000000 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin68=PB5 -Mcu.Pin69=PB6 -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PA14 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS -USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS -Mcu.Pin63=PD0 -Mcu.Pin60=PG8 -SH.S_TIM2_CH1_ETR.ConfNb=1 -Mcu.Pin61=PA13 -Mcu.Pin66=PG15 -Mcu.Pin67=PB3 -Mcu.Pin64=PD1 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PD6 +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.0.Instance=DMA2_Stream0 +Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +Dma.ADC3.0.Mode=DMA_CIRCULAR +Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.0.Priority=DMA_PRIORITY_LOW +Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=ADC3 +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.RequestsNb=3 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream1 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -USB_DEVICE.VID-AUDIO_HS=0x1209 -PF8.GPIO_Label=EXTSPI_MISO -PC3.GPIOParameters=GPIO_Label -PD10.Signal=FMC_D15_DA15 -PA3.Mode=Asynchronous -SH.FMC_A3.0=FMC_A3,12b-sda1 -PB8.GPIO_Label=SW3 -Mcu.Pin59=PG5 +Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PD15 -Mcu.Pin58=PG4 -Mcu.Pin51=PB14 -RCC.USART6Freq_Value=108000000 -Mcu.Pin52=PB15 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin50=PB13 -Mcu.Pin55=PD10 -Mcu.Pin56=PD14 -Mcu.Pin53=PD8 -Mcu.Pin54=PD9 -SH.S_TIM2_CH2.ConfNb=1 -PB9.Locked=true -PB11.GPIOParameters=GPIO_Label -ADC3.NbrOfConversion=4 -Mcu.Pin48=PB10 -Mcu.Pin49=PB11 -Mcu.Pin46=PE14 -Mcu.Pin47=PE15 -PB10.Signal=GPIO_Output -PB14.Signal=USB_OTG_HS_DM -Mcu.Pin40=PE8 -Mcu.Pin41=PE9 -FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PE12 -Mcu.Pin45=PE13 -Mcu.Pin42=PE10 -Mcu.Pin43=PE11 -ProjectManager.LastFirmware=true +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -PE15.Signal=FMC_D12_DA12 -Mcu.Pin37=PG0 -Mcu.Pin38=PG1 -Mcu.Pin35=PF14 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PF15 -PE8.Signal=FMC_D5_DA5 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE7 -PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PB1 -PA1.GPIO_Label=PWM2 -RCC.EthernetFreq_Value=168000000 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin33=PF12 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,Pulse-PWM Generation4 CH4 -Mcu.Pin34=PF13 -PA0/WKUP.GPIO_Label=PWM1 -ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin31=PB2/BOOT1 -Mcu.Pin32=PF11 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -TIM2.Period=1023 -PA13.Mode=Serial_Wire -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -ProjectManager.FreePins=true -Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PF9.GPIOParameters=GPIO_Label -SH.FMC_NBL1.ConfNb=1 -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA6 -Mcu.Pin27=PA7 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -RCC.RTCHSEDivFreq_Value=12500000 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32F4 +Mcu.IP0=ADC3 +Mcu.IP1=DMA +Mcu.IP10=SPI5 +Mcu.IP11=SYS +Mcu.IP12=TIM2 +Mcu.IP13=TIM3 +Mcu.IP14=USART2 +Mcu.IP15=USB_DEVICE +Mcu.IP16=USB_OTG_HS +Mcu.IP2=FMC +Mcu.IP3=FREERTOS +Mcu.IP4=NVIC +Mcu.IP5=RCC +Mcu.IP6=RTC +Mcu.IP7=SAI1 +Mcu.IP8=SPI1 +Mcu.IP9=SPI4 +Mcu.IPNb=17 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF9 +Mcu.Pin15=PF10 +Mcu.Pin16=PH0/OSC_IN +Mcu.Pin17=PH1/OSC_OUT +Mcu.Pin18=PC0 +Mcu.Pin19=PC1 +Mcu.Pin2=PE4 +Mcu.Pin20=PC2 +Mcu.Pin21=PC3 +Mcu.Pin22=PA0/WKUP +Mcu.Pin23=PA1 Mcu.Pin24=PA2 -ProjectManager.UnderRoot=false Mcu.Pin25=PA3 +Mcu.Pin26=PA6 +Mcu.Pin27=PA7 Mcu.Pin28=PC4 Mcu.Pin29=PC5 -SH.FMC_D7_DA7.ConfNb=1 -Mcu.Pin22=PA0/WKUP -PB5.Signal=FMC_SDCKE1 -Mcu.Pin23=PA1 -Mcu.Pin20=PC2 -Mcu.Pin21=PC3 +Mcu.Pin3=PE5 +Mcu.Pin30=PB0 +Mcu.Pin31=PB1 +Mcu.Pin32=PB2/BOOT1 +Mcu.Pin33=PF11 +Mcu.Pin34=PF12 +Mcu.Pin35=PF13 +Mcu.Pin36=PF14 +Mcu.Pin37=PF15 +Mcu.Pin38=PG0 +Mcu.Pin39=PG1 +Mcu.Pin4=PE6 +Mcu.Pin40=PE7 +Mcu.Pin41=PE8 +Mcu.Pin42=PE9 +Mcu.Pin43=PE10 +Mcu.Pin44=PE11 +Mcu.Pin45=PE12 +Mcu.Pin46=PE13 +Mcu.Pin47=PE14 +Mcu.Pin48=PE15 +Mcu.Pin49=PB10 +Mcu.Pin5=PC15/OSC32_OUT +Mcu.Pin50=PB11 +Mcu.Pin51=PB13 +Mcu.Pin52=PB14 +Mcu.Pin53=PB15 +Mcu.Pin54=PD8 +Mcu.Pin55=PD9 +Mcu.Pin56=PD10 +Mcu.Pin57=PD14 +Mcu.Pin58=PD15 +Mcu.Pin59=PG4 +Mcu.Pin6=PF0 +Mcu.Pin60=PG5 +Mcu.Pin61=PG8 +Mcu.Pin62=PA13 +Mcu.Pin63=PA14 +Mcu.Pin64=PD0 +Mcu.Pin65=PD1 +Mcu.Pin66=PD6 +Mcu.Pin67=PG15 +Mcu.Pin68=PB3 +Mcu.Pin69=PB5 +Mcu.Pin7=PF1 +Mcu.Pin70=PB6 +Mcu.Pin71=PB8 +Mcu.Pin72=PB9 +Mcu.Pin73=PE0 +Mcu.Pin74=PE1 +Mcu.Pin75=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin76=VP_RTC_VS_RTC_Activate +Mcu.Pin77=VP_SYS_VS_Systick +Mcu.Pin78=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS +Mcu.Pin8=PF2 +Mcu.Pin9=PF3 +Mcu.PinsNb=79 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true NVIC.ForceEnableDMAVector=true -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PF10 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH0/OSC_IN -ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PF8 -Dma.ADC3.0.Mode=DMA_CIRCULAR -Mcu.Pin14=PF9 -PF10.GPIOParameters=GPIO_Label -Mcu.Pin19=PC1 -ProjectManager.ComputerToolchain=false -PF9.Signal=SPI5_MOSI -Mcu.Pin17=PH1/OSC_OUT -Mcu.Pin18=PC0 -Dma.SAI1_B.2.Instance=DMA2_Stream4 +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF7 -Mcu.Pin10=PF4 -Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH -PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PE3.Signal=SAI1_SD_B -PC3.GPIO_Label=ADC1 -ADC3.Rank-33\#ChannelRegularConversion=3 -Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE -PC15/OSC32_OUT.Signal=GPIO_Output -PF4.Signal=FMC_A4 -Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D12_DA12.ConfNb=1 -RCC.I2C2Freq_Value=54000000 -SPI5.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0/WKUP.GPIOParameters=GPIO_Label +PA0/WKUP.GPIO_Label=PWM1 +PA0/WKUP.Signal=S_TIM2_CH1_ETR +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=PWM2 +PA1.Signal=S_TIM2_CH2 +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA2.Locked=true +PA2.Mode=Asynchronous +PA2.Signal=USART2_TX +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=PWM3 +PB1.Signal=S_TIM3_CH4 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_nCS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_nRST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB13.Mode=Activate_VBUS_FS +PB13.Signal=USB_OTG_HS_VBUS +PB14.Mode=Device_Only_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Device_Only_FS +PB15.Signal=USB_OTG_HS_DP +PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB2/BOOT1.GPIO_Label=SW2 +PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPXTI2 +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB8.GPIO_Label=SW3 +PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB8.GPIO_PuPd=GPIO_PULLUP +PB8.Locked=true +PB8.Signal=GPXTI8 +PB9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB9.GPIO_Label=SW1 +PB9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB9.GPIO_PuPd=GPIO_PULLUP +PB9.Locked=true +PB9.Signal=GPXTI9 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC3 +PC1.Locked=true PC1.Signal=ADCx_IN11 -ADC3.EnableAnalogWatchDog=false -Mcu.Family=STM32F4 -FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -PA6.Mode=Full_Duplex_Master -SH.FMC_A8.0=FMC_A8,12b-sda1 -RCC.SAI1Freq_Value=50000000 -RCC.CortexFreq_Value=168000000 -SH.FMC_A2.ConfNb=1 +PC15/OSC32_OUT.GPIOParameters=GPIO_Label PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -ProjectManager.KeepUserCode=true -Mcu.UserName=STM32F427ZITx -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE -SAI1.FrameLength-SAI_A_AsyncSlave=64 -SAI1.FrameLength-SAI_B_SyncSlave=64 +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS PC5.Locked=true -SPI4.Direction=SPI_DIRECTION_2LINES -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PA0/WKUP.Signal=S_TIM2_CH1_ETR -PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -RCC.PLLI2SRCLKFreq_Value=96000000 -RCC.USART2Freq_Value=54000000 -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -SH.FMC_A11.0=FMC_A11,12b-sda1 -TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 -PC1.Locked=true -PB11.Signal=GPIO_Output -PB15.Signal=USB_OTG_HS_DP -ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 +PC5.Signal=GPIO_Output +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_Label +PF7.GPIO_Label=EXTSPI_SCK +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK +PF8.GPIOParameters=GPIO_Label +PF8.GPIO_Label=EXTSPI_MISO +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=EXTSPI_MOSI +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 PG15.Signal=FMC_SDNCAS -PE5.GPIOParameters=GPIO_Label +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=0 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Alchemist.ioc +ProjectManager.ProjectName=Alchemist +ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -SH.GPXTI2.0=GPIO_EXTI2 -RCC.SAI_BClocksFreq_Value=25000000 -ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -RCC.I2C3Freq_Value=54000000 -Mcu.IP4=NVIC -Mcu.IP5=RCC +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=FMC -Mcu.IP3=FREERTOS -Mcu.IP0=ADC3 -SH.FMC_A7.0=FMC_A7,12b-sda1 -Mcu.IP1=DMA -PE4.GPIOParameters=GPIO_Label -PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.UserConstants= -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -RCC.SDMMCFreq_Value=216000000 -Mcu.ThirdPartyNb=0 -PH0/OSC_IN.Mode=HSE-External-Oscillator +RCC.FamilyName=M RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=17 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 -ProjectManager.PreviousToolchain= -TIM3.Period=1023 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 RCC.SPDIFRXFreq_Value=96000000 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -PB9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.Pin6=PF0 -Mcu.Pin7=PF1 -NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 RCC.VCOSAIOutputFreq_Value=100000000 -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction -Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -Mcu.Pin2=PE4 -FREERTOS.configUSE_PREEMPTION=0 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -Mcu.Pin5=PC15/OSC32_OUT -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 SH.FMC_A14_BA0.ConfNb=1 -ADC3.InjNumberOfConversion=0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.ExitSelfRefreshDelay1=6 -FMC.RPDelay2=2 -Mcu.IP10=SPI5 -FMC.RPDelay1=2 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=TIM2 -Mcu.IP11=SYS -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -PC15/OSC32_OUT.GPIOParameters=GPIO_Label -SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -Mcu.IP14=USART2 -PF9.Mode=Full_Duplex_Master -Mcu.IP13=TIM3 -PE13.Signal=FMC_D10_DA10 -Mcu.IP16=USB_OTG_HS -Mcu.IP15=USB_DEVICE -PF7.GPIO_Label=EXTSPI_SCK -RCC.VCOInputFreq_Value=1000000 -PA14.Mode=Serial_Wire -TIM3.Prescaler=16 -PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP -PF11.Signal=FMC_SDNRAS -PB5.Mode=SdramChipSelect2_1 -File.Version=6 -PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.ADCx_IN13.ConfNb=1 -SH.FMC_D5_DA5.ConfNb=1 -PB3.GPIOParameters=GPIO_Label -Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 SH.FMC_D2_DA2.ConfNb=1 -PB8.Locked=true -TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -PH1/OSC_OUT.Mode=HSE-External-Oscillator -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=3 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI8.0=GPIO_EXTI8 +SH.GPXTI8.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 +SH.S_TIM2_CH1_ETR.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 +SH.S_TIM3_CH4.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -ProjectManager.ProjectName=Alchemist -PA6.Signal=SPI1_MISO -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +SPI5.CalculateBaudRate=42.0 MBits/s +SPI5.Direction=SPI_DIRECTION_2LINES +SPI5.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI5.Mode=SPI_MODE_MASTER +SPI5.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM2.IPParameters=Period,Prescaler,Pulse-PWM Generation1 CH1,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Pulse-PWM Generation2 CH2 +TIM2.Period=1023 +TIM2.Prescaler=16 +TIM2.Pulse-PWM\ Generation1\ CH1=1023 +TIM2.Pulse-PWM\ Generation2\ CH2=1023 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,Pulse-PWM Generation4 CH4 +TIM3.Period=1023 +TIM3.Prescaler=16 +TIM3.Pulse-PWM\ Generation4\ CH4=1023 +USART2.IPParameters=VirtualMode USART2.VirtualMode=VM_ASYNC -SH.FMC_D4_DA4.ConfNb=1 -ProjectManager.ToolChainLocation= -RCC.LSI_VALUE=32000 -SH.FMC_A9.0=FMC_A9,12b-sda1 USB_DEVICE.CLASS_NAME_HS=AUDIO -PF8.Signal=SPI5_MISO -SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +USB_DEVICE.IPParameters=CLASS_NAME_HS,VirtualModeHS,SERIALNUMBER_STRING_AUDIO_HS,PRODUCT_STRING_AUDIO_HS,PID_AUDIO_HS,MANUFACTURER_STRING-AUDIO_HS,VID-AUDIO_HS,VirtualMode-AUDIO_HS,USBD_MAX_NUM_INTERFACES-AUDIO_HS,USBD_AUDIO_FREQ-AUDIO_HS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_HS=Rebel Technology +USB_DEVICE.PID_AUDIO_HS=0xDADA +USB_DEVICE.PRODUCT_STRING_AUDIO_HS=OWL-ALCHEMIST +USB_DEVICE.SERIALNUMBER_STRING_AUDIO_HS=00000000010D +USB_DEVICE.USBD_AUDIO_FREQ-AUDIO_HS=48000 +USB_DEVICE.USBD_MAX_NUM_INTERFACES-AUDIO_HS=5 +USB_DEVICE.VID-AUDIO_HS=0x1209 USB_DEVICE.VirtualMode-AUDIO_HS=Audio -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 USB_DEVICE.VirtualModeHS=Audio_HS -Dma.Request2=SAI1_B -SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS -Dma.Request1=SAI1_A -ADC3.Rank-32\#ChannelRegularConversion=2 -PC4.Locked=true -PF0.Signal=FMC_A0 -PC5.Signal=GPIO_Output -PE7.Signal=FMC_D4_DA4 -SH.FMC_NBL0.ConfNb=1 -PD6.Signal=SAI1_SD_A -SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS -Dma.Request0=ADC3 -PE3.Mode=SAI_B_SyncSlave -PE2.GPIO_Label=CS_SCK -PC2.GPIO_Label=ADC2 -USB_DEVICE.PRODUCT_STRING_AUDIO_HS=OWL-MIDI -PB3.Locked=true -PA3.Signal=USART2_RX -PA2.Locked=true -PB3.GPIO_Label=FLASH_SCK -SH.FMC_A3.ConfNb=1 -VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate -ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.I2SFreq_Value=96000000 -ADC3.DiscontinuousConvMode=DISABLE -SH.ADCx_IN13.0=ADC3_IN13,IN13 -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PA7.Mode=Full_Duplex_Master -RCC.UART7Freq_Value=54000000 -PB9.GPIO_Label=SW1 -ProjectManager.NoMain=false -SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -PG1.Signal=FMC_A11 -SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -USB_DEVICE.SERIALNUMBER_STRING_AUDIO_HS=00000000010D -ProjectManager.DeletePrevious=true -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -USB_DEVICE.IPParameters=CLASS_NAME_HS,VirtualModeHS,SERIALNUMBER_STRING_AUDIO_HS,PRODUCT_STRING_AUDIO_HS,PID_AUDIO_HS,MANUFACTURER_STRING-AUDIO_HS,VID-AUDIO_HS,VirtualMode-AUDIO_HS -SPI5.Mode=SPI_MODE_MASTER -RCC.FamilyName=M -TIM2.Pulse-PWM\ Generation1\ CH1=1023 -PB9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PA13.Signal=SYS_JTMS-SWDIO -PF7.Mode=Full_Duplex_Master +USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS +USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 -SH.ADCx_IN12.0=ADC3_IN12,IN12 -SH.FMC_A15_BA1.ConfNb=1 -PB2/BOOT1.Signal=GPXTI2 -ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ProjectManager.TargetToolchain=Makefile -PB10.GPIO_Label=CS_nCS -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SH.FMC_D1_DA1.ConfNb=1 -PC5.GPIOParameters=GPIO_Label -RCC.VcooutputI2SQ=96000000 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Mode=AUDIO_HS -PF2.Signal=FMC_A2 -PE2.GPIOParameters=GPIO_Label -PC2.Locked=true -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=EXTSPI_MOSI -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PA1.Signal=S_TIM2_CH2 -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -RCC.VCOI2SOutputFreq_Value=192000000 -RCC.PLLSAIPCLKFreq_Value=50000000 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS board=Alchemist -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Device_Only_FS -PH0/OSC_IN.Signal=RCC_OSC_IN -RCC.APB2Freq_Value=84000000 -RCC.UART4Freq_Value=54000000 -SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=5.6.0 -SH.FMC_D13_DA13.ConfNb=1 -PF10.Signal=ADC3_IN8 -PE5.Mode=SAI_A_AsyncSlave -PC1.GPIO_Label=ADC3 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=656.25 KBits/s -Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH -PF1.Signal=FMC_A1 -PE6.Signal=SPI4_MOSI -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 -ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -Mcu.Name=STM32F427Z(G-I)Tx -PE0.Signal=FMC_NBL0 -Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY -PE12.Signal=FMC_D9_DA9 -PA2.Signal=USART2_TX -Mcu.IP8=SPI1 -Mcu.IP9=SPI4 -PD14.Signal=FMC_D0_DA0 -Mcu.IP6=RTC -Mcu.IP7=SAI1 -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -PB3.Signal=SPI1_SCK -RCC.SYSCLKFreq_VALUE=168000000 -PA7.GPIO_Label=FLASH_MOSI -KeepUserPlacement=false -PC5.GPIO_Label=FLASH_nCS -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -SH.GPXTI9.ConfNb=1 -NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -PA14.Signal=SYS_JTCK-SWCLK -RCC.HSI_VALUE=16000000 -Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -SH.S_TIM3_CH4.ConfNb=1 -RCC.PLLQ=7 -RCC.PLLM=25 -RCC.PLLN=336 -PB2/BOOT1.Locked=true -Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PA2.Mode=Asynchronous -PB8.Signal=GPXTI8 -PE3.GPIO_Label=CS_SDOUT -SH.FMC_D8_DA8.ConfNb=1 -RCC.APB1Freq_Value=42000000 -ADC3.NbrOfConversionFlag=1 -TIM3.Pulse-PWM\ Generation4\ CH4=1023 -PB11.Locked=true -ProjectManager.DeviceId=STM32F427ZITx -ProjectManager.LibraryCopy=0 -SPI5.Direction=SPI_DIRECTION_2LINES -SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -ADC3.Rank-31\#ChannelRegularConversion=1 -PB1.GPIOParameters=GPIO_Label -PA7.Signal=SPI1_MOSI diff --git a/Alchemist/Inc/FreeRTOSConfig.h b/Alchemist/Inc/FreeRTOSConfig.h index 90c0b895..ab2425cc 100644 --- a/Alchemist/Inc/FreeRTOSConfig.h +++ b/Alchemist/Inc/FreeRTOSConfig.h @@ -78,13 +78,13 @@ * These definitions should be adjusted for your particular hardware and * application requirements. * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. * - * See http://www.freertos.org/a00110.html. + * See http://www.freertos.org/a00110.html *----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ #include "device.h" #ifdef DEBUG_STACK @@ -92,7 +92,7 @@ #define INCLUDE_uxTaskGetStackHighWaterMark 1 #endif /* DEBUG_STACK */ -/* USER CODE END Includes */ +/* USER CODE END Includes */ /* Ensure definitions are only used by the compiler, and not by the assembler. */ #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) @@ -124,7 +124,7 @@ /* Defaults to size_t for backward compatibility, but can be changed if lengths will always be less than the number of bytes in a size_t. */ #define configMESSAGE_BUFFER_LENGTH_TYPE size_t -/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 @@ -179,11 +179,11 @@ standard names. */ /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ - + /* #define xPortSysTickHandler SysTick_Handler */ -/* USER CODE BEGIN Defines */ +/* USER CODE BEGIN Defines */ /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ -/* USER CODE END Defines */ +/* USER CODE END Defines */ #endif /* FREERTOS_CONFIG_H */ diff --git a/Alchemist/Inc/hardware.h b/Alchemist/Inc/hardware.h index b5a674b2..4ce74a7e 100644 --- a/Alchemist/Inc/hardware.h +++ b/Alchemist/Inc/hardware.h @@ -6,15 +6,22 @@ #define HARDWARE_ID ALCHEMIST_HARDWARE #define HARDWARE_VERSION "Alchemist" +#define USE_SPI_FLASH + /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ #define USBD_HANDLE hUsbDeviceHS #define USE_MODE_BUTTON diff --git a/Alchemist/Inc/main.h b/Alchemist/Inc/main.h index cf07674e..8b221138 100644 --- a/Alchemist/Inc/main.h +++ b/Alchemist/Inc/main.h @@ -128,6 +128,8 @@ void Error_Handler(void); #define FLASH_HOLD_GPIO_Port GPIOC #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC +#define FLASH_WP_Pin GPIO_PIN_0 +#define FLASH_WP_GPIO_Port GPIOB #define PWM3_Pin GPIO_PIN_1 #define PWM3_GPIO_Port GPIOB #define SW2_Pin GPIO_PIN_2 diff --git a/Alchemist/Inc/stm32f4xx_hal_conf.h b/Alchemist/Inc/stm32f4xx_hal_conf.h index dceb54c5..535ae668 100644 --- a/Alchemist/Inc/stm32f4xx_hal_conf.h +++ b/Alchemist/Inc/stm32f4xx_hal_conf.h @@ -2,7 +2,7 @@ ****************************************************************************** * @file stm32f4xx_hal_conf_template.h * @author MCD Application Team - * @brief HAL configuration template file. + * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f4xx_hal_conf.h. ****************************************************************************** @@ -17,7 +17,7 @@ * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** - */ + */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_CONF_H @@ -32,14 +32,15 @@ /* ########################## Module Selection ############################## */ /** - * @brief This is the list of modules to be used in the HAL driver + * @brief This is the list of modules to be used in the HAL driver */ -#define HAL_MODULE_ENABLED +#define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DCMI_MODULE_ENABLED */ @@ -75,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -90,20 +92,20 @@ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). + * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). + * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ @@ -112,8 +114,8 @@ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -121,20 +123,20 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -144,19 +146,59 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ -#define USE_RTOS 0U +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U #define DATA_CACHE_ENABLE 1U +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + /* ########################## Assert Selection ############################## */ /** - * @brief Uncomment the line below to expanse the "assert_param" macro in the + * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ - #define USE_FULL_ASSERT 1U + #define USE_FULL_ASSERT 1U /* ################## Ethernet peripheral configuration ##################### */ @@ -170,29 +212,29 @@ #define MAC_ADDR4 0U #define MAC_ADDR5 0U -/* Definition of the Ethernet driver buffers size and count */ +/* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ -/* DP83848_PHY_ADDRESS Address*/ +/* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - + #define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ @@ -207,7 +249,7 @@ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - + /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ @@ -225,25 +267,25 @@ /* Includes ------------------------------------------------------------------*/ /** - * @brief Include module's header file + * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f4xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f4xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f4xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ - + #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f4xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ @@ -256,18 +298,18 @@ #include "stm32f4xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f4xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" + #include "stm32f4xx_hal_cryp.h" #endif /* HAL_CRYP_MODULE_ENABLED */ -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - #ifdef HAL_DMA2D_MODULE_ENABLED #include "stm32f4xx_hal_dma2d.h" #endif /* HAL_DMA2D_MODULE_ENABLED */ @@ -287,7 +329,7 @@ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f4xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ - + #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f4xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ @@ -302,11 +344,11 @@ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - +#endif /* HAL_PCCARD_MODULE_ENABLED */ + #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ +#endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_HASH_MODULE_ENABLED #include "stm32f4xx_hal_hash.h" @@ -316,6 +358,10 @@ #include "stm32f4xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f4xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ @@ -348,10 +394,6 @@ #include "stm32f4xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f4xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ @@ -387,7 +429,7 @@ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f4xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ - + #ifdef HAL_DSI_MODULE_ENABLED #include "stm32f4xx_hal_dsi.h" #endif /* HAL_DSI_MODULE_ENABLED */ @@ -404,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ @@ -415,14 +461,18 @@ #ifdef HAL_LPTIM_MODULE_ENABLED #include "stm32f4xx_hal_lptim.h" #endif /* HAL_LPTIM_MODULE_ENABLED */ - + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function + * @param expr If expr is false, it calls assert_failed function * which reports the name of the source file and the source - * line number of the call that failed. + * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ @@ -431,13 +481,12 @@ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ +#endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_CONF_H */ - /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Alchemist/Inc/stm32f4xx_it.h b/Alchemist/Inc/stm32f4xx_it.h index 82404a30..7699b0ab 100644 --- a/Alchemist/Inc/stm32f4xx_it.h +++ b/Alchemist/Inc/stm32f4xx_it.h @@ -39,7 +39,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ diff --git a/Alchemist/Inc/usbd_conf.h b/Alchemist/Inc/usbd_conf.h index 0d55589d..622a1a23 100644 --- a/Alchemist/Inc/usbd_conf.h +++ b/Alchemist/Inc/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ @@ -91,14 +91,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -154,6 +153,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/Alchemist/Inc/usbd_desc.h b/Alchemist/Inc/usbd_desc.h index 5528b019..a1b866aa 100644 --- a/Alchemist/Inc/usbd_desc.h +++ b/Alchemist/Inc/usbd_desc.h @@ -17,7 +17,7 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ @@ -41,7 +41,7 @@ * @brief Usb device descriptors module. * @{ */ - + /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants * @brief Constants. * @{ diff --git a/Alchemist/Makefile b/Alchemist/Makefile index a9db5952..e6d1367f 100644 --- a/Alchemist/Makefile +++ b/Alchemist/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp include $(OPENWARE)/Hardware/sources.mk diff --git a/Alchemist/Src/Alchemist.cpp b/Alchemist/Src/Alchemist.cpp index 143babec..40935a9d 100644 --- a/Alchemist/Src/Alchemist.cpp +++ b/Alchemist/Src/Alchemist.cpp @@ -49,7 +49,10 @@ void onChangePin(uint16_t pin){ } } -void loop(void){ +void onSetup(){ + initLed(); +} + +void onLoop(){ owl_mode_button(); - owl.loop(); } diff --git a/Alchemist/Src/freertos.c b/Alchemist/Src/freertos.c index ad5906e2..ace53e48 100644 --- a/Alchemist/Src/freertos.c +++ b/Alchemist/Src/freertos.c @@ -54,7 +54,7 @@ #include "main.h" /* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ /* USER CODE END Includes */ diff --git a/Alchemist/Src/main.c b/Alchemist/Src/main.c index f0ced17a..5f290973 100644 --- a/Alchemist/Src/main.c +++ b/Alchemist/Src/main.c @@ -47,7 +47,6 @@ ****************************************************************************** */ /* USER CODE END Header */ - /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" @@ -103,6 +102,7 @@ osThreadId defaultTaskHandle; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); +void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_ADC3_Init(void); @@ -153,6 +153,9 @@ int main(void) /* Configure the system clock */ SystemClock_Config(); +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ @@ -228,7 +231,7 @@ int main(void) /* Start scheduler */ osKernelStart(); - + /* We should never get here as control is now taken by the scheduler */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ @@ -250,19 +253,19 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - /** Macro to configure SAI1BlockB clock source selection + /** Macro to configure SAI1BlockB clock source selection */ __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); - /** Macro to configure SAI1BlockA clock source selection + /** Macro to configure SAI1BlockA clock source selection */ __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); - /** Configure the main internal regulator output voltage + /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; @@ -277,7 +280,7 @@ void SystemClock_Config(void) { Error_Handler(); } - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; @@ -290,11 +293,22 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI; PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; PeriphClkInitStruct.PLLSAIDivQ = 1; - PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -318,7 +332,7 @@ static void MX_ADC3_Init(void) /* USER CODE BEGIN ADC3_Init 1 */ /* USER CODE END ADC3_Init 1 */ - /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) */ hadc3.Instance = ADC3; hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; @@ -336,7 +350,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_13; sConfig.Rank = 1; @@ -345,7 +359,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_12; sConfig.Rank = 2; @@ -353,7 +367,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_11; sConfig.Rank = 3; @@ -361,7 +375,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_8; sConfig.Rank = 4; @@ -390,7 +404,7 @@ static void MX_RTC_Init(void) /* USER CODE BEGIN RTC_Init 1 */ /* USER CODE END RTC_Init 1 */ - /** Initialize RTC Only + /** Initialize RTC Only */ hrtc.Instance = RTC; hrtc.Init.HourFormat = RTC_HOURFORMAT_24; @@ -723,10 +737,10 @@ static void MX_USART2_UART_Init(void) } -/** +/** * Enable DMA controller clock */ -static void MX_DMA_Init(void) +static void MX_DMA_Init(void) { /* DMA controller clock enable */ @@ -815,13 +829,13 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PC13 PC14 PC6 PC7 - PC8 PC9 PC10 PC11 + /*Configure GPIO pins : PC13 PC14 PC6 PC7 + PC8 PC9 PC10 PC11 PC12 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 |GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -840,18 +854,19 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : PA4 PA5 PA8 PA9 + /*Configure GPIO pins : PA4 PA5 PA8 PA9 PA10 PA11 PA12 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9 + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9 |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PB0 PB12 PB4 PB7 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + /*Configure GPIO pins : FLASH_WP_Pin CS_nCS_Pin CS_nRST_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|CS_nCS_Pin|CS_nRST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : SW2_Pin SW3_Pin SW1_Pin */ @@ -860,26 +875,25 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : CS_nCS_Pin CS_nRST_Pin */ - GPIO_InitStruct.Pin = CS_nCS_Pin|CS_nRST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + /*Configure GPIO pins : PB12 PB4 PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PD11 PD12 PD13 PD2 + /*Configure GPIO pins : PD11 PD12 PD13 PD2 PD3 PD4 PD5 PD7 */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PG2 PG3 PG6 PG7 - PG9 PG10 PG11 PG12 + /*Configure GPIO pins : PG2 PG3 PG6 PG7 + PG9 PG10 PG11 PG12 PG13 PG14 */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 |GPIO_PIN_13|GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -918,7 +932,7 @@ void StartDefaultTask(void const * argument) loop(); /* osDelay(1); */ } - /* USER CODE END 5 */ + /* USER CODE END 5 */ } /** @@ -946,7 +960,7 @@ void Error_Handler(void) * @retval None */ void assert_failed(uint8_t *file, uint32_t line) -{ +{ /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ diff --git a/Alchemist/Src/stm32f4xx_hal_msp.c b/Alchemist/Src/stm32f4xx_hal_msp.c index e716d151..643bc552 100644 --- a/Alchemist/Src/stm32f4xx_hal_msp.c +++ b/Alchemist/Src/stm32f4xx_hal_msp.c @@ -89,7 +89,7 @@ extern DMA_HandleTypeDef hdma_adc3; /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ - + void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); /** * Initializes the Global MSP. @@ -128,14 +128,14 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_ADC3_CLK_ENABLE(); - + __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); - /**ADC3 GPIO Configuration + /**ADC3 GPIO Configuration PF10 ------> ADC3_IN8 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 - PC3 ------> ADC3_IN13 + PC3 ------> ADC3_IN13 */ GPIO_InitStruct.Pin = ADC4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; @@ -188,12 +188,12 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_ADC3_CLK_DISABLE(); - - /**ADC3 GPIO Configuration + + /**ADC3 GPIO Configuration PF10 ------> ADC3_IN8 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 - PC3 ------> ADC3_IN13 + PC3 ------> ADC3_IN13 */ HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); @@ -216,11 +216,21 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) */ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) { + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hrtc->Instance==RTC) { /* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE END RTC_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */ @@ -268,13 +278,13 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI1_CLK_ENABLE(); - + __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); - /**SPI1 GPIO Configuration + /**SPI1 GPIO Configuration PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI - PB3 ------> SPI1_SCK + PB3 ------> SPI1_SCK */ GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -301,11 +311,11 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI4_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI4_CLK_ENABLE(); - + __HAL_RCC_GPIOE_CLK_ENABLE(); - /**SPI4 GPIO Configuration + /**SPI4 GPIO Configuration PE2 ------> SPI4_SCK - PE6 ------> SPI4_MOSI + PE6 ------> SPI4_MOSI */ GPIO_InitStruct.Pin = CS_SCK_Pin|CS_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -325,12 +335,12 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI5_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI5_CLK_ENABLE(); - + __HAL_RCC_GPIOF_CLK_ENABLE(); - /**SPI5 GPIO Configuration + /**SPI5 GPIO Configuration PF7 ------> SPI5_SCK PF8 ------> SPI5_MISO - PF9 ------> SPI5_MOSI + PF9 ------> SPI5_MOSI */ GPIO_InitStruct.Pin = EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -361,11 +371,11 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI1_CLK_DISABLE(); - - /**SPI1 GPIO Configuration + + /**SPI1 GPIO Configuration PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI - PB3 ------> SPI1_SCK + PB3 ------> SPI1_SCK */ HAL_GPIO_DeInit(GPIOA, FLASH_MISO_Pin|FLASH_MOSI_Pin); @@ -382,10 +392,10 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI4_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI4_CLK_DISABLE(); - - /**SPI4 GPIO Configuration + + /**SPI4 GPIO Configuration PE2 ------> SPI4_SCK - PE6 ------> SPI4_MOSI + PE6 ------> SPI4_MOSI */ HAL_GPIO_DeInit(GPIOE, CS_SCK_Pin|CS_SDA_Pin); @@ -400,11 +410,11 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI5_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI5_CLK_DISABLE(); - - /**SPI5 GPIO Configuration + + /**SPI5 GPIO Configuration PF7 ------> SPI5_SCK PF8 ------> SPI5_MISO - PF9 ------> SPI5_MOSI + PF9 ------> SPI5_MOSI */ HAL_GPIO_DeInit(GPIOF, EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin); @@ -457,9 +467,9 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /* USER CODE END TIM2_MspPostInit 0 */ __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM2 GPIO Configuration + /**TIM2 GPIO Configuration PA0/WKUP ------> TIM2_CH1 - PA1 ------> TIM2_CH2 + PA1 ------> TIM2_CH2 */ GPIO_InitStruct.Pin = PWM1_Pin|PWM2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -477,10 +487,10 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /* USER CODE BEGIN TIM3_MspPostInit 0 */ /* USER CODE END TIM3_MspPostInit 0 */ - + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**TIM3 GPIO Configuration - PB1 ------> TIM3_CH4 + /**TIM3 GPIO Configuration + PB1 ------> TIM3_CH4 */ GPIO_InitStruct.Pin = PWM3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -544,11 +554,11 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) /* USER CODE END USART2_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_USART2_CLK_ENABLE(); - + __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART2 GPIO Configuration + /**USART2 GPIO Configuration PA2 ------> USART2_TX - PA3 ------> USART2_RX + PA3 ------> USART2_RX */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -579,10 +589,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) /* USER CODE END USART2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART2_CLK_DISABLE(); - - /**USART2 GPIO Configuration + + /**USART2 GPIO Configuration PA2 ------> USART2_TX - PA3 ------> USART2_RX + PA3 ------> USART2_RX */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); @@ -607,8 +617,8 @@ static void HAL_FMC_MspInit(void){ /* Peripheral clock enable */ __HAL_RCC_FMC_CLK_ENABLE(); - - /** FMC GPIO Configuration + + /** FMC GPIO Configuration PF0 ------> FMC_A0 PF1 ------> FMC_A1 PF2 ------> FMC_A2 @@ -648,8 +658,8 @@ static void HAL_FMC_MspInit(void){ PE0 ------> FMC_NBL0 PE1 ------> FMC_NBL1 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -664,7 +674,7 @@ static void HAL_FMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 |GPIO_PIN_8|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -672,8 +682,8 @@ static void HAL_FMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -681,7 +691,7 @@ static void HAL_FMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -723,8 +733,8 @@ static void HAL_FMC_MspDeInit(void){ FMC_DeInitialized = 1; /* Peripheral clock enable */ __HAL_RCC_FMC_CLK_DISABLE(); - - /** FMC GPIO Configuration + + /** FMC GPIO Configuration PF0 ------> FMC_A0 PF1 ------> FMC_A1 PF2 ------> FMC_A2 @@ -764,20 +774,20 @@ static void HAL_FMC_MspDeInit(void){ PE0 ------> FMC_NBL0 PE1 ------> FMC_NBL1 */ - HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 |GPIO_PIN_8|GPIO_PIN_15); - HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); @@ -820,11 +830,11 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) HAL_NVIC_EnableIRQ(SAI1_IRQn); } SAI1_client ++; - - /**SAI1_A_Block_A GPIO Configuration + + /**SAI1_A_Block_A GPIO Configuration PE4 ------> SAI1_FS_A PE5 ------> SAI1_SCK_A - PD6 ------> SAI1_SD_A + PD6 ------> SAI1_SD_A */ GPIO_InitStruct.Pin = CS_LRCK_Pin|CS_SCKE5_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -840,8 +850,8 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ - + /* Peripheral DMA init*/ + hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; @@ -876,9 +886,9 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) HAL_NVIC_EnableIRQ(SAI1_IRQn); } SAI1_client ++; - - /**SAI1_B_Block_B GPIO Configuration - PE3 ------> SAI1_SD_B + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B */ GPIO_InitStruct.Pin = CS_SDOUT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -887,8 +897,8 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ - + /* Peripheral DMA init*/ + hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; hdma_sai1_b.Init.Direction = DMA_PERIPH_TO_MEMORY; @@ -919,20 +929,22 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) SAI1_client --; if (SAI1_client == 0) { - /* Peripheral clock disable */ + /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } - - /**SAI1_A_Block_A GPIO Configuration + + /**SAI1_A_Block_A GPIO Configuration PE4 ------> SAI1_FS_A PE5 ------> SAI1_SCK_A - PD6 ------> SAI1_SD_A + PD6 ------> SAI1_SD_A */ HAL_GPIO_DeInit(GPIOE, CS_LRCK_Pin|CS_SCKE5_Pin); HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -943,14 +955,16 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } - - /**SAI1_B_Block_B GPIO Configuration - PE3 ------> SAI1_SD_B + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/Alchemist/Src/stm32f4xx_it.c b/Alchemist/Src/stm32f4xx_it.c index 7bdc4bbc..ef986573 100644 --- a/Alchemist/Src/stm32f4xx_it.c +++ b/Alchemist/Src/stm32f4xx_it.c @@ -84,7 +84,7 @@ extern SAI_HandleTypeDef hsai_BlockB1; /* USER CODE END EV */ /******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ +/* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** * @brief This function handles System tick timer. diff --git a/Alchemist/Src/usbd_desc.c b/Alchemist/Src/usbd_desc.c index 3c5e84c0..8229e52e 100644 --- a/Alchemist/Src/usbd_desc.c +++ b/Alchemist/Src/usbd_desc.c @@ -97,19 +97,18 @@ /** * @} */ - + /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @brief Private functions declaration. * @{ */ - + static void Get_SerialNum(void); static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); - + /** * @} - */ - + */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @brief Private functions declaration for HS. @@ -220,7 +219,7 @@ __ALIGN_BEGIN uint8_t USBD_HS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -236,7 +235,7 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 + #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, @@ -385,8 +384,8 @@ uint8_t * USBD_HS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) #endif /* (USBD_LPM_ENABLED == 1) */ /** - * @brief Create the serial number string descriptor - * @param None + * @brief Create the serial number string descriptor + * @param None * @retval None */ static void Get_SerialNum(void) @@ -407,9 +406,9 @@ static void Get_SerialNum(void) } /** - * @brief Convert Hex 32Bits value into char + * @brief Convert Hex 32Bits value into char * @param value: value to convert - * @param pbuf: pointer to the buffer + * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ diff --git a/Alchemist/cube-update.sh b/Alchemist/cube-update.sh index 5ea8ad2c..e024f220 100755 --- a/Alchemist/cube-update.sh +++ b/Alchemist/cube-update.sh @@ -2,6 +2,7 @@ # git checkout Src/usbd_desc.c git checkout Makefile git checkout Src/usb_device.c +git checkout Src/usbd_conf.c # git checkout Inc/FreeRTOSConfig.h Middlewares/Third_Party/FreeRTOS # git checkout Src/usb_host.c Inc/usb_host.h rm Src/usbd_audio_if.c diff --git a/BioSignals/Makefile b/BioSignals/Makefile index be1ee131..1a7776a8 100644 --- a/BioSignals/Makefile +++ b/BioSignals/Makefile @@ -8,7 +8,7 @@ include $(OPENWARE)/Hardware/owl2.mk C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/ble_midi.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp include $(OPENWARE)/Hardware/sources.mk @@ -21,6 +21,3 @@ C_SRC += $(C_SRC_I2S) C_SRC += $(C_SRC_RTC) include $(OPENWARE)/Hardware/f4.mk - -flash: - openocd -f openocd.cfg -c "program Build/$(PROJECT).elf verify reset exit" diff --git a/BioSignals/Src/BioSignals.cpp b/BioSignals/Src/BioSignals.cpp new file mode 100644 index 00000000..89708a36 --- /dev/null +++ b/BioSignals/Src/BioSignals.cpp @@ -0,0 +1,94 @@ +#include +#include +#include "device.h" +#include "Owl.h" + +#include "ads.h" +#ifdef USE_KX122 +#include "kx122.h" +#endif +#include "ble_midi.h" + +void setup(){ + ble_init(); + setLed(1, NO_COLOUR); + owl.setup(); +} + +void initLed(){ + // Initialise RGB LED PWM timers +#ifdef USE_LED_PWM + extern TIM_HandleTypeDef htim1; + HAL_TIM_Base_Start(&htim1); + HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); + HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); + HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3); +#else + /*Configure GPIO pin : LED_GREEN_Pin, LED_RED_Pin */ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + GPIO_InitStruct.Pin = LED_GREEN_Pin | LED_RED_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED_GREEN_GPIO_Port, &GPIO_InitStruct); +#endif +} + +void setLed(uint8_t led, uint32_t rgb){ + // rgb should be a 3x 10 bit value + if(led == 0){ +#ifdef USE_LED_PWM + rgb &= COLOUR_LEVEL5; // turn down intensity + TIM1->CCR1 = 1023 - ((rgb>>20)&0x3ff); // red + TIM1->CCR3 = 1023 - ((rgb>>10)&0x3ff); // green + TIM1->CCR2 = 1023 - ((rgb>>00)&0x3ff); // blue +#else + switch(rgb){ // sinking current + case RED_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + break; + case GREEN_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + break; + case YELLOW_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + break; + case NO_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + break; + } +#endif + }else if(led == 1){ + if(rgb == NO_COLOUR) + HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_RESET); + else + HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET); + } +} + +void onChangePin(uint16_t pin){ + switch(pin){ + case ADC_DRDY_Pin: { + ads_drdy(); + break; + } +#ifdef USE_KX122 + case ACC_INT1_Pin: { + kx122_drdy(); + break; + } +#endif +#ifdef PUSHBUTTON_Pin + case PUSHBUTTON_Pin: { + bool isSet = !(PUSHBUTTON_GPIO_Port->IDR & PUSHBUTTON_Pin); + setButtonValue(PUSHBUTTON, isSet); + midi_tx.sendCc(PUSHBUTTON, isSet ? 127 : 0); + break; + } +#endif + } +} diff --git a/BioSignals/Src/codec_biosignals.cpp b/BioSignals/Src/codec_biosignals.cpp index 7a513100..fb323124 100644 --- a/BioSignals/Src/codec_biosignals.cpp +++ b/BioSignals/Src/codec_biosignals.cpp @@ -1,3 +1,4 @@ +#include #include "Codec.h" #include "device.h" #include "errorhandlers.h" diff --git a/Expander/expander-notes.txt b/Expander/expander-notes.txt index c7d1becd..8a8f82bd 100644 --- a/Expander/expander-notes.txt +++ b/Expander/expander-notes.txt @@ -1,6 +1,7 @@ LQFP-48 +STM32F100CBT6/7 24 MHz 128k FLASH 8k RAM full compatible: STM32F100C8Tx 24 MHz 64k FLASH 8k RAM @@ -21,3 +22,19 @@ STM32L4P5CE 120MHz 1M FLASH 320k RAM, 1x USB OTG STM32L4P5CET6 LQFP-48, USD 3.9641 / 10k Ultra-low-power with FPU Arm Cortex-M4 MCU 120 MHz with 512 kbytes of Flash memory, USB OTG, DFSDM, CHROM-ART + + +LCSC STM32F103C8T6 4943 in stock 29/10 2021 +https://lcsc.com/product-detail/ST-Microelectronics_STMicroelectronics-STM32F103C8T6_C8734.html +USD 10.1218 @100 + +STM32L051C8T6TR 13602 in stock 29/10 2021 +https://lcsc.com/product-detail/ST-Microelectronics_STMicroelectronics-STM32L051C8T6TR_C2802165.html +USD 1.9934 @100 + +STM32L051C8 M0 32 Mhz 64k FLASH 8k RAM compatible? + +STM32F030CCT6 US$ 5.7171 @100 48Mhz 32k RAM 256k FLASH compatible? + +STM32F302C8T6 2879 in stock, US$4.3153 @100 + diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index fd3d7f3f..5c88c791 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -1,884 +1,943 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label -Dma.USART2_TX.7.MemInc=DMA_MINC_ENABLE -PB13.GPIOParameters=GPIO_Speed -Dma.USART2_TX.7.Priority=DMA_PRIORITY_LOW -PA15\ (JTDI).GPIOParameters=GPIO_PuPd,GPIO_Label -SH.FMC_D0_DA0.ConfNb=1 +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_16 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_17 +ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV64 +ADC1.ContinuousConvMode=ENABLE +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR +ADC1.EOCSelection=ADC_EOC_SEQ_CONV +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection,ConversionDataManagement +ADC1.NbrOfConversion=2 +ADC1.NbrOfConversionFlag=1 +ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN +ADC1.Rank-0\#ChannelRegularConversion=1 +ADC1.Rank-1\#ChannelRegularConversion=2 +ADC1.Resolution=ADC_RESOLUTION_12B_OPT +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.master=1 +DAC1.DAC1_OutputBuffer-DAC_OUT1=DAC_OUTPUTBUFFER_DISABLE +DAC1.DAC2_OutputBuffer-DAC_OUT2=DAC_OUTPUTBUFFER_DISABLE +DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 +DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 +DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1,DAC2_OutputBuffer-DAC_OUT2,DAC1_OutputBuffer-DAC_OUT1 +Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC1.3.EventEnable=DISABLE +Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC1.3.Instance=DMA1_Stream0 +Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC1.3.MemInc=DMA_MINC_ENABLE +Dma.ADC1.3.Mode=DMA_CIRCULAR +Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE +Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.ADC1.3.Priority=DMA_PRIORITY_LOW +Dma.ADC1.3.RequestNumber=1 +Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.ADC1.3.SignalID=NONE +Dma.ADC1.3.SyncEnable=DISABLE +Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.ADC1.3.SyncRequestNumber=1 +Dma.ADC1.3.SyncSignalID=NONE +Dma.Request0=SPI2_TX +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.Request3=ADC1 +Dma.Request4=UART5_RX +Dma.Request5=UART5_TX +Dma.Request6=USART2_RX +Dma.Request7=USART2_TX +Dma.RequestsNb=8 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.EventEnable=DISABLE +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream1 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_A.1.Priority=DMA_PRIORITY_HIGH +Dma.SAI1_A.1.RequestNumber=1 +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber Dma.SAI1_A.1.SignalID=NONE -USART2.IPParameters=WordLength,VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam -SH.FMC_A8.ConfNb=1 -SH.FMC_A0.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -PC10.GPIO_PuPd=GPIO_PULLUP -SH.FMC_D9_DA9.ConfNb=1 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD -PG8.Signal=FMC_SDCLK -SH.GPXTI14.0=GPIO_EXTI14 +Dma.SAI1_A.1.SyncEnable=DISABLE +Dma.SAI1_A.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_A.1.SyncRequestNumber=1 Dma.SAI1_A.1.SyncSignalID=NONE -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -Dma.UART5_TX.5.SignalID=NONE -RCC.PLLFRACN=0 -Dma.USART2_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE -DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1 -RCC.RTCFreq_Value=32000 -Dma.SAI1_A.1.Mode=DMA_CIRCULAR -PA15\ (JTDI).Signal=S_TIM2_CH1 -RCC.CpuClockFreq_Value=480000000 -PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FMC_SDNWE.ConfNb=1 -PG14.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -Dma.UART5_TX.5.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_PuPd,GPIO_Label -Dma.USART2_RX.6.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=120000000 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.S_TIM3_CH2.ConfNb=1 -PF7.Signal=SPI5_SCK -PB4\ (NJTRST).GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -Dma.SAI1_A.1.Instance=DMA2_Stream1 -RCC.I2C4Freq_Value=120000000 -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=FMC_SDNE1 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC -Dma.USART2_RX.6.Instance=DMA1_Stream3 -PD0.Signal=FMC_D2_DA2 -PD8.Signal=FMC_D13_DA13 -Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE -PE1.Signal=FMC_NBL1 -RCC.USART3Freq_Value=42000000 -NVIC.EXTI15_10_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PA0.Locked=true -Dma.ADC1.3.RequestNumber=1 -SH.GPXTI12.0=GPIO_EXTI12 +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.EventEnable=DISABLE +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_B.2.Priority=DMA_PRIORITY_HIGH +Dma.SAI1_B.2.RequestNumber=1 +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_B.2.SignalID=NONE +Dma.SAI1_B.2.SyncEnable=DISABLE +Dma.SAI1_B.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_B.2.SyncRequestNumber=1 +Dma.SAI1_B.2.SyncSignalID=NONE +Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI2_TX.0.EventEnable=DISABLE +Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI2_TX.0.Instance=DMA1_Stream4 +Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE +Dma.SPI2_TX.0.Mode=DMA_NORMAL +Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE +Dma.SPI2_TX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SPI2_TX.0.Priority=DMA_PRIORITY_LOW +Dma.SPI2_TX.0.RequestNumber=1 +Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SPI2_TX.0.SignalID=NONE +Dma.SPI2_TX.0.SyncEnable=DISABLE Dma.SPI2_TX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 -ProjectManager.BackupPrevious=false -RCC.FMCFreq_Value=240000000 -PE9.Signal=FMC_D6_DA6 -Dma.ADC1.3.Mode=DMA_CIRCULAR -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Host_FS -Dma.UART5_TX.5.Instance=DMA1_Stream2 +Dma.SPI2_TX.0.SyncRequestNumber=1 +Dma.SPI2_TX.0.SyncSignalID=NONE +Dma.UART5_RX.4.Direction=DMA_PERIPH_TO_MEMORY +Dma.UART5_RX.4.EventEnable=DISABLE +Dma.UART5_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.UART5_RX.4.Instance=DMA1_Stream1 +Dma.UART5_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.UART5_RX.4.MemInc=DMA_MINC_ENABLE +Dma.UART5_RX.4.Mode=DMA_NORMAL +Dma.UART5_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.UART5_RX.4.PeriphInc=DMA_PINC_DISABLE +Dma.UART5_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.UART5_RX.4.Priority=DMA_PRIORITY_LOW +Dma.UART5_RX.4.RequestNumber=1 +Dma.UART5_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.UART5_RX.4.SignalID=NONE +Dma.UART5_RX.4.SyncEnable=DISABLE Dma.UART5_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -NVIC.TIM2_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -RCC.USART16Freq_Value=120000000 -PE4.GPIO_Label=CS_LRCK -Dma.SPI2_TX.0.EventEnable=DISABLE -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +Dma.UART5_RX.4.SyncRequestNumber=1 +Dma.UART5_RX.4.SyncSignalID=NONE +Dma.UART5_TX.5.Direction=DMA_MEMORY_TO_PERIPH Dma.UART5_TX.5.EventEnable=DISABLE -USB_OTG_HS.IPParameters=VirtualMode-Host_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -ProjectManager.HalAssertFull=true -RCC.DIVP2Freq_Value=30000000 -PA0.Signal=ADC1_INP16 -Mcu.Package=LQFP144 -SPI2.Mode=SPI_MODE_MASTER -Dma.SAI1_B.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -PC3_C.GPIO_Label=OLED_DC -SH.FMC_A11.ConfNb=1 -PA10.Signal=GPIO_Input -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -SPI5.CalculateBaudRate=937.5 KBits/s -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -Dma.UART5_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.APB1TimFreq_Value=84000000 -RCC.LPUART1Freq_Value=120000000 -Dma.USART2_TX.7.SyncSignalID=NONE -FMC.RowCycleDelay1=6 -USB_OTG_FS.IPParameters=VirtualMode -PB13.Mode=Asynchronous -PD15.Signal=FMC_D1_DA1 -RCC.PLLSAIQCLKFreq_Value=50000000 -RCC.VCO3OutputFreq_Value=100781250 -SH.FMC_D3_DA3.ConfNb=1 -PA6.GPIOParameters=GPIO_PuPd,GPIO_Label -SH.GPXTI10.0=GPIO_EXTI10 -PD6.GPIOParameters=GPIO_Label -Mcu.Pin80=PB3 (JTDO/TRACESWO) -Mcu.Pin81=PB4 (NJTRST) -SH.FMC_A4.0=FMC_A4,12b-sda1 -ProjectManager.ProjectFileName=Genius.ioc -SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PG15 -Mcu.PinsNb=91 -PC11.Locked=true -Mcu.Pin73=PD3 -Mcu.Pin74=PD4 -Mcu.Pin71=PD1 -Mcu.Pin72=PD2 -Mcu.Pin77=PG10 -PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PG14 -ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE -Mcu.Pin75=PD6 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=PG9 -FREERTOS.INCLUDE_vTaskDelayUntil=1 -PD3.Signal=GPIO_Output -Dma.ADC1.3.Priority=DMA_PRIORITY_LOW -Mcu.Pin70=PD0 -Mcu.Pin68=PC11 -Mcu.Pin69=PC12 -PD6.Mode=SAI_A_AsyncSlave -PG14.Locked=true -Mcu.Pin62=PA11 -Mcu.Pin63=PA12 -Mcu.Pin60=PA9 -Mcu.Pin61=PA10 -Mcu.Pin66=PA15 (JTDI) -Mcu.Pin67=PC10 -Mcu.Pin64=PA13 (JTMS/SWDIO) -Mcu.Pin65=PA14 (JTCK/SWCLK) -Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -PF8.GPIO_Label=Flash_MISO +Dma.UART5_TX.5.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.UART5_TX.5.Instance=DMA1_Stream2 +Dma.UART5_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.UART5_TX.5.MemInc=DMA_MINC_ENABLE +Dma.UART5_TX.5.Mode=DMA_NORMAL +Dma.UART5_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.UART5_TX.5.PeriphInc=DMA_PINC_DISABLE +Dma.UART5_TX.5.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.UART5_TX.5.Priority=DMA_PRIORITY_LOW +Dma.UART5_TX.5.RequestNumber=1 +Dma.UART5_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.UART5_TX.5.SignalID=NONE +Dma.UART5_TX.5.SyncEnable=DISABLE +Dma.UART5_TX.5.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.UART5_TX.5.SyncRequestNumber=1 +Dma.UART5_TX.5.SyncSignalID=NONE +Dma.USART2_RX.6.Direction=DMA_PERIPH_TO_MEMORY +Dma.USART2_RX.6.EventEnable=DISABLE Dma.USART2_RX.6.FIFOMode=DMA_FIFOMODE_DISABLE -PD10.Signal=FMC_D15_DA15 -RCC.D1CPREFreq_Value=480000000 -PA3.Mode=Asynchronous +Dma.USART2_RX.6.Instance=DMA1_Stream3 +Dma.USART2_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE Dma.USART2_RX.6.MemInc=DMA_MINC_ENABLE Dma.USART2_RX.6.Mode=DMA_NORMAL -RCC.Tim1OutputFreq_Value=240000000 -Mcu.Pin59=PC9 -SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PG5 -Mcu.Pin58=PG8 -Dma.SPI2_TX.0.SyncRequestNumber=1 -Mcu.Pin51=PD8 -RCC.USART6Freq_Value=84000000 -Mcu.Pin52=PD9 -SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 -Mcu.Pin50=PB15 -Mcu.Pin55=PD15 -Mcu.Pin56=PG4 -Mcu.Pin53=PD10 -Mcu.Pin54=PD14 -PB13.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -PB11.GPIOParameters=GPIO_Label -Dma.SPI2_TX.0.SyncEnable=DISABLE -Mcu.Pin48=PB13 -SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin49=PB14 -Mcu.Pin46=PB11 -Mcu.Pin47=PB12 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC -PB14.Signal=USB_OTG_HS_DM -PA5.Signal=COMP_DAC12_group -Mcu.Pin40=PE11 -Mcu.Pin41=PE12 -Mcu.Pin44=PE15 -Mcu.Pin45=PB10 -Mcu.Pin42=PE13 -Mcu.Pin43=PE14 -NVIC.TIM3_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +Dma.USART2_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_RX.6.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_RX.6.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_RX.6.Priority=DMA_PRIORITY_LOW +Dma.USART2_RX.6.RequestNumber=1 +Dma.USART2_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.USART2_RX.6.SignalID=NONE +Dma.USART2_RX.6.SyncEnable=DISABLE +Dma.USART2_RX.6.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.USART2_RX.6.SyncRequestNumber=1 +Dma.USART2_RX.6.SyncSignalID=NONE +Dma.USART2_TX.7.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART2_TX.7.EventEnable=DISABLE +Dma.USART2_TX.7.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART2_TX.7.Instance=DMA1_Stream5 +Dma.USART2_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART2_TX.7.MemInc=DMA_MINC_ENABLE +Dma.USART2_TX.7.Mode=DMA_NORMAL +Dma.USART2_TX.7.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_TX.7.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_TX.7.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_TX.7.Priority=DMA_PRIORITY_LOW +Dma.USART2_TX.7.RequestNumber=1 +Dma.USART2_TX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.USART2_TX.7.SignalID=NONE +Dma.USART2_TX.7.SyncEnable=DISABLE +Dma.USART2_TX.7.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.USART2_TX.7.SyncRequestNumber=1 +Dma.USART2_TX.7.SyncSignalID=NONE +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadBurst1,ReadPipeDelay1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,WriteRecoveryTime1,RPDelay1,RCDDelay1,SDClockPeriod1,CASLatency1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -PC2_C.GPIO_Label=OLED_RST -SH.FMC_A6.0=FMC_A6,12b-sda1 -RCC.AHB12Freq_Value=240000000 -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PE8 -Mcu.Pin38=PE9 -Mcu.Pin35=PG1 -RCC.I2C1Freq_Value=42000000 -Mcu.Pin36=PE7 -RCC.PLLI2SPCLKFreq_Value=96000000 -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE10 -SAI1.TriState-SAI_A_AsyncSlave=SAI_OUTPUT_NOTRELEASED -Dma.ADC1.3.SyncSignalID=NONE -Mcu.Pin30=PF12 -PA1.GPIO_Label=ADC1 -Mcu.Pin33=PF15 -Mcu.Pin34=PG0 -Mcu.Pin31=PF13 -PA15\ (JTDI).GPIO_PuPd=GPIO_PULLUP -Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Mcu.Pin32=PF14 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,MEMORY_ALLOCATION,configUSE_MUTEXES,FootprintOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -PC10.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -Dma.USART2_TX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -TIM2.Period=0xffff -PG14.GPIO_PuPd=GPIO_PULLUP -PC9.GPIOParameters=GPIO_Label -PF9.GPIOParameters=GPIO_Label -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA5 -Mcu.Pin27=PA6 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Mcu.Pin24=PA3 -Mcu.Pin25=PA4 -Mcu.Pin28=PA7 -Mcu.Pin29=PF11 -Mcu.Pin22=PA1 -Mcu.Pin23=PA2 -Mcu.Pin20=PC3_C -ADC1.master=1 -Mcu.Pin21=PA0 -PA10.Locked=true -NVIC.ForceEnableDMAVector=true -Dma.UART5_RX.4.Priority=DMA_PRIORITY_LOW -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PC12.GPIO_Label=SW_B -PE5.GPIO_Label=CS_SCK -Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x400 -Mcu.Pin15=PH0-OSC_IN (PH0) -PA0.GPIOParameters=GPIO_Label -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH1-OSC_OUT (PH1) -Mcu.Pin13=PF8 -Mcu.Pin14=PF9 -Mcu.Pin19=PC2_C -Mcu.Pin17=PC0 -Mcu.Pin18=PC1 -Dma.USART2_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE -SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF6 -Mcu.Pin12=PF7 -Mcu.Pin10=PF5 -SH.GPXTI10.ConfNb=1 -PE3.Signal=SAI1_SD_B -Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE -PF4.Signal=FMC_A4 -PD2.Signal=GPXTI2 -PB4\ (NJTRST).GPIO_PuPd=GPIO_PULLUP -PC1.Mode=TX_Only_Simplex_Unidirect_Master +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=true Mcu.Family=STM32H7 -FMC.IPParameters=ReadBurst1,ReadPipeDelay1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,WriteRecoveryTime1,RPDelay1,RCDDelay1,SDClockPeriod1,CASLatency1 -NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE -SH.FMC_A8.0=FMC_A8,12b-sda1 -PG9.GPIOParameters=GPIO_Label -ProjectManager.KeepUserCode=true -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN -SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 -Dma.UART5_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PA0.GPIO_Label=ADC0 -SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL -PA11.Mode=Device_Only -PD6.Locked=true -PD2.Locked=true -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -RCC.VCO2OutputFreq_Value=150000000 -SH.FMC_A11.0=FMC_A11,12b-sda1 -PB15.Signal=USB_OTG_HS_DP -PG15.Signal=FMC_SDNCAS -Dma.USART2_RX.6.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -SH.GPXTI2.0=GPIO_EXTI2 -Dma.SAI1_A.1.RequestNumber=1 -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -Mcu.IP4=DMA -Mcu.IP5=FMC -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DAC1 -Mcu.IP3=DEBUG -PC11.GPIO_PuPd=GPIO_PULLUP Mcu.IP0=ADC1 Mcu.IP1=CORTEX_M7 -PE4.GPIOParameters=GPIO_Label -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -RCC.DIVP3Freq_Value=50390625 -RCC.SDMMCFreq_Value=48000000 -Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.UART5_RX.4.RequestNumber=1 -ProjectManager.PreviousToolchain=TrueSTUDIO -TIM3.Period=0xffff -SH.COMP_DAC12_group.ConfNb=1 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,VirtualType,Direction -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,MEMORY_ALLOCATION,configUSE_MUTEXES,FootprintOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil -FREERTOS.configUSE_PREEMPTION=0 -RCC.HRTIMFreq_Value=240000000 -ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_16 -PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator -Dma.SAI1_B.2.SignalID=NONE -RCC.DIVR3Freq_Value=50390625 -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 -FMC.ExitSelfRefreshDelay1=6 Mcu.IP10=SPI2 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=SPI5 Mcu.IP11=SPI4 -PC10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.IP18=USART2 -Mcu.IP17=UART5 -Mcu.IP19=USB_OTG_FS -PA6.GPIO_PuPd=GPIO_PULLUP -RCC.DIVP1Freq_Value=480000000 -Mcu.IP14=TIM2 -PF9.Mode=Full_Duplex_Master +Mcu.IP12=SPI5 Mcu.IP13=SYS -Mcu.IP16=TIM6 +Mcu.IP14=TIM2 Mcu.IP15=TIM3 -RCC.VCOInputFreq_Value=1000000 -PF11.Signal=FMC_SDNRAS -PC11.GPIO_Label=TR_IN_A -PB5.Mode=SdramChipSelect2_1 -PE3.GPIOParameters=GPIO_Label -Mcu.IP20=USB_OTG_HS -Dma.UART5_RX.4.Mode=DMA_NORMAL -SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface -PB3\ (JTDO/TRACESWO).GPIO_PuPd=GPIO_PULLUP -PB4\ (NJTRST).Locked=true -PA6.Signal=S_TIM3_CH1 -PG14.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PB12.Mode=Asynchronous -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -ProjectManager.ToolChainLocation= -PF8.Signal=SPI5_MISO -UART5.IPParameters=BaudRate,DMADisableonRxErrorParam,OverrunDisableParam -RCC.DIVR1Freq_Value=480000000 -Dma.Request2=SAI1_B -Dma.Request1=SAI1_A -Dma.Request4=UART5_RX -Dma.Request3=ADC1 -Dma.Request6=USART2_RX -Dma.Request5=UART5_TX +Mcu.IP16=TIM6 +Mcu.IP17=UART5 +Mcu.IP18=USART2 +Mcu.IP19=USB_HOST +Mcu.IP2=DAC1 +Mcu.IP20=USB_OTG_FS +Mcu.IP21=USB_OTG_HS +Mcu.IP3=DEBUG +Mcu.IP4=DMA +Mcu.IP5=FMC +Mcu.IP6=FREERTOS +Mcu.IP7=NVIC +Mcu.IP8=RCC +Mcu.IP9=SAI1 +Mcu.IPNb=22 +Mcu.Name=STM32H743ZGTx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF6 +Mcu.Pin13=PF7 +Mcu.Pin14=PF8 +Mcu.Pin15=PF9 +Mcu.Pin16=PF10 +Mcu.Pin17=PH0-OSC_IN (PH0) +Mcu.Pin18=PH1-OSC_OUT (PH1) +Mcu.Pin19=PC0 +Mcu.Pin2=PE4 +Mcu.Pin20=PC1 +Mcu.Pin21=PC2_C +Mcu.Pin22=PC3_C +Mcu.Pin23=PA0 +Mcu.Pin24=PA1 +Mcu.Pin25=PA2 +Mcu.Pin26=PA3 +Mcu.Pin27=PA4 +Mcu.Pin28=PA5 +Mcu.Pin29=PA6 +Mcu.Pin3=PE5 +Mcu.Pin30=PA7 +Mcu.Pin31=PF11 +Mcu.Pin32=PF12 +Mcu.Pin33=PF13 +Mcu.Pin34=PF14 +Mcu.Pin35=PF15 +Mcu.Pin36=PG0 +Mcu.Pin37=PG1 +Mcu.Pin38=PE7 +Mcu.Pin39=PE8 +Mcu.Pin4=PE6 +Mcu.Pin40=PE9 +Mcu.Pin41=PE10 +Mcu.Pin42=PE11 +Mcu.Pin43=PE12 +Mcu.Pin44=PE13 +Mcu.Pin45=PE14 +Mcu.Pin46=PE15 +Mcu.Pin47=PB10 +Mcu.Pin48=PB11 +Mcu.Pin49=PB12 +Mcu.Pin5=PC13 +Mcu.Pin50=PB13 +Mcu.Pin51=PB14 +Mcu.Pin52=PB15 +Mcu.Pin53=PD8 +Mcu.Pin54=PD9 +Mcu.Pin55=PD10 +Mcu.Pin56=PD14 +Mcu.Pin57=PD15 +Mcu.Pin58=PG4 +Mcu.Pin59=PG5 +Mcu.Pin6=PF0 +Mcu.Pin60=PG8 +Mcu.Pin61=PC9 +Mcu.Pin62=PA9 +Mcu.Pin63=PA10 +Mcu.Pin64=PA11 +Mcu.Pin65=PA12 +Mcu.Pin66=PA13 (JTMS/SWDIO) +Mcu.Pin67=PA14 (JTCK/SWCLK) +Mcu.Pin68=PA15 (JTDI) +Mcu.Pin69=PC10 +Mcu.Pin7=PF1 +Mcu.Pin70=PC11 +Mcu.Pin71=PC12 +Mcu.Pin72=PD0 +Mcu.Pin73=PD1 +Mcu.Pin74=PD2 +Mcu.Pin75=PD3 +Mcu.Pin76=PD4 +Mcu.Pin77=PD6 +Mcu.Pin78=PG9 +Mcu.Pin79=PG10 +Mcu.Pin8=PF2 +Mcu.Pin80=PG14 +Mcu.Pin81=PG15 +Mcu.Pin82=PB3 (JTDO/TRACESWO) +Mcu.Pin83=PB4 (NJTRST) +Mcu.Pin84=PB5 +Mcu.Pin85=PB6 +Mcu.Pin86=PE0 +Mcu.Pin87=PE1 +Mcu.Pin88=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin89=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC +Mcu.Pin9=PF3 +Mcu.Pin90=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC +Mcu.Pin91=VP_SYS_VS_Systick +Mcu.Pin92=VP_TIM6_VS_ClockSourceINT +Mcu.Pin93=VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS +Mcu.PinsNb=94 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32H743ZGTx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -PD3.GPIO_Label=TR_OUT_B -Mcu.Pin90=VP_TIM6_VS_ClockSourceINT -Dma.Request7=USART2_TX -Dma.SAI1_A.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PE7.Signal=FMC_D4_DA4 -PD6.Signal=SAI1_SD_A -Dma.Request0=SPI2_TX -PE2.GPIO_Label=CS_SCK -Mcu.Pin84=PE0 -Mcu.Pin85=PE1 -Mcu.Pin82=PB5 -Mcu.Pin83=PB6 -Mcu.Pin88=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC -PA3.Signal=USART2_RX -Mcu.Pin89=VP_SYS_VS_Systick -Mcu.Pin86=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin87=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC -SH.FMC_A3.ConfNb=1 -PB3\ (JTDO/TRACESWO).GPIO_Label=ENC1_CH2 -RCC.I2SFreq_Value=96000000 -Dma.UART5_RX.4.SyncEnable=DISABLE -Dma.UART5_TX.5.Mode=DMA_NORMAL -SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface -Dma.SPI2_TX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.UART7Freq_Value=42000000 -USART2.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR -PC9.GPIO_Label=USB_HOST_PWR_EN -SPI4.DataSize=SPI_DATASIZE_8BIT +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI15_10_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI4_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SPI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true NVIC.SavedSvcallIrqHandlerGenerated=true -PC11.Signal=GPXTI11 -TIM6.Prescaler=3500 -VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer -ProjectManager.DefaultFWLocation=true -Dma.UART5_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE -PD9.Signal=FMC_D14_DA14 -PB12.Locked=true -ProjectManager.DeletePrevious=true -RCC.LCDTFToutputFreq_Value=25000000 -SPI5.Mode=SPI_MODE_MASTER -RCC.FamilyName=M -PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -PA9.Mode=Activate_VBUS -SH.FMC_A15_BA1.ConfNb=1 -TIM6.IPParameters=Prescaler,Period,TIM_MasterOutputTrigger -PF6.Signal=GPIO_Output -PB10.GPIO_Label=OLED_SCK -RCC.VCO1OutputFreq_Value=960000000 -PC3_C.Locked=true -PF6.Locked=true -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -Dma.ADC1.3.SyncRequestNumber=1 -SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT -RCC.AXIClockFreq_Value=240000000 -SH.GPXTI12.ConfNb=1 -SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction -PE2.GPIOParameters=GPIO_Label -PG10.GPIOParameters=GPIO_Label -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=Flash_MOSI +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.TIM2_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.TIM3_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.UART5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0.GPIOParameters=GPIO_Label +PA0.GPIO_Label=ADC0 +PA0.Locked=true +PA0.Mode=IN16-Single-Ended +PA0.Signal=ADC1_INP16 +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=ADC1 +PA1.Locked=true PA1.Signal=SharedAnalog_PA1 -PA7.GPIO_PuPd=GPIO_PULLUP -Dma.USART2_TX.7.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -RCC.CKPERFreq_Value=16000000 -RCC.VCOI2SOutputFreq_Value=192000000 -Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Player -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Host_FS -RCC.UART4Freq_Value=42000000 -MxCube.Version=6.2.0 -RCC.FDCANFreq_Value=48000000 -PE5.Mode=SAI_A_AsyncSlave -RCC.ADCFreq_Value=30000000 -PC1.GPIO_Label=OLED_MOSI PA10.GPIOParameters=GPIO_Label -PD4.GPIOParameters=GPIO_Label -VP_SYS_VS_Systick.Mode=SysTick -TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF1.Signal=FMC_A1 -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=42000000 +PA10.GPIO_Label=USB_HOST_PWR_FAULT +PA10.Locked=true +PA10.Signal=GPIO_Input +PA11.GPIOParameters=GPIO_Speed +PA11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.GPIOParameters=GPIO_Speed +PA12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13\ (JTMS/SWDIO).Mode=Serial_Wire +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +PA14\ (JTCK/SWCLK).Mode=Serial_Wire +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PA15\ (JTDI).GPIOParameters=GPIO_PuPd,GPIO_Label PA15\ (JTDI).GPIO_Label=ENC1_CH1 -RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLFRACN,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value -ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -Dma.USART2_TX.7.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Mcu.IP8=RCC -Mcu.IP9=SAI1 -Mcu.IP6=FREERTOS -Mcu.IP7=NVIC -ProjectManager.CoupleFile=false -RCC.SYSCLKFreq_VALUE=480000000 -Dma.USART2_RX.6.SignalID=NONE -RCC.I2C123Freq_Value=120000000 -PA1.Locked=true -SH.GPXTI4.0=GPIO_EXTI4 -KeepUserPlacement=true -SH.GPXTI4.ConfNb=1 -Dma.UART5_TX.5.RequestNumber=1 -RCC.HSI_VALUE=16000000 -SH.SharedAnalog_PA1.1=ADC1_INP17,IN17-Single-Ended -RCC.PLLQ=7 -SH.SharedAnalog_PA1.0=ADC1_INN16 -RCC.PLLM=25 -PC3_C.Signal=GPIO_Output -RCC.PLLN=336 +PA15\ (JTDI).GPIO_PuPd=GPIO_PULLUP +PA15\ (JTDI).Signal=S_TIM2_CH1 PA2.Mode=Asynchronous -NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -SH.FMC_D8_DA8.ConfNb=1 -Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH -Dma.UART5_TX.5.Direction=DMA_MEMORY_TO_PERIPH +PA2.Signal=USART2_TX +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA4.Signal=COMP_DAC11_group +PA5.Signal=COMP_DAC12_group +PA6.GPIOParameters=GPIO_PuPd,GPIO_Label +PA6.GPIO_Label=ENC2_CH1 +PA6.GPIO_PuPd=GPIO_PULLUP +PA6.Signal=S_TIM3_CH1 +PA7.GPIOParameters=GPIO_PuPd,GPIO_Label +PA7.GPIO_Label=ENC2_CH2 +PA7.GPIO_PuPd=GPIO_PULLUP +PA7.Signal=S_TIM3_CH2 +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=OLED_SCK +PB10.Mode=TX_Only_Simplex_Unidirect_Master +PB10.Signal=SPI2_SCK +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=OLED_CS +PB11.Locked=true +PB11.Signal=GPIO_Output +PB12.GPIOParameters=GPIO_Speed +PB12.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PB12.Locked=true +PB12.Mode=Asynchronous PB12.Signal=UART5_RX +PB13.GPIOParameters=GPIO_Speed +PB13.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PB13.Locked=true +PB13.Mode=Asynchronous +PB13.Signal=UART5_TX +PB14.GPIOParameters=GPIO_Speed +PB14.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB14.Mode=Host_FS +PB14.Signal=USB_OTG_HS_DM +PB15.GPIOParameters=GPIO_Speed +PB15.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB15.Mode=Host_FS +PB15.Signal=USB_OTG_HS_DP +PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_PuPd,GPIO_Label +PB3\ (JTDO/TRACESWO).GPIO_Label=ENC1_CH2 +PB3\ (JTDO/TRACESWO).GPIO_PuPd=GPIO_PULLUP +PB3\ (JTDO/TRACESWO).Signal=S_TIM2_CH2 +PB4\ (NJTRST).GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB4\ (NJTRST).GPIO_Label=ENC2_SW +PB4\ (NJTRST).GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB4\ (NJTRST).GPIO_PuPd=GPIO_PULLUP +PB4\ (NJTRST).Locked=true PB4\ (NJTRST).Signal=GPXTI4 -USB_OTG_HS.VirtualMode-Host_FS=Host_FS -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -Dma.USART2_RX.6.RequestNumber=1 -RCC.USART1Freq_Value=84000000 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -FMC.RCDDelay1=2 -Dma.USART2_TX.7.FIFOMode=DMA_FIFOMODE_DISABLE -SPI2.VirtualType=VM_MASTER -PB10.Mode=TX_Only_Simplex_Unidirect_Master -Dma.UART5_TX.5.Priority=DMA_PRIORITY_LOW +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=OLED_MOSI +PC1.Mode=TX_Only_Simplex_Unidirect_Master +PC1.Signal=SPI2_MOSI +PC10.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PC10.GPIO_Label=SW_A +PC10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PC10.GPIO_PuPd=GPIO_PULLUP +PC10.Locked=true +PC10.Signal=GPXTI10 +PC11.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PC11.GPIO_Label=TR_IN_A +PC11.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PC11.GPIO_PuPd=GPIO_PULLUP +PC11.Locked=true +PC11.Signal=GPXTI11 +PC12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PC12.GPIO_Label=SW_B +PC12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PC12.GPIO_PuPd=GPIO_PULLUP PC12.Locked=true -PG4.Signal=FMC_A14_BA0 -NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -RCC.PLLCLKFreq_Value=168000000 PC12.Signal=GPXTI12 -SPI5.DataSize=SPI_DATASIZE_8BIT +PC13.GPIOParameters=GPIO_Label +PC13.GPIO_Label=FLASH_WP +PC13.Locked=true +PC13.Signal=GPIO_Output +PC2_C.GPIOParameters=GPIO_Label +PC2_C.GPIO_Label=OLED_RST +PC2_C.Locked=true +PC2_C.Signal=GPIO_Output +PC3_C.GPIOParameters=GPIO_Label +PC3_C.GPIO_Label=OLED_DC +PC3_C.Locked=true +PC3_C.Signal=GPIO_Output +PC9.GPIOParameters=GPIO_Label +PC9.GPIO_Label=USB_HOST_PWR_EN +PC9.Locked=true +PC9.Signal=GPIO_Output +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PD2.GPIO_Label=TR_IN_B +PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PD2.GPIO_PuPd=GPIO_PULLUP +PD2.Locked=true +PD2.Signal=GPXTI2 PD3.GPIOParameters=GPIO_Label -Dma.USART2_TX.7.SignalID=NONE -FMC.LoadToActiveDelay1=2 -Dma.SAI1_B.2.SyncSignalID=NONE -PA6.GPIO_Label=ENC2_CH1 -Dma.USART2_RX.6.SyncEnable=DISABLE -Dma.USART2_TX.7.EventEnable=DISABLE +PD3.GPIO_Label=TR_OUT_B +PD3.Locked=true +PD3.Signal=GPIO_Output +PD4.GPIOParameters=GPIO_Label +PD4.GPIO_Label=TR_OUT_A PD4.Locked=true -PB13.Signal=UART5_TX -Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +PD4.Signal=GPIO_Output +PD6.GPIOParameters=GPIO_Label PD6.GPIO_Label=CS_SDIN -Dma.SAI1_B.2.Mode=DMA_CIRCULAR -Dma.SPI2_TX.0.Instance=DMA1_Stream4 -PinOutPanel.RotationAngle=0 -PE6.GPIO_Label=CS_SDA -PF6.GPIO_Label=Flash_CS -RCC.MCO1PinFreq_Value=16000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.AHB4Freq_Value=240000000 -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -Dma.UART5_RX.4.SyncRequestNumber=1 -Dma.ADC1.3.MemInc=DMA_MINC_ENABLE -Dma.UART5_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE -PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK -Dma.SPI2_TX.0.SignalID=NONE +PD6.Locked=true +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK PE2.Mode=TX_Only_Simplex_Unidirect_Master -Dma.SAI1_B.2.SyncEnable=DISABLE -TIM2.IPParameters=EncoderMode,Period -PD4.Signal=GPIO_Output -SH.FMC_D10_DA10.ConfNb=1 -PB6.Mode=SdramChipSelect2_1 -RCC.DIVQ3Freq_Value=50390625 -Dma.USART2_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -RCC.SAI2Freq_Value=50000000 -PE5.Signal=SAI1_SCK_A -PB13.Locked=true -Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE -PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -RCC.DIVM2=2 -RCC.DIVM1=5 -UART5.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR -Dma.ADC1.3.Instance=DMA1_Stream0 -Dma.USART2_RX.6.EventEnable=DISABLE -MxDb.Version=DB.6.0.20 -PA1.GPIOParameters=GPIO_Label -Dma.UART5_RX.4.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D15_DA15.ConfNb=1 -PA0.Mode=IN16-Single-Ended -SPI2.CalculateBaudRate=375.0 KBits/s PE2.Signal=SPI4_SCK -PF8.Mode=Full_Duplex_Master -PA14\ (JTCK/SWCLK).Mode=Serial_Wire -Dma.USART2_RX.6.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.GPXTI11.ConfNb=1 -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=FLASH_HOLD +PF10.Locked=true +PF10.Signal=GPIO_Output +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 PF3.Signal=FMC_A3 -RCC.DIVR2Freq_Value=75000000 -PE10.Signal=FMC_D7_DA7 -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 -RCC.MCO2PinFreq_Value=480000000 -UART5.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF6.GPIOParameters=GPIO_Label +PF6.GPIO_Label=FLASH_nCS +PF6.Locked=true +PF6.Signal=GPIO_Output +PF7.GPIOParameters=GPIO_Label +PF7.GPIO_Label=FLASH_CLK +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK PF8.GPIOParameters=GPIO_Label -SH.GPXTI11.0=GPIO_EXTI11 -Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH -RCC.DFSDMFreq_Value=120000000 -SH.FMC_A1.0=FMC_A1,12b-sda1 -SH.GPXTI14.ConfNb=1 -Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE -Dma.USART2_TX.7.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.TraceFreq_Value=480000000 -RCC.APB4Freq_Value=120000000 -RCC.CECFreq_Value=32000 -RCC.SAI23Freq_Value=48000000 -PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -UART5.BaudRate=31250 -PB10.GPIOParameters=GPIO_Label -PC12.GPIO_PuPd=GPIO_PULLUP -PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -Dma.USART2_TX.7.Instance=DMA1_Stream5 -SPI5.VirtualType=VM_MASTER -ProjectManager.CustomerFirmwarePackage= -USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE -NVIC.EXTI4_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -SH.FMC_A1.ConfNb=1 -RCC.DIVQ1=20 -ADC1.Rank-0\#ChannelRegularConversion=1 -DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 -DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 -Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.USART2_RX.6.SyncSignalID=NONE -PD2.GPIO_PuPd=GPIO_PULLUP -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master +PF8.GPIO_Label=FLASH_MISO +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=FLASH_MOSI +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG10.GPIOParameters=GPIO_Label +PG10.GPIO_Label=CS_RST +PG10.Locked=true +PG10.Signal=GPIO_Output +PG14.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG14.GPIO_Label=ENC1_SW +PG14.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG14.GPIO_PuPd=GPIO_PULLUP +PG14.Locked=true +PG14.Signal=GPXTI14 +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_Label +PG9.GPIO_Label=CS_CS PG9.Locked=true PG9.Signal=GPIO_Output -RCC.SWPMI1Freq_Value=120000000 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -PB11.GPIO_Label=OLED_CS -PD1.Signal=FMC_D3_DA3 -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC -RCC.DIVP2=5 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -RCC.UART8Freq_Value=42000000 -PC0.Signal=FMC_SDNWE -Dma.UART5_RX.4.MemInc=DMA_MINC_ENABLE +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=2 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32H743ZGTx +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x400 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain=TrueSTUDIO +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Genius.ioc +ProjectManager.ProjectName=Genius +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x200 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +RCC.ADCFreq_Value=30000000 +RCC.AHB12Freq_Value=240000000 +RCC.AHB4Freq_Value=240000000 +RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 -PC11.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -RCC.QSPIFreq_Value=240000000 -Dma.USART2_RX.6.PeriphInc=DMA_PINC_DISABLE -PG10.Signal=GPIO_Output -PG10.Locked=true -VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT -SH.FMC_A3.0=FMC_A3,12b-sda1 -Dma.SAI1_A.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.USART234578Freq_Value=120000000 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -RCC.SPI123Freq_Value=48000000 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PC3_C.GPIOParameters=GPIO_Label -Dma.UART5_RX.4.SignalID=NONE -PA9.Signal=USB_OTG_FS_VBUS -SH.S_TIM2_CH2.ConfNb=1 -RCC.DIVN2=12 +RCC.APB1Freq_Value=120000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=120000000 +RCC.APB2TimFreq_Value=168000000 +RCC.APB3Freq_Value=120000000 +RCC.APB4Freq_Value=120000000 +RCC.AXIClockFreq_Value=240000000 +RCC.CECFreq_Value=32000 +RCC.CKPERFreq_Value=16000000 +RCC.CortexFreq_Value=480000000 +RCC.CpuClockFreq_Value=480000000 +RCC.D1CPREFreq_Value=480000000 +RCC.D1PPRE=RCC_APB3_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D3PPRE=RCC_APB4_DIV2 +RCC.DFSDMACLkFreq_Value=48000000 +RCC.DFSDMFreq_Value=120000000 +RCC.DIVM1=5 +RCC.DIVM2=2 RCC.DIVN1=192 -ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE -PB10.Signal=SPI2_SCK -FREERTOS.MEMORY_ALLOCATION=2 -ProjectManager.LastFirmware=true -PE15.Signal=FMC_D12_DA12 -Dma.UART5_TX.5.Polarity=HAL_DMAMUX_REQ_GEN_RISING -PC11.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PE8.Signal=FMC_D5_DA5 -RCC.RNGFreq_Value=48000000 +RCC.DIVN2=12 +RCC.DIVP1Freq_Value=480000000 +RCC.DIVP2=5 +RCC.DIVP2Freq_Value=30000000 +RCC.DIVP3Freq_Value=50390625 +RCC.DIVQ1=20 +RCC.DIVQ1Freq_Value=48000000 +RCC.DIVQ2Freq_Value=75000000 +RCC.DIVQ3Freq_Value=50390625 +RCC.DIVR1Freq_Value=480000000 +RCC.DIVR2Freq_Value=75000000 +RCC.DIVR3Freq_Value=50390625 RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=EncoderMode,Period -Dma.USART2_TX.7.Direction=DMA_MEMORY_TO_PERIPH -Dma.SAI1_A.1.EventEnable=DISABLE -PG14.GPIO_Label=ENC1_SW -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -RCC.ProductRev=revV -ProjectManager.FreePins=true +RCC.FCLKCortexFreq_Value=168000000 +RCC.FDCANFreq_Value=48000000 +RCC.FMCFreq_Value=240000000 +RCC.FamilyName=M +RCC.HCLK3ClockFreq_Value=240000000 +RCC.HCLKFreq_Value=240000000 +RCC.HPRE=RCC_HCLK_DIV2 +RCC.HRTIMFreq_Value=240000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C123Freq_Value=120000000 +RCC.I2C1Freq_Value=42000000 +RCC.I2C2Freq_Value=42000000 +RCC.I2C3Freq_Value=42000000 +RCC.I2C4Freq_Value=120000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLFRACN,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=120000000 RCC.LPTIM2Freq_Value=120000000 -SH.FMC_NBL1.ConfNb=1 -Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE -ProjectManager.UnderRoot=false -SH.FMC_D7_DA7.ConfNb=1 -PA4.Signal=COMP_DAC11_group -PB5.Signal=FMC_SDCKE1 -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SH.FMC_A10.ConfNb=1 -Dma.SAI1_A.1.SyncRequestNumber=1 -ProjectManager.CompilerOptimize=2 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -Dma.ADC1.3.SignalID=NONE -SH.S_TIM3_CH1.ConfNb=1 RCC.LPTIM345Freq_Value=120000000 -ProjectManager.ComputerToolchain=false -PF9.Signal=SPI5_MOSI -SAI1.InitProtocol-SAI_A_AsyncSlave=Enable +RCC.LPUART1Freq_Value=120000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 RCC.LTDCFreq_Value=50390625 -Dma.SAI1_B.2.Instance=DMA2_Stream4 -Dma.SAI1_A.1.Priority=DMA_PRIORITY_HIGH -Dma.ADC1.3.EventEnable=DISABLE -SPI2.DataSize=SPI_DATASIZE_8BIT -PB4\ (NJTRST).GPIO_Label=ENC2_SW -Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D12_DA12.ConfNb=1 -RCC.HCLK3ClockFreq_Value=240000000 -RCC.I2C2Freq_Value=42000000 -SPI5.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction -PA7.GPIOParameters=GPIO_PuPd,GPIO_Label -PC1.Signal=SPI2_MOSI -PB12.GPIOParameters=GPIO_Speed -PD2.GPIO_Label=TR_IN_B -PG10.GPIO_Label=CS_RST -Dma.USART2_RX.6.SyncRequestNumber=1 -PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO -RCC.DIVQ2Freq_Value=75000000 -RCC.SAI1Freq_Value=48000000 -RCC.CortexFreq_Value=480000000 -SH.FMC_A2.ConfNb=1 -Mcu.UserName=STM32H743ZGTx -RCC.HPRE=RCC_HCLK_DIV2 -Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE -PC10.Locked=true -PC10.Signal=GPXTI10 -SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -TIM3.EncoderMode=TIM_ENCODERMODE_TI12 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_OTG_HS_HCD_Init-USB_OTG_HS-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PC9.Locked=true +RCC.MCO1PinFreq_Value=16000000 +RCC.MCO2PinFreq_Value=480000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLFRACN=0 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 RCC.PLLI2SRCLKFreq_Value=96000000 -TIM2.EncoderMode=TIM_ENCODERMODE_TI12 -RCC.USART2Freq_Value=42000000 -Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PB11.Signal=GPIO_Output -NVIC.DMA1_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Dma.UART5_TX.5.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x200 -NVIC.UART5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -RCC.VCOInput3Freq_Value=781250 -RCC.I2C3Freq_Value=42000000 -SH.FMC_A7.0=FMC_A7,12b-sda1 -PA12.Signal=USB_OTG_FS_DP -Dma.SAI1_B.2.SyncRequestNumber=1 -Mcu.UserConstants= -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -Mcu.ThirdPartyNb=0 -Dma.SPI2_TX.0.SyncSignalID=NONE -Dma.USART2_TX.7.PeriphInc=DMA_PINC_DISABLE -RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=21 RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.ProductRev=revV +RCC.QSPIFreq_Value=240000000 +RCC.RNGFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.SAI1Freq_Value=48000000 +RCC.SAI23Freq_Value=48000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI4AFreq_Value=48000000 +RCC.SAI4BFreq_Value=48000000 +RCC.SDMMCFreq_Value=48000000 RCC.SPDIFRXFreq_Value=48000000 -Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE -SH.SharedAnalog_PA1.ConfNb=2 -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF1 -Mcu.Pin7=PF2 -Mcu.Pin8=PF3 -Mcu.Pin9=PF4 +RCC.SPI123Freq_Value=48000000 +RCC.SPI45Freq_Value=120000000 +RCC.SPI6Freq_Value=120000000 +RCC.SWPMI1Freq_Value=120000000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.Tim1OutputFreq_Value=240000000 +RCC.Tim2OutputFreq_Value=240000000 +RCC.TraceFreq_Value=480000000 +RCC.UART4Freq_Value=42000000 +RCC.UART5Freq_Value=42000000 +RCC.UART7Freq_Value=42000000 +RCC.UART8Freq_Value=42000000 +RCC.USART16Freq_Value=120000000 +RCC.USART1Freq_Value=84000000 +RCC.USART234578Freq_Value=120000000 +RCC.USART2Freq_Value=42000000 +RCC.USART3Freq_Value=42000000 +RCC.USART6Freq_Value=84000000 +RCC.USBFreq_Value=48000000 +RCC.VCO1OutputFreq_Value=960000000 +RCC.VCO2OutputFreq_Value=150000000 +RCC.VCO3OutputFreq_Value=100781250 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInput1Freq_Value=5000000 +RCC.VCOInput2Freq_Value=12500000 +RCC.VCOInput3Freq_Value=781250 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 RCC.VCOSAIOutputFreq_Value=100000000 -Dma.SPI2_TX.0.Mode=DMA_NORMAL -PC2_C.Signal=GPIO_Output -SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -Mcu.Pin5=PF0 -Dma.USART2_TX.7.SyncEnable=DISABLE -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -USART2.VirtualMode-Asynchronous=VM_ASYNC -FMC.RPDelay1=2 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,AudioMode-SAI_A_AsyncSlave,TriState-SAI_A_AsyncSlave,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,BasicDataSize-SAI_B_SyncSlave,BasicDataSize-SAI_A_AsyncSlave,AudioMode-SAI_B_SyncSlave +SAI1.InitProtocol-SAI_A_AsyncSlave=Enable +SAI1.InitProtocol-SAI_B_SyncSlave=Enable +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.TriState-SAI_A_AsyncSlave=SAI_OUTPUT_NOTRELEASED +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL +SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL +SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 +SH.COMP_DAC11_group.ConfNb=1 +SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 +SH.COMP_DAC12_group.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 +SH.FMC_A10.0=FMC_A10,12b-sda1 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -PE13.Signal=FMC_D10_DA10 -PF7.GPIO_Label=Flash_CLK -Dma.UART5_TX.5.PeriphInc=DMA_PINC_DISABLE -File.Version=6 -PA10.GPIO_Label=USB_HOST_PWR_FAULT -SH.FMC_D5_DA5.ConfNb=1 -SH.S_TIM2_CH1.ConfNb=1 SH.FMC_D2_DA2.ConfNb=1 -NVIC.SPI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave -TIM6.Period=8 -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -Dma.SPI2_TX.0.RequestNumber=1 -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=8 -Dma.UART5_TX.5.MemInc=DMA_MINC_ENABLE -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -PC2_C.Locked=true -ProjectManager.ProjectName=Genius -RCC.APB3Freq_Value=120000000 -SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -RCC.D1PPRE=RCC_APB3_DIV2 -RCC.LSI_VALUE=32000 -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -USART2.WordLength=WORDLENGTH_8B -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -Dma.UART5_RX.4.SyncSignalID=NONE -SPI2.Direction=SPI_DIRECTION_2LINES_TXONLY -PF0.Signal=FMC_A0 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 SH.FMC_NBL0.ConfNb=1 -Dma.SAI1_A.1.SyncEnable=DISABLE -SH.COMP_DAC11_group.ConfNb=1 -Dma.UART5_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PE3.Mode=SAI_B_SyncSlave -PC12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -RCC.Tim2OutputFreq_Value=240000000 -RCC.DFSDMACLkFreq_Value=48000000 -Dma.USART2_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SAI1_B.2.EventEnable=DISABLE -SH.FMC_A9.ConfNb=1 -Dma.USART2_TX.7.SyncRequestNumber=1 -PA13\ (JTMS/SWDIO).Mode=Serial_Wire -PC10.GPIO_Label=SW_A -Dma.UART5_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -ProjectManager.NoMain=false -PG1.Signal=FMC_A11 -RCC.SAI4BFreq_Value=48000000 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 SH.FMC_SDCLK.ConfNb=1 -RCC.D2PPRE2=RCC_APB2_DIV2 -RCC.D2PPRE1=RCC_APB1_DIV2 -Dma.UART5_RX.4.EventEnable=DISABLE -NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.ADC1.3.SyncEnable=DISABLE -RCC.SPI6Freq_Value=120000000 -PC12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PF7.Mode=Full_Duplex_Master +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI10.0=GPIO_EXTI10 +SH.GPXTI10.ConfNb=1 +SH.GPXTI11.0=GPIO_EXTI11 +SH.GPXTI11.ConfNb=1 +SH.GPXTI12.0=GPIO_EXTI12 +SH.GPXTI12.ConfNb=1 +SH.GPXTI14.0=GPIO_EXTI14 +SH.GPXTI14.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI4.0=GPIO_EXTI4 +SH.GPXTI4.ConfNb=1 +SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface +SH.S_TIM2_CH1.ConfNb=1 SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface -PB4\ (NJTRST).GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -Dma.UART5_TX.5.SyncSignalID=NONE -RCC.SPI45Freq_Value=120000000 -SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT -PB3\ (JTDO/TRACESWO).Signal=S_TIM2_CH2 -ProjectManager.TargetToolchain=Other Toolchains (GPDSC) -NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -SH.FMC_D1_DA1.ConfNb=1 -PF2.Signal=FMC_A2 -ProjectManager.RegisterCallBack= -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PD3.Locked=true -Dma.USART2_TX.7.Mode=DMA_NORMAL -PB12.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -Dma.UART5_TX.5.SyncEnable=DISABLE -Dma.UART5_RX.4.PeriphInc=DMA_PINC_DISABLE -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -PG9.GPIO_Label=CS_CS +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface +SH.S_TIM3_CH1.ConfNb=1 SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface -PG14.Signal=GPXTI14 -Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,AudioMode-SAI_A_AsyncSlave,TriState-SAI_A_AsyncSlave,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,BasicDataSize-SAI_B_SyncSlave,BasicDataSize-SAI_A_AsyncSlave,AudioMode-SAI_B_SyncSlave -RCC.VCOInput1Freq_Value=5000000 -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=120000000 -Dma.UART5_TX.5.SyncRequestNumber=1 -Dma.USART2_TX.7.RequestNumber=1 -SH.FMC_D13_DA13.ConfNb=1 -PD4.GPIO_Label=TR_OUT_A -Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SAI1_B.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PF15.Signal=FMC_A9 +SH.S_TIM3_CH2.ConfNb=1 +SH.SharedAnalog_PA1.0=ADC1_INN16 +SH.SharedAnalog_PA1.1=ADC1_INP17,IN17-Single-Ended +SH.SharedAnalog_PA1.ConfNb=2 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI2.CalculateBaudRate=375.0 KBits/s +SPI2.DataSize=SPI_DATASIZE_8BIT +SPI2.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction +SPI2.Mode=SPI_MODE_MASTER +SPI2.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 SPI4.CalculateBaudRate=3.75 MBits/s -Dma.SAI1_B.2.Priority=DMA_PRIORITY_HIGH -Dma.UART5_RX.4.Instance=DMA1_Stream1 -PE6.Signal=SPI4_MOSI -Mcu.Name=STM32H743ZGTx -Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY -PA2.Signal=USART2_TX -PD14.Signal=FMC_D0_DA0 -Dma.SPI2_TX.0.Priority=DMA_PRIORITY_LOW -Dma.UART5_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PA7.GPIO_Label=ENC2_CH2 -Dma.SAI1_B.2.RequestNumber=1 -PA12.Mode=Device_Only -Dma.UART5_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -PF6.GPIOParameters=GPIO_Label -Dma.USART2_RX.6.Priority=DMA_PRIORITY_LOW -RCC.SAI4AFreq_Value=48000000 -ADC1.NbrOfConversionFlag=1 -Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -RCC.DIVQ1Freq_Value=48000000 -PC2_C.GPIOParameters=GPIO_Label -PE3.GPIO_Label=CS_SDOUT -RCC.D3PPRE=RCC_APB4_DIV2 -PC9.Signal=GPIO_Output -RCC.VCOInput2Freq_Value=12500000 -RCC.APB1Freq_Value=120000000 -SAI1.InitProtocol-SAI_B_SyncSlave=Enable -PB11.Locked=true -ProjectManager.DeviceId=STM32H743ZGTx -ProjectManager.LibraryCopy=2 +SPI4.DataSize=SPI_DATASIZE_8BIT +SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI4.VirtualType=VM_MASTER +SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4 +SPI5.CalculateBaudRate=30.0 MBits/s +SPI5.DataSize=SPI_DATASIZE_8BIT SPI5.Direction=SPI_DIRECTION_2LINES -PA7.Signal=S_TIM3_CH2 +SPI5.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction,NSSPMode +SPI5.Mode=SPI_MODE_MASTER +SPI5.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI5.VirtualType=VM_MASTER +TIM2.EncoderMode=TIM_ENCODERMODE_TI12 +TIM2.IC1Filter=8 +TIM2.IC2Filter=8 +TIM2.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter +TIM2.Period=0xffff +TIM3.EncoderMode=TIM_ENCODERMODE_TI12 +TIM3.IC1Filter=8 +TIM3.IC2Filter=8 +TIM3.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter +TIM3.Period=0xffff +TIM6.IPParameters=Prescaler,Period,TIM_MasterOutputTrigger +TIM6.Period=8 +TIM6.Prescaler=3500 +TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE +UART5.BaudRate=31250 +UART5.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR +UART5.IPParameters=BaudRate,DMADisableonRxErrorParam,OverrunDisableParam +UART5.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE +USART2.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR +USART2.IPParameters=WordLength,VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam +USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE +USART2.VirtualMode-Asynchronous=VM_ASYNC +USART2.WordLength=WORDLENGTH_8B +USB_HOST.BSP.number=1 +USB_HOST.IPParameters=USBH_HandleTypeDef-ALL_Classes_HS,VirtualModeHS +USB_HOST.USBH_HandleTypeDef-ALL_Classes_HS=hUsbHostHS +USB_HOST.VirtualModeHS=All_Classes +USB_HOST0.BSP.STBoard=false +USB_HOST0.BSP.api=Unknown +USB_HOST0.BSP.component= +USB_HOST0.BSP.condition= +USB_HOST0.BSP.i2caddr=0 +USB_HOST0.BSP.i2creg= +USB_HOST0.BSP.instance=PC9 +USB_HOST0.BSP.ip=GPIO +USB_HOST0.BSP.mode=Output +USB_HOST0.BSP.name=Drive_VBUS_HS +USB_HOST0.BSP.semaphore= +USB_HOST0.BSP.solution=PC9 +USB_OTG_FS.IPParameters=VirtualMode,Sof_enable +USB_OTG_FS.Sof_enable=ENABLE +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Host_FS +USB_OTG_HS.VirtualMode-Host_FS=Host_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT +VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Mode=ALL_Classes_HS +VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Signal=USB_HOST_VS_USB_HOST_ALL_CLASS_HS +board=Player diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index a691442f..9eaf50ff 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -1,14 +1,16 @@ -#ifndef __ParameterController_hpp__ -#define __ParameterController_hpp__ +#ifndef __GeniusParameterController_hpp__ +#define __GeniusParameterController_hpp__ #include #include +#include #include "device.h" #include "errorhandlers.h" #include "ProgramVector.h" #include "VersionToken.h" #include "ScreenBuffer.h" #include "Owl.h" +#include "message.h" #ifdef USE_DIGITALBUS #include "DigitalBusReader.h" extern DigitalBusReader bus; @@ -26,80 +28,239 @@ extern DigitalBusReader bus; extern VersionToken* bootloader_token; -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); +#define NOF_ENCODERS 2 +#define GENIUS_ADC_OFFSET (-120) -/* shows a single parameter selected and controlled with a single encoder - */ -template -class ParameterController { +enum DisplayMode { + STANDARD_DISPLAY_MODE, CONFIGURATION_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, SELECT_ONE_DISPLAY_MODE, SELECT_TWO_DISPLAY_MODE, EXIT_DISPLAY_MODE, ASSIGN_DISPLAY_MODE, ERROR_DISPLAY_MODE +}; +// DisplayMode displayMode; +void setDisplayMode(DisplayMode mode); + +class Page { +protected: + static constexpr int16_t encoder_sensitivity = 1; + static constexpr int16_t encoder_mask = 0x01; public: - char title[11] = "Genius"; - int16_t parameters[SIZE]; - char names[SIZE][12]; - int8_t selected = 0; - ParameterController(){ - reset(); + virtual void draw(ScreenBuffer& screen){} + // virtual void updateEncoders(int16_t* data, uint8_t size){} + virtual void enter(){} + virtual void exit(){} + virtual void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} + int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0 && (current & encoder_mask) == encoder_mask) + return 1; + if(delta < 0 && (current & encoder_mask) == encoder_mask) + return -1; + return 0; } - void setTitle(const char* str){ - strncpy(title, str, 10); + + int16_t getContinuousEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0) + delta = 20 << (delta/2); + else + delta = -20 << (-delta/2); + return delta; + } +}; + +class GeniusParameterController : public ParameterController { +private: +public: + Page* page; + int16_t encoders[NOF_ENCODERS]; // last seen encoder values + int16_t user[NOF_ADC_VALUES]; // user set values (ie by encoder or MIDI) + // for assignable CV / modulations + // int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) + GeniusParameterController() { + // encoders[0] = INT16_MAX/2; + // encoders[1] = INT16_MAX/2; + encoders[0] = 0; + encoders[1] = 0; + reset(); + setDisplayMode(PROGRESS_DISPLAY_MODE); } void reset(){ - drawCallback = defaultDrawCallback; - for(int i=0; ipage != page){ + if(this->page != NULL) + this->page->exit(); + this->page = page; + page->enter(); + } } void draw(ScreenBuffer& screen){ screen.clear(); - if(sw1()){ - drawStats(screen); - // todo: show patch name and next/previous patch - }else if(sw2()){ - screen.fill(BLACK); - drawGlobalParameterNames(42, screen); - }else if(getErrorStatus() != NO_ERROR && getErrorMessage() != NULL){ - screen.setTextSize(1); - screen.print(2, 20, getErrorMessage()); + page->draw(screen); + } + void updateEncoders(int16_t* data, uint8_t size){ + if(data[0] != encoders[0]){ + page->encoderChanged(0, data[0], encoders[0]); + encoders[0] = data[0]; + } + if(data[1] != encoders[1]){ + page->encoderChanged(1, data[1], encoders[1]); + encoders[1] = data[1]; + } + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + page->encoderChanged(encoder, current, previous); + } + void setValue(uint8_t pid, int16_t value){ + if(pid < NOF_ADC_VALUES){ + user[pid] = value; }else{ - drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); - screen.setTextSize(1); - screen.print(2, 56, names[selected]); - screen.print(": "); - screen.print((int)parameters[selected]/41); + parameters[pid] = value; } } - void drawParameterNames(int y, int pid, const char names[][12], int size, ScreenBuffer& screen){ + int16_t getUserValue(uint8_t ch){ + if(ch < NOF_ADC_VALUES) + return user[ch]; + return parameters[ch]; + } + // @param values the modulation ADC values + void updateValues(int16_t* values, size_t len){ + for(size_t pid=0; pid>1)); + } +private: +}; + +static bool sw1(){ + return HAL_GPIO_ReadPin(ENC1_SW_GPIO_Port, ENC1_SW_Pin) != GPIO_PIN_SET; +} +static bool sw2(){ + return HAL_GPIO_ReadPin(ENC2_SW_GPIO_Port, ENC2_SW_Pin) != GPIO_PIN_SET; +} +static bool sw(uint8_t ctrl){ + return ctrl == 0 ? sw1() : sw2(); +} + +extern GeniusParameterController params; + +class SelectControlPage : public Page { + const uint8_t ctrl; + size_t counter; // ticks since switch was pressed down + static constexpr size_t TOGGLE_LIMIT = (400/SCREEN_LOOP_SLEEP_MS); +public: + int8_t select; + SelectControlPage(uint8_t ctrl, int8_t select): ctrl(ctrl), select(select){} + void enter(){ + counter = 0; + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ctrl) + select = std::clamp(select + getDiscreteEncoderValue(current, previous), 0, NOF_PARAMETERS-1); + } + void draw(ScreenBuffer& screen){ + if(!sw(ctrl)){ + // encoder switch released + if(counter < TOGGLE_LIMIT){ + setDisplayMode(ctrl == 0 ? CONFIGURATION_DISPLAY_MODE : ASSIGN_DISPLAY_MODE); + }else{ + setDisplayMode(STANDARD_DISPLAY_MODE); + } + }else{ + counter++; + } + drawGlobalParameterNames(42, screen); + } + + void drawParameterNames(int y, int pid, int size, ScreenBuffer& screen){ screen.setTextSize(1); - // int selected = selectedPid[pid]; - if(selected > 2) - screen.print(1, y-30, names[selected-3]); - if(selected > 1) - screen.print(1, y-20, names[selected-2]); - if(selected > 0) - screen.print(1, y-10, names[selected-1]); - screen.print(1, y, names[selected]); - if(selected < size-1) - screen.print(1, y+10, names[selected+1]); - if(selected < size-2) - screen.print(1, y+20, names[selected+2]); - if(selected < size-3) - screen.print(1, y+30, names[selected+3]); + // int select = selectPid[pid]; + if(select > 2) + screen.print(1, y-30, params.getName(select-3)); + if(select > 1) + screen.print(1, y-20, params.getName(select-2)); + if(select > 0) + screen.print(1, y-10, params.getName(select-1)); + screen.print(1, y, params.getName(select)); + if(select < size-1) + screen.print(1, y+10, params.getName(select+1)); + if(select < size-2) + screen.print(1, y+20, params.getName(select+2)); + if(select < size-3) + screen.print(1, y+30, params.getName(select+3)); screen.invert(0, y-9, screen.getWidth(), 10); } - void drawGlobalParameterNames(int y, ScreenBuffer& screen){ - drawParameterNames(y, 0, names, SIZE, screen); + void drawGlobalParameterNames(int y, ScreenBuffer& screen){ + drawParameterNames(y, 0, NOF_PARAMETERS, screen); + } +}; + +class ProgressPage : public Page { + void draw(ScreenBuffer& screen){ + drawLoadProgress(screen); + } + void drawLoadProgress(ScreenBuffer &screen){ + extern char* progress_message; + extern uint16_t progress_counter; + screen.drawRectangle(0, 30, 128, 20, WHITE); + // if(progress_counter != 4095) + screen.fillRectangle(0, 44, progress_counter * 128 / 4095, 5, WHITE); + screen.setCursor(33, 40); + screen.setTextSize(1); + if(progress_message == NULL) + screen.print("Loading"); + else + screen.print(progress_message); + } +}; + +class ErrorPage : public Page { + void draw(ScreenBuffer& screen){ + if(sw1()) + setErrorStatus(0); + if(getErrorStatus() == NO_ERROR){ + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(1, 16, "ERROR"); + screen.setTextSize(1); + if(getErrorMessage() != NULL) + screen.print(2, 25, getErrorMessage()); + if(getDebugMessage() != NULL) + screen.print(2, 32, getDebugMessage()); + } + } +}; + +class ExitPage : public Page { +public: + void draw(ScreenBuffer& screen){ + if(!(sw1() || sw2())){ // leave configuration mode on release + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(40, 26, "exit"); + } } +}; +class StatsPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} + void draw(ScreenBuffer& screen){ + if(sw1() || sw2()){ + setDisplayMode(EXIT_DISPLAY_MODE); + }else{ + drawStats(screen); + } + } void drawStats(ScreenBuffer& screen){ screen.setTextSize(1); ProgramVector* pv = getProgramVector(); @@ -111,7 +272,6 @@ class ParameterController { screen.print("% "); screen.print((int)(pv->heap_bytes_used)/1024); screen.print("kB"); - // draw firmware version screen.print(1, 36, getFirmwareVersion()); if (bootloader_token->magic == BOOTLOADER_MAGIC){ @@ -133,66 +293,111 @@ class ParameterController { } #endif } +}; + +SelectControlPage selectOnePage(0, 0); +SelectControlPage selectTwoPage(1, 1); - void encoderChanged(uint8_t encoder, int32_t delta){ +class AssignPage : public Page { +private: + uint8_t select; + uint8_t assign; + static constexpr const char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; + int16_t enc, del; +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == 0){ - if(sw2()){ - if(delta > 1) - selected = min(SIZE-1, selected+1); - else if(delta < 1) - selected = max(0, selected-1); - }else{ - parameters[selected] += delta*10; - parameters[selected] = min(4095, max(0, parameters[selected])); - } - } // todo: change patch with enc1/sw1 - } - void setName(uint8_t pid, const char* name){ - if(pid < SIZE) - strncpy(names[pid], name, 11); - } - uint8_t getSize(){ - return SIZE; + select = std::clamp(select + getDiscreteEncoderValue(current, previous), 0, 3); + }else{ + assign = std::clamp(assign + getDiscreteEncoderValue(current, previous), 0, NOF_PARAMETERS-1); + } + enc = current; + del = current - previous; } - void setValue(uint8_t ch, int16_t value){ - parameters[ch] = value; + void enter(){ + select = 0; + assign = 0; } - - void drawMessage(int16_t y, ScreenBuffer& screen){ - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL){ + void draw(ScreenBuffer& screen){ + if(sw1() || sw2()){ + setDisplayMode(EXIT_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(1, 16, "ASSIGN"); screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, y, pv->message); - screen.setTextWrap(false); - } + screen.print(1, 26, assignations[select]); + screen.print(": "); + screen.print(params.getName(assign)); + screen.setCursor(1, 36); + screen.print(enc); + screen.setCursor(1, 46); + screen.print(del); + } } +}; - void drawTitle(ScreenBuffer& screen){ - drawTitle(title, screen); +class StandardPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + uint8_t select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; + int16_t value = getContinuousEncoderValue(current, previous); + value = std::clamp(params.getUserValue(select) + value, 0, 4095); + params.setValue(select, value); } - - void drawTitle(const char* title, ScreenBuffer& screen){ - // draw title - screen.setTextSize(2); - screen.print(1, 17, title); + void draw(ScreenBuffer& screen){ + if(sw1()){ + setDisplayMode(SELECT_ONE_DISPLAY_MODE); + }else if(sw2()){ + setDisplayMode(SELECT_TWO_DISPLAY_MODE); + }else{ + int s1 = selectOnePage.select; + int s2 = selectTwoPage.select; + screen.setTextSize(1); + screen.print(2, 56, params.getName(s1)); + screen.print(": "); + screen.print((int)params.getValue(s1)/41); + screen.print(2, 64, params.getName(s2)); + screen.print(": "); + screen.print((int)params.getValue(s2)/41); + graphics.drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); + } } +}; - void setCallback(void *callback){ - if(callback == NULL) - drawCallback = defaultDrawCallback; - else - drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; - } - -private: - void (*drawCallback)(uint8_t*, uint16_t, uint16_t); - bool sw1(){ - return HAL_GPIO_ReadPin(ENC1_SW_GPIO_Port, ENC1_SW_Pin) != GPIO_PIN_SET; - } - bool sw2(){ - return HAL_GPIO_ReadPin(ENC2_SW_GPIO_Port, ENC2_SW_Pin) != GPIO_PIN_SET; +StandardPage standardPage; +ProgressPage progressPage; +ErrorPage errorPage; +ExitPage exitPage; +StatsPage configurationPage; +AssignPage assignPage; + +void setDisplayMode(DisplayMode mode){ + switch(mode){ + case STANDARD_DISPLAY_MODE: + params.changePage(&standardPage); + break; + case CONFIGURATION_DISPLAY_MODE: + params.changePage(&configurationPage); + break; + case PROGRESS_DISPLAY_MODE: + params.changePage(&progressPage); + break; + case SELECT_ONE_DISPLAY_MODE: + params.changePage(&selectOnePage); + break; + case SELECT_TWO_DISPLAY_MODE: + params.changePage(&selectTwoPage); + break; + case EXIT_DISPLAY_MODE: + params.changePage(&exitPage); + break; + case ASSIGN_DISPLAY_MODE: + params.changePage(&assignPage); + break; + case ERROR_DISPLAY_MODE: + params.changePage(&errorPage); + break; } -}; +} -#endif // __ParameterController_hpp__ +#endif // __GeniusParameterController_hpp__ diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index f098a386..61165a1e 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -5,13 +5,23 @@ #define HARDWARE_ID GENIUS_HARDWARE #define HARDWARE_VERSION "Genius" +#define USE_SPI_FLASH +#define SPI_FLASH_HSPI hspi5 + +/* #define USE_USBH_HID */ + /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM + +#ifndef DEBUG #define USE_ICACHE #define USE_DCACHE +#endif + +/* #define USE_BKPSRAM */ #define MAX_SYSEX_PROGRAM_SIZE (512*1024) @@ -19,9 +29,10 @@ #define USE_SCREEN #define SSD1309 +#define OLED_DMA -#define ENCODER_TIM1 htim2 -#define ENCODER_TIM2 htim3 +#define ENCODER_TIM1 htim3 +#define ENCODER_TIM2 htim2 /* #define OLED_DMA */ #define OLED_SOFT_CS @@ -35,17 +46,17 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define AUDIO_OUTPUT_GAIN 121 /* -6dB */ #define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS #define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define MAIN_LOOP_SLEEP_MS 20 -#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ - #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS @@ -53,11 +64,15 @@ #define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI + +#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ + // Serial MIDI #define USE_UART_MIDI_RX #define USE_UART_MIDI_TX #define UART_MIDI_HANDLE huart5 #define UART_MIDI_RX_BUFFER_SIZE 256 + // Digital bus /* #define USE_DIGITALBUS */ /* #define DIGITAL_BUS_ENABLED 1 */ @@ -69,7 +84,7 @@ #define ADC_A 0 #define ADC_B 1 #define NOF_ADC_VALUES 2 -#define NOF_PARAMETERS 20 -#define NOF_BUTTONS (2+2) +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (4+2) #define USE_DAC diff --git a/Genius/Inc/main.h b/Genius/Inc/main.h index 81a9c44a..f3a5e5a3 100644 --- a/Genius/Inc/main.h +++ b/Genius/Inc/main.h @@ -68,14 +68,18 @@ void Error_Handler(void); #define CS_SCKE5_GPIO_Port GPIOE #define CS_SDA_Pin GPIO_PIN_6 #define CS_SDA_GPIO_Port GPIOE -#define Flash_CS_Pin GPIO_PIN_6 -#define Flash_CS_GPIO_Port GPIOF -#define Flash_CLK_Pin GPIO_PIN_7 -#define Flash_CLK_GPIO_Port GPIOF -#define Flash_MISO_Pin GPIO_PIN_8 -#define Flash_MISO_GPIO_Port GPIOF -#define Flash_MOSI_Pin GPIO_PIN_9 -#define Flash_MOSI_GPIO_Port GPIOF +#define FLASH_WP_Pin GPIO_PIN_13 +#define FLASH_WP_GPIO_Port GPIOC +#define FLASH_nCS_Pin GPIO_PIN_6 +#define FLASH_nCS_GPIO_Port GPIOF +#define FLASH_CLK_Pin GPIO_PIN_7 +#define FLASH_CLK_GPIO_Port GPIOF +#define FLASH_MISO_Pin GPIO_PIN_8 +#define FLASH_MISO_GPIO_Port GPIOF +#define FLASH_MOSI_Pin GPIO_PIN_9 +#define FLASH_MOSI_GPIO_Port GPIOF +#define FLASH_HOLD_Pin GPIO_PIN_10 +#define FLASH_HOLD_GPIO_Port GPIOF #define OLED_MOSI_Pin GPIO_PIN_1 #define OLED_MOSI_GPIO_Port GPIOC #define OLED_RST_Pin GPIO_PIN_2 @@ -111,6 +115,7 @@ void Error_Handler(void); #define SW_B_EXTI_IRQn EXTI15_10_IRQn #define TR_IN_B_Pin GPIO_PIN_2 #define TR_IN_B_GPIO_Port GPIOD +#define TR_IN_B_EXTI_IRQn EXTI2_IRQn #define TR_OUT_B_Pin GPIO_PIN_3 #define TR_OUT_B_GPIO_Port GPIOD #define TR_OUT_A_Pin GPIO_PIN_4 diff --git a/Genius/Inc/stm32h7xx_hal_conf.h b/Genius/Inc/stm32h7xx_hal_conf.h index 5f834e34..ae041d25 100644 --- a/Genius/Inc/stm32h7xx_hal_conf.h +++ b/Genius/Inc/stm32h7xx_hal_conf.h @@ -65,6 +65,7 @@ /* #define HAL_LPTIM_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_RAMECC_MODULE_ENABLED */ /* #define HAL_RNG_MODULE_ENABLED */ /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SAI_MODULE_ENABLED diff --git a/Genius/Inc/stm32h7xx_it.h b/Genius/Inc/stm32h7xx_it.h index 4b5f80d3..3ebd5c6c 100644 --- a/Genius/Inc/stm32h7xx_it.h +++ b/Genius/Inc/stm32h7xx_it.h @@ -48,6 +48,7 @@ /* Exported functions prototypes ---------------------------------------------*/ void SysTick_Handler(void); +void EXTI2_IRQHandler(void); void EXTI4_IRQHandler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); @@ -55,6 +56,7 @@ void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void DMA1_Stream4_IRQHandler(void); void DMA1_Stream5_IRQHandler(void); +void ADC_IRQHandler(void); void TIM2_IRQHandler(void); void TIM3_IRQHandler(void); void SPI2_IRQHandler(void); diff --git a/Genius/Inc/usbd_conf.h b/Genius/Inc/usbd_conf.h index 7ab14be8..b06311a0 100644 --- a/Genius/Inc/usbd_conf.h +++ b/Genius/Inc/usbd_conf.h @@ -64,13 +64,13 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ diff --git a/Genius/Inc/usbh_conf.h b/Genius/Inc/usbh_conf.h index 2fa26bdb..4a6c551d 100644 --- a/Genius/Inc/usbh_conf.h +++ b/Genius/Inc/usbh_conf.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -36,6 +36,13 @@ #include "stm32h7xx_hal.h" /* USER CODE BEGIN INCLUDE */ +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif + void *pvPortMalloc( size_t xSize ); + void vPortFree( void *pv ); /* USER CODE END INCLUDE */ @@ -69,13 +76,13 @@ #define USBH_MAX_NUM_INTERFACES 10U /*---------- -----------*/ -#define USBH_MAX_NUM_CONFIGURATION 1U +#define USBH_MAX_NUM_CONFIGURATION 5U /*---------- -----------*/ #define USBH_KEEP_CFG_DESCRIPTOR 1U /*---------- -----------*/ -#define USBH_MAX_NUM_SUPPORTED_CLASS 1U +#define USBH_MAX_NUM_SUPPORTED_CLASS 5U /*---------- -----------*/ #define USBH_MAX_SIZE_CONFIGURATION 256U @@ -84,7 +91,7 @@ #define USBH_MAX_DATA_BUFFER 512U /*---------- -----------*/ -#define USBH_DEBUG_LEVEL 0U +#define USBH_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBH_USE_OS 0U @@ -112,10 +119,10 @@ /* Memory management macros */ /** Alias for memory allocation. */ -#define USBH_malloc malloc +#define USBH_malloc pvPortMalloc /** Alias for memory release. */ -#define USBH_free free +#define USBH_free vPortFree /** Alias for memory set. */ #define USBH_memset memset diff --git a/Genius/Makefile b/Genius/Makefile index 3f0f3365..0eaf9434 100644 --- a/Genius/Makefile +++ b/Genius/Makefile @@ -9,7 +9,7 @@ CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c C_SRC += $(OPENWARE)/Source/ssd1309.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/uart_midi.cpp CPP_SRC += $(OPENWARE)/Source/bus.cpp @@ -33,4 +33,6 @@ C_SRC += $(C_SRC_DSP) C_SRC += $(C_SRC_OS) C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_USBH_HID) + include $(OPENWARE)/Hardware/h7.mk diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 69f35582..48a16d1f 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -1,7 +1,9 @@ #include "Owl.h" +#include "OpenWareMidiControl.h" #include "Graphics.h" - +#include "Pin.h" +#include "GeniusParameterController.hpp" extern "C"{ #if 0 @@ -16,7 +18,7 @@ extern "C"{ {return 0;} int eeprom_wait() {return 0;} - int eeprom_erase_sector(uint32_t sector) + int eeprom_erase_sector(uint32_t sector, uint32_t bank) {return 0;} int eeprom_write_unlock(uint32_t wrp_sectors) {return 0;} @@ -34,57 +36,154 @@ extern "C"{ extern TIM_HandleTypeDef ENCODER_TIM1; extern TIM_HandleTypeDef ENCODER_TIM2; -Graphics graphics; +Pin tr_out_a_pin(GPIOD, GPIO_PIN_4); +Pin tr_out_b_pin(GPIOD, GPIO_PIN_3); + +GeniusParameterController params; +Graphics graphics DMA_RAM; + +char* progress_message = NULL; +uint16_t progress_counter = 0; + +void setProgress(uint16_t value, const char* reason){ + progress_message = (char*)reason; + progress_counter = value; +} -void setup(){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + switch(new_mode){ + case STARTUP_MODE: + case STREAM_MODE: + case LOAD_MODE: + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case CONFIGURE_MODE: + setDisplayMode(CONFIGURATION_DISPLAY_MODE); + break; + case RUN_MODE: + setDisplayMode(STANDARD_DISPLAY_MODE); + break; + case ERROR_MODE: + setDisplayMode(ERROR_DISPLAY_MODE); + break; + } +} + +void onSetup(){ + progress_counter = 1000; + tr_out_a_pin.outputMode(); + tr_out_b_pin.outputMode(); + tr_out_a_pin.high(); + tr_out_b_pin.high(); + setAnalogValue(PARAMETER_F, 0); + setAnalogValue(PARAMETER_G, 0); HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); - + graphics.begin(¶ms, &OLED_SPI); + progress_counter = 2000; #ifdef USE_USB_HOST // enable USB Host power HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); __HAL_TIM_SET_COUNTER(&ENCODER_TIM2, INT16_MAX/2); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); + progress_counter = 3000; +} - owl.setup(); +void setGateValue(uint8_t ch, int16_t value){ + switch(ch){ + case PUSHBUTTON: + case BUTTON_1: + tr_out_a_pin.set(!value); + break; + case BUTTON_2: + tr_out_b_pin.set(!value); + break; + } } -// int16_t* Encoders_get(){ -void updateEncoders(){ - static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; - int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); - int16_t delta = value - encoder_values[0]; - if(delta) - graphics.params.encoderChanged(0, delta); - encoder_values[0] = value; - value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM2); - delta = value - encoder_values[1]; - if(delta) - graphics.params.encoderChanged(1, delta); - encoder_values[1] = value; +// 12x12 bit multiplication with unsigned operands and result +#define U12_MUL_U12(a,b) (__USAT(((uint32_t)(a)*(b))>>12, 12)) +static uint16_t scaleForDac(int16_t value){ + // return U12_MUL_U12(value + 70, 3521); + return value; } - // case ENC1_SW_Pin: // GPIO_PIN_14: - // setButtonValue(BUTTON_A, !(ENC1_SW_GPIO_Port->IDR & ENC1_SW_Pin)); - // setButtonValue(PUSHBUTTON, !(ENC1_SW_GPIO_Port->IDR & ENC1_SW_Pin)); - // break; - // case ENC2_SW_Pin: // GPIO_PIN_4: - // setButtonValue(BUTTON_B, !(ENC2_SW_GPIO_Port->IDR & ENC2_SW_Pin)); - // break; - // case TR_IN_A_Pin: // GPIO_PIN_11: - // setButtonValue(BUTTON_C, !(TR_IN_A_GPIO_Port->IDR & TR_IN_A_Pin)); - // break; - // case TR_IN_B_Pin: // GPIO_PIN_10: - // setButtonValue(BUTTON_D, !(TR_IN_B_GPIO_Port->IDR & TR_IN_B_Pin)); - // break; - -void loop(void){ +void setAnalogValue(uint8_t ch, int16_t value){ + // if(owl.getOperationMode() == RUN_MODE){ + extern DAC_HandleTypeDef hdac; + switch(ch){ + case PARAMETER_F: + HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, scaleForDac(value)); + break; + case PARAMETER_G: + HAL_DAC_SetValue(&hdac, DAC_CHANNEL_2, DAC_ALIGN_12B_R, scaleForDac(value)); + break; + } + // } +} +void onChangePin(uint16_t pin){ + switch(pin){ + case TR_IN_A_Pin: + case SW_A_Pin: { + bool state = HAL_GPIO_ReadPin(SW_A_GPIO_Port, SW_A_Pin) == GPIO_PIN_RESET; + state |= HAL_GPIO_ReadPin(TR_IN_A_GPIO_Port, TR_IN_A_Pin) == GPIO_PIN_RESET; + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_A, state); + // midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + break; + } + case TR_IN_B_Pin: + case SW_B_Pin: { + bool state = HAL_GPIO_ReadPin(SW_B_GPIO_Port, SW_B_Pin) == GPIO_PIN_RESET; + state |= HAL_GPIO_ReadPin(TR_IN_B_GPIO_Port, TR_IN_B_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_B, state); + break; + } + } +} + +extern "C"{ + static uint16_t smooth_adc_values[NOF_ADC_VALUES]; + void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ + // this runs at apprx 3.3kHz + // with 64.5 cycles sample time, 30 MHz ADC clock, and ClockPrescaler = 32 + extern uint16_t adc_values[NOF_ADC_VALUES]; + for(size_t i=0; i> 2; + } + // tr_out_a_pin.toggle(); + } + void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc){ + error(CONFIG_ERROR, "ADC error"); + } + void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + params.updateValues((int16_t*)smooth_adc_values, adc_len); + } +} + +void updateEncoders(){ + int16_t encoder_values[2] = {(int16_t)__HAL_TIM_GET_COUNTER(&ENCODER_TIM1), + (int16_t)__HAL_TIM_GET_COUNTER(&ENCODER_TIM2)}; + params.updateEncoders(encoder_values, 2); + // static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; + // int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); + // int16_t delta = value - encoder_values[0]; + // if(delta) + // graphics.params.encoderChanged(0, delta); + // encoder_values[0] = value; + // value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM2); + // delta = value - encoder_values[1]; + // if(delta) + // graphics.params.encoderChanged(1, delta); + // encoder_values[1] = value; +} + +void onLoop(void){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ @@ -99,11 +198,35 @@ void loop(void){ // SCB_CleanInvalidateDCache_by_Addr((uint32_t*)graphics.params.user, sizeof(graphics.params.user)); #endif updateEncoders(); +} -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ +#ifdef DEBUG_USBD_AUDIO +void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ + extern int usbd_tx_flow; + extern int usbd_rx_flow; + extern int usbd_tx_capacity; + extern int usbd_rx_capacity; + ScreenBuffer& screen = graphics.screen; + params.drawTitle(screen); + params.drawMessage(26, screen); - owl.loop(); + screen.setTextSize(1); + screen.print(2, 36, "rx "); + screen.print(usbd_rx_flow); + screen.print(" / "); + screen.print(usbd_rx_capacity); + screen.print(2, 46, "tx "); + screen.print(usbd_tx_flow); + screen.print(" / "); + screen.print(usbd_tx_capacity); } +// #else +// void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ +// ScreenBuffer& screen = graphics.screen; +// params.drawTitle(screen); +// params.drawMessage(26, screen); + +// screen.setTextSize(1); +// encoder_values +// } +#endif diff --git a/Genius/Src/main.c b/Genius/Src/main.c index b6d5b3f5..0d5e5940 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -20,6 +20,8 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" +#include "usb_host.h" +#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -71,7 +73,6 @@ DMA_HandleTypeDef hdma_usart2_rx; DMA_HandleTypeDef hdma_usart2_tx; PCD_HandleTypeDef hpcd_USB_OTG_FS; -HCD_HandleTypeDef hhcd_USB_OTG_HS; SDRAM_HandleTypeDef hsdram1; @@ -97,13 +98,11 @@ static void MX_ADC1_Init(void); static void MX_DAC1_Init(void); static void MX_UART5_Init(void); static void MX_USB_OTG_FS_PCD_Init(void); -static void MX_USB_OTG_HS_HCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ void setup(void); void loop(void); -void MX_USB_HOST_Process(void); void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); void initialise_monitor_handles(void); void MPU_Config(void); @@ -184,8 +183,7 @@ int main(void) MX_ADC1_Init(); MX_DAC1_Init(); MX_UART5_Init(); - /* MX_USB_OTG_FS_PCD_Init(); */ - /* MX_USB_OTG_HS_HCD_Init(); */ + /* MX_USB_OTG_FS_PCD_Init(); hangs if bootloader has run */ /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); HAL_SAI_DeInit(&hsai_BlockB1); @@ -335,18 +333,18 @@ static void MX_ADC1_Init(void) /** Common config */ hadc1.Instance = ADC1; - hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; - hadc1.Init.Resolution = ADC_RESOLUTION_16B; - hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; - hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV32; + hadc1.Init.Resolution = ADC_RESOLUTION_12B_OPT; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; - hadc1.Init.ContinuousConvMode = DISABLE; - hadc1.Init.NbrOfConversion = 1; + hadc1.Init.ContinuousConvMode = ENABLE; + hadc1.Init.NbrOfConversion = 2; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; - hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR; + hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; hadc1.Init.OversamplingMode = DISABLE; if (HAL_ADC_Init(&hadc1) != HAL_OK) @@ -364,7 +362,7 @@ static void MX_ADC1_Init(void) */ sConfig.Channel = ADC_CHANNEL_16; sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; + sConfig.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; @@ -373,6 +371,14 @@ static void MX_ADC1_Init(void) { Error_Handler(); } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_17; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC1_Init 2 */ /* USER CODE END ADC1_Init 2 */ @@ -407,7 +413,7 @@ static void MX_DAC1_Init(void) */ sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; sConfig.DAC_Trigger = DAC_TRIGGER_NONE; - sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; + sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE; sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) @@ -421,7 +427,12 @@ static void MX_DAC1_Init(void) Error_Handler(); } /* USER CODE BEGIN DAC1_Init 2 */ - + /* extern DAC_HandleTypeDef hdac; */ + /* DAC_ChannelConfTypeDef *sConfig; */ + /* if (HAL_DACEx_SelfCalibrate(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) */ + /* Error_Handler(); */ + /* if (HAL_DACEx_SelfCalibrate(&hdac1, &sConfig, DAC_CHANNEL_2) != HAL_OK) */ + /* Error_Handler(); */ /* USER CODE END DAC1_Init 2 */ } @@ -508,7 +519,7 @@ static void MX_SPI2_Init(void) hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; - hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE; if (HAL_SPI_Init(&hspi2) != HAL_OK) @@ -592,12 +603,12 @@ static void MX_SPI5_Init(void) hspi5.Init.CLKPolarity = SPI_POLARITY_LOW; hspi5.Init.CLKPhase = SPI_PHASE_1EDGE; hspi5.Init.NSS = SPI_NSS_SOFT; - hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi5.Init.TIMode = SPI_TIMODE_DISABLE; hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi5.Init.CRCPolynomial = 0x0; - hspi5.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi5.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; hspi5.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi5.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi5.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; @@ -645,11 +656,11 @@ static void MX_TIM2_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 8; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 8; if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) { Error_Handler(); @@ -694,11 +705,11 @@ static void MX_TIM3_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 8; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 8; if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) { Error_Handler(); @@ -873,7 +884,7 @@ static void MX_USB_OTG_FS_PCD_Init(void) hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; @@ -889,39 +900,6 @@ static void MX_USB_OTG_FS_PCD_Init(void) } -/** - * @brief USB_OTG_HS Initialization Function - * @param None - * @retval None - */ -static void MX_USB_OTG_HS_HCD_Init(void) -{ - - /* USER CODE BEGIN USB_OTG_HS_Init 0 */ - - /* USER CODE END USB_OTG_HS_Init 0 */ - - /* USER CODE BEGIN USB_OTG_HS_Init 1 */ - - /* USER CODE END USB_OTG_HS_Init 1 */ - hhcd_USB_OTG_HS.Instance = USB_OTG_HS; - hhcd_USB_OTG_HS.Init.Host_channels = 16; - hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; - hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; - hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; - hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; - if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USB_OTG_HS_Init 2 */ - - /* USER CODE END USB_OTG_HS_Init 2 */ - -} - /** * Enable DMA controller clock */ @@ -1027,10 +1005,10 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(Flash_CS_GPIO_Port, Flash_CS_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOC, FLASH_WP_Pin|OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOF, FLASH_nCS_Pin|FLASH_HOLD_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(OLED_CS_GPIO_Port, OLED_CS_Pin, GPIO_PIN_RESET); @@ -1041,33 +1019,27 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOG, CS_CS_Pin|CS_RST_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PC13 PC14 PC15 PC4 - PC5 PC6 PC7 PC8 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4 - |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pin : Flash_CS_Pin */ - GPIO_InitStruct.Pin = Flash_CS_Pin; + /*Configure GPIO pins : FLASH_WP_Pin OLED_RST_Pin OLED_DC_Pin USB_HOST_PWR_EN_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(Flash_CS_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pin : PF10 */ - GPIO_InitStruct.Pin = GPIO_PIN_10; + /*Configure GPIO pins : PC14 PC15 PC4 PC5 + PC6 PC7 PC8 */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : OLED_RST_Pin OLED_DC_Pin USB_HOST_PWR_EN_Pin */ - GPIO_InitStruct.Pin = OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin; + /*Configure GPIO pins : FLASH_nCS_Pin FLASH_HOLD_Pin */ + GPIO_InitStruct.Pin = FLASH_nCS_Pin|FLASH_HOLD_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : PB0 PB1 PB2 PB7 PB8 PB9 */ @@ -1151,10 +1123,13 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(ENC2_SW_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI4_IRQn, 10, 0); + HAL_NVIC_SetPriority(EXTI2_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI4_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI4_IRQn); - HAL_NVIC_SetPriority(EXTI15_10_IRQn, 10, 0); + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); } @@ -1164,6 +1139,7 @@ static void MX_GPIO_Init(void) /* USER CODE END 4 */ /* USER CODE BEGIN Header_StartDefaultTask */ +#if 0 /** * @brief Function implementing the defaultTask thread. * @param argument: Not used @@ -1172,7 +1148,11 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { + /* init code for USB_HOST */ + MX_USB_HOST_Init(); /* USER CODE BEGIN 5 */ +#endif + void StartDefaultTask(void const * argument) { /* init code for USB_DEVICE */ /* NOTE: we get frequent boot failures if host is called first */ MX_USB_DEVICE_Init(); diff --git a/Genius/Src/stm32h7xx_hal_msp.c b/Genius/Src/stm32h7xx_hal_msp.c index e9abf926..72f5046e 100644 --- a/Genius/Src/stm32h7xx_hal_msp.c +++ b/Genius/Src/stm32h7xx_hal_msp.c @@ -154,6 +154,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspInit 1 */ /* USER CODE END ADC1_MspInit 1 */ @@ -186,6 +189,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* ADC1 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspDeInit 1 */ /* USER CODE END ADC1_MspDeInit 1 */ @@ -387,7 +393,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) PF8 ------> SPI5_MISO PF9 ------> SPI5_MOSI */ - GPIO_InitStruct.Pin = Flash_CLK_Pin|Flash_MISO_Pin|Flash_MOSI_Pin; + GPIO_InitStruct.Pin = FLASH_CLK_Pin|FLASH_MISO_Pin|FLASH_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; @@ -465,7 +471,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) PF8 ------> SPI5_MISO PF9 ------> SPI5_MOSI */ - HAL_GPIO_DeInit(GPIOF, Flash_CLK_Pin|Flash_MISO_Pin|Flash_MOSI_Pin); + HAL_GPIO_DeInit(GPIOF, FLASH_CLK_Pin|FLASH_MISO_Pin|FLASH_MOSI_Pin); /* USER CODE BEGIN SPI5_MspDeInit 1 */ @@ -905,7 +911,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -921,58 +927,6 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) } -/** -* @brief HCD MSP Initialization -* This function configures the hardware resources used in this example -* @param hhcd: HCD handle pointer -* @retval None -*/ -void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hhcd->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ - - /* USER CODE END USB_OTG_HS_MspInit 0 */ - - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; - PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Enable USB Voltage detector - */ - HAL_PWREx_EnableUSBVoltageDetector(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USB_OTG_HS GPIO Configuration - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); - /* USB_OTG_HS interrupt Init */ - HAL_NVIC_SetPriority(OTG_HS_IRQn, 10, 0); - HAL_NVIC_EnableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ - - /* USER CODE END USB_OTG_HS_MspInit 1 */ - } - -} - /** * @brief PCD MSP De-Initialization * This function freeze the hardware resources used in this example @@ -1005,37 +959,6 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) } -/** -* @brief HCD MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hhcd: HCD handle pointer -* @retval None -*/ -void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hhcd) -{ - if(hhcd->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); - - /**USB_OTG_HS GPIO Configuration - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); - - /* USB_OTG_HS interrupt DeInit */ - HAL_NVIC_DisableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 1 */ - } - -} - static uint32_t FMC_Initialized = 0; static void HAL_FMC_MspInit(void){ @@ -1299,7 +1222,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; @@ -1351,7 +1274,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; @@ -1396,6 +1319,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -1413,6 +1337,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/Genius/Src/stm32h7xx_it.c b/Genius/Src/stm32h7xx_it.c index 0707f453..6aa96e18 100644 --- a/Genius/Src/stm32h7xx_it.c +++ b/Genius/Src/stm32h7xx_it.c @@ -58,7 +58,9 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern DMA_HandleTypeDef hdma_spi2_tx; @@ -72,7 +74,6 @@ extern DMA_HandleTypeDef hdma_usart2_tx; extern UART_HandleTypeDef huart5; extern UART_HandleTypeDef huart2; extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -109,6 +110,20 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32h7xx.s). */ /******************************************************************************/ +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + /** * @brief This function handles EXTI line4 interrupt. */ @@ -207,6 +222,20 @@ void DMA1_Stream5_IRQHandler(void) /* USER CODE END DMA1_Stream5_IRQn 1 */ } +/** + * @brief This function handles ADC1 and ADC2 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + /** * @brief This function handles TIM2 global interrupt. */ diff --git a/Genius/Src/usb_host.c b/Genius/Src/usb_host.c index 02c1c118..15afa143 100644 --- a/Genius/Src/usb_host.c +++ b/Genius/Src/usb_host.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -23,15 +23,23 @@ #include "usb_host.h" #include "usbh_core.h" -#include "usbh_midi.h" /* USER CODE BEGIN Includes */ - +#include "device.h" +#include "message.h" +#include "errorhandlers.h" +#ifdef USE_USBH_MIDI +#include "usbh_midi.h" +#endif +#ifdef USE_USBH_HID +#include "usbh_hid.h" +#endif /* USER CODE END Includes */ /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ - +#define HUSB_HOST hUsbHostHS +#define HUSB_HOST_HSFS HOST_HS /* USER CODE END PV */ /* USER CODE BEGIN PFP */ @@ -40,7 +48,7 @@ /* USER CODE END PFP */ /* USB Host core handle declaration */ -USBH_HandleTypeDef hUsbHostHS; +USBH_HandleTypeDef HUSB_HOST; ApplicationTypeDef Appli_state = APPLICATION_IDLE; /* @@ -59,11 +67,45 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); * -- Insert your external function declaration here -- */ /* USER CODE BEGIN 1 */ + +#ifdef USE_USBH_HID +void USBH_HID_EventCallback(USBH_HandleTypeDef *phost){ + debugMessage("HID"); +} +#endif + +/* + * Background task +*/ void MX_USB_HOST_Process() { /* USB Host Background task */ - USBH_Process(&hUsbHostHS); + USBH_Process(&HUSB_HOST); + /* if(Appli_state == APPLICATION_DISCONNECT){ */ + /* USBH_Stop(&HUSB_HOST); */ + /* USBH_DeInit(&HUSB_HOST); */ + /* Appli_state = APPLICATION_DISCONNECTED; */ + /* }else if(Appli_state == APPLICATION_DISCONNECTED){ */ + /* MX_USB_HOST_Init(); */ + /* Appli_state = APPLICATION_IDLE; */ + /* } */ + USBH_HandleTypeDef *phost = &HUSB_HOST; +#ifdef USE_USBH_HID + if(USBH_HID_GetDeviceType(phost) == HID_KEYBOARD){ + HID_KEYBD_Info_TypeDef* pinfo = USBH_HID_GetKeybdInfo(phost); + if(pinfo != NULL){ + uint8_t c = USBH_HID_GetASCIICode(pinfo); + // or c = pinfo->keys[0]; + if(c >= 32 && c <= 126) { // readable ascii + char* msg = "char[ ]"; + msg[5] = c; + debugMessage(msg); + } + } + } +#endif } + /* USER CODE END 1 */ /** @@ -73,24 +115,34 @@ void MX_USB_HOST_Process() void MX_USB_HOST_Init(void) { /* USER CODE BEGIN USB_HOST_Init_PreTreatment */ - + /* USER CODE END USB_HOST_Init_PreTreatment */ - + /* Init host Library, add supported class and start the library. */ - if (USBH_Init(&hUsbHostHS, USBH_UserProcess, HOST_HS) != USBH_OK) + if (USBH_Init(&HUSB_HOST, USBH_UserProcess, HUSB_HOST_HSFS) != USBH_OK) + { + Error_Handler(); + } +#ifdef USE_USBH_MIDI + if (USBH_RegisterClass(&HUSB_HOST, USBH_MIDI_CLASS) != USBH_OK) { Error_Handler(); } - if (USBH_RegisterClass(&hUsbHostHS, USBH_MIDI_CLASS) != USBH_OK) +#endif +#ifdef USE_USBH_HID + if (USBH_RegisterClass(&HUSB_HOST, USBH_HID_CLASS) != USBH_OK) { Error_Handler(); } - if (USBH_Start(&hUsbHostHS) != USBH_OK) +#endif + if (USBH_Start(&HUSB_HOST) != USBH_OK) { Error_Handler(); } /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ + HAL_PWREx_EnableUSBVoltageDetector(); + /* USER CODE END USB_HOST_Init_PostTreatment */ } @@ -100,25 +152,43 @@ void MX_USB_HOST_Init(void) static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) { /* USER CODE BEGIN CALL_BACK_1 */ + USBH_UsrLog("USBH UserProcess %d %d %d", phost->EnumState, phost->gState, id); switch(id) { case HOST_USER_SELECT_CONFIGURATION: - break; + break; - case HOST_USER_DISCONNECTION: - Appli_state = APPLICATION_DISCONNECT; - break; + case HOST_USER_CONNECTION: + Appli_state = APPLICATION_START; + break; case HOST_USER_CLASS_ACTIVE: - Appli_state = APPLICATION_READY; - break; + if(Appli_state == APPLICATION_START){ +#ifdef USE_USBH_MIDI + usbh_midi_begin(); +#endif + Appli_state = APPLICATION_READY; + } + break; - case HOST_USER_CONNECTION: - Appli_state = APPLICATION_START; - break; + case HOST_USER_DISCONNECTION: + Appli_state = APPLICATION_DISCONNECT; +#ifdef USE_USBH_MIDI + usbh_midi_reset(); +#endif + break; + + case HOST_USER_UNRECOVERED_ERROR: + /* phost->Control.state = CTRL_SETUP; */ + /* phost->RequestState = CMD_SEND; */ + Appli_state = APPLICATION_DISCONNECT; + /* usbh_midi_reset(); // reset and hope for the best */ + /* USBH_LL_ResetPort(&USBH_HANDLE); */ + error(USB_ERROR, "USB Host error"); + break; default: - break; + break; } /* USER CODE END CALL_BACK_1 */ } diff --git a/Genius/Src/usbd_conf.c b/Genius/Src/usbd_conf.c index eabadcf8..e989bde2 100644 --- a/Genius/Src/usbd_conf.c +++ b/Genius/Src/usbd_conf.c @@ -277,11 +277,11 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; hpcd_USB_OTG_FS.Init.use_external_vbus = DISABLE; if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) diff --git a/Genius/Src/usbh_conf.c b/Genius/Src/usbh_conf.c index 1f61f845..b96127ac 100644 --- a/Genius/Src/usbh_conf.c +++ b/Genius/Src/usbh_conf.c @@ -24,7 +24,7 @@ #include "usbh_platform.h" /* USER CODE BEGIN Includes */ - +#include "message.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -36,7 +36,7 @@ /* USER CODE END PV */ -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; +HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -61,6 +60,76 @@ void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URB *******************************************************************************/ /* MSP Init */ +void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 10, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } +} + +void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) +{ + if(hcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } +} + /** * @brief SOF callback. * @param hhcd: HCD handle @@ -78,6 +147,7 @@ void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd) */ void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) { + debugMessage("USBH Connect"); USBH_LL_Connect(hhcd->pData); } @@ -88,6 +158,7 @@ void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) */ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) { + debugMessage("USBH Disconnect"); USBH_LL_Disconnect(hhcd->pData); } @@ -98,14 +169,15 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* USBH_MIDI_NotifyURBChange((USBH_HandleTypeDef*)hhcd->pData, chnum, urb_state); */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* // calls (void)osMessagePut(phost->os_event, phost->os_msg, 0U); */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle @@ -147,8 +219,10 @@ USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost) hhcd_USB_OTG_HS.Init.Host_channels = 16; hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hhcd_USB_OTG_HS.Init.phy_itface = HCD_PHY_EMBEDDED; + hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) { Error_Handler( ); @@ -388,7 +462,6 @@ USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) } /* USER CODE BEGIN 0 */ - /* USER CODE END 0*/ HAL_Delay(200); diff --git a/Genius/Src/usbh_platform.c b/Genius/Src/usbh_platform.c index 33001136..3c2e63db 100644 --- a/Genius/Src/usbh_platform.c +++ b/Genius/Src/usbh_platform.c @@ -31,8 +31,8 @@ * @brief Drive VBUS. * @param state : VBUS state * This parameter can be one of the these values: - * - 1 : VBUS Active - * - 0 : VBUS Inactive + * - 1 : VBUS Active + * - 0 : VBUS Inactive */ void MX_DriverVbusHS(uint8_t state) { @@ -49,7 +49,7 @@ void MX_DriverVbusHS(uint8_t state) data = GPIO_PIN_RESET; } /* USER CODE END PREPARE_GPIO_DATA_VBUS_HS */ - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, (GPIO_PinState)data); + HAL_GPIO_WritePin(GPIOC,GPIO_PIN_9,(GPIO_PinState)data); } /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/HISTORY.md b/HISTORY.md index 8721a7f9..a7b62b99 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,35 @@ +22.2.0 +------ + +* Improved USB Audio FIFO allocation +* Refactored Graphics code +* Move screen handling to separate task +* Added patch text/message handlers +* Changed loop/setup callbacks to onLoop and onSetup +* Support for OWL Pedal mk2 +* Prevent invalid characters in reported patch names +* Send resource size and checksum with name +* Improved backwards patch compatibility (CCM linked stack) + + +22.1.rc2 +------ + +* Process USB messages each audio block, before patch runs (or in loop if no patch is loaded) + + +22.1.rc1 +------ + +* Fix USBD audio sync issues: +* rx asynchronous mode with explicit feedback +* tx asynchronous mode with variable output size +* Fix USBD audio descriptor issues (Windows support) + +Known Issues: +* USB Host does not support reconnecting devices + + 22.0.0 ------ @@ -119,4 +151,4 @@ Known Issues: 20.0.0 ------ -* First release of the OpenWare firmware as shipped on Alchemist and Wizard Kickstarter rewards \ No newline at end of file +* First release of the OpenWare firmware as shipped on Alchemist and Wizard Kickstarter rewards diff --git a/Hardware/common.mk b/Hardware/common.mk index ffc3a0ff..891167f5 100644 --- a/Hardware/common.mk +++ b/Hardware/common.mk @@ -45,7 +45,7 @@ vpath %.s $(sort $(dir $(S_SRC))) build_dir: $(BUILD) $(BUILD): - $(MKDIR) $(BUILD) + @$(MKDIR) $(BUILD) # Build executable $(ELF) : $(OBJS) $(LDSCRIPT) diff --git a/Hardware/f4-libs.mk b/Hardware/f4-libs.mk index 469c0de1..a77620e1 100644 --- a/Hardware/f4-libs.mk +++ b/Hardware/f4-libs.mk @@ -63,6 +63,7 @@ C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_core.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_pipes.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ioreq.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ctlreq.c +C_SRC_USBH_HID = $(wildcard $(USB_HOST_FILE)/Class/HID/Src/*.c) ### CMSIS DSP Library #### C_SRC_DSP = $(DSPLIB)/FastMathFunctions/arm_sin_f32.c diff --git a/Hardware/f4.mk b/Hardware/f4.mk index 5b2fb97e..ac49b038 100644 --- a/Hardware/f4.mk +++ b/Hardware/f4.mk @@ -14,14 +14,13 @@ CMSIS_CORE=$(LIBROOT)/CMSIS/Include DSPLIB=$(LIBROOT)/CMSIS/DSP/Source USB_DEVICE_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Device_Library USB_HOST_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Host_Library -USB_OTG_FILE=$(LIBROOT)/STM32_USB_OTG_Driver FREERTOS_DIR=$(OPENWARE)/Libraries/Middlewares/Third_Party/FreeRTOS/Source INC_FLAGS = -I$(CMSIS_CORE) -I$(CMSIS_DEVICE)/Include -I$(DRIVERS)/Inc INC_FLAGS += -I$(OPENWARE)/Source -I$(BUILDROOT)/Inc INC_FLAGS += -I$(USB_HOST_FILE)/Core/Inc +INC_FLAGS += -I$(USB_HOST_FILE)/Class/HID/Inc INC_FLAGS += -I$(USB_DEVICE_FILE)/Core/Inc -INC_FLAGS += -I$(USB_OTG_FILE)/inc INC_FLAGS += -I$(FREERTOS_DIR)/include INC_FLAGS += -I$(FREERTOS_DIR)/portable/GCC/ARM_CM4F/ INC_FLAGS += -I$(FREERTOS_DIR)/CMSIS_RTOS diff --git a/Hardware/h7-libs.mk b/Hardware/h7-libs.mk index 2f56b8b8..d97c173a 100644 --- a/Hardware/h7-libs.mk +++ b/Hardware/h7-libs.mk @@ -13,10 +13,10 @@ C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_flash.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_flash_ex.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_tim_ex.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_tim.c +C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_lptim.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_cortex.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_spi.c # C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_rng.c -# C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_qspi.c # C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_dma2d.c # optionals @@ -29,6 +29,8 @@ C_SRC_RTC = $(DRIVERS)/Src/stm32h7xx_hal_rtc.c C_SRC_RTC += $(DRIVERS)/Src/stm32h7xx_hal_pwr.c C_SRC_RTC += $(DRIVERS)/Src/stm32h7xx_hal_rtc_ex.c C_SRC_IWDG = $(DRIVERS)/Src/stm32h7xx_hal_iwdg.c +C_SRC_QSPI = $(DRIVERS)/Src/stm32h7xx_hal_qspi.c +C_SRC_MDMA = $(DRIVERS)/Src/stm32h7xx_hal_mdma.c # required by OWL 2 C_SRC_SAI = $(DRIVERS)/Src/stm32h7xx_hal_sai.c @@ -64,6 +66,7 @@ C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_core.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_pipes.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ioreq.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ctlreq.c +C_SRC_USBH_HID = $(wildcard $(USB_HOST_FILE)/Class/HID/Src/*.c) ### CMSIS DSP Library #### C_SRC_DSP = $(DSPLIB)/FastMathFunctions/arm_sin_f32.c diff --git a/Hardware/h7.mk b/Hardware/h7.mk index 2083e1e1..871c3826 100644 --- a/Hardware/h7.mk +++ b/Hardware/h7.mk @@ -14,14 +14,16 @@ CMSIS_CORE=$(LIBROOT)/CMSIS/Include DSPLIB=$(LIBROOT)/CMSIS/DSP/Source USB_DEVICE_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Device_Library USB_HOST_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Host_Library -USB_OTG_FILE=$(LIBROOT)/STM32_USB_OTG_Driver FREERTOS_DIR=$(OPENWARE)/Libraries/Middlewares/Third_Party/FreeRTOS/Source INC_FLAGS = -I$(CMSIS_CORE) -I$(CMSIS_DEVICE)/Include -I$(DRIVERS)/Inc INC_FLAGS += -I$(OPENWARE)/Source -I$(BUILDROOT)/Inc +INC_FLAGS += -I$(BUILDROOT)/Core/Inc +INC_FLAGS += -I$(BUILDROOT)/USB_DEVICE/App -I$(BUILDROOT)/USB_DEVICE/Target +INC_FLAGS += -I$(BUILDROOT)/USB_HOST/App -I$(BUILDROOT)/USB_HOST/Target INC_FLAGS += -I$(USB_HOST_FILE)/Core/Inc +INC_FLAGS += -I$(USB_HOST_FILE)/Class/HID/Inc INC_FLAGS += -I$(USB_DEVICE_FILE)/Core/Inc -INC_FLAGS += -I$(USB_OTG_FILE)/inc INC_FLAGS += -I$(FREERTOS_DIR)/include INC_FLAGS += -I$(FREERTOS_DIR)/portable/GCC/ARM_CM7/r0p1 INC_FLAGS += -I$(FREERTOS_DIR)/CMSIS_RTOS diff --git a/Hardware/owl1.mk b/Hardware/owl1.mk index a47f585e..5c7ae8b5 100644 --- a/Hardware/owl1.mk +++ b/Hardware/owl1.mk @@ -4,11 +4,12 @@ ifeq ($(CONFIG),Debug) CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT ASFLAGS = -g3 CFLAGS = -g3 -endif -ifeq ($(CONFIG),Release) +else ifeq ($(CONFIG),Release) CPPFLAGS = -O2 ASFLAGS = -O2 CFLAGS = -O2 +else + $(error Invalid CONFIG=$(CONFIG)) endif # compile with semihosting if Debug is selected diff --git a/Hardware/owl2.mk b/Hardware/owl2.mk index 4980b071..f4bc10b9 100644 --- a/Hardware/owl2.mk +++ b/Hardware/owl2.mk @@ -4,11 +4,12 @@ ifeq ($(CONFIG),Debug) CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT ASFLAGS = -g3 CFLAGS = -g3 -endif -ifeq ($(CONFIG),Release) +else ifeq ($(CONFIG),Release) CPPFLAGS = -O2 ASFLAGS = -O2 CFLAGS = -O2 +else + $(error Invalid CONFIG=$(CONFIG)) endif # compile with semihosting if Debug is selected @@ -25,11 +26,8 @@ endif LDFLAGS += -Wl,--gc-sections LDSCRIPT ?= $(OPENWARE)/Hardware/owl2.ld LDLIBS += -lc -lm -# CPPFLAGS += -DEXTERNAL_SRAM -DARM_CORTEX -# CPPFLAGS += -fpic -fpie CPPFLAGS += -Wdouble-promotion -Werror=double-promotion -CPPFLAGS += -fdata-sections -CPPFLAGS += -ffunction-sections +CPPFLAGS += -fdata-sections -ffunction-sections CPPFLAGS += -fno-builtin -ffreestanding LDFLAGS += -fno-builtin -ffreestanding CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++17 diff --git a/Hardware/owl3.ld b/Hardware/owl3.ld index 881f2032..72f1160d 100644 --- a/Hardware/owl3.ld +++ b/Hardware/owl3.ld @@ -2,19 +2,26 @@ ENTRY(Reset_Handler) /* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x000; /* required amount of heap */ +_Min_Heap_Size = 0x200; /* required amount of heap */ _Min_Stack_Size = 0x200; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K + /* DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K */ + /* RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K */ + /* RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K */ + /* RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K */ + /* ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K */ + /* FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K */ +DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K PATCHRAM (rwx) : ORIGIN = 0x2000c000, LENGTH = 80K PLUSRAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* D1 RAM */ HEAP_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 256K -DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K -RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K -ITCMRAM (xrw) : ORIGIN = 0x00000008, LENGTH = 65528 /* 64K - 8 to avoid starting at 0x0 - FreeRTOS fails if stack address is NULL */ +DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K +RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 4K +CCMRAM (xrw) : ORIGIN = 0x00001000, LENGTH = 60K EXTRAM (rwx) : ORIGIN = 0xD0000000, LENGTH = 8M /* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K */ /* FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K */ @@ -122,19 +129,18 @@ SECTIONS . = ALIGN(4); _ebss = .; /* define a global symbol at bss end */ __bss_end__ = _ebss; + + end = .; /* system heap, used e.g. by printf in DEBUG builds */ + . = . + _Min_Heap_Size; } >DTCMRAM /* User_heap_stack section, used to check that there is enough RAM left */ ._user_heap_stack : { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; . = . + _Min_Stack_Size; . = ALIGN(8); - } >DTCMRAM - _estack = ORIGIN(DTCMRAM)+LENGTH(DTCMRAM); + } >ITCMRAM + _estack = ORIGIN(ITCMRAM)+LENGTH(ITCMRAM); /* CCM section, vars must be located here explicitly */ /* Example: int foo __attribute__ ((section (".ccmdata"))); */ @@ -143,8 +149,8 @@ SECTIONS *(.ccmdata) . = ALIGN(8); PROVIDE (_CCMRAM = .); - } >ITCMRAM - _CCMRAM_END = ORIGIN(ITCMRAM) + LENGTH(ITCMRAM); + } >CCMRAM + _CCMRAM_END = ORIGIN(CCMRAM) + LENGTH(CCMRAM); _CCMRAM_SIZE = _CCMRAM_END - _CCMRAM; /* Bootloader end will be used for finding bootloader token */ diff --git a/Hardware/owl3.mk b/Hardware/owl3.mk index 40718463..f74f91e7 100644 --- a/Hardware/owl3.mk +++ b/Hardware/owl3.mk @@ -4,11 +4,12 @@ ifeq ($(CONFIG),Debug) CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT ASFLAGS = -g3 CFLAGS = -g3 -endif -ifeq ($(CONFIG),Release) +else ifeq ($(CONFIG),Release) CPPFLAGS = -O2 ASFLAGS = -O2 CFLAGS = -O2 +else + $(error Invalid CONFIG=$(CONFIG)) endif # compile with semihosting if Debug is selected @@ -25,11 +26,8 @@ endif LDFLAGS += -Wl,--gc-sections LDSCRIPT ?= $(OPENWARE)/Hardware/owl3.ld LDLIBS += -lc -lm -# CPPFLAGS += -DEXTERNAL_SRAM -DARM_CORTEX -# CPPFLAGS += -fpic -fpie -CPPFLAGS += -Wdouble-promotion -CPPFLAGS += -fdata-sections -CPPFLAGS += -ffunction-sections +CPPFLAGS += -Wdouble-promotion -Werror=double-promotion +CPPFLAGS += -fdata-sections -ffunction-sections CPPFLAGS += -fno-builtin -ffreestanding LDFLAGS += -fno-builtin -ffreestanding CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++17 diff --git a/Hardware/xibeca.ld b/Hardware/xibeca.ld new file mode 100644 index 00000000..5b80fbad --- /dev/null +++ b/Hardware/xibeca.ld @@ -0,0 +1,224 @@ +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x200; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ + /* DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K */ + /* RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K */ + /* RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K */ + /* RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K */ + /* ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K */ + /* FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K */ +DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K +PATCHRAM (rwx) : ORIGIN = 0x2000c000, LENGTH = 80K +PLUSRAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* D1 RAM */ +HEAP_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 256K +DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K +RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 2K +CCMRAM (xrw) : ORIGIN = 0x00000800, LENGTH = 62K +/* EXTRAM (rwx) : ORIGIN = 0xD0000000, LENGTH = 8M */ +EXTRAM (rwx) : ORIGIN = 0xC0000000, LENGTH = 64M /* 64M in Rev01 prototypes */ + +BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K +FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K +/* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K */ +/* FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K */ +STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 512K /* Assuming 1Mb FLASH */ +/* STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 1536K /\* Assuming 2Mb FLASH *\/ */ +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + PROVIDE ( _ISR_VECTOR = . ); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + PROVIDE ( _ISR_VECTOR_END = . ); + } >FLASH + _ISR_VECTOR_SIZE = _ISR_VECTOR_END - _ISR_VECTOR; + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >DTCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + + end = .; /* system heap, used e.g. by printf in DEBUG builds */ + . = . + _Min_Heap_Size; + } >DTCMRAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >ITCMRAM + _estack = ORIGIN(ITCMRAM)+LENGTH(ITCMRAM); + + /* CCM section, vars must be located here explicitly */ + /* Example: int foo __attribute__ ((section (".ccmdata"))); */ + .ccmdata (NOLOAD) : + { + *(.ccmdata) + . = ALIGN(8); + PROVIDE (_CCMRAM = .); + } >CCMRAM + _CCMRAM_END = ORIGIN(CCMRAM) + LENGTH(CCMRAM); + _CCMRAM_SIZE = _CCMRAM_END - _CCMRAM; + + /* Bootloader end will be used for finding bootloader token */ + .bootloader (NOLOAD) : + { + PROVIDE (_BOOTLOADER = .); + } >BOOTLOADER + _BOOTLOADER_END = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER); + + /* External memory, vars must be located here explicitly */ + /* Example: int foo __attribute__ ((section (".extdata"))); */ + .extdata (NOLOAD) : + { + /* *(.extdata) */ + /* . = ALIGN(8); */ + PROVIDE ( _EXTRAM = . ); + /* } >RAM_D1 */ + /* _EXTRAM_END = ORIGIN(RAM_D1) + LENGTH(RAM_D1); */ + /* _EXTRAM_SIZE = LENGTH(RAM_D1); */ + } >EXTRAM + _EXTRAM_END = ORIGIN(EXTRAM) + LENGTH(EXTRAM); + _EXTRAM_SIZE = LENGTH(EXTRAM); + + .patchram (NOLOAD) : + { + PROVIDE (_PATCHRAM = .); + } >PATCHRAM + _PATCHRAM_END = ORIGIN(PATCHRAM) + LENGTH(PATCHRAM); + _PATCHRAM_SIZE = LENGTH(PATCHRAM); + + .plusram (NOLOAD) : + { + PROVIDE (_PLUSRAM = .); + } >PLUSRAM + _PLUSRAM_END = ORIGIN(PLUSRAM) + LENGTH(PLUSRAM); + _PLUSRAM_SIZE = LENGTH(PLUSRAM); + + .heapd2 (NOLOAD) : + { + PROVIDE (_HEAP_D2 = .); + } >HEAP_D2 + _HEAP_D2_END = ORIGIN(HEAP_D2) + LENGTH(HEAP_D2); + _HEAP_D2_SIZE = LENGTH(HEAP_D2); + + .dmadata (NOLOAD) : + { + PROVIDE (_DMA_DATA = .); + *(.dmadata) + } >DMA_D2 + + .flash_storage (NOLOAD) : + { + PROVIDE (_FLASH_STORAGE_BEGIN = .); + } >STORAGE + _FLASH_STORAGE_END = ORIGIN(STORAGE) + LENGTH(STORAGE); + _FLASH_STORAGE_SIZE = LENGTH(STORAGE); + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/Libraries b/Libraries index 1a54c805..5a3f9643 160000 --- a/Libraries +++ b/Libraries @@ -1 +1 @@ -Subproject commit 1a54c8057d4056ac235f9b0ca0c4e4c99ecf0bc0 +Subproject commit 5a3f9643d27bf1a26b5e712bea81df4bb593c5fb diff --git a/Lich/Inc/hardware.h b/Lich/Inc/hardware.h index 7edd12e7..935ca628 100644 --- a/Lich/Inc/hardware.h +++ b/Lich/Inc/hardware.h @@ -5,16 +5,23 @@ #define HARDWARE_ID LICH_HARDWARE #define HARDWARE_VERSION "Lich" +#define USE_SPI_FLASH + /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ + #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS diff --git a/Lich/Makefile b/Lich/Makefile index 6c6381da..8d28666c 100644 --- a/Lich/Makefile +++ b/Lich/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/bus.cpp diff --git a/Lich/Src/Lich.cpp b/Lich/Src/Lich.cpp index 1764bdb6..2a28ed5a 100644 --- a/Lich/Src/Lich.cpp +++ b/Lich/Src/Lich.cpp @@ -56,7 +56,6 @@ Pin seg_pins[8] = Pin(DISPLAY_DP_GPIO_Port, DISPLAY_DP_Pin), }; -// set value to 10 for no display static void setSegmentDisplay(int value, bool dot=false){ seg_pins[7].set(!dot); // HAL_GPIO_WritePin(seg_ports[7], seg_pins[7], dot ? GPIO_PIN_RESET : GPIO_PIN_SET); @@ -138,11 +137,10 @@ void setEncoderValue(int value){ __HAL_TIM_SET_COUNTER(&htim2, value<<2); } -void setup(){ +void onSetup(){ // __HAL_TIM_SET_COUNTER(&htim2, INT16_MAX/2); HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL); setSegmentDisplay(SEG_DISPLAY_L, true); - owl.setup(); setEncoderValue(program.getProgramIndex()); setLed(1, 0); setLed(2, 0); @@ -156,13 +154,23 @@ void setProgress(uint16_t value, const char* msg){ progress = value; } -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ progress = 0; patchselect = program.getProgramIndex(); setEncoderValue(patchselect); } -static void update_preset(){ +extern "C" { + void usbh_midi_reset(void){ + HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); + HAL_Delay(100); // wait 100mS + HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); + // extern USBH_HandleTypeDef USBH_HANDLE; // defined in usb_host.c + // USBH_LL_ResetPort(&USBH_HANDLE); + } +} + +void onLoop(void){ static uint32_t counter = PATCH_RESET_COUNTER; switch(owl.getOperationMode()){ case STARTUP_MODE: @@ -226,26 +234,3 @@ static void update_preset(){ break; } } - -extern "C" { - void usbh_midi_reset(void){ - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); - HAL_Delay(100); // wait 100mS - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); - // extern USBH_HandleTypeDef USBH_HANDLE; // defined in usb_host.c - // USBH_LL_ResetPort(&USBH_HANDLE); - } -} - -void loop(void){ - if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ - if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); - error(USB_ERROR, "USBH PWR Fault"); - } - }else{ - MX_USB_HOST_Process(); - } - update_preset(); - owl.loop(); -} diff --git a/Lich/Src/usbh_conf.c b/Lich/Src/usbh_conf.c index 622a3a73..238743bf 100644 --- a/Lich/Src/usbh_conf.c +++ b/Lich/Src/usbh_conf.c @@ -39,7 +39,6 @@ HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END 0 */ @@ -155,14 +154,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); -/* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Magus/Inc/hardware.h b/Magus/Inc/hardware.h index 76f7ded3..692a159e 100644 --- a/Magus/Inc/hardware.h +++ b/Magus/Inc/hardware.h @@ -10,7 +10,6 @@ #define USE_SCREEN #define SSD1309 /* #define OLED_DMA */ -#define OLED_SOFT_CS #define OLED_SPI hspi6 /* #define OLED_IT */ /* #define OLED_BITBANG */ @@ -25,17 +24,17 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define MAIN_LOOP_SLEEP_MS 20 - #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS -#define USBD_HANDLE hUsbDeviceFS -#define USBH_HANDLE hUsbHostHS +#define USBD_HANDLE hUsbDeviceFS +#define USBH_HANDLE hUsbHostHS #define USE_USB_HOST +#define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI -#define USB_HOST_RX_BUFF_SIZE 256 // Serial MIDI TX only #define USE_UART_MIDI_TX @@ -43,14 +42,14 @@ #define UART_MIDI_RX_BUFFER_SIZE 256 #define USE_TLC5946 -#define LEDS_BRIGTHNESS 20 +#define LEDS_BRIGTHNESS 2 #define TLC5946_SPI hspi6 #define MAX11300_SPI hspi5 #define ENCODERS_SPI hspi5 #undef USE_ADC #define NOF_ADC_VALUES 0 -#define NOF_PARAMETERS 20 +#define NOF_PARAMETERS 40 #define NOF_BUTTONS 0 #undef USE_DAC diff --git a/Magus/Makefile b/Magus/Makefile index 10b2dd70..2628b40d 100644 --- a/Magus/Makefile +++ b/Magus/Makefile @@ -12,7 +12,7 @@ C_SRC += $(OPENWARE)/Source/ssd1309.c C_SRC += $(OPENWARE)/Source/HAL_MAX11300.c C_SRC += $(OPENWARE)/Source/HAL_TLC5946.c C_SRC += $(OPENWARE)/Source/HAL_Encoders.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/uart_midi.cpp diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index e3aac9c2..24689e4c 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -9,15 +9,48 @@ #include "HAL_Encoders.h" #include "Pin.h" #include "ApplicationSettings.h" - -// 63, 19, 60 // TODO: balance levels +#include "Storage.h" +#include "MagusParameterController.hpp" const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -Graphics graphics; + +MagusParameterController params; +Graphics graphics DMA_RAM; extern "C" void onResourceUpdate(void); +char* progress_message = NULL; +uint16_t progress_counter = 0; + +void setProgress(uint16_t value, const char* reason){ + progress_message = (char*)reason; + progress_counter = value; +} + +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + switch(new_mode){ + case STREAM_MODE: + setProgress(0, "Streaming"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case STARTUP_MODE: + case LOAD_MODE: + setProgress(0, "Loading"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case CONFIGURE_MODE: + setDisplayMode(STATUS_DISPLAY_MODE); + break; + case RUN_MODE: + setDisplayMode(STANDARD_DISPLAY_MODE); + break; + case ERROR_MODE: + setDisplayMode(ERROR_DISPLAY_MODE); + break; + } +} + static bool updateMAX11300 = false; static uint8_t portMode[20]; void setPortMode(uint8_t index, uint8_t mode){ @@ -62,9 +95,11 @@ void onResourceUpdate(void){ } } -void setup(){ +void onSetup(){ HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_SET); // LEDs off Pin enc_nrst(ENC_NRST_GPIO_Port, ENC_NRST_Pin); + + // Encoders_reset(); enc_nrst.outputMode(); enc_nrst.low(); @@ -74,8 +109,8 @@ void setup(){ // LEDs TLC5946_init(&TLC5946_SPI); - TLC5946_setAll_DC(0); // Start with 0 brightness here, update from settings later - TLC5946_setAll(0x10, 0x10, 0x10); + TLC5946_setAll_DC(0); // Start with low brightness here, update from settings later + TLC5946_setAll(0, 0, 0); HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_RESET); @@ -108,16 +143,15 @@ void setup(){ HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); + graphics.begin(¶ms, &OLED_SPI); #ifdef USE_USB_HOST // enable USB Host power HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - owl.setup(); - - // Update LEDs brighness from settings + // Update LEDs brightness from settings + // TLC5946_setRGB_DC(63, 19, 60); TLC5946_setAll_DC(settings.leds_brightness); TLC5946_Refresh_DC(); @@ -125,10 +159,24 @@ void setup(){ // allows us to program chip with SWD enc_nrst.inputMode(); enc_nrst.setPull(PIN_PULL_UP); + HAL_Delay(20); Encoders_readAll(); } -void loop(void){ +void onScreenDraw(){ +#ifdef USE_TLC5946 + for(int i=0; i<16; ++i){ + uint16_t val = params.getValue(i)>>2; + if(getPortMode(i) == PORT_UNI_INPUT) + setLed(i, dyn_rainbowinputs[val&0x3ff]); + else + setLed(i, dyn_rainbowoutputs[val&0x3ff]); + } + TLC5946_Refresh_GS(); +#endif +} + +void onLoop(){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ @@ -141,13 +189,6 @@ void loop(void){ } #endif -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ - - owl.loop(); - if(updateMAX11300){ MAX11300_setDeviceControl(DCR_DACCTL_ImmUpdate|DCR_DACREF_Int|DCR_ADCCTL_ContSweep /* |DCR_ADCCONV_200ksps|DCR_BRST_Contextual*/); for(int i=0; i<20; ++i){ @@ -165,35 +206,31 @@ void loop(void){ } updateMAX11300 = false; } -#ifdef USE_TLC5946 - TLC5946_Refresh_GS(); -#endif Encoders_readAll(); - graphics.params.updateEncoders(Encoders_get(), 7); + params.updateEncoders(Encoders_get(), 7); MAX11300_bulkreadADC(); for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = graphics.params.parameters[i]>>2; - setLed(i, dyn_rainbowinputs[val&0x3ff]); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ // DACs // TODO: store values set from patch somewhere and multiply with user[] value for outputs - // graphics.params.updateOutput(i, getOutputValue(i)); - // MAX11300_setDACValue(i+1, graphics.params.parameters[i]); - graphics.params.updateValue(i, 0); - uint16_t val = graphics.params.parameters[i]>>2; - setLed(i, dyn_rainbowoutputs[val&0x3ff]); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + // params.updateOutput(i, getOutputValue(i)); + // MAX11300_setDACValue(i+1, params.parameters[i]); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } for(int i=16; i<20; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ - graphics.params.updateValue(i, 0); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } + for(int i=20; i < NOF_PARAMETERS; i++) { + params.updateValue(i, 0); + } // MAX11300_bulkwriteDAC(); } diff --git a/Magus/Src/usbh_conf.c b/Magus/Src/usbh_conf.c index 3c105db3..1b95f814 100644 --- a/Magus/Src/usbh_conf.c +++ b/Magus/Src/usbh_conf.c @@ -48,7 +48,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -167,14 +166,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Magus3/Inc/FreeRTOSConfig.h b/Magus3/Inc/FreeRTOSConfig.h index 25e7cb9c..e4702a11 100644 --- a/Magus3/Inc/FreeRTOSConfig.h +++ b/Magus3/Inc/FreeRTOSConfig.h @@ -1,72 +1,31 @@ /* USER CODE BEGIN Header */ /* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.2.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* USER CODE END Header */ #ifndef FREERTOS_CONFIG_H @@ -85,7 +44,7 @@ *----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ - +/* Section where include file can be added */ #include "device.h" #ifdef DEBUG_STACK #define configUSE_TRACE_FACILITY 1 @@ -168,7 +127,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ /* USER CODE BEGIN 1 */ -#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} /* USER CODE END 1 */ /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index 5c89de1b..11e31232 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -3,19 +3,22 @@ #define OWL_MAGUS #define HARDWARE_ID MAGUS_HARDWARE -#define HARDWARE_VERSION "Magus" +#define HARDWARE_VERSION "Magus3" + +/* #define USE_SPI_FLASH */ -/* #define NO_EXTERNAL_RAM */ -/* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -/* #define USE_ICACHE */ -/* #define USE_DCACHE */ +#define USE_ICACHE +#define USE_DCACHE + +/* #define USE_BKPSRAM */ + +#define MAX_SYSEX_PROGRAM_SIZE (512*1024) #define USE_SCREEN #define SSD1309 /* #define OLED_DMA */ -#define OLED_SOFT_CS #define OLED_SPI hspi6 /* #define OLED_IT */ /* #define OLED_BITBANG */ @@ -32,12 +35,15 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define MAIN_LOOP_SLEEP_MS 20 +/* #define SCREEN_LOOP_SLEEP_MS 20 /\* 40mS = 25 fps *\/ */ +/* #define MAIN_LOOP_SLEEP_MS 5 /\* 2mS = 500 Hz *\/ */ #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ #define USE_USBD_AUDIO -/* #define USE_USBD_AUDIO_TX // microphone */ -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS @@ -51,7 +57,7 @@ /* #define UART_MIDI_RX_BUFFER_SIZE 256 */ #define USE_TLC5946 -#define LEDS_BRIGTHNESS 20 +#define LEDS_BRIGTHNESS 2 #define TLC5946_SPI hspi6 #define MAX11300_SPI hspi5 #define ENCODERS_SPI hspi5 diff --git a/Magus3/Inc/main.h b/Magus3/Inc/main.h index 518785df..a97c6ed8 100644 --- a/Magus3/Inc/main.h +++ b/Magus3/Inc/main.h @@ -132,8 +132,8 @@ void Error_Handler(void); #define FLASH_HOLD_GPIO_Port GPIOC #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC -#define FLASH_nWP_Pin GPIO_PIN_0 -#define FLASH_nWP_GPIO_Port GPIOB +#define FLASH_WP_Pin GPIO_PIN_0 +#define FLASH_WP_GPIO_Port GPIOB #define TLC_GSCLK_Pin GPIO_PIN_1 #define TLC_GSCLK_GPIO_Port GPIOB #define ENC_CHGRDY_Pin GPIO_PIN_2 diff --git a/Magus3/Inc/stm32h7xx_hal_conf.h b/Magus3/Inc/stm32h7xx_hal_conf.h index 6378c585..a16c3613 100644 --- a/Magus3/Inc/stm32h7xx_hal_conf.h +++ b/Magus3/Inc/stm32h7xx_hal_conf.h @@ -65,6 +65,7 @@ /* #define HAL_LPTIM_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_RAMECC_MODULE_ENABLED */ /* #define HAL_RNG_MODULE_ENABLED */ /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SAI_MODULE_ENABLED diff --git a/Magus3/Magus3.ioc b/Magus3/Magus3.ioc index 7db39f0f..adfbc33c 100644 --- a/Magus3/Magus3.ioc +++ b/Magus3/Magus3.ioc @@ -1,842 +1,848 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label -PA15\ (JTDI).GPIOParameters=GPIO_Speed,GPIO_Label -SH.FMC_D0_DA0.ConfNb=1 Bdma.Request0=SPI6_TX -USART2.IPParameters=VirtualMode,BaudRate,Mode,VirtualMode-Asynchronous -SH.FMC_A8.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SH.FMC_A0.ConfNb=1 -PC10.GPIO_PuPd=GPIO_PULLUP -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -Dma.USART2_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PG8.Signal=FMC_SDCLK -Dma.SPI5_TX.2.MemInc=DMA_MINC_ENABLE -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -RCC.RTCFreq_Value=32000 -PA15\ (JTDI).Signal=S_TIM2_CH1 -RCC.CpuClockFreq_Value=480000000 -SH.FMC_SDNWE.ConfNb=1 -PG14.GPIOParameters=GPIO_Label -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_Label -Dma.SPI5_TX.2.EventEnable=DISABLE -PA2.GPIOParameters=GPIO_Speed,GPIO_Label -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=120000000 -USB_DEVICE.PID_AUDIO_FS=0xDADA -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Dma.SPI5_TX.2.Direction=DMA_MEMORY_TO_PERIPH -PF7.Signal=SPI5_SCK -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -RCC.I2C4Freq_Value=120000000 -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=FMC_SDNE1 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC -SPI1.CalculateBaudRate=3.0 MBits/s -PD0.Signal=FMC_D2_DA2 -PD8.Signal=FMC_D13_DA13 -Bdma.SPI6_TX.0.RequestNumber=1 -PE1.Signal=FMC_NBL1 +Bdma.RequestsNb=1 +Bdma.SPI6_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Bdma.SPI6_TX.0.EventEnable=DISABLE +Bdma.SPI6_TX.0.Instance=BDMA_Channel0 +Bdma.SPI6_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Bdma.SPI6_TX.0.MemInc=DMA_MINC_ENABLE +Bdma.SPI6_TX.0.Mode=DMA_NORMAL +Bdma.SPI6_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Bdma.SPI6_TX.0.PeriphInc=DMA_PINC_DISABLE Bdma.SPI6_TX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.USART3Freq_Value=54000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PA0.Locked=true -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS -PG14.Mode=TX_Only_Simplex_Unidirect_Master -FMC.SelfRefreshTime1=4 -SPI6.NSSPMode=SPI_NSS_PULSE_DISABLE -ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -ProjectManager.BackupPrevious=false -RCC.FMCFreq_Value=240000000 -PC4.GPIO_Label=FLASH_HOLD -RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL2 -PB1.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PE9.Signal=FMC_D6_DA6 -Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Host_FS -PB1.GPIO_Label=TLC_GSCLK -RCC.USART16Freq_Value=120000000 -SPI1.DataSize=SPI_DATASIZE_8BIT -PE4.GPIO_Label=CS_LRCK -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS +Bdma.SPI6_TX.0.Priority=DMA_PRIORITY_LOW +Bdma.SPI6_TX.0.RequestNumber=1 +Bdma.SPI6_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Bdma.SPI6_TX.0.SignalID=NONE Bdma.SPI6_TX.0.SyncEnable=DISABLE -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -USB_OTG_HS.IPParameters=VirtualMode-Host_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -ProjectManager.HalAssertFull=true -RCC.DIVP2Freq_Value=30000000 -PA0.Signal=GPIO_Output -Mcu.Package=LQFP144 -TIM2.Prescaler=4095 -PB1.Signal=S_TIM3_CH4 -PA5.Locked=true -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 +Bdma.SPI6_TX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Bdma.SPI6_TX.0.SyncRequestNumber=1 +Bdma.SPI6_TX.0.SyncSignalID=NONE +Dma.Request0=SAI1_A +Dma.Request1=SAI1_B +Dma.Request2=SPI5_TX +Dma.Request3=USART2_TX +Dma.Request4=USART2_RX +Dma.RequestsNb=5 +Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.0.EventEnable=DISABLE +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.0.Instance=DMA2_Stream1 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.0.RequestNumber=1 +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_A.0.SignalID=NONE +Dma.SAI1_A.0.SyncEnable=DISABLE +Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_A.0.SyncRequestNumber=1 Dma.SAI1_A.0.SyncSignalID=NONE -SPI5.CalculateBaudRate=1.875 MBits/s -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -RCC.APB1TimFreq_Value=84000000 -RCC.LPUART1Freq_Value=120000000 -FMC.RowCycleDelay2=6 -FMC.RowCycleDelay1=6 -USB_OTG_FS.IPParameters=VirtualMode -PB13.Mode=Activate_VBUS_FS -Dma.USART2_TX.3.SyncSignalID=NONE -NVIC.DMA1_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -PA4.GPIO_Label=OLED_CS -PD15.Signal=FMC_D1_DA1 -RCC.PLLSAIQCLKFreq_Value=50000000 -RCC.VCO3OutputFreq_Value=100781250 -SH.FMC_D3_DA3.ConfNb=1 -Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PA6.GPIOParameters=GPIO_Label -USB_DEVICE.VID-AUDIO_FS=0x1209 -PD6.GPIOParameters=GPIO_Label -Mcu.Pin80=PE1 -Mcu.Pin81=VP_FREERTOS_VS_CMSIS_V1 -SH.FMC_A4.0=FMC_A4,12b-sda1 -ProjectManager.ProjectFileName=Magus3.ioc -SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PE0 -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=87 -PC11.Locked=true -Mcu.Pin73=PG13 -Mcu.Pin74=PG14 +Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.1.EventEnable=DISABLE +Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.1.Instance=DMA2_Stream4 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE -Mcu.Pin71=PG9 -Mcu.Pin72=PG11 -Mcu.Pin77=PB5 -PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PB6 -Mcu.Pin75=PG15 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=PB3 (JTDO/TRACESWO) -FREERTOS.INCLUDE_vTaskDelayUntil=1 -Mcu.Pin70=PD6 -RCC.VCOSAIOutputFreq_ValueQ=25000000 -Mcu.Pin68=PD0 -Mcu.Pin69=PD1 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PA12 -Mcu.Pin63=PA13 (JTMS/SWDIO) -Mcu.Pin60=PC8 -USART2.BaudRate=31250 -Mcu.Pin61=PA11 -Mcu.Pin66=PC10 -RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 -Mcu.Pin67=PC11 -Mcu.Pin64=PA14 (JTCK/SWCLK) -Mcu.Pin65=PA15 (JTDI) -PF8.GPIO_Label=SPI_A_MISO -USB_HOST0.BSP.semaphore= -PD10.Signal=FMC_D15_DA15 -RCC.D1CPREFreq_Value=480000000 -PA3.Mode=Asynchronous -RCC.Tim1OutputFreq_Value=240000000 -Mcu.Pin59=PC6 -Mcu.Pin57=PG5 -SH.GPXTI2.ConfNb=1 -Mcu.Pin58=PG8 -Mcu.Pin51=PD8 -RCC.USART6Freq_Value=108000000 -Mcu.Pin52=PD9 -Mcu.Pin50=PB15 -Mcu.Pin55=PD15 -Mcu.Pin56=PG4 -Mcu.Pin53=PD10 -Mcu.Pin54=PD14 -PB11.GPIOParameters=GPIO_Label -NVIC.DMA2_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.Pin48=PB13 -SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin49=PB14 -Mcu.Pin46=PB10 -Mcu.Pin47=PB11 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC -PB14.Signal=USB_OTG_HS_DM -Mcu.Pin40=PE10 -PA5.Signal=GPIO_Output -Mcu.Pin41=PE11 -Mcu.Pin44=PE14 -Mcu.Pin45=PE15 -Mcu.Pin42=PE12 -Mcu.Pin43=PE13 -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 -FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -RCC.AHB12Freq_Value=240000000 -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PE7 -Mcu.Pin38=PE8 -Mcu.Pin35=PG0 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PG1 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE9 +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.1.RequestNumber=1 +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_B.1.SignalID=NONE +Dma.SAI1_B.1.SyncEnable=DISABLE +Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_B.1.SyncRequestNumber=1 +Dma.SAI1_B.1.SyncSignalID=NONE +Dma.SPI5_TX.2.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI5_TX.2.EventEnable=DISABLE +Dma.SPI5_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI5_TX.2.Instance=DMA2_Stream6 +Dma.SPI5_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.SPI5_TX.2.MemInc=DMA_MINC_ENABLE +Dma.SPI5_TX.2.Mode=DMA_NORMAL +Dma.SPI5_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.SPI5_TX.2.PeriphInc=DMA_PINC_DISABLE +Dma.SPI5_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SPI5_TX.2.Priority=DMA_PRIORITY_LOW +Dma.SPI5_TX.2.RequestNumber=1 +Dma.SPI5_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SPI5_TX.2.SignalID=NONE +Dma.SPI5_TX.2.SyncEnable=DISABLE +Dma.SPI5_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SPI5_TX.2.SyncRequestNumber=1 +Dma.SPI5_TX.2.SyncSignalID=NONE +Dma.USART2_RX.4.Direction=DMA_PERIPH_TO_MEMORY +Dma.USART2_RX.4.EventEnable=DISABLE +Dma.USART2_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART2_RX.4.Instance=DMA1_Stream5 +Dma.USART2_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART2_RX.4.MemInc=DMA_MINC_ENABLE +Dma.USART2_RX.4.Mode=DMA_NORMAL +Dma.USART2_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_RX.4.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_RX.4.Priority=DMA_PRIORITY_LOW +Dma.USART2_RX.4.RequestNumber=1 +Dma.USART2_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.USART2_RX.4.SignalID=NONE +Dma.USART2_RX.4.SyncEnable=DISABLE +Dma.USART2_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.USART2_RX.4.SyncRequestNumber=1 +Dma.USART2_RX.4.SyncSignalID=NONE +Dma.USART2_TX.3.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART2_TX.3.EventEnable=DISABLE +Dma.USART2_TX.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART2_TX.3.Instance=DMA1_Stream6 +Dma.USART2_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART2_TX.3.MemInc=DMA_MINC_ENABLE Dma.USART2_TX.3.Mode=DMA_NORMAL -Mcu.Pin30=PF11 -PA1.GPIO_Label=OLED_RST -Mcu.Pin33=PF14 -Mcu.Pin34=PF15 -Mcu.Pin31=PF12 -Mcu.Pin32=PF13 -Dma.SAI1_A.0.SyncRequestNumber=1 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -PC10.GPIOParameters=GPIO_PuPd,GPIO_Label -TIM2.Period=200 -PF9.GPIOParameters=GPIO_Label -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PC5 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin27=PB0 -SPI1.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin24=PA7 -Mcu.Pin25=PC4 -Mcu.Pin28=PB1 -Mcu.Pin29=PB2 -PC8.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin22=PA5 -Mcu.Pin23=PA6 -Mcu.Pin20=PA3 -Mcu.Pin21=PA4 -PA5.GPIO_Label=PIXI_nCS -NVIC.ForceEnableDMAVector=true -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK +Dma.USART2_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_TX.3.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_TX.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_TX.3.Priority=DMA_PRIORITY_LOW +Dma.USART2_TX.3.RequestNumber=1 +Dma.USART2_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber Dma.USART2_TX.3.SignalID=NONE -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PH1-OSC_OUT (PH1) -PA0.GPIOParameters=GPIO_Label -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PC0 -Mcu.Pin13=PF9 -Mcu.Pin14=PH0-OSC_IN (PH0) -Mcu.Pin19=PA2 -Mcu.Pin17=PA0 -Mcu.Pin18=PA1 -SPI6.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 -SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF7 -Mcu.Pin12=PF8 -Mcu.Pin10=PF5 -PE3.Signal=SAI1_SD_B -PF4.Signal=FMC_A4 -Bdma.SPI6_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART2_TX.3.SyncEnable=DISABLE +Dma.USART2_TX.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT Dma.USART2_TX.3.SyncRequestNumber=1 -Mcu.Family=STM32H7 +Dma.USART2_TX.3.SyncSignalID=NONE +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -PA6.Mode=Full_Duplex_Master -USB_DEVICE.CLASS_NAME_FS=AUDIO -NVIC.SPI6_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -SH.FMC_A8.0=FMC_A8,12b-sda1 -PG9.GPIOParameters=GPIO_Label -ProjectManager.KeepUserCode=true -Dma.SPI5_TX.2.SyncSignalID=NONE -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN -PC5.Locked=true -PA0.GPIO_Label=OLED_DC -SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL -PA11.Mode=Device_Only -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -RCC.VCO2OutputFreq_Value=150000000 -SH.FMC_A11.0=FMC_A11,12b-sda1 -PB15.Signal=USB_OTG_HS_DP -Bdma.SPI6_TX.0.SyncSignalID=NONE -PG11.Signal=GPIO_Output -PG15.Signal=FMC_SDNCAS -SH.GPXTI2.0=GPIO_EXTI2 -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -Mcu.IP4=FMC -Mcu.IP5=FREERTOS -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DEBUG -Mcu.IP3=DMA -NVIC.BDMA_Channel0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.IP0=BDMA -Mcu.IP1=CORTEX_M7 -PE4.GPIOParameters=GPIO_Label -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -RCC.DIVP3Freq_Value=50390625 -RCC.SDMMCFreq_Value=48000000 -ProjectManager.PreviousToolchain= -TIM3.Period=100 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -TIM2.ClockDivision=TIM_CLOCKDIVISION_DIV2 -Dma.SPI5_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction,DataSize,NSSPMode +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_MUTEXES,FootprintOK,INCLUDE_vTaskDelayUntil -USB_HOST0.BSP.ip=GPIO -Dma.SAI1_B.1.Instance=DMA2_Stream4 -Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 FREERTOS.configUSE_PREEMPTION=0 -RCC.HRTIMFreq_Value=240000000 -PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator -RCC.DIVR3Freq_Value=50390625 -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 -Dma.USART2_TX.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -FMC.ExitSelfRefreshDelay1=6 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32H7 +Mcu.IP0=BDMA +Mcu.IP1=CORTEX_M7 Mcu.IP10=SPI4 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=SPI6 Mcu.IP11=SPI5 -Bdma.SPI6_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Mcu.IP18=USB_HOST -Bdma.SPI6_TX.0.MemInc=DMA_MINC_ENABLE -Mcu.IP17=USB_DEVICE -Mcu.IP19=USB_OTG_FS -RCC.DIVP1Freq_Value=480000000 -Mcu.IP14=TIM2 -PF9.Mode=Full_Duplex_Master +Mcu.IP12=SPI6 Mcu.IP13=SYS -Mcu.IP16=USART2 +Mcu.IP14=TIM2 Mcu.IP15=TIM3 -RCC.VCOInputFreq_Value=1000000 -Dma.SPI5_TX.2.SyncRequestNumber=1 -PF11.Signal=FMC_SDNRAS -PC11.GPIO_Label=TLC_XLAT -PB5.Mode=SdramChipSelect2_1 -PE3.GPIOParameters=GPIO_Label -Dma.USART2_RX.4.SyncSignalID=NONE +Mcu.IP16=USART2 +Mcu.IP17=USB_DEVICE +Mcu.IP18=USB_HOST +Mcu.IP19=USB_OTG_FS +Mcu.IP2=DEBUG Mcu.IP20=USB_OTG_HS -TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -PB0.Locked=true -Dma.USART2_RX.4.Priority=DMA_PRIORITY_LOW -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-MAGUS -PA6.Signal=SPI1_MISO -PG11.Locked=true -Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -ProjectManager.ToolChainLocation= -Dma.USART2_RX.4.MemInc=DMA_MINC_ENABLE -Bdma.SPI6_TX.0.Mode=DMA_NORMAL -PF8.Signal=SPI5_MISO -RCC.DIVR1Freq_Value=480000000 -USB_HOST0.BSP.name=Drive_VBUS_HS -Dma.Request2=SPI5_TX -Dma.Request1=SAI1_B -Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE -Dma.Request4=USART2_RX -Bdma.SPI6_TX.0.SignalID=NONE -Dma.Request3=USART2_TX -PG11.GPIO_Label=TLC_MODE -PC5.Signal=GPIO_Output -PE7.Signal=FMC_D4_DA4 -PD6.Signal=SAI1_SD_A -Dma.Request0=SAI1_A -Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH -PE2.GPIO_Label=CS_SCK -Mcu.Pin84=VP_SYS_VS_Systick -Mcu.Pin85=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.IP3=DMA +Mcu.IP4=FMC +Mcu.IP5=FREERTOS +Mcu.IP6=NVIC +Mcu.IP7=RCC +Mcu.IP8=SAI1 +Mcu.IP9=SPI1 +Mcu.IPNb=21 +Mcu.Name=STM32H743ZGTx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF5 +Mcu.Pin11=PF7 +Mcu.Pin12=PF8 +Mcu.Pin13=PF9 +Mcu.Pin14=PH0-OSC_IN (PH0) +Mcu.Pin15=PH1-OSC_OUT (PH1) +Mcu.Pin16=PC0 +Mcu.Pin17=PA0 +Mcu.Pin18=PA1 +Mcu.Pin19=PA2 +Mcu.Pin2=PE4 +Mcu.Pin20=PA3 +Mcu.Pin21=PA4 +Mcu.Pin22=PA5 +Mcu.Pin23=PA6 +Mcu.Pin24=PA7 +Mcu.Pin25=PC4 +Mcu.Pin26=PC5 +Mcu.Pin27=PB0 +Mcu.Pin28=PB1 +Mcu.Pin29=PB2 +Mcu.Pin3=PE5 +Mcu.Pin30=PF11 +Mcu.Pin31=PF12 +Mcu.Pin32=PF13 +Mcu.Pin33=PF14 +Mcu.Pin34=PF15 +Mcu.Pin35=PG0 +Mcu.Pin36=PG1 +Mcu.Pin37=PE7 +Mcu.Pin38=PE8 +Mcu.Pin39=PE9 +Mcu.Pin4=PE6 +Mcu.Pin40=PE10 +Mcu.Pin41=PE11 +Mcu.Pin42=PE12 +Mcu.Pin43=PE13 +Mcu.Pin44=PE14 +Mcu.Pin45=PE15 +Mcu.Pin46=PB10 +Mcu.Pin47=PB11 +Mcu.Pin48=PB13 +Mcu.Pin49=PB14 +Mcu.Pin5=PF0 +Mcu.Pin50=PB15 +Mcu.Pin51=PD8 +Mcu.Pin52=PD9 +Mcu.Pin53=PD10 +Mcu.Pin54=PD14 +Mcu.Pin55=PD15 +Mcu.Pin56=PG4 +Mcu.Pin57=PG5 +Mcu.Pin58=PG8 +Mcu.Pin59=PC6 +Mcu.Pin6=PF1 +Mcu.Pin60=PC8 +Mcu.Pin61=PA11 +Mcu.Pin62=PA12 +Mcu.Pin63=PA13 (JTMS/SWDIO) +Mcu.Pin64=PA14 (JTCK/SWCLK) +Mcu.Pin65=PA15 (JTDI) +Mcu.Pin66=PC10 +Mcu.Pin67=PC11 +Mcu.Pin68=PD0 +Mcu.Pin69=PD1 +Mcu.Pin7=PF2 +Mcu.Pin70=PD6 +Mcu.Pin71=PG9 +Mcu.Pin72=PG11 +Mcu.Pin73=PG13 +Mcu.Pin74=PG14 +Mcu.Pin75=PG15 +Mcu.Pin76=PB3 (JTDO/TRACESWO) +Mcu.Pin77=PB5 +Mcu.Pin78=PB6 +Mcu.Pin79=PE0 +Mcu.Pin8=PF3 +Mcu.Pin80=PE1 +Mcu.Pin81=VP_FREERTOS_VS_CMSIS_V1 Mcu.Pin82=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC Mcu.Pin83=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC -PA3.Signal=USART2_RX -PH1-OSC_OUT\ (PH1).GPIO_Label=OSC2 +Mcu.Pin84=VP_SYS_VS_Systick +Mcu.Pin85=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin86=VP_USB_HOST_VS_USB_HOST_AUDIO_HS -SH.FMC_A3.ConfNb=1 -PB3\ (JTDO/TRACESWO).GPIO_Label=FLASH_SCK -Dma.USART2_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE -RCC.I2SFreq_Value=96000000 -USB_HOST.IPParameters=VirtualModeHS,USBH_HandleTypeDef-AUDIO_HS,USBH_MAX_NUM_ENDPOINTS-AUDIO_HS,USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS -SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 -Dma.SAI1_B.1.Mode=DMA_CIRCULAR -RCC.UART7Freq_Value=54000000 -Dma.USART2_TX.3.Instance=DMA1_Stream6 -SPI4.DataSize=SPI_DATASIZE_8BIT -Dma.SAI1_B.1.RequestNumber=1 +Mcu.Pin9=PF4 +Mcu.PinsNb=87 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32H743ZGTx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BDMA_Channel0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SPI5_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.SPI6_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true NVIC.SavedSvcallIrqHandlerGenerated=true -Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH -PC11.Signal=GPIO_Output -Dma.SAI1_A.0.SignalID=NONE -PC8.Signal=GPIO_Input -USB_HOST0.BSP.solution=PC6 -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -ProjectManager.DeletePrevious=true -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS,SERIALNUMBER_STRING_AUDIO_FS -SPI5.Mode=SPI_MODE_MASTER -RCC.FamilyName=M -PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT -Dma.SPI5_TX.2.PeriphInc=DMA_PINC_DISABLE -Dma.USART2_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SH.FMC_A15_BA1.ConfNb=1 -PH1-OSC_OUT\ (PH1).GPIOParameters=GPIO_Label -PB10.GPIO_Label=CS_CS -Dma.SAI1_A.0.Mode=DMA_CIRCULAR -RCC.VCO1OutputFreq_Value=960000000 -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT -PC5.GPIOParameters=GPIO_Label -RCC.AXIClockFreq_Value=240000000 -PE2.GPIOParameters=GPIO_Label -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=SPI_A_MOSI -Dma.SAI1_B.1.SyncEnable=DISABLE +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0.GPIOParameters=GPIO_Label +PA0.GPIO_Label=OLED_DC +PA0.Locked=true +PA0.Signal=GPIO_Output +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=OLED_RST +PA1.Locked=true PA1.Signal=GPIO_Output -RCC.CKPERFreq_Value=16000000 -Dma.USART2_RX.4.PeriphInc=DMA_PINC_DISABLE -RCC.VCOI2SOutputFreq_Value=192000000 -Dma.USART2_TX.3.FIFOMode=DMA_FIFOMODE_DISABLE -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Magus -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Host_FS -RCC.UART4Freq_Value=54000000 -Dma.SPI5_TX.2.SignalID=NONE -MxCube.Version=6.2.0 -RCC.FDCANFreq_Value=48000000 -PE5.Mode=SAI_A_AsyncSlave -RCC.ADCFreq_Value=30000000 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF1.Signal=FMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13\ (JTMS/SWDIO).Mode=Serial_Wire +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +PA14\ (JTCK/SWCLK).Mode=Serial_Wire +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PA15\ (JTDI).GPIOParameters=GPIO_Speed,GPIO_Label PA15\ (JTDI).GPIO_Label=TLC_BLANK -RCC.IPParameters=48MHZClocksFreq_Value,ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,PWR_Regulator_Voltage_Scale,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 -Dma.SAI1_B.1.SyncSignalID=NONE -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -PB2.Locked=true -Mcu.IP8=SAI1 -Mcu.IP9=SPI1 -Mcu.IP6=NVIC -Mcu.IP7=RCC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -RCC.SYSCLKFreq_VALUE=480000000 -RCC.I2C123Freq_Value=120000000 -PA1.Locked=true -KeepUserPlacement=false -USB_HOST.USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS=256 -PB2.GPIO_Label=ENC_CHGRDY -PC6.GPIOParameters=PinState,GPIO_Label -RCC.HSI_VALUE=16000000 -RCC.PLLQ=7 -SH.S_TIM3_CH4.ConfNb=1 -PH0-OSC_IN\ (PH0).GPIO_Label=OSC1 -RCC.PLLM=25 -RCC.PLLN=336 +PA15\ (JTDI).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA15\ (JTDI).Signal=S_TIM2_CH1 +PA2.GPIOParameters=GPIO_Speed,GPIO_Label +PA2.GPIO_Label=UART_MOSI +PA2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PA2.Locked=true PA2.Mode=Asynchronous -PC8.Locked=true -Dma.SPI5_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.FMC_D8_DA8.ConfNb=1 -SPI5.NSSPMode=SPI_NSS_PULSE_DISABLE -Dma.SAI1_A.0.SyncEnable=DISABLE -PG11.GPIOParameters=GPIO_Label +PA2.Signal=USART2_TX +PA3.GPIOParameters=GPIO_Speed,GPIO_Label PA3.GPIO_Label=UART_MISO -PH0-OSC_IN\ (PH0).GPIOParameters=GPIO_Label -USB_HOST0.BSP.instance=PC6 -SPI6.Mode=SPI_MODE_MASTER -USB_OTG_HS.VirtualMode-Host_FS=Host_FS -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -RCC.USART1Freq_Value=108000000 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -Dma.SPI5_TX.2.SyncEnable=DISABLE -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -USB_HOST.USBH_MAX_NUM_ENDPOINTS-AUDIO_HS=10 -FMC.RCDDelay1=2 -SPI1.VirtualType=VM_MASTER -Dma.USART2_TX.3.MemInc=DMA_MINC_ENABLE -PG4.Signal=FMC_A14_BA0 -RCC.PLLCLKFreq_Value=168000000 -SPI5.DataSize=SPI_DATASIZE_8BIT -FMC.LoadToActiveDelay1=2 -USB_HOST0.BSP.condition= +PA3.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA4.GPIOParameters=GPIO_Label +PA4.GPIO_Label=OLED_CS +PA4.Locked=true +PA4.Signal=GPIO_Output +PA5.GPIOParameters=GPIO_Label +PA5.GPIO_Label=PIXI_nCS +PA5.Locked=true +PA5.Signal=GPIO_Output +PA6.GPIOParameters=GPIO_Speed,GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Speed,GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB1.GPIOParameters=GPIO_Speed,GPIO_Label +PB1.GPIO_Label=TLC_GSCLK +PB1.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB1.Locked=true +PB1.Signal=S_TIM3_CH4 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_CS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_RST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB13.Mode=Activate_VBUS_FS +PB13.Signal=USB_OTG_HS_VBUS +PB14.Mode=Host_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Host_FS +PB15.Signal=USB_OTG_HS_DP +PB2.GPIOParameters=GPIO_Label +PB2.GPIO_Label=ENC_CHGRDY +PB2.Locked=true +PB2.Signal=GPXTI2 +PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_Speed,GPIO_Label +PB3\ (JTDO/TRACESWO).GPIO_Label=FLASH_SCK +PB3\ (JTDO/TRACESWO).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB3\ (JTDO/TRACESWO).Locked=true +PB3\ (JTDO/TRACESWO).Mode=Full_Duplex_Master +PB3\ (JTDO/TRACESWO).Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PC0.Signal=FMC_SDNWE +PC10.GPIOParameters=GPIO_PuPd,GPIO_Label +PC10.GPIO_Label=ENC_NRST +PC10.GPIO_PuPd=GPIO_PULLUP +PC10.Locked=true +PC10.Signal=GPIO_Output +PC11.GPIOParameters=GPIO_Label +PC11.GPIO_Label=TLC_XLAT +PC11.Locked=true +PC11.Signal=GPIO_Output +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PC6.GPIOParameters=PinState,GPIO_Label PC6.GPIO_Label=USB_HOST_PWR_EN -PA3.GPIOParameters=GPIO_Speed,GPIO_Label -PA6.GPIO_Label=FLASH_MISO -Dma.USART2_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PA3.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -PB13.Signal=USB_OTG_HS_VBUS +PC6.Locked=true +PC6.PinState=GPIO_PIN_SET +PC6.Signal=GPIO_Output +PC8.GPIOParameters=GPIO_PuPd,GPIO_Label +PC8.GPIO_Label=USB_HOST_PWR_FAULT +PC8.GPIO_PuPd=GPIO_PULLUP +PC8.Locked=true +PC8.Signal=GPIO_Input +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD6.GPIOParameters=GPIO_Label PD6.GPIO_Label=CS_SDIN -PG13.Signal=SPI6_SCK -Dma.USART2_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PinOutPanel.RotationAngle=0 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -PE6.GPIO_Label=CS_MOSI -RCC.MCO1PinFreq_Value=16000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -Dma.USART2_TX.3.EventEnable=DISABLE -RCC.AHB4Freq_Value=240000000 -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK PE2.Mode=TX_Only_Simplex_Unidirect_Master -TIM2.IPParameters=Channel-PWM Generation1 CH1,Prescaler,ClockDivision,Period,Pulse-PWM Generation1 CH1 -SH.FMC_D10_DA10.ConfNb=1 -USB_HOST0.BSP.component= -RCC.DIVQ3Freq_Value=50390625 -PB6.Mode=SdramChipSelect2_1 -RCC.SAI2Freq_Value=50000000 -PE5.Signal=SAI1_SCK_A -Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PB2.Signal=GPXTI2 -PA4.Locked=true -RCC.DIVM2=2 -Bdma.SPI6_TX.0.PeriphInc=DMA_PINC_DISABLE -RCC.DIVM1=5 -MxDb.Version=DB.6.0.20 -PB0.GPIOParameters=GPIO_Label -PA1.GPIOParameters=GPIO_Label -SH.FMC_D15_DA15.ConfNb=1 -Dma.USART2_RX.4.EventEnable=DISABLE PE2.Signal=SPI4_SCK -PF8.Mode=Full_Duplex_Master -PA14\ (JTCK/SWCLK).Mode=Serial_Wire -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_MOSI +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 PF3.Signal=FMC_A3 -RCC.DIVR2Freq_Value=75000000 -PE10.Signal=FMC_D7_DA7 -Dma.USART2_TX.3.SyncEnable=DISABLE -RCC.MCO2PinFreq_Value=480000000 -PC8.GPIOParameters=GPIO_PuPd,GPIO_Label -PF8.GPIOParameters=GPIO_Label +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_Speed,GPIO_Label +PF7.GPIO_Label=SPI_A_SCK +PF7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK +PF8.GPIOParameters=GPIO_Speed,GPIO_Label +PF8.GPIO_Label=SPI_A_MISO +PF8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Speed,GPIO_Label +PF9.GPIO_Label=SPI_A_MOSI +PF9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG11.GPIOParameters=GPIO_Label +PG11.GPIO_Label=TLC_MODE +PG11.Locked=true +PG11.Signal=GPIO_Output PG13.GPIOParameters=GPIO_Label -RCC.DFSDMFreq_Value=120000000 -PA5.GPIOParameters=GPIO_Label -SH.FMC_A1.0=FMC_A1,12b-sda1 -Bdma.SPI6_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.TraceFreq_Value=480000000 -RCC.APB4Freq_Value=120000000 -RCC.CECFreq_Value=32000 -RCC.SAI23Freq_Value=48000000 -PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Dma.SPI5_TX.2.RequestNumber=1 -PB10.GPIOParameters=GPIO_Label -PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -SPI5.VirtualType=VM_MASTER -ProjectManager.CustomerFirmwarePackage= -PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -Dma.SAI1_B.1.EventEnable=DISABLE -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -SH.FMC_A1.ConfNb=1 -RCC.DIVQ1=20 -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC +PG13.GPIO_Label=SPI_B_CLK +PG13.Mode=TX_Only_Simplex_Unidirect_Master +PG13.Signal=SPI6_SCK +PG14.GPIOParameters=GPIO_Label +PG14.GPIO_Label=SPI_B_MOSI +PG14.Mode=TX_Only_Simplex_Unidirect_Master +PG14.Signal=SPI6_MOSI +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_Label +PG9.GPIO_Label=ENC_nCS PG9.Locked=true PG9.Signal=GPIO_Output -RCC.SWPMI1Freq_Value=120000000 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -PC6.Signal=GPIO_Output -PB11.GPIO_Label=CS_RST -PD1.Signal=FMC_D3_DA3 -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC -RCC.DIVP2=5 -Dma.USART2_TX.3.PeriphInc=DMA_PINC_DISABLE -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -Dma.USART2_RX.4.RequestNumber=1 +PH0-OSC_IN\ (PH0).GPIOParameters=GPIO_Label +PH0-OSC_IN\ (PH0).GPIO_Label=OSC1 +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PH1-OSC_OUT\ (PH1).GPIOParameters=GPIO_Label +PH1-OSC_OUT\ (PH1).GPIO_Label=OSC2 +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32H743ZGTx +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Magus3.ioc +ProjectManager.ProjectName=Magus3 +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_BDMA_Init-BDMA-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI5_Init-SPI5-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_USART2_UART_Init-USART2-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_USB_HOST_Init-USB_HOST-false-HAL-false,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM2_Init-TIM2-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.ADCFreq_Value=30000000 +RCC.AHB12Freq_Value=240000000 +RCC.AHB4Freq_Value=240000000 +RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 -PC11.GPIOParameters=GPIO_Label -RCC.QSPIFreq_Value=240000000 -PG13.GPIO_Label=SPI_B_CLK -USB_HOST0.BSP.STBoard=false -SH.FMC_A3.0=FMC_A3,12b-sda1 -RCC.USART234578Freq_Value=120000000 -Bdma.SPI6_TX.0.Instance=BDMA_Channel0 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -SPI6.CalculateBaudRate=7.5 MBits/s -RCC.SPI123Freq_Value=48000000 -Dma.SAI1_A.0.RequestNumber=1 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -USB_HOST.VirtualModeHS=Audio -PC6.Locked=true -RCC.DIVN2=12 +RCC.APB1Freq_Value=120000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=120000000 +RCC.APB2TimFreq_Value=168000000 +RCC.APB3Freq_Value=120000000 +RCC.APB4Freq_Value=120000000 +RCC.AXIClockFreq_Value=240000000 +RCC.CECFreq_Value=32000 +RCC.CKPERFreq_Value=16000000 +RCC.CortexFreq_Value=480000000 +RCC.CpuClockFreq_Value=480000000 +RCC.D1CPREFreq_Value=480000000 +RCC.D1PPRE=RCC_APB3_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D3PPRE=RCC_APB4_DIV2 +RCC.DFSDMACLkFreq_Value=30000000 +RCC.DFSDMFreq_Value=120000000 +RCC.DIVM1=5 +RCC.DIVM2=2 RCC.DIVN1=192 -PB10.Signal=GPIO_Output -PC6.PinState=GPIO_PIN_SET -Bdma.SPI6_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -FREERTOS.MEMORY_ALLOCATION=2 -PA15\ (JTDI).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -ProjectManager.LastFirmware=true -Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE -PE15.Signal=FMC_D12_DA12 -PE8.Signal=FMC_D5_DA5 -RCC.RNGFreq_Value=48000000 +RCC.DIVN2=12 +RCC.DIVP1Freq_Value=480000000 +RCC.DIVP2=5 +RCC.DIVP2Freq_Value=30000000 +RCC.DIVP3Freq_Value=50390625 +RCC.DIVQ1=20 +RCC.DIVQ1Freq_Value=48000000 +RCC.DIVQ2Freq_Value=75000000 +RCC.DIVQ3Freq_Value=50390625 +RCC.DIVR1Freq_Value=480000000 +RCC.DIVR2Freq_Value=75000000 +RCC.DIVR3Freq_Value=50390625 RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Pulse-PWM Generation4 CH4,Period,OCFastMode_PWM-PWM Generation4 CH4,ClockDivision -Bdma.SPI6_TX.0.SyncRequestNumber=1 -PG14.GPIO_Label=SPI_B_MOSI -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -RCC.ProductRev=revV -ProjectManager.FreePins=true -RCC.LPTIM2Freq_Value=120000000 -SH.FMC_NBL1.ConfNb=1 -RCC.RTCHSEDivFreq_Value=12500000 -ProjectManager.UnderRoot=false -SH.FMC_D7_DA7.ConfNb=1 -Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PA4.Signal=GPIO_Output -Bdma.SPI6_TX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PB5.Signal=FMC_SDCKE1 -Dma.USART2_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -RCC.LPTIM345Freq_Value=120000000 -ProjectManager.ComputerToolchain=false -PF9.Signal=SPI5_MOSI -SAI1.InitProtocol-SAI_A_AsyncSlave=Enable -Dma.USART2_TX.3.Priority=DMA_PRIORITY_LOW -RCC.LTDCFreq_Value=50390625 -Dma.SPI5_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PB3\ (JTDO/TRACESWO).Mode=Full_Duplex_Master -Dma.USART2_RX.4.Mode=DMA_NORMAL -SH.FMC_D12_DA12.ConfNb=1 -Bdma.SPI6_TX.0.EventEnable=DISABLE +RCC.FCLKCortexFreq_Value=168000000 +RCC.FDCANFreq_Value=48000000 +RCC.FMCFreq_Value=240000000 +RCC.FamilyName=M RCC.HCLK3ClockFreq_Value=240000000 -RCC.I2C2Freq_Value=54000000 -SPI5.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode -PB0.Signal=GPIO_Output -Dma.SPI5_TX.2.Mode=DMA_NORMAL -Dma.USART2_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE -USB_HOST0.BSP.mode=Output -PA7.GPIOParameters=GPIO_Label -Dma.SAI1_A.0.Instance=DMA2_Stream1 -Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO -SPI6.VirtualType=VM_MASTER -Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -RCC.DIVQ2Freq_Value=75000000 -RCC.SAI1Freq_Value=30000000 -RCC.CortexFreq_Value=480000000 -SH.FMC_A2.ConfNb=1 -Mcu.UserName=STM32H743ZGTx +RCC.HCLKFreq_Value=240000000 RCC.HPRE=RCC_HCLK_DIV2 -Dma.USART2_TX.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING -PC10.Locked=true -PC10.Signal=GPIO_Output -SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_BDMA_Init-BDMA-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI5_Init-SPI5-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_USART2_UART_Init-USART2-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_USB_HOST_Init-USB_HOST-false-HAL-false,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM2_Init-TIM2-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true -PA2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PB0.GPIO_Label=FLASH_nWP -RCC.PLLI2SRCLKFreq_Value=96000000 -RCC.USART2Freq_Value=54000000 -Dma.USART2_TX.3.Direction=DMA_MEMORY_TO_PERIPH -Dma.USART2_RX.4.Instance=DMA1_Stream5 -PB11.Signal=GPIO_Output -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -RCC.SAI_BClocksFreq_Value=25000000 -RCC.VCOInput3Freq_Value=781250 +RCC.HRTIMFreq_Value=240000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C123Freq_Value=120000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 RCC.I2C3Freq_Value=54000000 -USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS -SH.FMC_A7.0=FMC_A7,12b-sda1 -PA12.Signal=USB_OTG_FS_DP -Mcu.UserConstants= -SPI4.Mode=SPI_MODE_MASTER -Mcu.ThirdPartyNb=0 -RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=21 +RCC.I2C4Freq_Value=120000000 RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,PWR_Regulator_Voltage_Scale,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=120000000 +RCC.LPTIM2Freq_Value=120000000 +RCC.LPTIM345Freq_Value=120000000 +RCC.LPUART1Freq_Value=120000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.LTDCFreq_Value=50390625 +RCC.MCO1PinFreq_Value=16000000 +RCC.MCO2PinFreq_Value=480000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 -Dma.USART2_RX.4.SignalID=NONE -Dma.USART2_TX.3.RequestNumber=1 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 +RCC.ProductRev=revV +RCC.QSPIFreq_Value=240000000 +RCC.RNGFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL2 +RCC.SAI1Freq_Value=30000000 +RCC.SAI23Freq_Value=48000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI4AFreq_Value=48000000 +RCC.SAI4BFreq_Value=48000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=48000000 RCC.SPDIFRXFreq_Value=48000000 -SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF1 -Mcu.Pin7=PF2 -Mcu.Pin8=PF3 -Mcu.Pin9=PF4 -Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +RCC.SPI123Freq_Value=48000000 +RCC.SPI45Freq_Value=120000000 +RCC.SPI6Freq_Value=120000000 +RCC.SWPMI1Freq_Value=120000000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.Tim1OutputFreq_Value=240000000 +RCC.Tim2OutputFreq_Value=240000000 +RCC.TraceFreq_Value=480000000 +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART16Freq_Value=120000000 +RCC.USART1Freq_Value=108000000 +RCC.USART234578Freq_Value=120000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCO1OutputFreq_Value=960000000 +RCC.VCO2OutputFreq_Value=150000000 +RCC.VCO3OutputFreq_Value=100781250 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInput1Freq_Value=5000000 +RCC.VCOInput2Freq_Value=12500000 +RCC.VCOInput3Freq_Value=781250 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,Synchro_A,Synchro_B,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,BasicDataSize-SAI_A_AsyncSlave,BasicDataSize-SAI_B_SyncSlave +SAI1.InitProtocol-SAI_A_AsyncSlave=Enable +SAI1.InitProtocol-SAI_B_SyncSlave=Enable +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL +SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -TIM3.ClockDivision=TIM_CLOCKDIVISION_DIV2 -Mcu.Pin4=PE6 -Mcu.Pin5=PF0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.RPDelay2=2 -USART2.VirtualMode-Asynchronous=VM_ASYNC -FMC.RPDelay1=2 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -Dma.SPI5_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE -PE13.Signal=FMC_D10_DA10 -Dma.USART2_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE -PF7.GPIO_Label=SPI_A_SCK -Dma.SPI5_TX.2.Priority=DMA_PRIORITY_LOW -File.Version=6 -Dma.USART2_RX.4.SyncRequestNumber=1 -Dma.SAI1_A.0.EventEnable=DISABLE -SH.FMC_D5_DA5.ConfNb=1 -SH.S_TIM2_CH1.ConfNb=1 SH.FMC_D2_DA2.ConfNb=1 -PG13.Mode=TX_Only_Simplex_Unidirect_Master -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -USB_HOST0.BSP.i2creg= -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=5 -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -ProjectManager.ProjectName=Magus3 -RCC.APB3Freq_Value=120000000 -USB_HOST0.BSP.i2caddr=0 -SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -RCC.D1PPRE=RCC_APB3_DIV2 -USART2.VirtualMode=VM_ASYNC -PA2.GPIO_Label=UART_MOSI -RCC.LSI_VALUE=32000 -Bdma.SPI6_TX.0.Priority=DMA_PRIORITY_LOW -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -Dma.SPI5_TX.2.Instance=DMA2_Stream6 -Dma.SAI1_B.1.SignalID=NONE -PC4.Locked=true -PF0.Signal=FMC_A0 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 +SH.S_TIM2_CH1.ConfNb=1 +SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 +SH.S_TIM3_CH4.ConfNb=1 SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 -PE3.Mode=SAI_B_SyncSlave -Dma.SPI5_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE -RCC.Tim2OutputFreq_Value=240000000 -RCC.DFSDMACLkFreq_Value=30000000 -PA2.Locked=true -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PA7.Mode=Full_Duplex_Master -PA13\ (JTMS/SWDIO).Mode=Serial_Wire -PC10.GPIO_Label=ENC_NRST -Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING -ProjectManager.NoMain=false +SPI1.CalculateBaudRate=3.0 MBits/s +SPI1.DataSize=SPI_DATASIZE_8BIT +SPI1.Direction=SPI_DIRECTION_2LINES SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,NSSPMode,BaudRatePrescaler -USB_DEVICE.VirtualModeFS=Audio_FS -PG1.Signal=FMC_A11 -RCC.SAI4BFreq_Value=48000000 -SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -USB_HOST.BSP.number=1 -RCC.D2PPRE2=RCC_APB2_DIV2 -RCC.D2PPRE1=RCC_APB1_DIV2 -Dma.SPI5_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE -NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.SPI5_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -TIM2.Pulse-PWM\ Generation1\ CH1=100 -RCC.SPI6Freq_Value=120000000 -PC8.GPIO_Label=USB_HOST_PWR_FAULT -PF7.Mode=Full_Duplex_Master -RCC.SPI45Freq_Value=120000000 -SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SPI1.Mode=SPI_MODE_MASTER +SPI1.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 +SPI4.CalculateBaudRate=3.75 MBits/s +SPI4.DataSize=SPI_DATASIZE_8BIT +SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction,DataSize,NSSPMode +SPI4.Mode=SPI_MODE_MASTER +SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI4.VirtualType=VM_MASTER +SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 +SPI5.CalculateBaudRate=3.75 MBits/s +SPI5.DataSize=SPI_DATASIZE_8BIT +SPI5.Direction=SPI_DIRECTION_2LINES +SPI5.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode +SPI5.Mode=SPI_MODE_MASTER +SPI5.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI5.VirtualType=VM_MASTER +SPI6.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +SPI6.CalculateBaudRate=7.5 MBits/s SPI6.DataSize=SPI_DATASIZE_8BIT -PB3\ (JTDO/TRACESWO).Locked=true -PB3\ (JTDO/TRACESWO).Signal=SPI1_SCK -ProjectManager.TargetToolchain=Other Toolchains (GPDSC) -NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -SH.FMC_D1_DA1.ConfNb=1 -Bdma.RequestsNb=1 -PB2.GPIOParameters=GPIO_Label -RCC.VcooutputI2SQ=96000000 -PF2.Signal=FMC_A2 -Dma.USART2_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -ProjectManager.RegisterCallBack= -RCC.PLLSAIoutputFreq_Value=50000000 -USB_DEVICE.SERIALNUMBER_STRING_AUDIO_FS=00000000010D -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PB1.Locked=true -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH -PG9.GPIO_Label=ENC_nCS -PG14.Signal=SPI6_MOSI -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,Synchro_A,Synchro_B,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,BasicDataSize-SAI_A_AsyncSlave,BasicDataSize-SAI_B_SyncSlave -RCC.VCOInput1Freq_Value=5000000 -Dma.USART2_RX.4.SyncEnable=DISABLE -Dma.USART2_RX.4.Direction=DMA_PERIPH_TO_MEMORY -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=120000000 -USB_HOST0.BSP.api=Unknown -SH.FMC_D13_DA13.ConfNb=1 SPI6.Direction=SPI_DIRECTION_2LINES_TXONLY -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=3.75 MBits/s -PA4.GPIOParameters=GPIO_Label -PE6.Signal=SPI4_MOSI -Mcu.Name=STM32H743ZGTx -PA2.Signal=USART2_TX -PD14.Signal=FMC_D0_DA0 +SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode +SPI6.Mode=SPI_MODE_MASTER +SPI6.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI6.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.ClockDivision=TIM_CLOCKDIVISION_DIV2 +TIM2.IPParameters=Channel-PWM Generation1 CH1,Prescaler,ClockDivision,Period,Pulse-PWM Generation1 CH1 +TIM2.Period=200 +TIM2.Prescaler=4095 +TIM2.Pulse-PWM\ Generation1\ CH1=100 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.ClockDivision=TIM_CLOCKDIVISION_DIV2 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Pulse-PWM Generation4 CH4,Period,OCFastMode_PWM-PWM Generation4 CH4,ClockDivision TIM3.OCFastMode_PWM-PWM\ Generation4\ CH4=TIM_OCFAST_DISABLE -PA7.GPIO_Label=FLASH_MOSI -PA12.Mode=Device_Only -Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY -PC5.GPIO_Label=FLASH_nCS -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -RCC.SAI4AFreq_Value=48000000 -RCC.DIVQ1Freq_Value=48000000 -PE3.GPIO_Label=CS_SDOUT -Dma.SAI1_B.1.SyncRequestNumber=1 -RCC.D3PPRE=RCC_APB4_DIV2 -RCC.VCOInput2Freq_Value=12500000 -RCC.APB1Freq_Value=120000000 -USART2.Mode=MODE_TX_RX -SAI1.InitProtocol-SAI_B_SyncSlave=Enable +TIM3.Period=100 TIM3.Pulse-PWM\ Generation4\ CH4=50 -PB11.Locked=true -ProjectManager.DeviceId=STM32H743ZGTx -ProjectManager.LibraryCopy=2 -SPI5.Direction=SPI_DIRECTION_2LINES -SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -PB1.GPIOParameters=GPIO_Speed,GPIO_Label -PA7.Signal=SPI1_MOSI +USART2.BaudRate=31250 +USART2.IPParameters=VirtualMode,BaudRate,Mode,VirtualMode-Asynchronous +USART2.Mode=MODE_TX_RX +USART2.VirtualMode=VM_ASYNC +USART2.VirtualMode-Asynchronous=VM_ASYNC +USB_DEVICE.CLASS_NAME_FS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS,SERIALNUMBER_STRING_AUDIO_FS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +USB_DEVICE.PID_AUDIO_FS=0xDADA +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-MAGUS +USB_DEVICE.SERIALNUMBER_STRING_AUDIO_FS=00000000010D +USB_DEVICE.VID-AUDIO_FS=0x1209 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +USB_DEVICE.VirtualModeFS=Audio_FS +USB_HOST.BSP.number=1 +USB_HOST.IPParameters=VirtualModeHS,USBH_HandleTypeDef-AUDIO_HS,USBH_MAX_NUM_ENDPOINTS-AUDIO_HS,USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS +USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS +USB_HOST.USBH_MAX_NUM_ENDPOINTS-AUDIO_HS=10 +USB_HOST.USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS=256 +USB_HOST.VirtualModeHS=Audio +USB_HOST0.BSP.STBoard=false +USB_HOST0.BSP.api=Unknown +USB_HOST0.BSP.component= +USB_HOST0.BSP.condition= +USB_HOST0.BSP.i2caddr=0 +USB_HOST0.BSP.i2creg= +USB_HOST0.BSP.instance=PC6 +USB_HOST0.BSP.ip=GPIO +USB_HOST0.BSP.mode=Output +USB_HOST0.BSP.name=Drive_VBUS_HS +USB_HOST0.BSP.semaphore= +USB_HOST0.BSP.solution=PC6 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Host_FS +USB_OTG_HS.VirtualMode-Host_FS=Host_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS +VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS +board=Magus diff --git a/Magus3/Makefile b/Magus3/Makefile index a980a29d..4372e577 100644 --- a/Magus3/Makefile +++ b/Magus3/Makefile @@ -12,7 +12,7 @@ C_SRC += $(OPENWARE)/Source/ssd1309.c C_SRC += $(OPENWARE)/Source/HAL_MAX11300.c C_SRC += $(OPENWARE)/Source/HAL_TLC5946.c C_SRC += $(OPENWARE)/Source/HAL_Encoders.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index 3e9b73cd..24689e4c 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -9,15 +9,48 @@ #include "HAL_Encoders.h" #include "Pin.h" #include "ApplicationSettings.h" - -// 63, 19, 60 // TODO: balance levels +#include "Storage.h" +#include "MagusParameterController.hpp" const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -Graphics graphics; + +MagusParameterController params; +Graphics graphics DMA_RAM; extern "C" void onResourceUpdate(void); +char* progress_message = NULL; +uint16_t progress_counter = 0; + +void setProgress(uint16_t value, const char* reason){ + progress_message = (char*)reason; + progress_counter = value; +} + +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + switch(new_mode){ + case STREAM_MODE: + setProgress(0, "Streaming"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case STARTUP_MODE: + case LOAD_MODE: + setProgress(0, "Loading"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case CONFIGURE_MODE: + setDisplayMode(STATUS_DISPLAY_MODE); + break; + case RUN_MODE: + setDisplayMode(STANDARD_DISPLAY_MODE); + break; + case ERROR_MODE: + setDisplayMode(ERROR_DISPLAY_MODE); + break; + } +} + static bool updateMAX11300 = false; static uint8_t portMode[20]; void setPortMode(uint8_t index, uint8_t mode){ @@ -48,25 +81,25 @@ void onResourceUpdate(void){ extern const uint32_t rainbowoutputs[]; extern const uint32_t* dyn_rainbowinputs; extern const uint32_t* dyn_rainbowoutputs; - ResourceHeader* res = registry.getResource("Rainbow.in"); - if (res == NULL){ + Resource* res = storage.getResourceByName("Rainbow.in"); + if(res && res->isMemoryMapped()){ + dyn_rainbowinputs = (uint32_t*)res->getData(); + }else{ dyn_rainbowinputs = rainbowinputs; } - else { - dyn_rainbowinputs = (uint32_t*)registry.getData(res); - } - res = registry.getResource("Rainbow.out"); - if (res == NULL){ + res = storage.getResourceByName("Rainbow.out"); + if(res && res->isMemoryMapped()){ + dyn_rainbowoutputs = (uint32_t*)res->getData(); + }else{ dyn_rainbowoutputs = rainbowoutputs; } - else { - dyn_rainbowoutputs = (uint32_t*)registry.getData(res); - } } -void setup(){ +void onSetup(){ HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_SET); // LEDs off Pin enc_nrst(ENC_NRST_GPIO_Port, ENC_NRST_Pin); + + // Encoders_reset(); enc_nrst.outputMode(); enc_nrst.low(); @@ -76,8 +109,8 @@ void setup(){ // LEDs TLC5946_init(&TLC5946_SPI); - TLC5946_setAll_DC(0); // Start with 0 brightness here, update from settings later - TLC5946_setAll(0x10, 0x10, 0x10); + TLC5946_setAll_DC(0); // Start with low brightness here, update from settings later + TLC5946_setAll(0, 0, 0); HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_RESET); @@ -110,16 +143,15 @@ void setup(){ HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); + graphics.begin(¶ms, &OLED_SPI); #ifdef USE_USB_HOST // enable USB Host power HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - owl.setup(); - - // Update LEDs brighness from settings + // Update LEDs brightness from settings + // TLC5946_setRGB_DC(63, 19, 60); TLC5946_setAll_DC(settings.leds_brightness); TLC5946_Refresh_DC(); @@ -127,10 +159,24 @@ void setup(){ // allows us to program chip with SWD enc_nrst.inputMode(); enc_nrst.setPull(PIN_PULL_UP); + HAL_Delay(20); Encoders_readAll(); } -void loop(void){ +void onScreenDraw(){ +#ifdef USE_TLC5946 + for(int i=0; i<16; ++i){ + uint16_t val = params.getValue(i)>>2; + if(getPortMode(i) == PORT_UNI_INPUT) + setLed(i, dyn_rainbowinputs[val&0x3ff]); + else + setLed(i, dyn_rainbowoutputs[val&0x3ff]); + } + TLC5946_Refresh_GS(); +#endif +} + +void onLoop(){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ @@ -143,13 +189,6 @@ void loop(void){ } #endif -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ - - owl.loop(); - if(updateMAX11300){ MAX11300_setDeviceControl(DCR_DACCTL_ImmUpdate|DCR_DACREF_Int|DCR_ADCCTL_ContSweep /* |DCR_ADCCONV_200ksps|DCR_BRST_Contextual*/); for(int i=0; i<20; ++i){ @@ -167,35 +206,31 @@ void loop(void){ } updateMAX11300 = false; } -#ifdef USE_TLC5946 - TLC5946_Refresh_GS(); -#endif Encoders_readAll(); - graphics.params.updateEncoders(Encoders_get(), 7); + params.updateEncoders(Encoders_get(), 7); MAX11300_bulkreadADC(); for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = graphics.params.parameters[i]>>2; - setLed(i, dyn_rainbowinputs[val&0x3ff]); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ // DACs // TODO: store values set from patch somewhere and multiply with user[] value for outputs - // graphics.params.updateOutput(i, getOutputValue(i)); - // MAX11300_setDACValue(i+1, graphics.params.parameters[i]); - graphics.params.updateValue(i, 0); - uint16_t val = graphics.params.parameters[i]>>2; - setLed(i, dyn_rainbowoutputs[val&0x3ff]); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + // params.updateOutput(i, getOutputValue(i)); + // MAX11300_setDACValue(i+1, params.parameters[i]); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } for(int i=16; i<20; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ - graphics.params.updateValue(i, 0); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } + for(int i=20; i < NOF_PARAMETERS; i++) { + params.updateValue(i, 0); + } // MAX11300_bulkwriteDAC(); } diff --git a/Magus3/Src/main.c b/Magus3/Src/main.c index 9ffde582..d90c7e7a 100644 --- a/Magus3/Src/main.c +++ b/Magus3/Src/main.c @@ -52,6 +52,8 @@ #include "cmsis_os.h" #include "usb_device.h" #include "usb_host.h" +#include "usb_device.h" +#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -199,30 +201,33 @@ int main(void) MX_SPI6_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ - HAL_SAI_DeInit(&hsai_BlockA1); - HAL_SAI_DeInit(&hsai_BlockB1); - hsai_BlockA1.Instance = SAI1_Block_A; - hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; - hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; - hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; - hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; - hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; - if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) - Error_Handler(); - hsai_BlockB1.Instance = SAI1_Block_B; - hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; - hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; - hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; - hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; - hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; - if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) - Error_Handler(); + /* HAL_SAI_DeInit(&hsai_BlockA1); */ + /* HAL_SAI_DeInit(&hsai_BlockB1); */ + /* hsai_BlockA1.Instance = SAI1_Block_A; */ + /* hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; */ + /* hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; */ + /* hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; */ + /* hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; */ + /* hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; */ + /* hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; */ + /* hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; */ + /* hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; */ + /* if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) */ + /* Error_Handler(); */ + /* hsai_BlockB1.Instance = SAI1_Block_B; */ + /* hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; */ + /* hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; */ + /* hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; */ + /* hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; */ + /* hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; */ + /* hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; */ + /* hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; */ + /* hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; */ + /* if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) */ + /* Error_Handler(); */ + + /* HAL_NVIC_SetPriority(EXTI2_IRQn, 3, 0); */ + /* HAL_NVIC_EnableIRQ(EXTI2_IRQn); */ SDRAM_Initialization_Sequence(&hsdram1); @@ -521,7 +526,7 @@ static void MX_SPI5_Init(void) hspi5.Init.CLKPolarity = SPI_POLARITY_LOW; hspi5.Init.CLKPhase = SPI_PHASE_1EDGE; hspi5.Init.NSS = SPI_NSS_SOFT; - hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi5.Init.TIMode = SPI_TIMODE_DISABLE; hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; @@ -858,7 +863,7 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOC, FLASH_HOLD_Pin|FLASH_nCS_Pin|ENC_NRST_Pin|TLC_XLAT_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, FLASH_nWP_Pin|CS_CS_Pin|CS_RST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|CS_CS_Pin|CS_RST_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); @@ -896,8 +901,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : FLASH_nWP_Pin CS_CS_Pin CS_RST_Pin */ - GPIO_InitStruct.Pin = FLASH_nWP_Pin|CS_CS_Pin|CS_RST_Pin; + /*Configure GPIO pins : FLASH_WP_Pin CS_CS_Pin CS_RST_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|CS_CS_Pin|CS_RST_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; diff --git a/Magus3/Src/startup_stm32h743xx.s b/Magus3/Src/startup_stm32h743xx.s new file mode 100644 index 00000000..2b1034a6 --- /dev/null +++ b/Magus3/Src/startup_stm32h743xx.s @@ -0,0 +1,749 @@ +/** + ****************************************************************************** + * @file startup_stm32h743xx.s + * @author MCD Application Team + * @brief STM32H743xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Call the clock system intitialization function.*/ + bl SystemInit + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word RNG_IRQHandler /* Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word SAI2_IRQHandler /* SAI2 */ + .word QUADSPI_IRQHandler /* QUADSPI */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word OTG_FS_EP1_OUT_IRQHandler /* USB OTG FS End Point 1 Out */ + .word OTG_FS_EP1_IN_IRQHandler /* USB OTG FS End Point 1 In */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word HRTIM1_Master_IRQHandler /* HRTIM Master Timer global Interrupt */ + .word HRTIM1_TIMA_IRQHandler /* HRTIM Timer A global Interrupt */ + .word HRTIM1_TIMB_IRQHandler /* HRTIM Timer B global Interrupt */ + .word HRTIM1_TIMC_IRQHandler /* HRTIM Timer C global Interrupt */ + .word HRTIM1_TIMD_IRQHandler /* HRTIM Timer D global Interrupt */ + .word HRTIM1_TIME_IRQHandler /* HRTIM Timer E global Interrupt */ + .word HRTIM1_FLT_IRQHandler /* HRTIM Fault global Interrupt */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word SAI3_IRQHandler /* SAI3 global Interrupt */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word JPEG_IRQHandler /* JPEG global Interrupt */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak RNG_IRQHandler + .thumb_set RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak SAI2_IRQHandler + .thumb_set SAI2_IRQHandler,Default_Handler + + .weak QUADSPI_IRQHandler + .thumb_set QUADSPI_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_OUT_IRQHandler + .thumb_set OTG_FS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_IN_IRQHandler + .thumb_set OTG_FS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak HRTIM1_Master_IRQHandler + .thumb_set HRTIM1_Master_IRQHandler,Default_Handler + + .weak HRTIM1_TIMA_IRQHandler + .thumb_set HRTIM1_TIMA_IRQHandler,Default_Handler + + .weak HRTIM1_TIMB_IRQHandler + .thumb_set HRTIM1_TIMB_IRQHandler,Default_Handler + + .weak HRTIM1_TIMC_IRQHandler + .thumb_set HRTIM1_TIMC_IRQHandler,Default_Handler + + .weak HRTIM1_TIMD_IRQHandler + .thumb_set HRTIM1_TIMD_IRQHandler,Default_Handler + + .weak HRTIM1_TIME_IRQHandler + .thumb_set HRTIM1_TIME_IRQHandler,Default_Handler + + .weak HRTIM1_FLT_IRQHandler + .thumb_set HRTIM1_FLT_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SAI3_IRQHandler + .thumb_set SAI3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak JPEG_IRQHandler + .thumb_set JPEG_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/Magus3/Src/stm32h7xx_hal_msp.c b/Magus3/Src/stm32h7xx_hal_msp.c index 89dfb0a9..348a4ae7 100644 --- a/Magus3/Src/stm32h7xx_hal_msp.c +++ b/Magus3/Src/stm32h7xx_hal_msp.c @@ -124,14 +124,14 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = FLASH_SCK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(FLASH_SCK_GPIO_Port, &GPIO_InitStruct); @@ -200,7 +200,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) GPIO_InitStruct.Pin = SPI_A_SCK_Pin|SPI_A_MISO_Pin|SPI_A_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI5; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); @@ -871,7 +871,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; @@ -914,7 +914,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; @@ -959,6 +959,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -976,6 +977,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/Magus3/Src/usbh_conf.c b/Magus3/Src/usbh_conf.c index dffac0ea..3e039c1e 100644 --- a/Magus3/Src/usbh_conf.c +++ b/Magus3/Src/usbh_conf.c @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -175,14 +174,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Makefile b/Makefile index d89a38b6..606e4887 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif export OPENWARE CONFIG -all: alchemist wizard magus lich witch owlpedal noctua effectsbox biosignals midiboot midibootowl midiboot3 genius # tesseract prism player quadfm ## build most targets +all: alchemist wizard magus lich witch owlpedal noctua biosignals midiboot midibootowl midiboot3 genius # effectsbox tesseract prism player quadfm ## build most targets midiboot: ## build MidiBoot project @$(MAKE) -C MidiBoot all diff --git a/MidiBoot/Inc/hardware.h b/MidiBoot/Inc/hardware.h index 00cc2b1e..4e4eb29a 100644 --- a/MidiBoot/Inc/hardware.h +++ b/MidiBoot/Inc/hardware.h @@ -4,7 +4,6 @@ #define USE_BOOTLOADER_MODE #define USE_USBD_MIDI -#define USBD_MAX_POWER 100 // 100mA for iPad compatibility #ifdef USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #else @@ -15,6 +14,7 @@ #define HARDWARE_VERSION "OWL Magus Boot" #define HARDWARE_ID MAGUS_HARDWARE #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_LICH #define HARDWARE_VERSION "OWL Lich Boot" #define HARDWARE_ID LICH_HARDWARE @@ -27,6 +27,7 @@ #define LED1_GPIO_Port GPIOF #define LED2_Pin GPIO_PIN_8 #define LED2_GPIO_Port GPIOF + #define USE_SPI_FLASH #elif defined OWL_WITCH #define HARDWARE_VERSION "OWL Witch Boot" #define HARDWARE_ID WITCH_HARDWARE @@ -52,6 +53,7 @@ #define LED2_Pin GPIO_PIN_1 #define LED2_GPIO_Port GPIOA #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_WIZARD #define HARDWARE_VERSION "OWL Wizard Boot" #define HARDWARE_ID WIZARD_HARDWARE @@ -64,6 +66,20 @@ #define LED2_Pin GPIO_PIN_1 #define LED2_GPIO_Port GPIOA #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH +#elif defined OWL_PEDAL + #define HARDWARE_VERSION "OWL Pedal Boot" + #define HARDWARE_ID OWL_PEDAL_HARDWARE + #define USE_BOOT1_PIN + #define BOOT1_Pin GPIO_PIN_10 // only valid for green/Rev04 + #define BOOT1_GPIO_Port GPIOG + #define USE_LED + #define LED1_Pin GPIO_PIN_8 + #define LED1_GPIO_Port GPIOB + #define LED2_Pin GPIO_PIN_9 + #define LED2_GPIO_Port GPIOB + #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_NOCTUA #define HARDWARE_VERSION "OWL Noctua Boot" #define HARDWARE_ID NOCTUA_HARDWARE @@ -79,6 +95,3 @@ #else #error Invalid configuration #endif - -/* #define USE_IWDG */ -/* #define INIT_FMC */ diff --git a/MidiBoot/Makefile b/MidiBoot/Makefile index 7c02a97b..b3d4806a 100644 --- a/MidiBoot/Makefile +++ b/MidiBoot/Makefile @@ -43,6 +43,9 @@ else ifeq ($(PLATFORM),Alchemist) else ifeq ($(PLATFORM),Wizard) CPPFLAGS += -Iusbd-hs -DOWL_WIZARD -DUSE_USBD_HS vpath %.c usbd-hs +else ifeq ($(PLATFORM),Pedal) + CPPFLAGS += -Iusbd-hs -DOWL_PEDAL -DUSE_USBD_HS + vpath %.c usbd-hs else ifeq ($(PLATFORM),EuroWizard) CPPFLAGS += -Iusbd-fs -DOWL_WIZARD -DUSE_USBD_FS vpath %.c usbd-fs @@ -55,6 +58,8 @@ else ifeq ($(PLATFORM),Noctua) else ifeq ($(PLATFORM),BioSignals) CPPFLAGS += -Iusbd-hs -DOWL_BIOSIGNALS -DUSE_USBD_HS vpath %.c usbd-hs +else + $(error Invalid PLATFORM=$(PLATFORM)) endif CPP_SRC += $(OPENWARE)/Source/MidiController.cpp diff --git a/MidiBoot/Src/MidiBoot.cpp b/MidiBoot/Src/MidiBoot.cpp index 2cd2803a..4c8a7bf0 100644 --- a/MidiBoot/Src/MidiBoot.cpp +++ b/MidiBoot/Src/MidiBoot.cpp @@ -21,7 +21,7 @@ ProgramManager::ProgramManager(){} void ProgramManager::exitProgram(bool isr){} void setParameterValue(uint8_t ch, int16_t value){} void SystemMidiReader::reset(){} -void Owl::setOperationMode(OperationMode mode){} +void Owl::setOperationMode(uint8_t mode){} const char* getFirmwareVersion(){ return (const char*)(HARDWARE_VERSION " " FIRMWARE_VERSION) ; @@ -95,10 +95,10 @@ void eraseFromFlash(uint8_t sector){ storage.erase(RESOURCE_PORT_MAPPED); #endif storage.erase(RESOURCE_MEMORY_MAPPED); - sendMessage(SYSEX_PROGRAM_MESSAGE, "Erased patch storage"); + sendMessage(SYSEX_PROGRAM_MESSAGE, "Erased storage"); led_green(); }else{ - eeprom_erase_sector(sector); + eeprom_erase_sector(sector, FLASH_BANK_1); sendMessage(SYSEX_PROGRAM_MESSAGE, "Erased flash sector"); led_green(); } @@ -108,11 +108,11 @@ void eraseFromFlash(uint8_t sector){ void saveToFlash(uint8_t sector, void* data, uint32_t length){ if(sector == FIRMWARE_SECTOR && length <= (64+3*128)*1024){ eeprom_unlock(); - eeprom_erase_sector(FLASH_SECTOR_4); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_1); if(length > 64*1024){ - eeprom_erase_sector(FLASH_SECTOR_5); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_1); if(length > (64+128)*1024){ - eeprom_erase_sector(FLASH_SECTOR_6); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_1); } } eeprom_write_block(ADDR_FLASH_SECTOR_4, data, length); diff --git a/MidiBoot/Src/main.c b/MidiBoot/Src/main.c index 7123715c..b9beb1c8 100644 --- a/MidiBoot/Src/main.c +++ b/MidiBoot/Src/main.c @@ -100,6 +100,16 @@ static int testWatchdogReset(){ return __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET; } +static int testPowerLowReset(){ + return __HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST) != RESET; +} + +static int testBrownOutReset(){ + return __HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) != RESET && // Power down or Brown out + __HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) == RESET; // Not power down + +} + /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ @@ -138,9 +148,13 @@ int main(void) }else if(testButton()){ setMessage("Bootloader requested"); }else if(testLoop()){ - error(RUNTIME_ERROR, "Unexpected firmware reset"); + error(RUNTIME_ERROR, "Unexpected reset"); }else if(testWatchdogReset()){ error(RUNTIME_ERROR, "Watchdog reset"); + }else if(testPowerLowReset()){ + error(RUNTIME_ERROR, "Low power reset"); + }else if(testBrownOutReset()){ + error(RUNTIME_ERROR, "Brown out reset"); }else if(testNoProgram()){ error(RUNTIME_ERROR, "No valid firmware"); }else{ diff --git a/MidiBoot3/Inc/hardware.h b/MidiBoot3/Inc/hardware.h index d4c8a158..b531d634 100644 --- a/MidiBoot3/Inc/hardware.h +++ b/MidiBoot3/Inc/hardware.h @@ -4,7 +4,6 @@ #define USE_BOOTLOADER_MODE #define USE_USBD_MIDI -#define USBD_MAX_POWER 100 // 100mA for iPad compatibility #ifdef USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #else @@ -15,9 +14,10 @@ #define HARDWARE_VERSION "OWL Genius Boot" #define HARDWARE_ID GENIUS_HARDWARE #define APPLICATION_ADDRESS 0x08020000 +#elif defined OWL_MAGUS + #define HARDWARE_VERSION "OWL Magus Boot" + #define HARDWARE_ID MAGUS_HARDWARE + #define APPLICATION_ADDRESS 0x08020000 #else #error Invalid configuration #endif - -/* #define USE_IWDG */ -/* #define INIT_FMC */ diff --git a/MidiBoot3/Makefile b/MidiBoot3/Makefile index 12b4255e..ce93a408 100644 --- a/MidiBoot3/Makefile +++ b/MidiBoot3/Makefile @@ -27,6 +27,11 @@ PROJECT = MidiBoot-$(PLATFORM) ifeq ($(PLATFORM),Genius) CPPFLAGS += -Iusbd-fs -DOWL_GENIUS -DUSE_USBD_FS vpath %.c usbd-fs +else ifeq ($(PLATFORM),Magus) + CPPFLAGS += -Iusbd-fs -DOWL_MAGUS -DUSE_USBD_FS + vpath %.c usbd-fs +else + $(error Invalid PLATFORM=$(PLATFORM)) endif CPP_SRC += $(OPENWARE)/Source/MidiController.cpp @@ -47,7 +52,7 @@ unlock: $(OPENOCD) -c "init" -c "reset halt" -c "flash protect 0 0 1 off" -c "flash info 0" -c "exit" erase: - $(OPENOCD) -c "init" -c "halt" -c "stm32h7 mass_erase 0" -c "flash info 0" -c "exit" + $(OPENOCD) -c "init" -c "halt" -c "stm32h7x mass_erase 0" -c "flash info 0" -c "exit" erase-boot: # flash erase_sector num first last $(OPENOCD) -c "init" -c "halt" -c "flash erase_sector 0 0 1" -c "exit" diff --git a/MidiBoot3/Src/MidiBoot.cpp b/MidiBoot3/Src/MidiBoot.cpp index 1b6ad5d3..a5617f3b 100644 --- a/MidiBoot3/Src/MidiBoot.cpp +++ b/MidiBoot3/Src/MidiBoot.cpp @@ -20,7 +20,7 @@ ProgramManager::ProgramManager(){} void ProgramManager::exitProgram(bool isr){} void setParameterValue(uint8_t ch, int16_t value){} void SystemMidiReader::reset(){} -void Owl::setOperationMode(OperationMode mode){} +void Owl::setOperationMode(uint8_t mode){} const char* getFirmwareVersion(){ return (const char*)(HARDWARE_VERSION " " FIRMWARE_VERSION) ; @@ -81,13 +81,13 @@ void eraseFromFlash(uint8_t sector){ uint32_t address = (uint32_t)&_FLASH_STORAGE_BEGIN; uint32_t sector = FLASH_SECTOR_4; while (address < (uint32_t)&_FLASH_STORAGE_END) { - eeprom_erase_sector(sector++); + eeprom_erase_sector(sector++, FLASH_BANK_1); address += FLASH_SECTOR_SIZE; } setMessage("Erased patch storage"); led_green(); }else{ - eeprom_erase_sector(sector); + eeprom_erase_sector(sector, FLASH_BANK_1); setMessage("Erased flash sector"); led_green(); } @@ -98,11 +98,11 @@ void saveToFlash(uint8_t sector, void* data, uint32_t length){ // TODO! if(sector == FIRMWARE_SECTOR && length <= (3*128)*1024){ eeprom_unlock(); - eeprom_erase_sector(FLASH_SECTOR_1); + eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_1); if(length > 128*1024){ - eeprom_erase_sector(FLASH_SECTOR_2); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); if(length > (128+128)*1024){ - eeprom_erase_sector(FLASH_SECTOR_3); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); } } extern char _BOOTLOADER_END; diff --git a/MidiBoot3/Src/usb_device.c b/MidiBoot3/Src/usb_device.c index 3c01e804..4b8646e6 100644 --- a/MidiBoot3/Src/usb_device.c +++ b/MidiBoot3/Src/usb_device.c @@ -1,96 +1,85 @@ -/* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file : usb_device.c + * @file : USB_DEVICE * @version : v1.0_Cube - * @brief : This file implements the USB Device + * @brief : This file implements the USB Device ****************************************************************************** - * @attention * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved. * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** - */ -/* USER CODE END Header */ +*/ /* Includes ------------------------------------------------------------------*/ +#include "device.h" #include "usb_device.h" #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_midi.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -/* USER CODE END PFP */ - -/* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; - -/* - * -- Insert your variables declaration here -- - */ -/* USER CODE BEGIN 0 */ +/* USB Device Core handle declaration */ +USBD_HandleTypeDef USBD_HANDLE; -/* USER CODE END 0 */ - -/* - * -- Insert your external function declaration here -- - */ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** - * Init USB device Library, add supported class and start the library - * @retval None - */ +/* init function */ void MX_USB_DEVICE_Init(void) { - /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ - - /* USER CODE END USB_DEVICE_Init_PreTreatment */ - - /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + /* Init Device Library,Add Supported Class and Start the library*/ +#if defined USE_USBD_FS + if (USBD_Init(&USBD_HANDLE, &FS_Desc, DEVICE_FS) != USBD_OK) +#elif defined USE_USBD_HS + if (USBD_Init(&USBD_HANDLE, &HS_Desc, DEVICE_HS) != USBD_OK) +#else +#error Invalid USB configuration +#endif { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } - - /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ - HAL_PWREx_EnableUSBVoltageDetector(); - - /* USER CODE END USB_DEVICE_Init_PostTreatment */ } - /** * @} */ diff --git a/MidiBootOwl/Makefile b/MidiBootOwl/Makefile index 3cf44e26..2aa4e2bd 100644 --- a/MidiBootOwl/Makefile +++ b/MidiBootOwl/Makefile @@ -33,6 +33,8 @@ else ifeq ($(PLATFORM),Modular) else ifeq ($(PLATFORM),Rack) CPPFLAGS += -Iusbd-fs -IOWL_PEDAL -DOWL_RACK # vpath %.c usbd-fs +else + $(error Invalid PLATFORM=$(PLATFORM)) endif C_SRC += $(C_SRC_SRAM) @@ -42,8 +44,6 @@ C_SRC += $(C_SRC_IWDG) include $(OPENWARE)/Hardware/f4.mk -DFUCMD = $(DFUUTIL) -d 0483:df11 -c 1 -i 0 -a 0 - .PHONY: clean deploy unlock erase upload lock info: diff --git a/MidiBootOwl/Src/MidiBoot.cpp b/MidiBootOwl/Src/MidiBoot.cpp index c570ea26..864fce1c 100644 --- a/MidiBootOwl/Src/MidiBoot.cpp +++ b/MidiBootOwl/Src/MidiBoot.cpp @@ -18,7 +18,7 @@ ProgramManager::ProgramManager(){} void ProgramManager::exitProgram(bool isr){} void setParameterValue(uint8_t ch, int16_t value){} void SystemMidiReader::reset(){} -void Owl::setOperationMode(OperationMode mode) {} +void Owl::setOperationMode(uint8_t mode) {} const char* getFirmwareVersion(){ return (const char*)(HARDWARE_VERSION " " FIRMWARE_VERSION) ; @@ -66,15 +66,15 @@ void sendMessage(){ void eraseFromFlash(uint8_t sector){ eeprom_unlock(); if(sector == 0xff){ - eeprom_erase_sector(FLASH_SECTOR_7); - eeprom_erase_sector(FLASH_SECTOR_8); - eeprom_erase_sector(FLASH_SECTOR_9); - eeprom_erase_sector(FLASH_SECTOR_10); - eeprom_erase_sector(FLASH_SECTOR_11); + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_8, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_9, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_10, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_11, FLASH_BANK_1); setMessage("Erased patch storage"); led_green(); }else{ - eeprom_erase_sector(sector); + eeprom_erase_sector(sector, FLASH_BANK_1); setMessage("Erased flash sector"); led_green(); } @@ -84,15 +84,15 @@ void eraseFromFlash(uint8_t sector){ void saveToFlash(uint8_t sector, void* data, uint32_t length){ if(sector == FIRMWARE_SECTOR && length <= (16 * 2 + 64 + 2 * 128) * 1024){ eeprom_unlock(); - eeprom_erase_sector(FLASH_SECTOR_2); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); if(length > 16 * 1024){ - eeprom_erase_sector(FLASH_SECTOR_3); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); if(length > (16 * 2) * 1024){ - eeprom_erase_sector(FLASH_SECTOR_4); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_1); if (length > (16 * 2 + 64) * 1024){ - eeprom_erase_sector(FLASH_SECTOR_5); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_1); if (length > (16 * 2 + 64 + 128) * 1024){ - eeprom_erase_sector(FLASH_SECTOR_6); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_1); } } } diff --git a/Mussol/Inc/usbd_conf.h b/Mussol/Inc/usbd_conf.h index 0d55589d..41419242 100644 --- a/Mussol/Inc/usbd_conf.h +++ b/Mussol/Inc/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ diff --git a/Mussol/Makefile b/Mussol/Makefile index 00fa16fd..1a561936 100644 --- a/Mussol/Makefile +++ b/Mussol/Makefile @@ -6,7 +6,7 @@ include $(OPENWARE)/Hardware/mussol.mk C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp C_SRC += $(OPENWARE)/Source/usbh_midi.c include $(OPENWARE)/Hardware/sources.mk diff --git a/Mussol/Src/usbh_conf.c b/Mussol/Src/usbh_conf.c index 59f3b20a..55fca072 100644 --- a/Mussol/Src/usbh_conf.c +++ b/Mussol/Src/usbh_conf.c @@ -154,13 +154,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Noctua/Inc/hardware.h b/Noctua/Inc/hardware.h index 7013d576..daa2e0f1 100644 --- a/Noctua/Inc/hardware.h +++ b/Noctua/Inc/hardware.h @@ -35,12 +35,14 @@ #define USBD_AUDIO_TX_CHANNELS 4 #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS -#define USBD_MAX_POWER 100 // 200mA for iPad compatibility +/* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ #define USE_USB_HOST #define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI diff --git a/Noctua/Makefile b/Noctua/Makefile index 31705a82..ec6e2868 100644 --- a/Noctua/Makefile +++ b/Noctua/Makefile @@ -9,7 +9,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/iis3dwb_reg.c C_SRC += $(OPENWARE)/Source/pcm3168a.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/uart_midi.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp diff --git a/Noctua/Src/usbh_conf.c b/Noctua/Src/usbh_conf.c index b5aa0c15..2b161533 100644 --- a/Noctua/Src/usbh_conf.c +++ b/Noctua/Src/usbh_conf.c @@ -149,13 +149,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/OwlPedal/Inc/FreeRTOSConfig.h b/OwlPedal/Inc/FreeRTOSConfig.h index 9a1589c9..1b299d46 100644 --- a/OwlPedal/Inc/FreeRTOSConfig.h +++ b/OwlPedal/Inc/FreeRTOSConfig.h @@ -78,13 +78,13 @@ * These definitions should be adjusted for your particular hardware and * application requirements. * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. * - * See http://www.freertos.org/a00110.html. + * See http://www.freertos.org/a00110.html *----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ #include "device.h" #ifdef DEBUG_STACK @@ -92,7 +92,7 @@ #define INCLUDE_uxTaskGetStackHighWaterMark 1 #endif /* DEBUG_STACK */ -/* USER CODE END Includes */ +/* USER CODE END Includes */ /* Ensure definitions are only used by the compiler, and not by the assembler. */ #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) @@ -124,7 +124,7 @@ /* Defaults to size_t for backward compatibility, but can be changed if lengths will always be less than the number of bytes in a size_t. */ #define configMESSAGE_BUFFER_LENGTH_TYPE size_t -/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 @@ -179,11 +179,11 @@ standard names. */ /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ - + /* #define xPortSysTickHandler SysTick_Handler */ -/* USER CODE BEGIN Defines */ +/* USER CODE BEGIN Defines */ /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ -/* USER CODE END Defines */ +/* USER CODE END Defines */ #endif /* FREERTOS_CONFIG_H */ diff --git a/OwlPedal/Inc/hardware.h b/OwlPedal/Inc/hardware.h index e52fb889..0434ead0 100644 --- a/OwlPedal/Inc/hardware.h +++ b/OwlPedal/Inc/hardware.h @@ -16,62 +16,60 @@ #define HARDWARE_VERSION "OWL Pedal" #define AUDIO_INPUT_GAIN 108 #define AUDIO_OUTPUT_GAIN 115 +#define OWL_PEDAL_LEGACY #endif #define MAX_SYSEX_BOOTLOADER_SIZE (32 * 1024) + +#define EXPRESSION_MODE_EXP_TRS 1 // TRS expression pedal +#define EXPRESSION_MODE_EXP_RTS 2 // TRS expression pedal +#define EXPRESSION_MODE_FS_TS 3 // single footswitch +#define EXPRESSION_MODE_FS_TRS 4 // dual footswitch +#define EXPRESSION_MODE_EXP_ITRS 5 // inverted TRS expression pedal +#define EXPRESSION_MODE_EXP_IRTS 6 // inverted RTS expression pedal +#define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS + #define OWLBOOT_MAGIC_NUMBER 0xF00B4400 #define USE_CODEC #define USE_WM8731 + #define USE_USBD_FS -#define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USBD_DESC FS_Desc +#define USBD_HSFS DEVICE_FS #define USBD_HANDLE hUsbDeviceFS +#define USBD_PCD_HANDLE hpcd_USB_OTG_FS + +/* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 -#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) -#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS +#define AUDIO_INT32_TO_SAMPLE(x) (x & 0xffff) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)) + +#define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone + +/* #define USE_BKPSRAM */ #ifdef OWL_RACK #define NOF_ADC_VALUES 0 #else #define USE_ADC -#define NOF_ADC_VALUES 5 +#define NOF_ADC_VALUES 6 #define ADC_PERIPH hadc3 #define ADC_A 0 #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 +#define ADC_E 5 +#define ADC_F 4 #endif #define NOF_PARAMETERS 40 #define NOF_BUTTONS (4 + 1) - -#if 0 -#define MIDI_INPUT_CHANNEL MIDI_OMNI_CHANNEL -#define MIDI_OUTPUT_CHANNEL 0 - -#define DIGITAL_BUS_ENABLED 0 -#define DIGITAL_BUS_FORWARD_MIDI 1 - -/* +0db in and out */ -#define AUDIO_INPUT_GAIN 0x017 -#define AUDIO_OUTPUT_GAIN 0x079 -#define AUDIO_INPUT_OFFSET 0xffffefaa /* -0.06382 * 65535 */ -#define AUDIO_INPUT_SCALAR 0xfffbb5c7 /* -4.290 * 65535 */ -#define AUDIO_OUTPUT_OFFSET 0x00001eec /* 0.1208 * 65535 */ -#define AUDIO_OUTPUT_SCALAR 0xfffb5bab /* -4.642 * 65535 */ -#define DEFAULT_PROGRAM 1 -#define BUTTON_PROGRAM_CHANGE -#define AUDIO_BIGEND -/* #define AUDIO_SATURATE_SAMPLES // SATURATE adds almost 500 cycles to 24-bit mode */ -#define AUDIO_PROTOCOL I2S_PROTOCOL_PHILIPS -#define AUDIO_BITDEPTH 24 /* bits per sample */ -#define AUDIO_DATAFORMAT 24 -#define AUDIO_CODEC_MASTER true -#define AUDIO_CHANNELS 2 -#define AUDIO_SAMPLINGRATE 48000 - -#endif diff --git a/OwlPedal/Inc/main.h b/OwlPedal/Inc/main.h index e8223bd8..3209af4e 100644 --- a/OwlPedal/Inc/main.h +++ b/OwlPedal/Inc/main.h @@ -91,14 +91,14 @@ void Error_Handler(void); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ -#define PUSHBUTTON_Pin GPIO_PIN_2 -#define PUSHBUTTON_GPIO_Port GPIOE -#define PUSHBUTTON_EXTI_IRQn EXTI2_IRQn +#define SW1_Pin GPIO_PIN_2 +#define SW1_GPIO_Port GPIOE +#define SW1_EXTI_IRQn EXTI2_IRQn #define LED_RED_Pin GPIO_PIN_3 #define LED_RED_GPIO_Port GPIOE -#define BYPASS_Pin GPIO_PIN_4 -#define BYPASS_GPIO_Port GPIOE -#define BYPASS_EXTI_IRQn EXTI4_IRQn +#define FOOTSWITCH_Pin GPIO_PIN_4 +#define FOOTSWITCH_GPIO_Port GPIOE +#define FOOTSWITCH_EXTI_IRQn EXTI4_IRQn #define LED_GREEN_Pin GPIO_PIN_5 #define LED_GREEN_GPIO_Port GPIOE #define ADC1_Pin GPIO_PIN_0 @@ -109,10 +109,10 @@ void Error_Handler(void); #define ADC3_GPIO_Port GPIOC #define ADC4_Pin GPIO_PIN_3 #define ADC4_GPIO_Port GPIOC -#define ADC5_Pin GPIO_PIN_2 -#define ADC5_GPIO_Port GPIOA -#define EXPRESSION_PEDAL_TIP_Pin GPIO_PIN_3 -#define EXPRESSION_PEDAL_TIP_GPIO_Port GPIOA +#define EXP1_RING_Pin GPIO_PIN_2 +#define EXP1_RING_GPIO_Port GPIOA +#define EXP1_TIP_Pin GPIO_PIN_3 +#define EXP1_TIP_GPIO_Port GPIOA #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC #define I2C_SCK_Pin GPIO_PIN_10 diff --git a/OwlPedal/Inc/stm32f4xx_hal_conf.h b/OwlPedal/Inc/stm32f4xx_hal_conf.h index 17031be0..347d0526 100644 --- a/OwlPedal/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal/Inc/stm32f4xx_hal_conf.h @@ -2,7 +2,7 @@ ****************************************************************************** * @file stm32f4xx_hal_conf_template.h * @author MCD Application Team - * @brief HAL configuration template file. + * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f4xx_hal_conf.h. ****************************************************************************** @@ -17,7 +17,7 @@ * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** - */ + */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_CONF_H @@ -32,14 +32,15 @@ /* ########################## Module Selection ############################## */ /** - * @brief This is the list of modules to be used in the HAL driver + * @brief This is the list of modules to be used in the HAL driver */ -#define HAL_MODULE_ENABLED +#define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DCMI_MODULE_ENABLED */ @@ -62,7 +63,7 @@ /* #define HAL_MMC_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ -#define HAL_UART_MODULE_ENABLED +/* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ @@ -75,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -90,20 +92,20 @@ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). + * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). + * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ @@ -112,8 +114,8 @@ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -121,20 +123,20 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -144,19 +146,59 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ -#define USE_RTOS 0U +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U #define DATA_CACHE_ENABLE 1U +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + /* ########################## Assert Selection ############################## */ /** - * @brief Uncomment the line below to expanse the "assert_param" macro in the + * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ - #define USE_FULL_ASSERT 1U + #define USE_FULL_ASSERT 1U /* ################## Ethernet peripheral configuration ##################### */ @@ -170,29 +212,29 @@ #define MAC_ADDR4 0U #define MAC_ADDR5 0U -/* Definition of the Ethernet driver buffers size and count */ +/* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ -/* DP83848_PHY_ADDRESS Address*/ +/* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - + #define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ @@ -207,7 +249,7 @@ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - + /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ @@ -225,25 +267,25 @@ /* Includes ------------------------------------------------------------------*/ /** - * @brief Include module's header file + * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f4xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f4xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f4xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ - + #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f4xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ @@ -256,18 +298,18 @@ #include "stm32f4xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f4xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" + #include "stm32f4xx_hal_cryp.h" #endif /* HAL_CRYP_MODULE_ENABLED */ -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - #ifdef HAL_DMA2D_MODULE_ENABLED #include "stm32f4xx_hal_dma2d.h" #endif /* HAL_DMA2D_MODULE_ENABLED */ @@ -287,7 +329,7 @@ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f4xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ - + #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f4xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ @@ -302,11 +344,11 @@ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - +#endif /* HAL_PCCARD_MODULE_ENABLED */ + #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ +#endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_HASH_MODULE_ENABLED #include "stm32f4xx_hal_hash.h" @@ -316,6 +358,10 @@ #include "stm32f4xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f4xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ @@ -348,10 +394,6 @@ #include "stm32f4xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f4xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ @@ -387,7 +429,7 @@ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f4xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ - + #ifdef HAL_DSI_MODULE_ENABLED #include "stm32f4xx_hal_dsi.h" #endif /* HAL_DSI_MODULE_ENABLED */ @@ -404,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ @@ -415,14 +461,18 @@ #ifdef HAL_LPTIM_MODULE_ENABLED #include "stm32f4xx_hal_lptim.h" #endif /* HAL_LPTIM_MODULE_ENABLED */ - + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function + * @param expr If expr is false, it calls assert_failed function * which reports the name of the source file and the source - * line number of the call that failed. + * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ @@ -431,13 +481,12 @@ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ +#endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_CONF_H */ - /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal/Inc/stm32f4xx_it.h b/OwlPedal/Inc/stm32f4xx_it.h index 0822b56a..83a1a485 100644 --- a/OwlPedal/Inc/stm32f4xx_it.h +++ b/OwlPedal/Inc/stm32f4xx_it.h @@ -65,12 +65,10 @@ void SysTick_Handler(void); void EXTI2_IRQHandler(void); void EXTI4_IRQHandler(void); -void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void DMA1_Stream4_IRQHandler(void); void EXTI9_5_IRQHandler(void); void SPI2_IRQHandler(void); -void UART4_IRQHandler(void); void DMA2_Stream0_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/OwlPedal/Inc/usb_device.h b/OwlPedal/Inc/usb_device.h index b4529d17..98cf5857 100644 --- a/OwlPedal/Inc/usb_device.h +++ b/OwlPedal/Inc/usb_device.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license diff --git a/OwlPedal/Inc/usbd_conf.h b/OwlPedal/Inc/usbd_conf.h index dc6c481c..27e21fa6 100644 --- a/OwlPedal/Inc/usbd_conf.h +++ b/OwlPedal/Inc/usbd_conf.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -36,7 +36,12 @@ #include "stm32f4xx_hal.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif /* USER CODE END INCLUDE */ /** @addtogroup USBD_OTG_DRIVER @@ -64,19 +69,18 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 1U +#define USBD_SELF_POWERED 0U /*---------- -----------*/ -#define USBD_AUDIO_FREQ 22100U /****************************************/ /* #define for FS and HS identification */ @@ -91,14 +95,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -112,25 +115,25 @@ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) printf(__VA_ARGS__);\ - printf("\n"); +#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ + printf("\n"); } while(0) #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) -#define USBD_ErrLog(...) printf("ERROR: ") ;\ +#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) printf("DEBUG : ") ;\ +#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_DbgLog(...) #endif @@ -154,6 +157,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/OwlPedal/Inc/usbd_desc.h b/OwlPedal/Inc/usbd_desc.h index 0c6619fd..90f8968c 100644 --- a/OwlPedal/Inc/usbd_desc.h +++ b/OwlPedal/Inc/usbd_desc.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -17,7 +17,7 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ @@ -30,7 +30,7 @@ #include "usbd_def.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY @@ -41,7 +41,7 @@ * @brief Usb device descriptors module. * @{ */ - + /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants * @brief Constants. * @{ @@ -105,7 +105,7 @@ */ /** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef FS_Desc; +extern USBD_DescriptorsTypeDef USBD_DESC; /* USER CODE BEGIN EXPORTED_VARIABLES */ diff --git a/OwlPedal/Makefile b/OwlPedal/Makefile index bb6c584e..f6634659 100644 --- a/OwlPedal/Makefile +++ b/OwlPedal/Makefile @@ -1,41 +1,43 @@ -BUILDROOT = . -OPENWARE ?= $(BUILDROOT)/.. - -include $(OPENWARE)/Hardware/owl1.mk - -C_SRC = $(wildcard Src/*.c) -CPP_SRC = $(wildcard Src/*.cpp) -C_SRC += $(OPENWARE)/Source/wm8731.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c - -ifndef PLATFORM -PLATFORM = Pedal -endif - -ifeq ($(PLATFORM),Pedal) - PROJECT = OwlPedal - CPPFLAGS += -DOWL_PEDAL -else ifeq ($(PLATFORM),Modular) - PROJECT = OwlModular - CPPFLAGS += -DOWL_MODULAR -else ifeq ($(PLATFORM),Rack) - PROJECT = OwlRack - CPPFLAGS += -IOWL_PEDAL -DOWL_RACK - CPP_SRC += DigitalBusHandler.cpp DigitalBusReader.cpp DigitalBusStreamReader.cpp bus.cpp -endif - -include $(OPENWARE)/Hardware/sources.mk - -C_SRC += $(C_SRC_I2S) -C_SRC += $(C_SRC_SRAM) -C_SRC += $(C_SRC_USBD) -C_SRC += $(C_SRC_DSP) -C_SRC += $(C_SRC_OS) -C_SRC += $(C_SRC_UART) - -include $(OPENWARE)/Hardware/f4.mk - -DFUCMD = dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -R -dfu: bin - @echo Flashing OWL $(PLATFORM) $(CONFIG) firmware - $(DFUCMD) -s 0x8008000:leave -D $(BIN) +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +include $(OPENWARE)/Hardware/owl1.mk + +C_SRC = $(wildcard Src/*.c) +CPP_SRC = $(wildcard Src/*.cpp) +C_SRC += $(OPENWARE)/Source/wm8731.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp + +ifndef PLATFORM +PLATFORM = Pedal +endif + +ifeq ($(PLATFORM),Pedal) + PROJECT = OwlPedal + CPPFLAGS += -DOWL_PEDAL +else ifeq ($(PLATFORM),Modular) + PROJECT = OwlModular + CPPFLAGS += -DOWL_MODULAR +else ifeq ($(PLATFORM),Rack) + PROJECT = OwlRack + CPPFLAGS += -DOWL_RACK + CPP_SRC += DigitalBusHandler.cpp DigitalBusReader.cpp DigitalBusStreamReader.cpp bus.cpp +else + $(error Invalid PLATFORM=$(PLATFORM)) +endif + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_I2S) +C_SRC += $(C_SRC_SRAM) +C_SRC += $(C_SRC_USBD) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) + +include $(OPENWARE)/Hardware/f4.mk + +DFUCMD = dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -R +dfu: bin + @echo Flashing OWL $(PLATFORM) $(CONFIG) firmware + $(DFUCMD) -s 0x8008000:leave -D $(BIN) diff --git a/OwlPedal/OwlPedal.ioc b/OwlPedal/OwlPedal.ioc index 7379def5..d3928e7f 100644 --- a/OwlPedal/OwlPedal.ioc +++ b/OwlPedal/OwlPedal.ioc @@ -1,558 +1,521 @@ #MicroXplorer Configuration settings - do not modify +ADC3.Channel-92\#ChannelRegularConversion=ADC_CHANNEL_10 ADC3.Channel-93\#ChannelRegularConversion=ADC_CHANNEL_11 -PB13.GPIOParameters=GPIO_Label -PH0-OSC_IN.Signal=RCC_OSC_IN -ADC3.SamplingTime-96\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SH.FSMC_D1_DA1.0=FSMC_D1,16b-d1 -PB10.Mode=I2C -PG4.Signal=FSMC_A14 -NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -RCC.PLLCLKFreq_Value=168000000 -Dma.ADC3.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PB14.GPIO_Label=I2S_SDI -SH.FSMC_NWE.0=FSMC_NWE,Sram1 -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FSMC_A10 -PC6.GPIO_Label=I2S_MCLK -PC3.Locked=true -ADC3.SamplingTime-93\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.RTCFreq_Value=32000 -PA3.GPIOParameters=GPIO_Label -PB6.GPIO_Label=PUSH_GATE_IN -ADC3.Rank-96\#ChannelRegularConversion=5 -PB13.Signal=I2S2_CK -PA2.GPIOParameters=GPIO_Label -PinOutPanel.RotationAngle=0 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -USB_DEVICE.PID_AUDIO_FS=0xDADA -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Dma.I2S2_EXT_RX.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -SH.FSMC_A15.ConfNb=1 -SH.FSMC_A11.ConfNb=1 -ADC3.Rank-93\#ChannelRegularConversion=2 -PD4.Signal=FSMC_NOE -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=GPXTI6 -PC3.Signal=ADCx_IN13 -PD0.Signal=FSMC_D2_DA2 -ADC3.ScanConvMode=ENABLE -PD8.Signal=FSMC_D13_DA13 -PE5.Signal=GPIO_Output -PE1.Signal=FSMC_NBL1 +ADC3.Channel-94\#ChannelRegularConversion=ADC_CHANNEL_12 +ADC3.Channel-95\#ChannelRegularConversion=ADC_CHANNEL_13 ADC3.Channel-96\#ChannelRegularConversion=ADC_CHANNEL_2 -PB13.Locked=true -SH.FSMC_D4_DA4.ConfNb=1 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Trace_Asynchronous_SW -PB12.GPIO_Label=I2S_LRCK -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.0 -MxDb.Version=DB.5.0.60 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -SH.FSMC_NOE.ConfNb=1 -ProjectManager.BackupPrevious=false -SH.FSMC_D10_DA10.0=FSMC_D10,16b-d1 -PE9.Signal=FSMC_D6_DA6 -SH.FSMC_A0.0=FSMC_A0,19b-a1 -PB14.Mode=Full_Duplex_Slave +ADC3.Channel-97\#ChannelRegularConversion=ADC_CHANNEL_3 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 ADC3.ContinuousConvMode=ENABLE -PE4.GPIO_Label=BYPASS -ADC3.IPParameters=Rank-92\#ChannelRegularConversion,Channel-92\#ChannelRegularConversion,SamplingTime-92\#ChannelRegularConversion,NbrOfConversionFlag,Rank-93\#ChannelRegularConversion,Channel-93\#ChannelRegularConversion,SamplingTime-93\#ChannelRegularConversion,Rank-94\#ChannelRegularConversion,Channel-94\#ChannelRegularConversion,SamplingTime-94\#ChannelRegularConversion,Rank-95\#ChannelRegularConversion,Channel-95\#ChannelRegularConversion,SamplingTime-95\#ChannelRegularConversion,Rank-96\#ChannelRegularConversion,Channel-96\#ChannelRegularConversion,SamplingTime-96\#ChannelRegularConversion,NbrOfConversion,ScanConvMode,ContinuousConvMode,EOCSelection,DMAContinuousRequests,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConv,ExternalTrigConvEdge,InjNumberOfConversion,EnableAnalogWatchDog -SH.ADCx_IN11.ConfNb=1 -PE2.Signal=GPXTI2 -I2S2.IPParameters=Instance,VirtualMode,FullDuplexMode,AudioFreq,RealAudioFreq,ErrorAudioFreq,DataFormat -FSMC.BusTurnAroundDuration1=1 -Dma.UART4_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PE1.Locked=true -PB6.Locked=true -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -PF3.Signal=FSMC_A3 -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -PE10.Signal=FSMC_D7_DA7 -SH.FSMC_D5_DA5.0=FSMC_D5,16b-d1 -ProjectManager.HalAssertFull=true -PB7.PinState=GPIO_PIN_SET -Dma.SPI2_TX.1.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FSMC_A0.ConfNb=1 -RCC.MCO2PinFreq_Value=168000000 -SH.FSMC_A8.ConfNb=1 -Mcu.Package=LQFP144 -SH.FSMC_D15_DA15.ConfNb=1 -FSMC.IPParameters=AddressSetupTime1,DataSetupTime1,BusTurnAroundDuration1,WriteOperation1,ExtendedMode1 -PD12.Signal=FSMC_A17_ALE -SH.FSMC_D14_DA14.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -FREERTOS.FootprintOK=true -Dma.SPI2_TX.1.Instance=DMA1_Stream4 -PB14.GPIOParameters=GPIO_Label -SH.FSMC_A1.0=FSMC_A1,19b-a1 ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -SH.FSMC_D3_DA3.0=FSMC_D3,16b-d1 +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -PF14.Signal=FSMC_A8 -RCC.APB1TimFreq_Value=84000000 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -USB_OTG_FS.IPParameters=VirtualMode -PB10.GPIOParameters=GPIO_Label -PB13.Mode=Full_Duplex_Slave -SH.FSMC_D7_DA7.ConfNb=1 -PD15.Signal=FSMC_D1_DA1 -ProjectManager.CustomerFirmwarePackage= -NVIC.UART4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -SH.FSMC_A5.ConfNb=1 -Dma.UART4_RX.0.MemInc=DMA_MINC_ENABLE -USB_DEVICE.VID-AUDIO_FS=0x1209 -Dma.SPI2_TX.1.MemInc=DMA_MINC_ENABLE +ADC3.IPParameters=Rank-92\#ChannelRegularConversion,Channel-92\#ChannelRegularConversion,SamplingTime-92\#ChannelRegularConversion,NbrOfConversionFlag,Rank-93\#ChannelRegularConversion,Channel-93\#ChannelRegularConversion,SamplingTime-93\#ChannelRegularConversion,Rank-94\#ChannelRegularConversion,Channel-94\#ChannelRegularConversion,SamplingTime-94\#ChannelRegularConversion,Rank-95\#ChannelRegularConversion,Channel-95\#ChannelRegularConversion,SamplingTime-95\#ChannelRegularConversion,Rank-96\#ChannelRegularConversion,Channel-96\#ChannelRegularConversion,SamplingTime-96\#ChannelRegularConversion,NbrOfConversion,ScanConvMode,ContinuousConvMode,EOCSelection,DMAContinuousRequests,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConv,ExternalTrigConvEdge,InjNumberOfConversion,EnableAnalogWatchDog,Rank-97\#ChannelRegularConversion,Channel-97\#ChannelRegularConversion,SamplingTime-97\#ChannelRegularConversion +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=6 +ADC3.NbrOfConversionFlag=1 ADC3.Rank-92\#ChannelRegularConversion=1 -NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -I2S2.AudioFreq=I2S_AUDIOFREQ_48K -ProjectManager.ProjectFileName=OwlPedal.ioc -FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -SH.FSMC_A2.0=FSMC_A2,19b-a1 -Mcu.PinsNb=74 -Mcu.Pin73=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin72=VP_SYS_VS_Systick -PG5.Signal=FSMC_A15 -FREERTOS.INCLUDE_vTaskDelayUntil=1 -PB6.GPIO_PuPd=GPIO_PULLUP -Dma.UART4_RX.0.Mode=DMA_NORMAL -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 -SH.FSMC_NBL1.ConfNb=1 -Dma.ADC3.3.Instance=DMA2_Stream0 -Mcu.Pin70=PE1 -PC6.Signal=GPIO_Input -PC2.Signal=ADCx_IN12 -PB11.GPIO_Label=I2C_SDA -SH.FSMC_A16_CLE.0=FSMC_A16,19b-a1 -SH.FSMC_D8_DA8.ConfNb=1 -PD1.Signal=FSMC_D3_DA3 -SH.FSMC_D9_DA9.0=FSMC_D9,16b-d1 -ADC3.SamplingTime-92\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin68=PB7 -Mcu.Pin69=PE0 -PC0.Signal=ADCx_IN10 -PB14.Locked=true -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -UART4.VirtualMode=Asynchronous -Mcu.Pin62=PD1 -Mcu.Pin63=PD4 -Mcu.Pin60=PA14 -Mcu.Pin61=PD0 -Mcu.Pin66=PB3 -Mcu.Pin67=PB6 -Mcu.Pin64=PD5 +ADC3.Rank-93\#ChannelRegularConversion=2 +ADC3.Rank-94\#ChannelRegularConversion=3 +ADC3.Rank-95\#ChannelRegularConversion=4 +ADC3.Rank-96\#ChannelRegularConversion=5 +ADC3.Rank-97\#ChannelRegularConversion=6 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PG10 -PA0-WKUP.Signal=UART4_TX -PG10.Signal=FSMC_NE3 -SH.FSMC_D8_DA8.0=FSMC_D8,16b-d1 -PC3.GPIOParameters=GPIO_Label -PA0-WKUP.Mode=Asynchronous -PD10.Signal=FSMC_D15_DA15 -SH.GPXTI6.ConfNb=1 -ADC3.Channel-92\#ChannelRegularConversion=ADC_CHANNEL_10 -Mcu.Pin59=PA13 -SH.FSMC_A14.ConfNb=1 -Mcu.Pin57=PA11 -SH.GPXTI2.ConfNb=1 -Mcu.Pin58=PA12 -PB11.Mode=I2C -SH.FSMC_A3.0=FSMC_A3,19b-a1 -SH.FSMC_A15.0=FSMC_A15,19b-a1 -FSMC.DataSetupTime1=2 -SH.FSMC_D5_DA5.ConfNb=1 -Mcu.Pin51=PG2 -Mcu.Pin52=PG3 -SH.FSMC_A10.ConfNb=1 -Mcu.Pin50=PD15 -Mcu.Pin55=PC6 -Mcu.Pin56=PA9 -Mcu.Pin53=PG4 -Mcu.Pin54=PG5 -PC6.Locked=true -SH.FSMC_A3.ConfNb=1 -PA9.Signal=USB_OTG_FS_VBUS -I2S2.VirtualMode=I2S_MODE_SLAVE -PB11.GPIOParameters=GPIO_Label -ADC3.NbrOfConversion=5 -Dma.UART4_RX.0.PeriphInc=DMA_PINC_DISABLE -Mcu.Pin48=PD13 -Mcu.Pin49=PD14 -Mcu.Pin46=PD11 -Mcu.Pin47=PD12 -Dma.ADC3.3.Direction=DMA_PERIPH_TO_MEMORY -PB10.Signal=I2C2_SCL -PB14.Signal=I2S2_ext_SD -PE2.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin40=PB13 -Mcu.Pin41=PB14 +ADC3.SamplingTime-92\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-93\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-94\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-95\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-96\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-97\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.2.Instance=DMA2_Stream0 +Dma.ADC3.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.2.MemInc=DMA_MINC_ENABLE +Dma.ADC3.2.Mode=DMA_CIRCULAR +Dma.ADC3.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.2.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.2.Priority=DMA_PRIORITY_LOW +Dma.ADC3.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.I2S2_EXT_RX.1.Direction=DMA_PERIPH_TO_MEMORY +Dma.I2S2_EXT_RX.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.I2S2_EXT_RX.1.Instance=DMA1_Stream3 +Dma.I2S2_EXT_RX.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.I2S2_EXT_RX.1.MemInc=DMA_MINC_ENABLE +Dma.I2S2_EXT_RX.1.Mode=DMA_CIRCULAR +Dma.I2S2_EXT_RX.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.I2S2_EXT_RX.1.PeriphInc=DMA_PINC_DISABLE +Dma.I2S2_EXT_RX.1.Priority=DMA_PRIORITY_HIGH +Dma.I2S2_EXT_RX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=SPI2_TX +Dma.Request1=I2S2_EXT_RX +Dma.Request2=ADC3 +Dma.RequestsNb=3 +Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI2_TX.0.Instance=DMA1_Stream4 +Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE +Dma.SPI2_TX.0.Mode=DMA_CIRCULAR +Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE +Dma.SPI2_TX.0.Priority=DMA_PRIORITY_HIGH +Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configCHECK_FOR_STACK_OVERFLOW,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PD9 -SH.FSMC_D7_DA7.0=FSMC_D7,16b-d1 -Mcu.Pin45=PD10 -Mcu.Pin42=PB15 -Mcu.Pin43=PD8 -ProjectManager.LastFirmware=true -Dma.UART4_RX.0.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FSMC_D3_DA3.ConfNb=1 -PA1.Mode=Asynchronous -PE14.Signal=FSMC_D11_DA11 -PE15.Signal=FSMC_D12_DA12 -Dma.SPI2_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Mcu.Pin37=PB10 -Mcu.Pin38=PB11 -Mcu.Pin35=PE14 -PB15.GPIO_Label=I2S_SDO -PE8.Signal=FSMC_D5_DA5 -Mcu.Pin36=PE15 -ADC3.Channel-95\#ChannelRegularConversion=ADC_CHANNEL_13 -Dma.SPI2_TX.1.Priority=DMA_PRIORITY_HIGH -Dma.ADC3.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -SH.FSMC_A18.0=FSMC_A18,19b-a1 -Mcu.Pin39=PB12 -PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PE9 -SH.FSMC_A4.0=FSMC_A4,19b-a1 -Dma.I2S2_EXT_RX.2.Instance=DMA1_Stream3 -RCC.EthernetFreq_Value=168000000 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin33=PE12 -Mcu.Pin34=PE13 -Mcu.Pin31=PE10 -Mcu.Pin32=PE11 -SH.FSMC_A4.ConfNb=1 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configTOTAL_HEAP_SIZE=4096 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FSMC_A7 -PA13.Mode=Trace_Asynchronous_SW -ProjectManager.FreePins=true -Mcu.Pin26=PG0 -Mcu.Pin27=PG1 -RCC.RTCHSEDivFreq_Value=4000000 -Mcu.Pin24=PF14 -ProjectManager.UnderRoot=false -PE4.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin25=PF15 -SH.FSMC_A17_ALE.0=FSMC_A17,19b-a1 +FREERTOS.configUSE_PREEMPTION=0 +FSMC.AddressSetupTime1=2 +FSMC.BusTurnAroundDuration1=1 +FSMC.DataSetupTime1=2 +FSMC.ExtendedMode1=FSMC_EXTENDED_MODE_DISABLE +FSMC.IPParameters=AddressSetupTime1,DataSetupTime1,BusTurnAroundDuration1,WriteOperation1,ExtendedMode1 +FSMC.WriteOperation1=FSMC_WRITE_OPERATION_ENABLE +File.Version=6 +I2S2.AudioFreq=I2S_AUDIOFREQ_48K +I2S2.DataFormat=I2S_DATAFORMAT_24B +I2S2.ErrorAudioFreq=-0.01 % I2S2.FullDuplexMode=I2S_FULLDUPLEXMODE_ENABLE -Mcu.Pin28=PE7 -Mcu.Pin29=PE8 -Mcu.Pin22=PF12 -Mcu.Pin23=PF13 -Mcu.Pin20=PC4 -PA3.Locked=true -Mcu.Pin21=PC5 -NVIC.ForceEnableDMAVector=true -PD11.Signal=FSMC_A16_CLE -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=LED_GREEN -ProjectManager.CompilerOptimize=6 -PA11.Signal=USB_OTG_FS_DM -Dma.I2S2_EXT_RX.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FSMC_D15_DA15.0=FSMC_D15,16b-d1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PC3 -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PA0-WKUP -ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PC1 -Mcu.Pin14=PC2 -Mcu.Pin19=PA3 -ProjectManager.ComputerToolchain=false -Mcu.Pin17=PA1 -Mcu.Pin18=PA2 -SH.FSMC_D1_DA1.ConfNb=1 -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -SH.FSMC_A5.0=FSMC_A5,19b-a1 -Mcu.Pin11=PH1-OSC_OUT -Mcu.Pin12=PC0 -Mcu.Pin10=PH0-OSC_IN -Dma.UART4_RX.0.Instance=DMA1_Stream2 -PE2.Locked=true -PE3.Signal=GPIO_Output -PC3.GPIO_Label=ADC4 -SH.FSMC_NBL0.ConfNb=1 -PE2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Dma.I2S2_EXT_RX.2.Mode=DMA_CIRCULAR -PF4.Signal=FSMC_A4 -Dma.SPI2_TX.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -PC0.Locked=true -PC1.Signal=ADCx_IN11 -PB12.GPIOParameters=GPIO_Label -SH.FSMC_A9.ConfNb=1 -SH.FSMC_D10_DA10.ConfNb=1 -ADC3.EnableAnalogWatchDog=false -Dma.I2S2_EXT_RX.2.MemInc=DMA_MINC_ENABLE +I2S2.IPParameters=Instance,VirtualMode,FullDuplexMode,AudioFreq,RealAudioFreq,ErrorAudioFreq,DataFormat +I2S2.Instance=SPI$Index +I2S2.RealAudioFreq=47.991 KHz +I2S2.VirtualMode=I2S_MODE_SLAVE +KeepUserPlacement=false Mcu.Family=STM32F4 -ProjectManager.MainLocation=Src -FSMC.AddressSetupTime1=2 -USB_DEVICE.CLASS_NAME_FS=AUDIO -RCC.CortexFreq_Value=168000000 -SH.FSMC_A12.0=FSMC_A12,19b-a1 -ProjectManager.KeepUserCode=true -Mcu.UserName=STM32F405ZGTx -SH.FSMC_A6.0=FSMC_A6,19b-a1 -PG2.Signal=FSMC_A12 -Dma.ADC3.3.PeriphInc=DMA_PINC_DISABLE -SH.ADCx_IN2.0=ADC3_IN2,IN2 -PC5.Locked=true -PB6.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_I2S2_Init-I2S2-false-HAL-true,5-MX_ADC3_Init-ADC3-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,9-MX_FSMC_Init-FSMC-false-HAL-true -PC0.GPIOParameters=GPIO_Label -SH.FSMC_D0_DA0.0=FSMC_D0,16b-d1 -Dma.SPI2_TX.1.PeriphInc=DMA_PINC_DISABLE -PC0.GPIO_Label=ADC1 -PA11.Mode=Device_Only -Dma.I2S2_EXT_RX.2.PeriphInc=DMA_PINC_DISABLE -PB13.GPIO_Label=I2S_SCLK -PC1.Locked=true -PB11.Signal=I2C2_SDA -NVIC.DMA1_Stream4_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -PB15.Signal=I2S2_SD -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -SH.GPXTI2.0=GPIO_EXTI2 -Dma.SPI2_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PD13.Signal=FSMC_A18 -Mcu.IP4=I2C2 -Mcu.IP5=I2S2 -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=FREERTOS -Mcu.IP3=FSMC Mcu.IP0=ADC3 Mcu.IP1=DMA -PA12.Signal=USB_OTG_FS_DP -PE4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FSMC_A11.0=FSMC_A11,19b-a1 -Mcu.UserConstants= -PC1.GPIOParameters=GPIO_Label -Dma.I2S2_EXT_RX.2.Priority=DMA_PRIORITY_HIGH -SH.FSMC_A7.0=FSMC_A7,19b-a1 -Mcu.ThirdPartyNb=0 -RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=12 -RCC.I2SClocksFreq_Value=86000000 -ProjectManager.PreviousToolchain= -RCC.VcooutputI2S=86000000 -PF12.Signal=FSMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF2 -Mcu.Pin7=PF3 -NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Mcu.Pin8=PF4 -Mcu.Pin9=PF5 -SH.FSMC_A10.0=FSMC_A10,19b-a1 -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configCHECK_FOR_STACK_OVERFLOW,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE -RCC.AHBFreq_Value=168000000 -PH0-OSC_IN.Mode=HSE-External-Oscillator +Mcu.IP2=FREERTOS +Mcu.IP3=FSMC +Mcu.IP4=I2C2 +Mcu.IP5=I2S2 +Mcu.IP6=NVIC +Mcu.IP7=RCC +Mcu.IP8=SYS +Mcu.IP9=USB_OTG_FS +Mcu.IPNb=10 +Mcu.Name=STM32F405ZGTx +Mcu.Package=LQFP144 Mcu.Pin0=PE2 Mcu.Pin1=PE3 +Mcu.Pin10=PH0-OSC_IN +Mcu.Pin11=PH1-OSC_OUT +Mcu.Pin12=PC0 +Mcu.Pin13=PC1 +Mcu.Pin14=PC2 +Mcu.Pin15=PC3 +Mcu.Pin16=PA2 +Mcu.Pin17=PA3 +Mcu.Pin18=PF12 +Mcu.Pin19=PF13 Mcu.Pin2=PE4 -FREERTOS.configUSE_PREEMPTION=0 +Mcu.Pin20=PF14 +Mcu.Pin21=PF15 +Mcu.Pin22=PG0 +Mcu.Pin23=PG1 +Mcu.Pin24=PE7 +Mcu.Pin25=PE8 +Mcu.Pin26=PE9 +Mcu.Pin27=PE10 +Mcu.Pin28=PE11 +Mcu.Pin29=PE12 Mcu.Pin3=PE5 -SH.FSMC_D12_DA12.ConfNb=1 +Mcu.Pin30=PE13 +Mcu.Pin31=PE14 +Mcu.Pin32=PE15 +Mcu.Pin33=PB10 +Mcu.Pin34=PB11 +Mcu.Pin35=PB12 +Mcu.Pin36=PB13 +Mcu.Pin37=PB14 +Mcu.Pin38=PB15 +Mcu.Pin39=PD8 Mcu.Pin4=PF0 +Mcu.Pin40=PD9 +Mcu.Pin41=PD10 +Mcu.Pin42=PD11 +Mcu.Pin43=PD12 +Mcu.Pin44=PD13 +Mcu.Pin45=PD14 +Mcu.Pin46=PD15 +Mcu.Pin47=PG2 +Mcu.Pin48=PG3 +Mcu.Pin49=PG4 Mcu.Pin5=PF1 -RCC.HSE_VALUE=8000000 +Mcu.Pin50=PG5 +Mcu.Pin51=PC6 +Mcu.Pin52=PA9 +Mcu.Pin53=PA11 +Mcu.Pin54=PA12 +Mcu.Pin55=PA13 +Mcu.Pin56=PA14 +Mcu.Pin57=PD0 +Mcu.Pin58=PD1 +Mcu.Pin59=PD4 +Mcu.Pin6=PF2 +Mcu.Pin60=PD5 +Mcu.Pin61=PG10 +Mcu.Pin62=PB3 +Mcu.Pin63=PB6 +Mcu.Pin64=PB7 +Mcu.Pin65=PE0 +Mcu.Pin66=PE1 +Mcu.Pin67=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin68=VP_SYS_VS_Systick +Mcu.Pin7=PF3 +Mcu.Pin8=PF4 +Mcu.Pin9=PF5 +Mcu.PinsNb=69 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F405ZGTx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA1_Stream3_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA1_Stream4_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -ADC3.InjNumberOfConversion=0 -Mcu.IP10=USB_DEVICE +NVIC.EXTI2_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SPI2_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -SH.FSMC_D6_DA6.ConfNb=1 -Dma.UART4_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Mcu.IP11=USB_OTG_FS -SH.FSMC_A16_CLE.ConfNb=1 -SH.FSMC_NBL0.0=FSMC_NBL0,2ByteEnable1 -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -SH.FSMC_A17_ALE.ConfNb=1 -PE13.Signal=FSMC_D10_DA10 -SH.FSMC_D14_DA14.0=FSMC_D14,16b-d1 -Dma.ADC3.3.Mode=DMA_CIRCULAR -RCC.VCOInputFreq_Value=1000000 -SH.FSMC_A14.0=FSMC_A14,19b-a1 +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13.Mode=Trace_Asynchronous_SW +PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Trace_Asynchronous_SW -ADC3.Rank-94\#ChannelRegularConversion=3 -SH.FSMC_D6_DA6.0=FSMC_D6,16b-d1 -File.Version=6 +PA14.Signal=SYS_JTCK-SWCLK +PA2.GPIOParameters=GPIO_Label +PA2.GPIO_Label=EXP1_RING +PA2.Locked=true +PA2.Signal=ADCx_IN2 +PA3.GPIOParameters=GPIO_Label +PA3.GPIO_Label=EXP1_TIP +PA3.Locked=true +PA3.Signal=ADCx_IN3 +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB10.GPIOParameters=GPIO_Label,GPIO_Pu +PB10.GPIO_Label=I2C_SCK +PB10.GPIO_Pu=GPIO_PULLUP +PB10.Locked=true +PB10.Mode=I2C +PB10.Signal=I2C2_SCL +PB11.GPIOParameters=GPIO_Label,GPIO_Pu +PB11.GPIO_Label=I2C_SDA +PB11.GPIO_Pu=GPIO_PULLUP +PB11.Mode=I2C +PB11.Signal=I2C2_SDA +PB12.GPIOParameters=GPIO_Label +PB12.GPIO_Label=I2S_LRCK +PB12.Mode=Full_Duplex_Slave +PB12.Signal=I2S2_WS +PB13.GPIOParameters=GPIO_Label +PB13.GPIO_Label=I2S_SCLK +PB13.Locked=true +PB13.Mode=Full_Duplex_Slave +PB13.Signal=I2S2_CK +PB14.GPIOParameters=GPIO_Label +PB14.GPIO_Label=I2S_SDI +PB14.Locked=true +PB14.Mode=Full_Duplex_Slave +PB14.Signal=I2S2_ext_SD +PB15.GPIOParameters=GPIO_Label +PB15.GPIO_Label=I2S_SDO +PB15.Locked=true +PB15.Mode=Full_Duplex_Slave +PB15.Signal=I2S2_SD +PB3.Mode=Trace_Asynchronous_SW +PB3.Signal=SYS_JTDO-SWO +PB6.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB6.GPIO_Label=PUSH_GATE_IN +PB6.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB6.GPIO_PuPd=GPIO_PULLUP +PB6.Locked=true +PB6.Signal=GPXTI6 +PB7.GPIOParameters=PinState,GPIO_Label +PB7.GPIO_Label=PUSH_GATE_OUT +PB7.Locked=true +PB7.PinState=GPIO_PIN_SET +PB7.Signal=GPIO_Output +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=ADC1 +PC0.Locked=true +PC0.Signal=ADCx_IN10 +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC2 +PC1.Locked=true +PC1.Signal=ADCx_IN11 +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC3 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC4 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC6.GPIOParameters=GPIO_Label +PC6.GPIO_Label=I2S_MCLK +PC6.Locked=true +PC6.Signal=GPIO_Input +PD0.Signal=FSMC_D2_DA2 +PD1.Signal=FSMC_D3_DA3 +PD10.Signal=FSMC_D15_DA15 +PD11.Signal=FSMC_A16_CLE +PD12.Signal=FSMC_A17_ALE +PD13.Signal=FSMC_A18 +PD14.Signal=FSMC_D0_DA0 +PD15.Signal=FSMC_D1_DA1 +PD4.Signal=FSMC_NOE +PD5.Signal=FSMC_NWE +PD8.Signal=FSMC_D13_DA13 +PD9.Signal=FSMC_D14_DA14 +PE0.Locked=true +PE0.Signal=FSMC_NBL0 +PE1.Locked=true +PE1.Signal=FSMC_NBL1 +PE10.Signal=FSMC_D7_DA7 +PE11.Signal=FSMC_D8_DA8 +PE12.Signal=FSMC_D9_DA9 +PE13.Signal=FSMC_D10_DA10 +PE14.Signal=FSMC_D11_DA11 +PE15.Signal=FSMC_D12_DA12 +PE2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PE2.GPIO_Label=SW1 +PE2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PE2.GPIO_PuPd=GPIO_PULLUP +PE2.Locked=true +PE2.Signal=GPXTI2 PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.FSMC_D9_DA9.ConfNb=1 -SH.ADCx_IN13.ConfNb=1 -SH.FSMC_A8.0=FSMC_A8,19b-a1 -Dma.ADC3.3.MemInc=DMA_MINC_ENABLE -Dma.ADC3.3.FIFOMode=DMA_FIFOMODE_DISABLE +PE3.GPIO_Label=LED_RED PE3.Locked=true -PB7.Signal=GPIO_Output -NVIC.SPI2_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -I2S2.DataFormat=I2S_DATAFORMAT_24B +PE3.Signal=GPIO_Output +PE4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PE4.GPIO_Label=FOOTSWITCH +PE4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PE4.GPIO_PuPd=GPIO_PULLUP +PE4.Locked=true PE4.Signal=GPXTI4 -Dma.RequestsNb=4 -PB6.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -FREERTOS.configTOTAL_HEAP_SIZE=4096 -ProjectManager.ProjectName=OwlPedal -SH.FSMC_D4_DA4.0=FSMC_D4,16b-d1 -PH1-OSC_OUT.Mode=HSE-External-Oscillator -PB7.GPIO_Label=PUSH_GATE_OUT -ADC3.SamplingTime-95\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-MIDI -SH.FSMC_A2.ConfNb=1 -PB12.Mode=Full_Duplex_Slave -Dma.SPI2_TX.1.Mode=DMA_CIRCULAR -SH.FSMC_NBL1.0=FSMC_NBL1,2ByteEnable1 -Dma.I2S2_EXT_RX.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -ProjectManager.ToolChainLocation= -PA2.GPIO_Label=ADC5 -RCC.LSI_VALUE=32000 -SH.FSMC_D13_DA13.0=FSMC_D13,16b-d1 -USB_OTG_FS.VirtualMode=Device_Only -SH.FSMC_A13.0=FSMC_A13,19b-a1 -SH.FSMC_A13.ConfNb=1 -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -PF5.Signal=FSMC_A5 -SH.FSMC_A9.0=FSMC_A9,19b-a1 -Dma.Request2=I2S2_EXT_RX -Dma.Request1=SPI2_TX -Dma.Request3=ADC3 -PC4.Locked=true -SH.FSMC_D2_DA2.0=FSMC_D2,16b-d1 -SH.FSMC_NWE.ConfNb=1 -PF0.Signal=FSMC_A0 -PC5.Signal=GPIO_Output +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=LED_GREEN +PE5.Locked=true +PE5.Signal=GPIO_Output PE7.Signal=FSMC_D4_DA4 -Dma.Request0=UART4_RX -PE2.GPIO_Label=PUSHBUTTON -PC2.GPIO_Label=ADC3 -PB15.Locked=true -PA3.Signal=GPIO_Output -PA2.Locked=true -ADC3.DiscontinuousConvMode=DISABLE -SH.ADCx_IN13.0=ADC3_IN13,IN13 -SH.FSMC_D12_DA12.0=FSMC_D12,16b-d1 -I2S2.Instance=SPI$Index -UART4.IPParameters=VirtualMode -FSMC.WriteOperation1=FSMC_WRITE_OPERATION_ENABLE -ProjectManager.NoMain=false -USB_DEVICE.VirtualModeFS=Audio_FS -PG3.Signal=FSMC_A13 +PE8.Signal=FSMC_D5_DA5 +PE9.Signal=FSMC_D6_DA6 +PF0.Signal=FSMC_A0 +PF1.Signal=FSMC_A1 +PF12.Signal=FSMC_A6 +PF13.Signal=FSMC_A7 +PF14.Signal=FSMC_A8 +PF15.Signal=FSMC_A9 +PF2.Signal=FSMC_A2 +PF3.Signal=FSMC_A3 +PF4.Signal=FSMC_A4 +PF5.Signal=FSMC_A5 +PG0.Signal=FSMC_A10 PG1.Signal=FSMC_A11 -FSMC.ExtendedMode1=FSMC_EXTENDED_MODE_DISABLE -NVIC.SavedSvcallIrqHandlerGenerated=true -PC4.Signal=GPIO_Output PG10.Mode=NorPsramChipSelect3_1 -PE4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG10.Signal=FSMC_NE3 +PG2.Signal=FSMC_A12 +PG3.Signal=FSMC_A13 +PG4.Signal=FSMC_A14 +PG5.Signal=FSMC_A15 +PH0-OSC_IN.Mode=HSE-External-Oscillator +PH0-OSC_IN.Signal=RCC_OSC_IN +PH1-OSC_OUT.Mode=HSE-External-Oscillator +PH1-OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= ProjectManager.DefaultFWLocation=true -Dma.I2S2_EXT_RX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PD5.Signal=FSMC_NWE -PD9.Signal=FSMC_D14_DA14 -SH.FSMC_D11_DA11.ConfNb=1 ProjectManager.DeletePrevious=true -PB10.Locked=true -USB_DEVICE.IPParameters=VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,SERIALNUMBER_STRING_AUDIO_FS,PRODUCT_STRING_AUDIO_FS,VirtualMode-AUDIO_FS -Dma.I2S2_EXT_RX.2.Direction=DMA_PERIPH_TO_MEMORY -RCC.FamilyName=M -PA0-WKUP.Locked=true -SH.GPXTI6.0=GPIO_EXTI6 -PA13.Signal=SYS_JTMS-SWDIO -SH.FSMC_D13_DA13.ConfNb=1 -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -PA9.Mode=Activate_VBUS -SH.ADCx_IN12.0=ADC3_IN12,IN12 -ADC3.Rank-95\#ChannelRegularConversion=4 -Dma.UART4_RX.0.Direction=DMA_PERIPH_TO_MEMORY -ProjectManager.TargetToolchain=Makefile -PB10.GPIO_Label=I2C_SCK -SH.FSMC_A18.ConfNb=1 -ADC3.Channel-94\#ChannelRegularConversion=ADC_CHANNEL_12 -PB7.GPIOParameters=PinState,GPIO_Label -PC5.GPIOParameters=GPIO_Label -PE4.Locked=true -PF2.Signal=FSMC_A2 -PE2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PC2.Locked=true +ProjectManager.DeviceId=STM32F405ZGTx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=0 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=OwlPedal.ioc +ProjectManager.ProjectName=OwlPedal ProjectManager.RegisterCallBack= -PE0.Locked=true -USB_DEVICE.SERIALNUMBER_STRING_AUDIO_FS=00000000010A -PE11.Signal=FSMC_D8_DA8 +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_I2S2_Init-I2S2-false-HAL-true,5-MX_ADC3_Init-ADC3-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true,7-MX_FSMC_Init-FSMC-false-HAL-true,8-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=168000000 +RCC.HSE_VALUE=8000000 +RCC.HSI_VALUE=16000000 +RCC.I2SClocksFreq_Value=86000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SN,PLLI2SR,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S RCC.LSE_VALUE=32768 -PA1.Signal=UART4_RX +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SN=258 +RCC.PLLI2SR=3 +RCC.PLLM=8 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=4000000 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.VCOI2SOutputFreq_Value=258000000 -SH.FSMC_A7.ConfNb=1 -board=OwlPedal -SH.FSMC_D0_DA0.ConfNb=1 -Dma.SPI2_TX.1.Direction=DMA_MEMORY_TO_PERIPH +RCC.VCOInputFreq_Value=1000000 RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Full_Duplex_Slave -Dma.ADC3.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.UART4_RX.0.Priority=DMA_PRIORITY_LOW -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=84000000 -Dma.ADC3.3.Priority=DMA_PRIORITY_LOW -SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=5.6.1 +RCC.VcooutputI2S=86000000 +SH.ADCx_IN10.0=ADC3_IN10,IN10 SH.ADCx_IN10.ConfNb=1 +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.ADCx_IN2.0=ADC3_IN2,IN2 SH.ADCx_IN2.ConfNb=1 -PC1.GPIO_Label=ADC2 -VP_SYS_VS_Systick.Mode=SysTick -PH1-OSC_OUT.Signal=RCC_OSC_OUT -Dma.UART4_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PF15.Signal=FSMC_A9 -PE5.Locked=true -PF1.Signal=FSMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -PB15.GPIOParameters=GPIO_Label -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SN,PLLI2SR,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S -ProjectManager.AskForMigrate=true -Mcu.Name=STM32F405ZGTx -PE0.Signal=FSMC_NBL0 -PE12.Signal=FSMC_D9_DA9 -ADC3.SamplingTime-94\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -NVIC.SavedPendsvIrqHandlerGenerated=true -PA2.Signal=ADCx_IN2 -Mcu.IP8=SYS -Mcu.IP9=UART4 -PD14.Signal=FSMC_D0_DA0 -Mcu.IP6=NVIC -Mcu.IP7=RCC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -PB3.Signal=SYS_JTDO-SWO -RCC.SYSCLKFreq_VALUE=168000000 +SH.ADCx_IN3.0=ADC3_IN3,IN3 +SH.ADCx_IN3.ConfNb=1 +SH.FSMC_A0.0=FSMC_A0,19b-a1 +SH.FSMC_A0.ConfNb=1 +SH.FSMC_A1.0=FSMC_A1,19b-a1 +SH.FSMC_A1.ConfNb=1 +SH.FSMC_A10.0=FSMC_A10,19b-a1 +SH.FSMC_A10.ConfNb=1 +SH.FSMC_A11.0=FSMC_A11,19b-a1 +SH.FSMC_A11.ConfNb=1 +SH.FSMC_A12.0=FSMC_A12,19b-a1 +SH.FSMC_A12.ConfNb=1 +SH.FSMC_A13.0=FSMC_A13,19b-a1 +SH.FSMC_A13.ConfNb=1 +SH.FSMC_A14.0=FSMC_A14,19b-a1 +SH.FSMC_A14.ConfNb=1 +SH.FSMC_A15.0=FSMC_A15,19b-a1 +SH.FSMC_A15.ConfNb=1 +SH.FSMC_A16_CLE.0=FSMC_A16,19b-a1 +SH.FSMC_A16_CLE.ConfNb=1 +SH.FSMC_A17_ALE.0=FSMC_A17,19b-a1 +SH.FSMC_A17_ALE.ConfNb=1 +SH.FSMC_A18.0=FSMC_A18,19b-a1 +SH.FSMC_A18.ConfNb=1 +SH.FSMC_A2.0=FSMC_A2,19b-a1 +SH.FSMC_A2.ConfNb=1 +SH.FSMC_A3.0=FSMC_A3,19b-a1 +SH.FSMC_A3.ConfNb=1 +SH.FSMC_A4.0=FSMC_A4,19b-a1 +SH.FSMC_A4.ConfNb=1 +SH.FSMC_A5.0=FSMC_A5,19b-a1 +SH.FSMC_A5.ConfNb=1 +SH.FSMC_A6.0=FSMC_A6,19b-a1 SH.FSMC_A6.ConfNb=1 -SH.GPXTI4.0=GPIO_EXTI4 -PA12.Mode=Device_Only -I2S2.ErrorAudioFreq=-0.01 % -KeepUserPlacement=false -PC5.GPIO_Label=FLASH_nCS -NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -PA14.Signal=SYS_JTCK-SWCLK -SH.ADCx_IN10.0=ADC3_IN10,IN10 -SH.GPXTI4.ConfNb=1 +SH.FSMC_A7.0=FSMC_A7,19b-a1 +SH.FSMC_A7.ConfNb=1 +SH.FSMC_A8.0=FSMC_A8,19b-a1 +SH.FSMC_A8.ConfNb=1 +SH.FSMC_A9.0=FSMC_A9,19b-a1 +SH.FSMC_A9.ConfNb=1 +SH.FSMC_D0_DA0.0=FSMC_D0,16b-d1 +SH.FSMC_D0_DA0.ConfNb=1 +SH.FSMC_D10_DA10.0=FSMC_D10,16b-d1 +SH.FSMC_D10_DA10.ConfNb=1 SH.FSMC_D11_DA11.0=FSMC_D11,16b-d1 -PC6.GPIOParameters=GPIO_Label -SH.FSMC_NOE.0=FSMC_NOE,Sram1 -SH.FSMC_A12.ConfNb=1 +SH.FSMC_D11_DA11.ConfNb=1 +SH.FSMC_D12_DA12.0=FSMC_D12,16b-d1 +SH.FSMC_D12_DA12.ConfNb=1 +SH.FSMC_D13_DA13.0=FSMC_D13,16b-d1 +SH.FSMC_D13_DA13.ConfNb=1 +SH.FSMC_D14_DA14.0=FSMC_D14,16b-d1 +SH.FSMC_D14_DA14.ConfNb=1 +SH.FSMC_D15_DA15.0=FSMC_D15,16b-d1 +SH.FSMC_D15_DA15.ConfNb=1 +SH.FSMC_D1_DA1.0=FSMC_D1,16b-d1 +SH.FSMC_D1_DA1.ConfNb=1 +SH.FSMC_D2_DA2.0=FSMC_D2,16b-d1 SH.FSMC_D2_DA2.ConfNb=1 -RCC.HSI_VALUE=16000000 -RCC.PLLQ=7 -RCC.PLLM=8 -RCC.PLLN=336 -PB7.Locked=true -PE3.GPIO_Label=LED_RED -NVIC.DMA1_Stream3_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -RCC.APB1Freq_Value=42000000 -ADC3.NbrOfConversionFlag=1 -RCC.PLLI2SR=3 -I2S2.RealAudioFreq=47.991 KHz -RCC.PLLI2SN=258 -ProjectManager.DeviceId=STM32F405ZGTx -PB12.Signal=I2S2_WS -ProjectManager.LibraryCopy=0 -PA3.GPIO_Label=EXPRESSION_PEDAL_TIP -SH.FSMC_A1.ConfNb=1 +SH.FSMC_D3_DA3.0=FSMC_D3,16b-d1 +SH.FSMC_D3_DA3.ConfNb=1 +SH.FSMC_D4_DA4.0=FSMC_D4,16b-d1 +SH.FSMC_D4_DA4.ConfNb=1 +SH.FSMC_D5_DA5.0=FSMC_D5,16b-d1 +SH.FSMC_D5_DA5.ConfNb=1 +SH.FSMC_D6_DA6.0=FSMC_D6,16b-d1 +SH.FSMC_D6_DA6.ConfNb=1 +SH.FSMC_D7_DA7.0=FSMC_D7,16b-d1 +SH.FSMC_D7_DA7.ConfNb=1 +SH.FSMC_D8_DA8.0=FSMC_D8,16b-d1 +SH.FSMC_D8_DA8.ConfNb=1 +SH.FSMC_D9_DA9.0=FSMC_D9,16b-d1 +SH.FSMC_D9_DA9.ConfNb=1 +SH.FSMC_NBL0.0=FSMC_NBL0,2ByteEnable1 +SH.FSMC_NBL0.ConfNb=1 +SH.FSMC_NBL1.0=FSMC_NBL1,2ByteEnable1 +SH.FSMC_NBL1.ConfNb=1 +SH.FSMC_NOE.0=FSMC_NOE,Sram1 +SH.FSMC_NOE.ConfNb=1 +SH.FSMC_NWE.0=FSMC_NWE,Sram1 +SH.FSMC_NWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI4.0=GPIO_EXTI4 +SH.GPXTI4.ConfNb=1 +SH.GPXTI6.0=GPIO_EXTI6 +SH.GPXTI6.ConfNb=1 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +board=OwlPedal diff --git a/OwlPedal/Src/OwlPedal.cpp b/OwlPedal/Src/OwlPedal.cpp index f8242c98..893a9181 100644 --- a/OwlPedal/Src/OwlPedal.cpp +++ b/OwlPedal/Src/OwlPedal.cpp @@ -1,236 +1,487 @@ +#include #include "Owl.h" -#include "device.h" #include "errorhandlers.h" +#include "Codec.h" #include "MidiController.h" -#include "OpenWareMidiControl.h" +#include "ProgramManager.h" #include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" #include "PatchRegistry.h" -#include "ProgramManager.h" +#include "Pin.h" +#include "usb_device.h" + +#define PATCH_RESET_COUNTER (768/MAIN_LOOP_SLEEP_MS) +#define PATCH_CONFIG_COUNTER (3072/MAIN_LOOP_SLEEP_MS) +#define PATCH_INDICATOR_COUNTER (256/MAIN_LOOP_SLEEP_MS) + +#define BYPASS_MODE (ERROR_MODE+1) +#define ENTER_CONFIG_MODE (ERROR_MODE+2) + +static int16_t knobvalues[2]; +static uint8_t patchselect; +#define PATCH_CONFIG_KNOB_THRESHOLD (4096/8) +#define PATCH_CONFIG_PROGRAM_CONTROL ADC_A +#define PATCH_CONFIG_VOLUME_CONTROL ADC_D + +#ifdef OWL_MODULAR +/* analogue values A, B, C, D are inverted on OWL Modular */ +#define GET_ABCD(x) (4095 - getAnalogValue(x)) +#else +#define GET_ABCD(x) (getAnalogValue(x)) +#endif + +#if 0 +#define SW3_Pin EXP2_T_Pin +#define SW3_GPIO_Port EXP2_T_GPIO_Port +#define SW4_Pin EXP2_R_Pin +#define SW4_GPIO_Port EXP2_R_GPIO_Port + +Pin bypass_pin(GPIOA, GPIO_PIN_0); +Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass +#endif -#define PROGRAM_CHANGE_PUSHBUTTON_TICKS 2000 -// Number of buffers before patch switching kicks in, with 2 ms loop delay this should take 5.23 seconds +Pin exp1_tip_pin(EXP1_TIP_GPIO_Port, EXP1_TIP_Pin); +Pin exp1_ring_pin(EXP1_RING_GPIO_Port, EXP1_RING_Pin); -#ifndef abs -#define abs(x) ((x)>0?(x):-(x)) +#ifndef OWL_PEDAL_PWM_LEDS +Pin led_green_pin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); +Pin led_red_pin(LED_RED_GPIO_Port, LED_RED_Pin); #endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) + +// Pin footswitch_pin(GPIOA, GPIO_PIN_0); + +static uint32_t counter = 0; +static uint8_t expression_mode = 0; + +#if 0 +bool getBufferedBypass(){ + return !bufpass_pin.get(); +} + +void setBufferedBypass(bool value){ + // setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + bufpass_pin.set(!value); + // todo; set BYPASS_MODE +} +#endif + +bool isBypassed(){ +#ifdef OWL_PEDAL_LEGACY + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_SET; +#else + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; #endif + // todo: || getBufferedBypass() +} -extern uint32_t ledstatus; +bool isPushbuttonPressed(){ + return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET +#ifdef SW1_ALT_GPIO_Port + || HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET +#endif + ; +} + +#ifdef OWL_PEDAL +void configureExpression(uint8_t mode){ + if(mode != expression_mode){ + switch(mode){ + case EXPRESSION_MODE_EXP_TRS: + // Ring is available on ADC_F + exp1_ring_pin.outputMode(); + exp1_ring_pin.high(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + exp1_tip_pin.analogMode(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_EXP_RTS: + exp1_tip_pin.outputMode(); + exp1_tip_pin.high(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + exp1_ring_pin.analogMode(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_FS_TS: + case EXPRESSION_MODE_FS_TRS: + exp1_tip_pin.inputMode(); + exp1_tip_pin.setPull(PIN_PULL_UP); + exp1_ring_pin.inputMode(); + exp1_ring_pin.setPull(PIN_PULL_UP); + break; + } + expression_mode = mode; + setButtonValue(PUSHBUTTON, isPushbuttonPressed()); + setButtonValue(BUTTON_1, isPushbuttonPressed()); + setButtonValue(BUTTON_2, false); + } +} +#endif void initLed(){ +#ifdef OWL_PEDAL_PWM_LEDS + extern TIM_HandleTypeDef htim4; + HAL_TIM_Base_Start(&htim4); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); +#else + led_green_pin.outputMode(); + led_red_pin.outputMode(); +#endif } -static bool pushButtonPressed = 0; -static uint16_t pushButtonPressDuration = 0; -static uint16_t pushButtonAnimation = 0; -static uint8_t owlSelectedProgramId = 0; -static uint16_t bank = 0; -static uint16_t prog = 0; +uint32_t getLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - TIM4->CCR3; + uint32_t g = TIM4->CCR4; + return (r<<20) | (g<<10); +#else + if(!led_green_pin.get() && led_red_pin.get()) + return RED_COLOUR; + else if(led_green_pin.get() && !led_red_pin.get()) + return GREEN_COLOUR; + else + return NO_COLOUR; +#endif +} +void toggleLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(led, getLed(led) == GREEN_COLOUR ? RED_COLOUR : GREEN_COLOUR); + // uint32_t r = TIM4->CCR3; + // uint32_t g = TIM4->CCR4; + // TIM4->CCR3 = 1023 - r; + // TIM4->CCR4 = 1023 - g; +#else + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); +#endif +} + void setLed(uint8_t led, uint32_t rgb){ - // rgb should be a 3x 10 bit value +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - ((rgb>>20) & 0x3ff); + uint32_t g = ((rgb>>10) & 0x3ff); // green TIM4 has reverse polarity + TIM4->CCR3 = r; + TIM4->CCR4 = g; +#else switch(rgb){ case RED_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + led_green_pin.low(); + led_red_pin.high(); break; case GREEN_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + led_green_pin.high(); + led_red_pin.low(); break; case NO_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + led_green_pin.low(); + led_red_pin.low(); break; + default: + break; } +#endif } void onChangePin(uint16_t pin){ - switch(pin){ - case PUSHBUTTON_Pin: { - pushButtonPressed = !(PUSHBUTTON_GPIO_Port->IDR & PUSHBUTTON_Pin); - if (pushButtonPressed) { - // Rising edge - pushButtonAnimation = 0x96; - } - else { - // Falling edge - if (pushButtonPressDuration > PROGRAM_CHANGE_PUSHBUTTON_TICKS && owlSelectedProgramId > 0) { - // This runs unless button was depressed too early or the same - // patch as before was selected. - program.loadProgram(owlSelectedProgramId); - program.resetProgram(true); - pushButtonPressDuration = 0; - } - } - setButtonValue(BUTTON_A, pushButtonPressed); - setButtonValue(PUSHBUTTON, pushButtonPressed); - midi_tx.sendCc(PUSHBUTTON, pushButtonPressed ? 127 : 0); - setLed(0, pushButtonPressed ? RED_COLOUR : GREEN_COLOUR); - break; - } -#ifdef OWL_PEDAL - case BYPASS_Pin: { - bool isSet = BYPASS_GPIO_Port->IDR & BYPASS_Pin; - setLed(0, isSet ? NO_COLOUR : GREEN_COLOUR); - break; + if(pin == FOOTSWITCH_Pin){ + setButtonValue(0, isBypassed()); } + if(owl.getOperationMode() == RUN_MODE){ + switch(pin){ + // case FOOTSWITCH_Pin: { // bypass / stomp switch + // bool state = isBypassed(); + // setButtonValue(0, state); + // setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + // break; + // } +#ifdef SW1_ALT_Pin + case SW1_ALT_Pin: #endif + case SW1_Pin: { // pushbutton + bool state = isPushbuttonPressed(); + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_1, state); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + break; + } #ifdef OWL_MODULAR - case PUSH_GATE_IN_Pin: { - bool isSet = !(PUSH_GATE_IN_GPIO_Port->IDR & PUSH_GATE_IN_Pin); - setButtonValue(PUSHBUTTON, isSet); - setLed(0, isSet ? RED_COLOUR : GREEN_COLOUR); - break; - } + case PUSH_GATE_IN_Pin: { + bool state = !(PUSH_GATE_IN_GPIO_Port->IDR & PUSH_GATE_IN_Pin); + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_1, state); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + break; + } #endif + // case SW2_Pin: { // mode button + // bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_2, state); + // break; + // } + // case SW3_Pin: { // EXP2 Tip + // bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_3, state); + // break; + // } + // case SW4_Pin: { // EXP2 Ring + // bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_4, state); + // break; + // } + } } } -inline uint16_t getProgramSelection(){ - // This code is copied from original firmware. The only difference is that - // it won't be running in a separate OS task. So we won't be waiting for - // usable patch being selected. Instead of that, we return -1 for invalid - // selection - it should be ignored by the caller. - #ifdef OWL_MODULAR - float a = (4095 - getAnalogValue(PARAMETER_A)) * 5 / 4096.0;// - 0.5 / 5; - float b = (4095 - getAnalogValue(PARAMETER_B)) * 8 / 4096.0;// - 0.5 / 8; - #else - float a = getAnalogValue(PARAMETER_A) * 5 / 4096.0;// - 0.5 / 5; - float b = getAnalogValue(PARAMETER_B) * 8 / 4096.0;// - 0.5 / 8; - #endif - // deadband each segment: [0.9-1.1] - if(a > 0.f && abs(a - (uint16_t)(a + 0.1f)) > 0.1f) - bank = (uint16_t)a; - else if (a <= 0.1f) - bank = 0; // Ignore bottom dead zone - else if (a >= 5.0f - 0.1f) - bank = 4; // Ignore top dead zone - - // deadband each segment: [0.85-1.15] - // larger deadband because we have the same amount of noise spread over more zones - if(b > 0.f && abs(b - (uint16_t)(b + 0.15f)) > 0.15f) - prog = (uint16_t)b + 1; - else if (b <= 0.15f) - prog = 1; // Ignore bottom dead zone - else if (b >= 8.0f - 0.15f) - prog = 8; // Ignore top dead zone - - uint16_t pc = max(bank * 8 + prog, 1); - // We must check that patch exists to avoid loading from a gap in the patches list - if (registry.hasPatch(pc)) - return pc; - else - return 0; +void setGateValue(uint8_t ch, int16_t value){ + if(owl.getOperationMode() == RUN_MODE){ + value = (value >> 2) & 0x3ff; // use top 10 bits of 12 + switch(ch){ + case BUTTON_1: + case PUSHBUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value << 20) | ((1023 - value) << 10)); +#else + setLed(0, value < 512 ? GREEN_COLOUR : RED_COLOUR); +#endif +#ifdef OWL_MODULAR + HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); +#endif + break; + case GREEN_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, value << 10); +#else + setLed(0, value < 512 ? NO_COLOUR : GREEN_COLOUR); +#endif + break; + case RED_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, value << 20); +#else + setLed(0, value < 512 ? NO_COLOUR : RED_COLOUR); +#endif + break; + } + } + // if(ch == 0) + // setBufferedBypass(value); } -void setGateValue(uint8_t ch, int16_t value){ - switch (ch) { - case BUTTON_A: - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); - break; - case PUSHBUTTON: - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); - // deliberate fall-through - this synchronizes LED to pushbutton value - case BUTTON_B: +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + if(owl.getOperationMode() == RUN_MODE){ #ifdef OWL_MODULAR - HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); + parameter_values[0] = (parameter_values[0]*3 + 4095 - adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + 4095 - adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + 4095 - adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + 4095 - adc_values[ADC_D])>>2; + parameter_values[4] = (parameter_values[4]*3 + adc_values[ADC_E])>>2; +#else + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; + + static uint8_t fs_state = 0; + uint8_t buttons = 0; + switch(expression_mode){ + case EXPRESSION_MODE_EXP_TRS: + parameter_values[4] = (parameter_values[4]*3 + adc_values[ADC_E])>>2; + break; + case EXPRESSION_MODE_EXP_ITRS: + parameter_values[4] = (parameter_values[4]*3 + 4095 - adc_values[ADC_E])>>2; + break; + case EXPRESSION_MODE_EXP_RTS: + parameter_values[4] = (parameter_values[4]*3 + adc_values[ADC_F])>>2; + break; + case EXPRESSION_MODE_EXP_IRTS: + parameter_values[4] = (parameter_values[4]*3 + 4095 - adc_values[ADC_F])>>2; + break; + case EXPRESSION_MODE_FS_TRS: + buttons = (!exp1_ring_pin.get()) << BUTTON_2; + buttons |= (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + if((buttons & (1 << BUTTON_2)) != (fs_state & (1 << BUTTON_2))){ + setButtonValue(BUTTON_2, buttons & (1 << BUTTON_2)); + } + if((buttons & (1 << BUTTON_1)) != (fs_state & (1 << BUTTON_1))){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + } + fs_state = buttons; + } + break; + case EXPRESSION_MODE_FS_TS: + buttons = (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + fs_state = buttons; + } + break; + } #endif - break; - case GREEN_BUTTON: - setLed(0, value ? GREEN_COLOUR : NO_COLOUR); - break; - case RED_BUTTON: - setLed(0, value ? RED_COLOUR : NO_COLOUR); } } -void setup(){ +void onSetup(){ + initLed(); +#if 0 + bypass_pin.outputMode(); + bypass_pin.low(); + bufpass_pin.outputMode(); + bufpass_pin.low(); + setBufferedBypass(false); +#endif #ifdef OWL_PEDAL - /* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported */ - // if (HAL_GetREVID() == 0x1001) - // { - // /* Enable the Flash prefetch */ - // __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); - // } - // enable expression pedal reference voltage - HAL_GPIO_WritePin(EXPRESSION_PEDAL_TIP_GPIO_Port, EXPRESSION_PEDAL_TIP_Pin, GPIO_PIN_SET); - // todo: on OWL Modular the ADC should read Exp pin PA2 instead of PA3 -#endif - owl.setup(); - } - -#define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) - -void loop(){ - static uint32_t counter = PATCH_RESET_COUNTER; + configureExpression(settings.expression_mode); +#endif + setLed(0, RED_COLOUR); + + MX_USB_DEVICE_Init(); + +} + +void onStartProgram(){ + setLed(0, GREEN_COLOUR); +} + +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + counter = 0; + static uint32_t saved_led = NO_COLOUR; + if(old_mode == RUN_MODE){ + saved_led = getLed(0); // leaving RUN_MODE, save LED state + } + setLed(0, NO_COLOUR); + if(new_mode == CONFIGURE_MODE){ + knobvalues[0] = GET_ABCD(PATCH_CONFIG_PROGRAM_CONTROL); + knobvalues[1] = GET_ABCD(PATCH_CONFIG_VOLUME_CONTROL); + patchselect = program.getProgramIndex(); + }else if(new_mode == RUN_MODE){ + setLed(0, saved_led); // restore to saved LED state + } +} + +// static uint16_t progress = 0; +void setProgress(uint16_t value, const char* msg){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value<<18) & (0x3ff<<20)); +#else + toggleLed(0); +#endif +} + +void onLoop(){ switch(owl.getOperationMode()){ case STARTUP_MODE: - case LOAD_MODE: + case STREAM_MODE: setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; + break; + case LOAD_MODE: + // setLed(0, counter > PATCH_INDICATOR_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + // todo: use setProgress()? + // if(counter-- == 0) + // counter = PATCH_RESET_COUNTER; + break; + case BYPASS_MODE: + if(!isBypassed()){ + owl.setOperationMode(RUN_MODE); + }else if(isPushbuttonPressed()){ + owl.setOperationMode(ENTER_CONFIG_MODE); + } break; case RUN_MODE: - if(getErrorStatus() != NO_ERROR) + if(getErrorStatus() != NO_ERROR){ owl.setOperationMode(ERROR_MODE); - else if (pushButtonPressed) { - if (pushButtonPressDuration++> PROGRAM_CHANGE_PUSHBUTTON_TICKS){ - // Pushbutton kept pressed above threshold, overflow is prevented - pushButtonPressDuration = PROGRAM_CHANGE_PUSHBUTTON_TICKS + 1; - if (pushButtonAnimation){ - // Pulse as we unlock patch selection - if ((pushButtonAnimation-- & 0xf) == 0){ - HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); - HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); - } - if (!pushButtonAnimation){ - // Animation just finished and we're ready to select patches on next cycle - owlSelectedProgramId = 0; -#ifdef OWL_MODULAR - bank = (4095 - getAnalogValue(PARAMETER_A)) * 5 / 4096; - prog = (4095 - getAnalogValue(PARAMETER_B)) * 8 / 4096 + 1; -#else - bank = getAnalogValue(PARAMETER_A) * 5 / 4096; - prog = getAnalogValue(PARAMETER_B) * 8 / 4096 + 1; -#endif - } - } - else { - // Ready to check for patch selection - uint16_t newOwlProgramId = getProgramSelection(); - if (!owlSelectedProgramId) { - // No program selected yet - if (!newOwlProgramId) { - // No color if nothing is selected - setLed(0, NO_COLOUR); - } - else { - // First selection, color chosen based on patch number - owlSelectedProgramId = newOwlProgramId; - setLed(0, (owlSelectedProgramId & 1) ? GREEN_COLOUR : RED_COLOUR); - } - } - else if (newOwlProgramId != owlSelectedProgramId && newOwlProgramId > 0){ - // Toggle pushbutton LEDs if patch number was changed - owlSelectedProgramId = newOwlProgramId; - HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); - HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); - } - } + }else if(isPushbuttonPressed()){ + if(--counter == 0){ // counter == 0 when we enter RUN_MODE + owl.setOperationMode(ENTER_CONFIG_MODE); + }else if(counter < PATCH_RESET_COUNTER && counter % 128 == 0){ + toggleLed(0); } + }else if(isBypassed()){ + // don't change to BYPASS_MODE while pushbutton is pressed + // (we might have just come from CONFIGURATION_MODE) + owl.setOperationMode(BYPASS_MODE); + }else{ + counter = PATCH_CONFIG_COUNTER; + } + break; + case ENTER_CONFIG_MODE: + if(isPushbuttonPressed()){ + // toggle rapidly for yellow-ish LED + toggleLed(0); + }else{ + owl.setOperationMode(CONFIGURE_MODE); } break; case CONFIGURE_MODE: - owl.setOperationMode(RUN_MODE); + if(isPushbuttonPressed()){ // exit configure mode + if(program.getProgramIndex() != patchselect && + registry.hasPatch(patchselect)){ + program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + program.resetProgram(false); + }else{ + owl.setOperationMode(RUN_MODE); + } + }else{ + // update patch control + if(abs(knobvalues[0] - GET_ABCD(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; + float pos = 0.5f + (GET_ABCD(PATCH_CONFIG_PROGRAM_CONTROL) * (registry.getNumberOfPatches() - 1)) / 4096.0f; + uint8_t idx = roundf(pos); + if(abs(patchselect - pos) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone + patchselect = idx; + midi_tx.sendPc(patchselect); + // update patch indicator + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); + } + } + // update volume control + if(abs(knobvalues[1] - GET_ABCD(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; + uint8_t value = (GET_ABCD(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; + if(settings.audio_output_gain != value){ + settings.audio_output_gain = value; + codec.setOutputGain(value); + midi_tx.sendCc(MIDI_CC_VOLUME, value); + } + } + // indicator LED + if(counter-- == 0){ + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); // patch indicator + setLed(0, NO_COLOUR); + }else if(counter <= PATCH_RESET_COUNTER){ + if(patchselect == 0){ + // toggle rapidly for yellow-ish LED + toggleLed(0); + }else{ + setLed(0, NO_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % (2*PATCH_INDICATOR_COUNTER) == 0){ + if((counter - PATCH_RESET_COUNTER) >= 10*PATCH_INDICATOR_COUNTER){ + counter -= 8*PATCH_INDICATOR_COUNTER; + setLed(0, RED_COLOUR); + }else{ + setLed(0, GREEN_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % PATCH_INDICATOR_COUNTER == 0){ + setLed(0, NO_COLOUR); + } + } break; - case STREAM_MODE: case ERROR_MODE: + if(isPushbuttonPressed()) + owl.setOperationMode(ENTER_CONFIG_MODE); setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; break; } - if(--counter == 0) - counter = PATCH_RESET_COUNTER; - - owl.loop(); +#ifdef OWL_PEDAL + configureExpression(settings.expression_mode); +#endif } diff --git a/OwlPedal/Src/freertos.c b/OwlPedal/Src/freertos.c index 7a85e1ef..f5688229 100644 --- a/OwlPedal/Src/freertos.c +++ b/OwlPedal/Src/freertos.c @@ -54,7 +54,7 @@ #include "main.h" /* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ /* USER CODE END Includes */ diff --git a/OwlPedal/Src/main.c b/OwlPedal/Src/main.c index 1c5728b4..66644161 100644 --- a/OwlPedal/Src/main.c +++ b/OwlPedal/Src/main.c @@ -5,11 +5,9 @@ * @retval None */ /* USER CODE END Header */ - /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" -#include "usb_device.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -44,8 +42,7 @@ I2S_HandleTypeDef hi2s2; DMA_HandleTypeDef hdma_spi2_tx; DMA_HandleTypeDef hdma_i2s2_ext_rx; -UART_HandleTypeDef huart4; -DMA_HandleTypeDef hdma_uart4_rx; +PCD_HandleTypeDef hpcd_USB_OTG_FS; SRAM_HandleTypeDef hsram1; @@ -62,8 +59,8 @@ static void MX_DMA_Init(void); static void MX_I2S2_Init(void); static void MX_ADC3_Init(void); static void MX_I2C2_Init(void); -static void MX_UART4_Init(void); static void MX_FSMC_Init(void); +static void MX_USB_OTG_FS_PCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -184,8 +181,8 @@ int main(void) MX_I2S2_Init(); MX_ADC3_Init(); MX_I2C2_Init(); - MX_UART4_Init(); MX_FSMC_Init(); + MX_USB_OTG_FS_PCD_Init(); /* USER CODE BEGIN 2 */ SDRAM_Init(); @@ -244,13 +241,13 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; @@ -264,7 +261,7 @@ void SystemClock_Config(void) { Error_Handler(); } - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; @@ -277,13 +274,6 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - PeriphClkInitStruct.PLLI2S.PLLI2SN = 258; - PeriphClkInitStruct.PLLI2S.PLLI2SR = 3; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } } /** @@ -314,7 +304,7 @@ static void MX_ADC3_Init(void) hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc3.Init.NbrOfConversion = 5; + hadc3.Init.NbrOfConversion = 6; hadc3.Init.DMAContinuousRequests = ENABLE; hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; if (HAL_ADC_Init(&hadc3) != HAL_OK) @@ -362,6 +352,14 @@ static void MX_ADC3_Init(void) { Error_Handler(); } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_3; + sConfig.Rank = 6; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC3_Init 2 */ /* USER CODE END ADC3_Init 2 */ @@ -437,35 +435,37 @@ static void MX_I2S2_Init(void) } /** - * @brief UART4 Initialization Function + * @brief USB_OTG_FS Initialization Function * @param None * @retval None */ -static void MX_UART4_Init(void) +static void MX_USB_OTG_FS_PCD_Init(void) { - /* USER CODE BEGIN UART4_Init 0 */ + /* USER CODE BEGIN USB_OTG_FS_Init 0 */ - /* USER CODE END UART4_Init 0 */ + /* USER CODE END USB_OTG_FS_Init 0 */ - /* USER CODE BEGIN UART4_Init 1 */ + /* USER CODE BEGIN USB_OTG_FS_Init 1 */ - /* USER CODE END UART4_Init 1 */ - huart4.Instance = UART4; - huart4.Init.BaudRate = 115200; - huart4.Init.WordLength = UART_WORDLENGTH_8B; - huart4.Init.StopBits = UART_STOPBITS_1; - huart4.Init.Parity = UART_PARITY_NONE; - huart4.Init.Mode = UART_MODE_TX_RX; - huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart4.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart4) != HAL_OK) + /* USER CODE END USB_OTG_FS_Init 1 */ + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) { Error_Handler(); } - /* USER CODE BEGIN UART4_Init 2 */ + /* USER CODE BEGIN USB_OTG_FS_Init 2 */ - /* USER CODE END UART4_Init 2 */ + /* USER CODE END USB_OTG_FS_Init 2 */ } @@ -480,9 +480,6 @@ static void MX_DMA_Init(void) __HAL_RCC_DMA2_CLK_ENABLE(); /* DMA interrupt init */ - /* DMA1_Stream2_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); /* DMA1_Stream3_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 8, 0); HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); @@ -517,17 +514,14 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOE, LED_RED_Pin|LED_GREEN_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(EXPRESSION_PEDAL_TIP_GPIO_Port, EXPRESSION_PEDAL_TIP_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4|FLASH_nCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, GPIO_PIN_SET); - /*Configure GPIO pins : PUSHBUTTON_Pin BYPASS_Pin */ - GPIO_InitStruct.Pin = PUSHBUTTON_Pin|BYPASS_Pin; + /*Configure GPIO pins : SW1_Pin FOOTSWITCH_Pin */ + GPIO_InitStruct.Pin = SW1_Pin|FOOTSWITCH_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); @@ -563,17 +557,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pin : EXPRESSION_PEDAL_TIP_Pin */ - GPIO_InitStruct.Pin = EXPRESSION_PEDAL_TIP_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(EXPRESSION_PEDAL_TIP_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : PA4 PA5 PA6 PA7 - PA8 PA10 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA1 PA4 PA5 + PA6 PA7 PA8 PA10 + PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_10 + |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -706,8 +695,6 @@ static void MX_FSMC_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); /* USER CODE BEGIN 5 */ /* Infinite loop */ for(;;) diff --git a/OwlPedal/Src/stm32f4xx_hal_msp.c b/OwlPedal/Src/stm32f4xx_hal_msp.c index a3b96a2b..9b420b24 100644 --- a/OwlPedal/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal/Src/stm32f4xx_hal_msp.c @@ -60,8 +60,6 @@ extern DMA_HandleTypeDef hdma_spi2_tx; extern DMA_HandleTypeDef hdma_i2s2_ext_rx; -extern DMA_HandleTypeDef hdma_uart4_rx; - /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ @@ -132,25 +130,26 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_ADC3_CLK_ENABLE(); - + __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); - /**ADC3 GPIO Configuration + /**ADC3 GPIO Configuration PC0 ------> ADC3_IN10 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 - PA2 ------> ADC3_IN2 + PA2 ------> ADC3_IN2 + PA3 ------> ADC3_IN3 */ GPIO_InitStruct.Pin = ADC1_Pin|ADC2_Pin|ADC3_Pin|ADC4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = ADC5_Pin; + GPIO_InitStruct.Pin = EXP1_RING_Pin|EXP1_TIP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ADC5_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* ADC3 DMA Init */ /* ADC3 Init */ @@ -193,17 +192,18 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_ADC3_CLK_DISABLE(); - - /**ADC3 GPIO Configuration + + /**ADC3 GPIO Configuration PC0 ------> ADC3_IN10 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 - PA2 ------> ADC3_IN2 + PA2 ------> ADC3_IN2 + PA3 ------> ADC3_IN3 */ HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC2_Pin|ADC3_Pin|ADC4_Pin); - HAL_GPIO_DeInit(ADC5_GPIO_Port, ADC5_Pin); + HAL_GPIO_DeInit(GPIOA, EXP1_RING_Pin|EXP1_TIP_Pin); /* ADC3 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); @@ -228,11 +228,11 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) /* USER CODE BEGIN I2C2_MspInit 0 */ /* USER CODE END I2C2_MspInit 0 */ - + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**I2C2 GPIO Configuration + /**I2C2 GPIO Configuration PB10 ------> I2C2_SCL - PB11 ------> I2C2_SDA + PB11 ------> I2C2_SDA */ GPIO_InitStruct.Pin = I2C_SCK_Pin|I2C_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; @@ -265,12 +265,14 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) /* USER CODE END I2C2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_I2C2_CLK_DISABLE(); - - /**I2C2 GPIO Configuration + + /**I2C2 GPIO Configuration PB10 ------> I2C2_SCL - PB11 ------> I2C2_SDA + PB11 ------> I2C2_SDA */ - HAL_GPIO_DeInit(GPIOB, I2C_SCK_Pin|I2C_SDA_Pin); + HAL_GPIO_DeInit(I2C_SCK_GPIO_Port, I2C_SCK_Pin); + + HAL_GPIO_DeInit(I2C_SDA_GPIO_Port, I2C_SDA_Pin); /* USER CODE BEGIN I2C2_MspDeInit 1 */ @@ -288,21 +290,32 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s) { GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hi2s->Instance==SPI2) { /* USER CODE BEGIN SPI2_MspInit 0 */ __HAL_RCC_PLLI2S_ENABLE(); /* USER CODE END SPI2_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; + PeriphClkInitStruct.PLLI2S.PLLI2SN = 258; + PeriphClkInitStruct.PLLI2S.PLLI2SR = 3; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_SPI2_CLK_ENABLE(); - + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**I2S2 GPIO Configuration + /**I2S2 GPIO Configuration PB12 ------> I2S2_WS PB13 ------> I2S2_CK PB14 ------> I2S2_ext_SD - PB15 ------> I2S2_SD + PB15 ------> I2S2_SD */ GPIO_InitStruct.Pin = I2S_LRCK_Pin|I2S_SCLK_Pin|I2S_SDO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -380,12 +393,12 @@ void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s) /* USER CODE END SPI2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI2_CLK_DISABLE(); - - /**I2S2 GPIO Configuration + + /**I2S2 GPIO Configuration PB12 ------> I2S2_WS PB13 ------> I2S2_CK PB14 ------> I2S2_ext_SD - PB15 ------> I2S2_SD + PB15 ------> I2S2_SD */ HAL_GPIO_DeInit(GPIOB, I2S_LRCK_Pin|I2S_SCLK_Pin|I2S_SDI_Pin|I2S_SDO_Pin); @@ -403,93 +416,78 @@ void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s) } /** -* @brief UART MSP Initialization +* @brief PCD MSP Initialization * This function configures the hardware resources used in this example -* @param huart: UART handle pointer +* @param hpcd: PCD handle pointer * @retval None */ -void HAL_UART_MspInit(UART_HandleTypeDef* huart) +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(huart->Instance==UART4) + if(hpcd->Instance==USB_OTG_FS) { - /* USER CODE BEGIN UART4_MspInit 0 */ + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ - /* USER CODE END UART4_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_UART4_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**UART4 GPIO Configuration - PA0-WKUP ------> UART4_TX - PA1 ------> UART4_RX + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF8_UART4; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /* UART4 DMA Init */ - /* UART4_RX Init */ - hdma_uart4_rx.Instance = DMA1_Stream2; - hdma_uart4_rx.Init.Channel = DMA_CHANNEL_4; - hdma_uart4_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_uart4_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_uart4_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_uart4_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_uart4_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_uart4_rx.Init.Mode = DMA_NORMAL; - hdma_uart4_rx.Init.Priority = DMA_PRIORITY_LOW; - hdma_uart4_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - if (HAL_DMA_Init(&hdma_uart4_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmarx,hdma_uart4_rx); - - /* UART4 interrupt Init */ - HAL_NVIC_SetPriority(UART4_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(UART4_IRQn); - /* USER CODE BEGIN UART4_MspInit 1 */ + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USB_OTG_FS interrupt Init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - /* USER CODE END UART4_MspInit 1 */ + /* USER CODE END USB_OTG_FS_MspInit 1 */ } } /** -* @brief UART MSP De-Initialization +* @brief PCD MSP De-Initialization * This function freeze the hardware resources used in this example -* @param huart: UART handle pointer +* @param hpcd: PCD handle pointer * @retval None */ -void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) { - if(huart->Instance==UART4) + if(hpcd->Instance==USB_OTG_FS) { - /* USER CODE BEGIN UART4_MspDeInit 0 */ + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - /* USER CODE END UART4_MspDeInit 0 */ + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ /* Peripheral clock disable */ - __HAL_RCC_UART4_CLK_DISABLE(); - - /**UART4 GPIO Configuration - PA0-WKUP ------> UART4_TX - PA1 ------> UART4_RX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1); + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - /* UART4 DMA DeInit */ - HAL_DMA_DeInit(huart->hdmarx); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); - /* UART4 interrupt DeInit */ - HAL_NVIC_DisableIRQ(UART4_IRQn); - /* USER CODE BEGIN UART4_MspDeInit 1 */ + /* USB_OTG_FS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - /* USER CODE END UART4_MspDeInit 1 */ + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ } } @@ -508,8 +506,8 @@ static void HAL_FSMC_MspInit(void){ /* Peripheral clock enable */ __HAL_RCC_FSMC_CLK_ENABLE(); - - /** FSMC GPIO Configuration + + /** FSMC GPIO Configuration PF0 ------> FSMC_A0 PF1 ------> FSMC_A1 PF2 ------> FSMC_A2 @@ -551,8 +549,8 @@ static void HAL_FSMC_MspInit(void){ PE0 ------> FSMC_NBL0 PE1 ------> FSMC_NBL1 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 |GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -560,7 +558,7 @@ static void HAL_FSMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -568,8 +566,8 @@ static void HAL_FSMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -577,8 +575,8 @@ static void HAL_FSMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 |GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -613,8 +611,8 @@ static void HAL_FSMC_MspDeInit(void){ FSMC_DeInitialized = 1; /* Peripheral clock enable */ __HAL_RCC_FSMC_CLK_DISABLE(); - - /** FSMC GPIO Configuration + + /** FSMC GPIO Configuration PF0 ------> FSMC_A0 PF1 ------> FSMC_A1 PF2 ------> FSMC_A2 @@ -656,19 +654,19 @@ static void HAL_FSMC_MspDeInit(void){ PE0 ------> FSMC_NBL0 PE1 ------> FSMC_NBL1 */ - HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 |GPIO_PIN_14|GPIO_PIN_15); - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_10); - HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 |GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5); /* USER CODE BEGIN FSMC_MspDeInit 1 */ diff --git a/OwlPedal/Src/stm32f4xx_it.c b/OwlPedal/Src/stm32f4xx_it.c index b47362b1..5208f682 100644 --- a/OwlPedal/Src/stm32f4xx_it.c +++ b/OwlPedal/Src/stm32f4xx_it.c @@ -73,13 +73,11 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_adc3; extern DMA_HandleTypeDef hdma_spi2_tx; extern DMA_HandleTypeDef hdma_i2s2_ext_rx; extern I2S_HandleTypeDef hi2s2; -extern DMA_HandleTypeDef hdma_uart4_rx; -extern UART_HandleTypeDef huart4; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -144,20 +142,6 @@ void EXTI4_IRQHandler(void) /* USER CODE END EXTI4_IRQn 1 */ } -/** - * @brief This function handles DMA1 stream2 global interrupt. - */ -void DMA1_Stream2_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ - - /* USER CODE END DMA1_Stream2_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_uart4_rx); - /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ - - /* USER CODE END DMA1_Stream2_IRQn 1 */ -} - /** * @brief This function handles DMA1 stream3 global interrupt. */ @@ -266,33 +250,6 @@ void SPI2_IRQHandler(void) /* USER CODE END SPI2_IRQn 1 */ } -/** - * @brief This function handles UART4 global interrupt. - */ -void UART4_IRQHandler(void) -{ - /* USER CODE BEGIN UART4_IRQn 0 */ - - /* USER CODE END UART4_IRQn 0 */ - HAL_UART_IRQHandler(&huart4); - /* USER CODE BEGIN UART4_IRQn 1 */ - /* Check for IDLE flag */ - UART_HandleTypeDef *huart = &huart4; - if(huart->Instance->SR & UART_FLAG_IDLE){ - /* This part is important */ - /* Clear IDLE flag by reading status and data registers */ - volatile uint32_t tmp; /* Must be volatile to prevent optimizations */ - tmp = huart->Instance->SR; /* Read status register */ - tmp = huart->Instance->DR; /* Read data register */ - (void)tmp; /* Prevent compiler warnings */ - if(huart->hdmarx != NULL) - huart->hdmarx->Instance->CR &= ~DMA_SxCR_EN; /* Disabling DMA will force transfer complete interrupt if enabled */ - /* DMA1_Stream2->CR &= ~DMA_SxCR_EN; /\* Disabling DMA will force transfer complete interrupt if enabled *\/ */ - } - - /* USER CODE END UART4_IRQn 1 */ -} - /** * @brief This function handles DMA2 stream0 global interrupt. */ diff --git a/OwlPedal/Src/usb_device.c b/OwlPedal/Src/usb_device.c index c1cf5446..723305ee 100644 --- a/OwlPedal/Src/usb_device.c +++ b/OwlPedal/Src/usb_device.c @@ -27,6 +27,7 @@ #include "usbd_audio.h" /* USER CODE BEGIN Includes */ +#include "device.h" /* USER CODE END Includes */ @@ -41,7 +42,7 @@ /* USER CODE END PFP */ /* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; +USBD_HandleTypeDef USBD_HANDLE; /* * -- Insert your variables declaration here -- @@ -68,19 +69,19 @@ void MX_USB_DEVICE_Init(void) /* USER CODE END USB_DEVICE_Init_PreTreatment */ /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + if (USBD_Init(&USBD_HANDLE, &USBD_DESC, USBD_HSFS) != USBD_OK) { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } diff --git a/OwlPedal/Src/usbd_conf.c b/OwlPedal/Src/usbd_conf.c index 96f0dcfe..9460a97a 100644 --- a/OwlPedal/Src/usbd_conf.c +++ b/OwlPedal/Src/usbd_conf.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -25,6 +25,8 @@ #include "usbd_def.h" #include "usbd_core.h" +#include "usbd_audio.h" + /* USER CODE BEGIN Includes */ #include "device.h" uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); @@ -39,7 +41,9 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -50,6 +54,7 @@ void SystemClock_Config(void); /* USER CODE BEGIN PFP */ /* Private function prototypes -----------------------------------------------*/ + USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /* USER CODE END PFP */ @@ -62,83 +67,18 @@ USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ -/* MSP Init */ - -void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - - /* USER CODE END USB_OTG_FS_MspInit 0 */ - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - - /* USER CODE END USB_OTG_FS_MspInit 1 */ - } -} -void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) -{ - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ - } -} +/* defined in stm32f4xx_hal_msp.c : + * void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) + * void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) + */ /** * @brief Setup stage callback * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); } @@ -149,11 +89,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } @@ -164,11 +100,7 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } @@ -178,11 +110,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); } @@ -192,12 +120,8 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ +{ USBD_SpeedTypeDef speed = USBD_SPEED_FULL; if ( hpcd->Init.speed == PCD_SPEED_HIGH) @@ -225,11 +149,7 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* Inform USB library that core enters in suspend Mode. */ USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); @@ -250,11 +170,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* USER CODE BEGIN 3 */ /* USER CODE END 3 */ @@ -267,11 +183,7 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -282,11 +194,7 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -296,11 +204,7 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -310,11 +214,7 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -330,44 +230,20 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { - /* Init USB Ip. */ - if (pdev->id == DEVICE_FS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_FS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_FS; - - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler( ); - } - -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) - /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); - } +#ifdef USE_USBD_FS + /* if (pdev->id == DEVICE_FS) { */ + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; +#endif + /* } else if (pdev->id == DEVICE_HS) { */ +#ifdef USE_USBD_HS + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; +#endif + /* } */ + USBD_AUDIO_SetFiFos(pdev->pData); return USBD_OK; } @@ -384,12 +260,12 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) hal_status = HAL_PCD_DeInit(pdev->pData); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** - * @brief Starts the low level portion of the device driver. + * @brief Starts the low level portion of the device driver. * @param pdev: Device handle * @retval USBD status */ @@ -397,11 +273,11 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_Start(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - + + usb_status = USBD_Get_USB_Status(hal_status); + return usb_status; } @@ -416,9 +292,9 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_Stop(pdev->pData); - + usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -438,7 +314,7 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -452,13 +328,13 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -471,12 +347,12 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -489,12 +365,12 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -507,12 +383,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -524,14 +400,14 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; - + if((ep_addr & 0x80) == 0x80) { - return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { - return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } @@ -545,12 +421,12 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); - + usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -558,7 +434,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a * @param pdev: Device handle * @param ep_addr: Endpoint number * @param pbuf: Pointer to data to be sent - * @param size: Data size + * @param size: Data size * @retval USBD status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) @@ -567,10 +443,10 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -587,23 +463,44 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** - * @brief Returns the last transfered packet size. + * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint number - * @retval Recived Data Size + * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms @@ -615,7 +512,7 @@ void USBD_LL_Delay(uint32_t Delay) } /** - * @brief Retuns the USB status depending on the HAL status: + * @brief Returns the USB status depending on the HAL status: * @param hal_status: HAL status * @retval USB status */ diff --git a/OwlPedal/Src/usbd_desc.c b/OwlPedal/Src/usbd_desc.c index c57c672d..5afb6ed8 100644 --- a/OwlPedal/Src/usbd_desc.c +++ b/OwlPedal/Src/usbd_desc.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -25,7 +25,7 @@ #include "usbd_conf.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /* Private typedef -----------------------------------------------------------*/ @@ -66,10 +66,10 @@ #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xDADA -#define USBD_PRODUCT_STRING_FS "OWL-MIDI" -#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" -#define USBD_INTERFACE_STRING_FS "AUDIO Interface" +#define USBD_PID_FSHS 0xDADA +#define USBD_PRODUCT_STRING_FSHS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_FSHS "AUDIO Config" +#define USBD_INTERFACE_STRING_FSHS "AUDIO Interface" #define USB_SIZ_BOS_DESC 0x0C @@ -97,34 +97,34 @@ /** * @} */ - + /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @brief Private functions declaration. * @{ */ - + static void Get_SerialNum(void); static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); - + /** * @} - */ - + */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for FS. + * @brief Private functions declaration for HS. * @{ */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + #if (USBD_LPM_ENABLED == 1) -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); #endif /* (USBD_LPM_ENABLED == 1) */ /** @@ -136,17 +136,17 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{ */ -USBD_DescriptorsTypeDef FS_Desc = +USBD_DescriptorsTypeDef USBD_DESC = { - USBD_FS_DeviceDescriptor -, USBD_FS_LangIDStrDescriptor -, USBD_FS_ManufacturerStrDescriptor -, USBD_FS_ProductStrDescriptor -, USBD_FS_SerialStrDescriptor -, USBD_FS_ConfigStrDescriptor -, USBD_FS_InterfaceStrDescriptor + USBD_FSHS_DeviceDescriptor +, USBD_FSHS_LangIDStrDescriptor +, USBD_FSHS_ManufacturerStrDescriptor +, USBD_FSHS_ProductStrDescriptor +, USBD_FSHS_SerialStrDescriptor +, USBD_FSHS_ConfigStrDescriptor +, USBD_FSHS_InterfaceStrDescriptor #if (USBD_LPM_ENABLED == 1) -, USBD_FS_USR_BOSDescriptor +, USBD_FSHS_USR_BOSDescriptor #endif /* (USBD_LPM_ENABLED == 1) */ }; @@ -154,7 +154,7 @@ USBD_DescriptorsTypeDef FS_Desc = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ /** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /*bLength */ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ @@ -165,6 +165,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = #else 0x00, /*bcdUSB */ #endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ @@ -172,8 +173,8 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_FS), /*idProduct*/ - HIBYTE(USBD_PID_FS), /*idProduct*/ + LOBYTE(USBD_PID_FSHS), /*idProduct*/ + HIBYTE(USBD_PID_FSHS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -182,24 +183,23 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ }; -/* USB_DeviceDescriptor */ /** BOS descriptor. */ #if (USBD_LPM_ENABLED == 1) #if defined ( __ICCARM__ ) /* IAR Compiler */ #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { 0x5, USB_DESC_TYPE_BOS, 0xC, 0x0, - 0x1, /* 1 device capability*/ - /* device capability*/ + 0x1, /* 1 device capability */ + /* device capability */ 0x7, USB_DEVICE_CAPABITY_TYPE, 0x2, - 0x2, /* LPM capability bit set*/ + 0x2, /*LPM capability bit set */ 0x0, 0x0, 0x0 @@ -219,7 +219,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -235,7 +235,7 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 + #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, @@ -257,11 +257,11 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_DeviceDesc); - return USBD_FS_DeviceDesc; + *length = sizeof(USBD_FSHS_DeviceDesc); + return USBD_FSHS_DeviceDesc; } /** @@ -270,7 +270,7 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = sizeof(USBD_LangIDDesc); @@ -279,19 +279,19 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /** * @brief Return the product string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer */ -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -302,7 +302,7 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); @@ -315,7 +315,7 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = USB_SIZ_STRING_SERIAL; @@ -323,9 +323,10 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); - /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ - - /* USER CODE END USBD_FS_SerialStrDescriptor */ + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; } @@ -335,15 +336,15 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -354,15 +355,15 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -374,17 +375,17 @@ uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_BOSDesc); - return (uint8_t*)USBD_FS_BOSDesc; + *length = sizeof(USBD_FSHS_BOSDesc); + return (uint8_t*)USBD_FSHS_BOSDesc; } #endif /* (USBD_LPM_ENABLED == 1) */ /** - * @brief Create the serial number string descriptor - * @param None + * @brief Create the serial number string descriptor + * @param None * @retval None */ static void Get_SerialNum(void) @@ -405,9 +406,9 @@ static void Get_SerialNum(void) } /** - * @brief Convert Hex 32Bits value into char + * @brief Convert Hex 32Bits value into char * @param value: value to convert - * @param pbuf: pointer to the buffer + * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ diff --git a/OwlPedal2/Inc/FreeRTOSConfig.h b/OwlPedal2/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..2b70be6a --- /dev/null +++ b/OwlPedal2/Inc/FreeRTOSConfig.h @@ -0,0 +1,189 @@ +/* USER CODE BEGIN Header */ +/* + FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. Full license text is available on the following + link: http://www.freertos.org/a00114.html + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * + * * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * + * * + *************************************************************************** + + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? + + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ + +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ + +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configENABLE_FPU 1 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)4096) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configENABLE_BACKWARD_COMPATIBILITY 0 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h new file mode 100644 index 00000000..b327c04f --- /dev/null +++ b/OwlPedal2/Inc/hardware.h @@ -0,0 +1,73 @@ +#include "main.h" +#include "stm32f4xx_hal.h" + +#define OWL_PEDAL +#define HARDWARE_ID OWL_PEDAL_HARDWARE +#define HARDWARE_VERSION "OWL Pedal mkII" + +#define EXPRESSION_MODE_EXP_TRS 1 +#define EXPRESSION_MODE_EXP_RTS 2 +#define EXPRESSION_MODE_FS_TS 3 // single footswitch +#define EXPRESSION_MODE_FS_TRS 4 // dual footswitch +#define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS + +#define OWL_PEDAL_PWM_LEDS + +#define USE_SPI_FLASH + +#define USE_USBD_HS +/* #define USE_USBD_FS */ + +#ifdef USE_USBD_FS +#define USBD_DESC FS_Desc +#define USBD_HSFS DEVICE_FS +#define USBD_HANDLE hUsbDeviceFS +#define USBD_PCD_HANDLE hpcd_USB_OTG_FS +#else +#define USBD_DESC HS_Desc +#define USBD_HSFS DEVICE_HS +#define USBD_HANDLE hUsbDeviceHS +#define USBD_PCD_HANDLE hpcd_USB_OTG_HS +#endif + +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + +#define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone + +#define USE_BKPSRAM +#define AUDIO_OUTPUT_GAIN 123 + + +/* #define USE_MODE_BUTTON */ +/* #define MODE_BUTTON_PIN SW3_Pin */ +/* #define MODE_BUTTON_PORT SW3_GPIO_Port */ +/* #define MODE_BUTTON_GAIN ADC_C */ +/* #define MODE_BUTTON_PATCH ADC_D */ + +#define USE_ADC +#define ADC_PERIPH hadc3 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 +#define ADC_E 4 +#define ADC_F 5 +#define USE_CODEC +#define USE_CS4271 +#define CODEC_HP_FILTER +#define CODEC_SPI hspi4 + +#define NOF_ADC_VALUES 6 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (2+4) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h new file mode 100644 index 00000000..0948f1f9 --- /dev/null +++ b/OwlPedal2/Inc/main.h @@ -0,0 +1,183 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define CS_SCK_Pin GPIO_PIN_2 +#define CS_SCK_GPIO_Port GPIOE +#define CS_SDOUT_Pin GPIO_PIN_3 +#define CS_SDOUT_GPIO_Port GPIOE +#define CS_LRCK_Pin GPIO_PIN_4 +#define CS_LRCK_GPIO_Port GPIOE +#define CS_SCKE5_Pin GPIO_PIN_5 +#define CS_SCKE5_GPIO_Port GPIOE +#define CS_SDA_Pin GPIO_PIN_6 +#define CS_SDA_GPIO_Port GPIOE +#define EXTSPI_nCS_Pin GPIO_PIN_15 +#define EXTSPI_nCS_GPIO_Port GPIOC +#define EXP2_T_Pin GPIO_PIN_7 +#define EXP2_T_GPIO_Port GPIOF +#define EXP2_T_EXTI_IRQn EXTI9_5_IRQn +#define EXP2_R_Pin GPIO_PIN_8 +#define EXP2_R_GPIO_Port GPIOF +#define EXP2_R_EXTI_IRQn EXTI9_5_IRQn +#define ADC4_Pin GPIO_PIN_10 +#define ADC4_GPIO_Port GPIOF +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOC +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOC +#define ADC1_Pin GPIO_PIN_3 +#define ADC1_GPIO_Port GPIOC +#define FOOTSWITCH_Pin GPIO_PIN_1 +#define FOOTSWITCH_GPIO_Port GPIOA +#define FOOTSWITCH_EXTI_IRQn EXTI1_IRQn +#define EXP_Pin GPIO_PIN_3 +#define EXP_GPIO_Port GPIOA +#define FLASH_MISO_Pin GPIO_PIN_6 +#define FLASH_MISO_GPIO_Port GPIOA +#define FLASH_MOSI_Pin GPIO_PIN_7 +#define FLASH_MOSI_GPIO_Port GPIOA +#define FLASH_HOLD_Pin GPIO_PIN_4 +#define FLASH_HOLD_GPIO_Port GPIOC +#define FLASH_nCS_Pin GPIO_PIN_5 +#define FLASH_nCS_GPIO_Port GPIOC +#define FLASH_WP_Pin GPIO_PIN_0 +#define FLASH_WP_GPIO_Port GPIOB +#define EXP_TIP_Pin GPIO_PIN_2 +#define EXP_TIP_GPIO_Port GPIOB +#define CS_nCS_Pin GPIO_PIN_10 +#define CS_nCS_GPIO_Port GPIOB +#define CS_nRST_Pin GPIO_PIN_11 +#define CS_nRST_GPIO_Port GPIOB +#define USBD_VBUS_Pin GPIO_PIN_9 +#define USBD_VBUS_GPIO_Port GPIOA +#define USBD_DM_Pin GPIO_PIN_11 +#define USBD_DM_GPIO_Port GPIOA +#define USBD_DP_Pin GPIO_PIN_12 +#define USBD_DP_GPIO_Port GPIOA +#define SW1_Pin GPIO_PIN_2 +#define SW1_GPIO_Port GPIOD +#define SW1_EXTI_IRQn EXTI2_IRQn +#define CS_SDIN_Pin GPIO_PIN_6 +#define CS_SDIN_GPIO_Port GPIOD +#define SW2_Pin GPIO_PIN_9 +#define SW2_GPIO_Port GPIOG +#define SW2_EXTI_IRQn EXTI9_5_IRQn +#define SW1_ALT_Pin GPIO_PIN_10 +#define SW1_ALT_GPIO_Port GPIOG +#define SW1_ALT_EXTI_IRQn EXTI15_10_IRQn +#define FLASH_SCK_Pin GPIO_PIN_3 +#define FLASH_SCK_GPIO_Port GPIOB +/* USER CODE BEGIN Private defines */ + +#define CS_CS_Pin GPIO_PIN_10 +#define CS_CS_GPIO_Port GPIOB +#define CS_RST_Pin GPIO_PIN_11 +#define CS_RST_GPIO_Port GPIOB + +#define USBD_VBUS_Pin GPIO_PIN_9 +#define USBD_VBUS_GPIO_Port GPIOA +#define USBD_ID_Pin GPIO_PIN_10 +#define USBD_ID_GPIO_Port GPIOA +#define USBD_DM_Pin GPIO_PIN_11 +#define USBD_DM_GPIO_Port GPIOA +#define USBD_DP_Pin GPIO_PIN_12 +#define USBD_DP_GPIO_Port GPIOA + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h new file mode 100644 index 00000000..2ea0e68a --- /dev/null +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -0,0 +1,492 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_I2C_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h new file mode 100644 index 00000000..1c8b5a32 --- /dev/null +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -0,0 +1,87 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32f4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * + * COPYRIGHT(c) 2019 STMicroelectronics + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_IT_H +#define __STM32F4xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void SysTick_Handler(void); +void EXTI1_IRQHandler(void); +void EXTI2_IRQHandler(void); +void ADC_IRQHandler(void); +void EXTI9_5_IRQHandler(void); +void EXTI15_10_IRQHandler(void); +void DMA2_Stream1_IRQHandler(void); +void DMA2_Stream3_IRQHandler(void); +void DMA2_Stream4_IRQHandler(void); +void OTG_FS_IRQHandler(void); +void OTG_HS_IRQHandler(void); +void SAI1_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usb_device.h b/OwlPedal2/Inc/usb_device.h new file mode 100644 index 00000000..98cf5857 --- /dev/null +++ b/OwlPedal2/Inc/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h new file mode 100644 index 00000000..27e21fa6 --- /dev/null +++ b/OwlPedal2/Inc/usbd_conf.h @@ -0,0 +1,181 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ +#include "device.h" +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 5U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 1U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL DEBUG_LEVEL +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 0U +/*---------- -----------*/ + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ +/* Memory management macros make sure to use static memory allocation */ +/** Alias for memory allocation. */ + +#define USBD_malloc (void *)USBD_static_malloc + +/** Alias for memory release. */ +#define USBD_free USBD_static_free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ + printf("\n"); } while(0) +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); } while(0) +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ + printf(__VA_ARGS__);\ + printf("\n"); } while(0) +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usbd_desc.h b/OwlPedal2/Inc/usbd_desc.h new file mode 100644 index 00000000..90f8968c --- /dev/null +++ b/OwlPedal2/Inc/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ +#include "device.h" +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef USBD_DESC; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile new file mode 100644 index 00000000..ddbad630 --- /dev/null +++ b/OwlPedal2/Makefile @@ -0,0 +1,23 @@ +PROJECT = OwlPedal2 +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +include $(OPENWARE)/Hardware/owl2.mk + +C_SRC = $(wildcard Src/*.c) +CPP_SRC = $(wildcard Src/*.cpp) +C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/cs4272.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_SAI) +C_SRC += $(C_SRC_SDRAM) +C_SRC += $(C_SRC_USBD) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_RTC) + +include $(OPENWARE)/Hardware/f4.mk diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc new file mode 100644 index 00000000..d0c234cb --- /dev/null +++ b/OwlPedal2/OwlPedal2.ioc @@ -0,0 +1,669 @@ +#MicroXplorer Configuration settings - do not modify +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 +ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_2 +ADC3.Channel-36\#ChannelRegularConversion=ADC_CHANNEL_3 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE +ADC3.DMAContinuousRequests=ENABLE +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START +ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion,Rank-36\#ChannelRegularConversion,Channel-36\#ChannelRegularConversion,SamplingTime-36\#ChannelRegularConversion +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=6 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 +ADC3.Rank-34\#ChannelRegularConversion=4 +ADC3.Rank-35\#ChannelRegularConversion=5 +ADC3.Rank-36\#ChannelRegularConversion=6 +ADC3.Resolution=ADC_RESOLUTION_12B +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-36\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.0.Instance=DMA2_Stream1 +Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +Dma.ADC3.0.Mode=DMA_CIRCULAR +Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.0.Priority=DMA_PRIORITY_LOW +Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=ADC3 +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.RequestsNb=3 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream3 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configTOTAL_HEAP_SIZE=8192 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32F4 +Mcu.IP0=ADC3 +Mcu.IP1=DMA +Mcu.IP10=SYS +Mcu.IP11=TIM4 +Mcu.IP12=USB_OTG_FS +Mcu.IP13=USB_OTG_HS +Mcu.IP2=FMC +Mcu.IP3=FREERTOS +Mcu.IP4=NVIC +Mcu.IP5=RCC +Mcu.IP6=RTC +Mcu.IP7=SAI1 +Mcu.IP8=SPI1 +Mcu.IP9=SPI4 +Mcu.IPNb=14 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF10 +Mcu.Pin15=PH0/OSC_IN +Mcu.Pin16=PH1/OSC_OUT +Mcu.Pin17=PC0 +Mcu.Pin18=PC1 +Mcu.Pin19=PC2 +Mcu.Pin2=PE4 +Mcu.Pin20=PC3 +Mcu.Pin21=PA1 +Mcu.Pin22=PA2 +Mcu.Pin23=PA3 +Mcu.Pin24=PA6 +Mcu.Pin25=PA7 +Mcu.Pin26=PC4 +Mcu.Pin27=PC5 +Mcu.Pin28=PB0 +Mcu.Pin29=PB2/BOOT1 +Mcu.Pin3=PE5 +Mcu.Pin30=PF11 +Mcu.Pin31=PF12 +Mcu.Pin32=PF13 +Mcu.Pin33=PF14 +Mcu.Pin34=PF15 +Mcu.Pin35=PG0 +Mcu.Pin36=PG1 +Mcu.Pin37=PE7 +Mcu.Pin38=PE8 +Mcu.Pin39=PE9 +Mcu.Pin4=PE6 +Mcu.Pin40=PE10 +Mcu.Pin41=PE11 +Mcu.Pin42=PE12 +Mcu.Pin43=PE13 +Mcu.Pin44=PE14 +Mcu.Pin45=PE15 +Mcu.Pin46=PB10 +Mcu.Pin47=PB11 +Mcu.Pin48=PB13 +Mcu.Pin49=PB14 +Mcu.Pin5=PC15/OSC32_OUT +Mcu.Pin50=PB15 +Mcu.Pin51=PD8 +Mcu.Pin52=PD9 +Mcu.Pin53=PD10 +Mcu.Pin54=PD14 +Mcu.Pin55=PD15 +Mcu.Pin56=PG4 +Mcu.Pin57=PG5 +Mcu.Pin58=PG8 +Mcu.Pin59=PA9 +Mcu.Pin6=PF0 +Mcu.Pin60=PA11 +Mcu.Pin61=PA12 +Mcu.Pin62=PA13 +Mcu.Pin63=PA14 +Mcu.Pin64=PD0 +Mcu.Pin65=PD1 +Mcu.Pin66=PD2 +Mcu.Pin67=PD6 +Mcu.Pin68=PG9 +Mcu.Pin69=PG10 +Mcu.Pin7=PF1 +Mcu.Pin70=PG15 +Mcu.Pin71=PB3 +Mcu.Pin72=PB5 +Mcu.Pin73=PB6 +Mcu.Pin74=PB8 +Mcu.Pin75=PB9 +Mcu.Pin76=PE0 +Mcu.Pin77=PE1 +Mcu.Pin78=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin79=VP_RTC_VS_RTC_Activate +Mcu.Pin8=PF2 +Mcu.Pin80=VP_SYS_VS_Systick +Mcu.Pin9=PF3 +Mcu.PinsNb=81 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.ADC_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream1_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA2_Stream3_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI15_10_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI1_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PA1.GPIO_Label=FOOTSWITCH +PA1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PA1.GPIO_PuPd=GPIO_NOPULL +PA1.Locked=true +PA1.Signal=GPXTI1 +PA11.GPIOParameters=GPIO_Label +PA11.GPIO_Label=USBD_DM +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.GPIOParameters=GPIO_Label +PA12.GPIO_Label=USBD_DP +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA2.Locked=true +PA2.Signal=ADCx_IN2 +PA3.GPIOParameters=GPIO_Label +PA3.GPIO_Label=EXP +PA3.Signal=ADCx_IN3 +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA9.GPIOParameters=GPIO_Label +PA9.GPIO_Label=USBD_VBUS +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_nCS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_nRST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB13.Mode=Activate_VBUS_FS +PB13.Signal=USB_OTG_HS_VBUS +PB14.Mode=Device_Only_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Device_Only_FS +PB15.Signal=USB_OTG_HS_DP +PB2/BOOT1.GPIOParameters=GPIO_Label +PB2/BOOT1.GPIO_Label=EXP_TIP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPIO_Output +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PB8.GPIOParameters=GPIO_Speed +PB8.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PB8.Signal=S_TIM4_CH3 +PB9.GPIOParameters=GPIO_Speed +PB9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PB9.Signal=S_TIM4_CH4 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC3 +PC1.Locked=true +PC1.Signal=ADCx_IN11 +PC15/OSC32_OUT.GPIOParameters=GPIO_Label +PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PD2.GPIO_Label=SW1 +PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PD2.GPIO_PuPd=GPIO_PULLUP +PD2.Locked=true +PD2.Signal=GPXTI2 +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PF7.GPIO_Label=EXP2_T +PF7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PF7.GPIO_PuPd=GPIO_PULLUP +PF7.Locked=true +PF7.Signal=GPXTI7 +PF8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PF8.GPIO_Label=EXP2_R +PF8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PF8.GPIO_PuPd=GPIO_PULLUP +PF8.Locked=true +PF8.Signal=GPXTI8 +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG10.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG10.GPIO_Label=SW1_ALT +PG10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG10.GPIO_PuPd=GPIO_PULLUP +PG10.Locked=true +PG10.Signal=GPXTI10 +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG9.GPIO_Label=SW2 +PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG9.GPIO_PuPd=GPIO_PULLUP +PG9.Locked=true +PG9.Signal=GPXTI9 +PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=OwlPedal2.ioc +ProjectManager.ProjectName=OwlPedal2 +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_USB_OTG_HS_PCD_Init-USB_OTG_HS-false-HAL-true,11-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=168000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 +RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 +RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 +RCC.SPDIFRXFreq_Value=96000000 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 +RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.1=ADC1_IN11 +SH.ADCx_IN11.ConfNb=2 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.1=ADC1_IN12 +SH.ADCx_IN12.ConfNb=2 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.1=ADC1_IN13 +SH.ADCx_IN13.ConfNb=2 +SH.ADCx_IN2.0=ADC3_IN2,IN2 +SH.ADCx_IN2.ConfNb=1 +SH.ADCx_IN3.0=ADC3_IN3,IN3 +SH.ADCx_IN3.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 +SH.FMC_A10.0=FMC_A10,12b-sda1 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 +SH.FMC_D2_DA2.ConfNb=1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI1.0=GPIO_EXTI1 +SH.GPXTI1.ConfNb=1 +SH.GPXTI10.0=GPIO_EXTI10 +SH.GPXTI10.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI7.0=GPIO_EXTI7 +SH.GPXTI7.ConfNb=1 +SH.GPXTI8.0=GPIO_EXTI8 +SH.GPXTI8.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3 +SH.S_TIM4_CH3.ConfNb=1 +SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4 +SH.S_TIM4_CH4.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM4.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4,Period,Prescaler,OCPolarity_4 +TIM4.OCPolarity_4=TIM_OCPOLARITY_LOW +TIM4.Period=1023 +TIM4.Prescaler=100 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS +USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +board=Alchemist diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp new file mode 100644 index 00000000..56ea02b3 --- /dev/null +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -0,0 +1,432 @@ +#include +#include "Owl.h" +#include "errorhandlers.h" +#include "Codec.h" +#include "MidiController.h" +#include "ProgramManager.h" +#include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" +#include "PatchRegistry.h" +#include "Pin.h" +#include "usb_device.h" + +#define PATCH_RESET_COUNTER (768/MAIN_LOOP_SLEEP_MS) +#define PATCH_CONFIG_COUNTER (3072/MAIN_LOOP_SLEEP_MS) +#define PATCH_INDICATOR_COUNTER (256/MAIN_LOOP_SLEEP_MS) + +#define BYPASS_MODE (ERROR_MODE+1) +#define ENTER_CONFIG_MODE (ERROR_MODE+2) + +static int16_t knobvalues[2]; +static uint8_t patchselect; +#define PATCH_CONFIG_KNOB_THRESHOLD (4096/8) +#define PATCH_CONFIG_PROGRAM_CONTROL 0 +#define PATCH_CONFIG_VOLUME_CONTROL 3 + +#define SW3_Pin EXP2_T_Pin +#define SW3_GPIO_Port EXP2_T_GPIO_Port +#define SW4_Pin EXP2_R_Pin +#define SW4_GPIO_Port EXP2_R_GPIO_Port + +// Pin footswitch_pin(GPIOA, GPIO_PIN_0); +Pin bypass_pin(GPIOA, GPIO_PIN_0); +Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass +Pin exp1_tip_pin(GPIOA, GPIO_PIN_2); +Pin exp1_ring_pin(GPIOA, GPIO_PIN_3); + +#ifndef OWL_PEDAL_PWM_LEDS +Pin led_green_pin(GPIOB, GPIO_PIN_8); +Pin led_red_pin(GPIOB, GPIO_PIN_9); +#endif + +static uint32_t counter = 0; +static uint8_t expression_mode = 0; + +bool getBufferedBypass(){ + return !bufpass_pin.get(); +} + +void setBufferedBypass(bool value){ + // setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + bufpass_pin.set(!value); + // todo; set BYPASS_MODE +} + +bool isBypassed(){ + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; + // todo: || getBufferedBypass() +} + +bool isPushbuttonPressed(){ + return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET || + HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET; +} + +void configureExpression(uint8_t mode){ + if(mode != expression_mode){ + switch(mode){ + case EXPRESSION_MODE_EXP_TRS: + // Ring is available on ADC_F + exp1_ring_pin.outputMode(); + exp1_ring_pin.high(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + exp1_tip_pin.analogMode(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_EXP_RTS: + exp1_tip_pin.outputMode(); + exp1_tip_pin.high(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + exp1_ring_pin.analogMode(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_FS_TS: + case EXPRESSION_MODE_FS_TRS: + exp1_tip_pin.inputMode(); + exp1_tip_pin.setPull(PIN_PULL_UP); + exp1_ring_pin.inputMode(); + exp1_ring_pin.setPull(PIN_PULL_UP); + break; + } + expression_mode = mode; + setButtonValue(PUSHBUTTON, isPushbuttonPressed()); + setButtonValue(BUTTON_1, isPushbuttonPressed()); + setButtonValue(BUTTON_2, false); + } +} + +void initLed(){ +#ifdef OWL_PEDAL_PWM_LEDS + extern TIM_HandleTypeDef htim4; + HAL_TIM_Base_Start(&htim4); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); +#else + led_green_pin.outputMode(); + led_red_pin.outputMode(); +#endif +} + +uint32_t getLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - TIM4->CCR3; + uint32_t g = TIM4->CCR4; + return (r<<20) | (g<<10); +#else + if(!led_green_pin.get() && led_red_pin.get()) + return RED_COLOUR; + else if(led_green_pin.get() && !led_red_pin.get()) + return GREEN_COLOUR; + else + return NO_COLOUR; +#endif +} + +void toggleLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(led, getLed(led) == GREEN_COLOUR ? RED_COLOUR : GREEN_COLOUR); + // uint32_t r = TIM4->CCR3; + // uint32_t g = TIM4->CCR4; + // TIM4->CCR3 = 1023 - r; + // TIM4->CCR4 = 1023 - g; +#else + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); +#endif +} + +void setLed(uint8_t led, uint32_t rgb){ +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - ((rgb>>20) & 0x3ff); + uint32_t g = ((rgb>>10) & 0x3ff); // green TIM4 has reverse polarity + TIM4->CCR3 = r; + TIM4->CCR4 = g; +#else + switch(rgb){ + case RED_COLOUR: + led_green_pin.low(); + led_red_pin.high(); + break; + case GREEN_COLOUR: + led_green_pin.high(); + led_red_pin.low(); + break; + case NO_COLOUR: + led_green_pin.low(); + led_red_pin.low(); + break; + default: + break; + } +#endif +} + +void onChangePin(uint16_t pin){ + if(pin == FOOTSWITCH_Pin){ + setButtonValue(0, isBypassed()); + } + if(owl.getOperationMode() == RUN_MODE){ + switch(pin){ + // case FOOTSWITCH_Pin: { // bypass / stomp switch + // bool state = isBypassed(); + // setButtonValue(0, state); + // setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + // break; + // } + case SW1_Pin: + case SW1_ALT_Pin: { // pushbutton + bool state = isPushbuttonPressed(); + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_1, state); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + break; + } + // case SW2_Pin: { // mode button + // bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_2, state); + // break; + // } + // case SW3_Pin: { // EXP2 Tip + // bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_3, state); + // break; + // } + // case SW4_Pin: { // EXP2 Ring + // bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_4, state); + // break; + // } + } + } +} + +void setGateValue(uint8_t ch, int16_t value){ + if(owl.getOperationMode() == RUN_MODE){ + value = (value >> 2) & 0x3ff; // use top 10 bits of 12 + switch(ch){ + case BUTTON_1: + case PUSHBUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value << 20) | ((1023 - value) << 10)); +#else + setLed(0, value < 2048 ? RED_COLOUR : GREEN_COLOUR); +#endif + break; + case GREEN_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, value << 10); +#else + setLed(0, value < 2048 ? GREEN_COLOUR : NO_COLOUR); +#endif + break; + case RED_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, value << 20); +#else + setLed(0, value < 2048 ? RED_COLOUR : NO_COLOUR); +#endif + break; + } + } + // if(ch == 0) + // setBufferedBypass(value); +} + +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + if(owl.getOperationMode() == RUN_MODE){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; + + static uint8_t fs_state = 0; + uint8_t buttons = 0; + switch(expression_mode){ + case EXPRESSION_MODE_EXP_TRS: + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + break; + case EXPRESSION_MODE_EXP_RTS: + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_F])>>2; + break; + case EXPRESSION_MODE_FS_TRS: + buttons = (!exp1_ring_pin.get()) << BUTTON_2; + buttons |= (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + if((buttons & (1 << BUTTON_2)) != (fs_state & (1 << BUTTON_2))){ + setButtonValue(BUTTON_2, buttons & (1 << BUTTON_2)); + } + if((buttons & (1 << BUTTON_1)) != (fs_state & (1 << BUTTON_1))){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + } + fs_state = buttons; + } + break; + case EXPRESSION_MODE_FS_TS: + buttons = (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + fs_state = buttons; + } + break; + } + } +} + +void onSetup(){ + initLed(); + bypass_pin.outputMode(); + bypass_pin.low(); + bufpass_pin.outputMode(); + bufpass_pin.low(); + configureExpression(settings.expression_mode); + + setLed(0, RED_COLOUR); + + MX_USB_DEVICE_Init(); + + setBufferedBypass(false); +} + +void onStartProgram(){ + setLed(0, GREEN_COLOUR); +} + +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + counter = 0; + static uint32_t saved_led = NO_COLOUR; + if(old_mode == RUN_MODE){ + saved_led = getLed(0); // leaving RUN_MODE, save LED state + } + setLed(0, NO_COLOUR); + if(new_mode == CONFIGURE_MODE){ + knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); + knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); + patchselect = program.getProgramIndex(); + }else if(new_mode == RUN_MODE){ + setLed(0, saved_led); // restore to saved LED state + } +} + +// static uint16_t progress = 0; +void setProgress(uint16_t value, const char* msg){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value<<18) & (0x3ff<<20)); +#else + toggleLed(0); +#endif +} + +void onLoop(){ + switch(owl.getOperationMode()){ + case STARTUP_MODE: + case STREAM_MODE: + setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; + break; + case LOAD_MODE: + // setLed(0, counter > PATCH_INDICATOR_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + // todo: use setProgress()? + // if(counter-- == 0) + // counter = PATCH_RESET_COUNTER; + break; + case BYPASS_MODE: + if(!isBypassed()){ + owl.setOperationMode(RUN_MODE); + }else if(isPushbuttonPressed()){ + owl.setOperationMode(ENTER_CONFIG_MODE); + } + break; + case RUN_MODE: + if(getErrorStatus() != NO_ERROR){ + owl.setOperationMode(ERROR_MODE); + }else if(isPushbuttonPressed()){ + if(--counter == 0){ // counter == 0 when we enter RUN_MODE + owl.setOperationMode(ENTER_CONFIG_MODE); + }else if(counter < PATCH_RESET_COUNTER && counter % 128 == 0){ + toggleLed(0); + } + }else if(isBypassed()){ + // don't change to BYPASS_MODE while pushbutton is pressed + // (we might have just come from CONFIGURATION_MODE) + owl.setOperationMode(BYPASS_MODE); + }else{ + counter = PATCH_CONFIG_COUNTER; + } + break; + case ENTER_CONFIG_MODE: + if(isPushbuttonPressed()){ + // toggle rapidly for yellow-ish LED + toggleLed(0); + }else{ + owl.setOperationMode(CONFIGURE_MODE); + } + break; + case CONFIGURE_MODE: + if(isPushbuttonPressed()){ // exit configure mode + if(program.getProgramIndex() != patchselect && + registry.hasPatch(patchselect)){ + program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + program.resetProgram(false); + }else{ + owl.setOperationMode(RUN_MODE); + } + }else{ + // update patch control + if(abs(knobvalues[0] - getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; + float pos = 0.5f + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * (registry.getNumberOfPatches() - 1)) / 4096.0f; + uint8_t idx = roundf(pos); + if(abs(patchselect - pos) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone + patchselect = idx; + midi_tx.sendPc(patchselect); + // update patch indicator + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); + } + } + // update volume control + if(abs(knobvalues[1] - getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; + uint8_t value = (getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; + if(settings.audio_output_gain != value){ + settings.audio_output_gain = value; + codec.setOutputGain(value); + midi_tx.sendCc(MIDI_CC_VOLUME, value); + } + } + // indicator LED + if(counter-- == 0){ + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); // patch indicator + setLed(0, NO_COLOUR); + }else if(counter <= PATCH_RESET_COUNTER){ + if(patchselect == 0){ + // toggle rapidly for yellow-ish LED + toggleLed(0); + }else{ + setLed(0, NO_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % (2*PATCH_INDICATOR_COUNTER) == 0){ + if((counter - PATCH_RESET_COUNTER) >= 10*PATCH_INDICATOR_COUNTER){ + counter -= 8*PATCH_INDICATOR_COUNTER; + setLed(0, RED_COLOUR); + }else{ + setLed(0, GREEN_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % PATCH_INDICATOR_COUNTER == 0){ + setLed(0, NO_COLOUR); + } + } + break; + case ERROR_MODE: + if(isPushbuttonPressed()) + owl.setOperationMode(ENTER_CONFIG_MODE); + setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; + break; + } + configureExpression(settings.expression_mode); +} diff --git a/OwlPedal2/Src/freertos.c b/OwlPedal2/Src/freertos.c new file mode 100644 index 00000000..ace53e48 --- /dev/null +++ b/OwlPedal2/Src/freertos.c @@ -0,0 +1,136 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c new file mode 100644 index 00000000..ce148442 --- /dev/null +++ b/OwlPedal2/Src/main.c @@ -0,0 +1,973 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +#include "device.h" +#include "errorhandlers.h" +#ifdef DEBUG +#include +#endif + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc3; +DMA_HandleTypeDef hdma_adc3; + +RTC_HandleTypeDef hrtc; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi1; +SPI_HandleTypeDef hspi4; + +TIM_HandleTypeDef htim4; + +#ifdef USE_USBD_FS +PCD_HandleTypeDef hpcd_USB_OTG_FS; +#endif +#ifdef USE_USBD_HS +PCD_HandleTypeDef hpcd_USB_OTG_HS; +#endif + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +void PeriphCommonClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_ADC3_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_SPI1_Init(void); +static void MX_SPI4_Init(void); +static void MX_RTC_Init(void); +static void MX_USB_OTG_HS_PCD_Init(void); +static void MX_USB_OTG_FS_PCD_Init(void); +static void MX_TIM4_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +void setup(); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_ADC3_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_SPI1_Init(); + MX_SPI4_Init(); + MX_RTC_Init(); + MX_USB_OTG_HS_PCD_Init(); + MX_USB_OTG_FS_PCD_Init(); + MX_TIM4_Init(); + /* USER CODE BEGIN 2 */ + + HAL_SAI_DeInit(&hsai_BlockA1); + HAL_SAI_DeInit(&hsai_BlockB1); + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) + Error_Handler(); + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) + Error_Handler(); + + SDRAM_Initialization_Sequence(&hsdram1); + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Macro to configure SAI1BlockB clock source selection + */ + __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); + /** Macro to configure SAI1BlockA clock source selection + */ + __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); + /** Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.LSIState = RCC_LSI_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 25; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; + PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; + PeriphClkInitStruct.PLLSAIDivQ = 1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC3 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC3_Init(void) +{ + + /* USER CODE BEGIN ADC3_Init 0 */ + + /* USER CODE END ADC3_Init 0 */ + + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC3_Init 1 */ + + /* USER CODE END ADC3_Init 1 */ + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + */ + hadc3.Instance = ADC3; + hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; + hadc3.Init.Resolution = ADC_RESOLUTION_12B; + hadc3.Init.ScanConvMode = ENABLE; + hadc3.Init.ContinuousConvMode = ENABLE; + hadc3.Init.DiscontinuousConvMode = DISABLE; + hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hadc3.Init.NbrOfConversion = 6; + hadc3.Init.DMAContinuousRequests = ENABLE; + hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; + if (HAL_ADC_Init(&hadc3) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_13; + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_12; + sConfig.Rank = 2; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_11; + sConfig.Rank = 3; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_8; + sConfig.Rank = 4; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_2; + sConfig.Rank = 5; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_3; + sConfig.Rank = 6; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC3_Init 2 */ + + /* USER CODE END ADC3_Init 2 */ + +} + +/** + * @brief RTC Initialization Function + * @param None + * @retval None + */ +static void MX_RTC_Init(void) +{ + + /* USER CODE BEGIN RTC_Init 0 */ + + /* USER CODE END RTC_Init 0 */ + + /* USER CODE BEGIN RTC_Init 1 */ + + /* USER CODE END RTC_Init 1 */ + /** Initialize RTC Only + */ + hrtc.Instance = RTC; + hrtc.Init.HourFormat = RTC_HOURFORMAT_24; + hrtc.Init.AsynchPrediv = 127; + hrtc.Init.SynchPrediv = 255; + hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; + hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; + hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; + if (HAL_RTC_Init(&hrtc) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN RTC_Init 2 */ + + /* USER CODE END RTC_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.FrameInit.FrameLength = 64; + hsai_BlockA1.FrameInit.ActiveFrameLength = 1; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 2; + hsai_BlockA1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.FrameInit.FrameLength = 64; + hsai_BlockB1.FrameInit.ActiveFrameLength = 1; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 2; + hsai_BlockB1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI1_Init(void) +{ + + /* USER CODE BEGIN SPI1_Init 0 */ + + /* USER CODE END SPI1_Init 0 */ + + /* USER CODE BEGIN SPI1_Init 1 */ + + /* USER CODE END SPI1_Init 1 */ + /* SPI1 parameter configuration*/ + hspi1.Instance = SPI1; + hspi1.Init.Mode = SPI_MODE_MASTER; + hspi1.Init.Direction = SPI_DIRECTION_2LINES; + hspi1.Init.DataSize = SPI_DATASIZE_8BIT; + hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi1.Init.NSS = SPI_NSS_SOFT; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; + hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi1.Init.TIMode = SPI_TIMODE_DISABLE; + hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi1.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI1_Init 2 */ + + /* USER CODE END SPI1_Init 2 */ + +} + +/** + * @brief SPI4 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI4_Init(void) +{ + + /* USER CODE BEGIN SPI4_Init 0 */ + + /* USER CODE END SPI4_Init 0 */ + + /* USER CODE BEGIN SPI4_Init 1 */ + + /* USER CODE END SPI4_Init 1 */ + /* SPI4 parameter configuration*/ + hspi4.Instance = SPI4; + hspi4.Init.Mode = SPI_MODE_MASTER; + hspi4.Init.Direction = SPI_DIRECTION_2LINES; + hspi4.Init.DataSize = SPI_DATASIZE_8BIT; + hspi4.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi4.Init.NSS = SPI_NSS_SOFT; + hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi4.Init.TIMode = SPI_TIMODE_DISABLE; + hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi4.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI4_Init 2 */ + + /* USER CODE END SPI4_Init 2 */ + +} + +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 4; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 1023; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim4) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_3) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW; + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + HAL_TIM_MspPostInit(&htim4); + +} + +/** + * @brief USB_OTG_FS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_FS_PCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_FS_Init 0 */ + + /* USER CODE END USB_OTG_FS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_FS_Init 1 */ +#ifdef USE_USBD_FS + /* USER CODE END USB_OTG_FS_Init 1 */ + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_FS_Init 2 */ +#endif /* USE_USBD_FS */ + + /* USER CODE END USB_OTG_FS_Init 2 */ + +} + +/** + * @brief USB_OTG_HS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_HS_PCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_HS_Init 0 */ + + /* USER CODE END USB_OTG_HS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_HS_Init 1 */ +#ifdef USE_USBD_HS + /* USER CODE END USB_OTG_HS_Init 1 */ + hpcd_USB_OTG_HS.Instance = USB_OTG_HS; + hpcd_USB_OTG_HS.Init.dev_endpoints = 6; + hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; + hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_HS_Init 2 */ +#endif /* USE_USBD_HS */ + /* USER CODE END USB_OTG_HS_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA2_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA2_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 10, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); + /* DMA2_Stream3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + /* DMA2_Stream4_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK2; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; + SdramTiming.ExitSelfRefreshDelay = 6; + SdramTiming.SelfRefreshTime = 4; + SdramTiming.RowCycleDelay = 6; + SdramTiming.WriteRecoveryTime = 2; + SdramTiming.RPDelay = 2; + SdramTiming.RCDDelay = 2; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PC13 PC14 ADC3_Pin ADC2_Pin + ADC1_Pin PC6 PC7 PC8 + PC9 PC10 PC11 PC12 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|ADC3_Pin|ADC2_Pin + |ADC1_Pin|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTSPI_nCS_Pin FLASH_HOLD_Pin FLASH_nCS_Pin */ + GPIO_InitStruct.Pin = EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PF6 PF9 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /*Configure GPIO pins : EXP2_T_Pin EXP2_R_Pin */ + GPIO_InitStruct.Pin = EXP2_T_Pin|EXP2_R_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /*Configure GPIO pins : PA0 PA4 PA5 PA8 + PA10 PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8 + |GPIO_PIN_10|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : FOOTSWITCH_Pin */ + GPIO_InitStruct.Pin = FOOTSWITCH_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(FOOTSWITCH_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : FLASH_WP_Pin EXP_TIP_Pin CS_nCS_Pin CS_nRST_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : PB1 PB12 PB4 PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : PD11 PD12 PD13 PD3 + PD4 PD5 PD7 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PG2 PG3 PG6 PG7 + PG11 PG12 PG13 PG14 */ + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pin : SW1_Pin */ + GPIO_InitStruct.Pin = SW1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(SW1_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : SW2_Pin SW1_ALT_Pin */ + GPIO_InitStruct.Pin = SW2_Pin|SW1_ALT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI1_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI1_IRQn); + + HAL_NVIC_SetPriority(EXTI2_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* USER CODE BEGIN 5 */ + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + } + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/startup_stm32f427xx.s b/OwlPedal2/Src/startup_stm32f427xx.s new file mode 100644 index 00000000..7ddee113 --- /dev/null +++ b/OwlPedal2/Src/startup_stm32f427xx.s @@ -0,0 +1,553 @@ +/** + ****************************************************************************** + * @file startup_stm32f427xx.s + * @author MCD Application Team + * @version V2.6.1 + * @date 14-February-2017 + * @brief STM32F427xx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2D_IRQHandler /* DMA2D */ +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c new file mode 100644 index 00000000..db99b0c9 --- /dev/null +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -0,0 +1,975 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : stm32f4xx_hal_msp.c + * Description : This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc3; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + __HAL_RCC_PWR_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hadc->Instance==ADC3) + { + /* USER CODE BEGIN ADC3_MspInit 0 */ + + /* USER CODE END ADC3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC3_CLK_ENABLE(); + + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**ADC3 GPIO Configuration + PF10 ------> ADC3_IN8 + PC1 ------> ADC3_IN11 + PC2 ------> ADC3_IN12 + PC3 ------> ADC3_IN13 + PA2 ------> ADC3_IN2 + PA3 ------> ADC3_IN3 + */ + GPIO_InitStruct.Pin = ADC4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADC4_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC3_Pin|ADC2_Pin|ADC1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_2|EXP_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* ADC3 DMA Init */ + /* ADC3 Init */ + hdma_adc3.Instance = DMA2_Stream1; + hdma_adc3.Init.Channel = DMA_CHANNEL_2; + hdma_adc3.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc3.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc3.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc3.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc3.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc3.Init.Mode = DMA_CIRCULAR; + hdma_adc3.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc3.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc3) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc3); + + /* ADC3 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 10, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC3_MspInit 1 */ + + /* USER CODE END ADC3_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC3) + { + /* USER CODE BEGIN ADC3_MspDeInit 0 */ + + /* USER CODE END ADC3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC3_CLK_DISABLE(); + + /**ADC3 GPIO Configuration + PF10 ------> ADC3_IN8 + PC1 ------> ADC3_IN11 + PC2 ------> ADC3_IN12 + PC3 ------> ADC3_IN13 + PA2 ------> ADC3_IN2 + PA3 ------> ADC3_IN3 + */ + HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); + + HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); + + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|EXP_Pin); + + /* ADC3 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC3 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC3_MspDeInit 1 */ + + /* USER CODE END ADC3_MspDeInit 1 */ + } + +} + +/** +* @brief RTC MSP Initialization +* This function configures the hardware resources used in this example +* @param hrtc: RTC handle pointer +* @retval None +*/ +void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hrtc->Instance==RTC) + { + /* USER CODE BEGIN RTC_MspInit 0 */ + + /* USER CODE END RTC_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_RTC_ENABLE(); + /* USER CODE BEGIN RTC_MspInit 1 */ + + /* USER CODE END RTC_MspInit 1 */ + } + +} + +/** +* @brief RTC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hrtc: RTC handle pointer +* @retval None +*/ +void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) +{ + if(hrtc->Instance==RTC) + { + /* USER CODE BEGIN RTC_MspDeInit 0 */ + + /* USER CODE END RTC_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_RTC_DISABLE(); + /* USER CODE BEGIN RTC_MspDeInit 1 */ + + /* USER CODE END RTC_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspInit 0 */ + + /* USER CODE END SPI1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI1 GPIO Configuration + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + PB3 ------> SPI1_SCK + */ + GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_SCK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(FLASH_SCK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI1_MspInit 1 */ + + /* USER CODE END SPI1_MspInit 1 */ + } + else if(hspi->Instance==SPI4) + { + /* USER CODE BEGIN SPI4_MspInit 0 */ + + /* USER CODE END SPI4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI4_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + /**SPI4 GPIO Configuration + PE2 ------> SPI4_SCK + PE6 ------> SPI4_MOSI + */ + GPIO_InitStruct.Pin = CS_SCK_Pin|CS_SDA_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI4_MspInit 1 */ + + /* USER CODE END SPI4_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspDeInit 0 */ + + /* USER CODE END SPI1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI1_CLK_DISABLE(); + + /**SPI1 GPIO Configuration + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + PB3 ------> SPI1_SCK + */ + HAL_GPIO_DeInit(GPIOA, FLASH_MISO_Pin|FLASH_MOSI_Pin); + + HAL_GPIO_DeInit(FLASH_SCK_GPIO_Port, FLASH_SCK_Pin); + + /* USER CODE BEGIN SPI1_MspDeInit 1 */ + + /* USER CODE END SPI1_MspDeInit 1 */ + } + else if(hspi->Instance==SPI4) + { + /* USER CODE BEGIN SPI4_MspDeInit 0 */ + + /* USER CODE END SPI4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI4_CLK_DISABLE(); + + /**SPI4 GPIO Configuration + PE2 ------> SPI4_SCK + PE6 ------> SPI4_MOSI + */ + HAL_GPIO_DeInit(GPIOE, CS_SCK_Pin|CS_SDA_Pin); + + /* USER CODE BEGIN SPI4_MspDeInit 1 */ + + /* USER CODE END SPI4_MspDeInit 1 */ + } + +} + +/** +* @brief TIM_PWM MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } + +} + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspPostInit 0 */ + + /* USER CODE END TIM4_MspPostInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PB8 ------> TIM4_CH3 + PB9 ------> TIM4_CH4 + */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM4_MspPostInit 1 */ + + /* USER CODE END TIM4_MspPostInit 1 */ + } + +} +/** +* @brief TIM_PWM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } + +} + +/** +* @brief PCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = USBD_VBUS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = USBD_DM_Pin|USBD_DP_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USB_OTG_FS interrupt Init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } + else if(hpcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + /* USB_OTG_HS interrupt Init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } + +} + +/** +* @brief PCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) +{ + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_DM_Pin|USBD_DP_Pin); + + /* USB_OTG_FS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } + else if(hpcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + /* USB_OTG_HS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PF0 ------> FMC_A0 + PF1 ------> FMC_A1 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PF5 ------> FMC_A5 + PC0 ------> FMC_SDNWE + PF11 ------> FMC_SDNRAS + PF12 ------> FMC_A6 + PF13 ------> FMC_A7 + PF14 ------> FMC_A8 + PF15 ------> FMC_A9 + PG0 ------> FMC_A10 + PG1 ------> FMC_A11 + PE7 ------> FMC_D4 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE10 ------> FMC_D7 + PE11 ------> FMC_D8 + PE12 ------> FMC_D9 + PE13 ------> FMC_D10 + PE14 ------> FMC_D11 + PE15 ------> FMC_D12 + PD8 ------> FMC_D13 + PD9 ------> FMC_D14 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD15 ------> FMC_D1 + PG4 ------> FMC_BA0 + PG5 ------> FMC_BA1 + PG8 ------> FMC_SDCLK + PD0 ------> FMC_D2 + PD1 ------> FMC_D3 + PG15 ------> FMC_SDNCAS + PB5 ------> FMC_SDCKE1 + PB6 ------> FMC_SDNE1 + PE0 ------> FMC_NBL0 + PE1 ------> FMC_NBL1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PF0 ------> FMC_A0 + PF1 ------> FMC_A1 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PF5 ------> FMC_A5 + PC0 ------> FMC_SDNWE + PF11 ------> FMC_SDNRAS + PF12 ------> FMC_A6 + PF13 ------> FMC_A7 + PF14 ------> FMC_A8 + PF15 ------> FMC_A9 + PG0 ------> FMC_A10 + PG1 ------> FMC_A11 + PE7 ------> FMC_D4 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE10 ------> FMC_D7 + PE11 ------> FMC_D8 + PE12 ------> FMC_D9 + PE13 ------> FMC_D10 + PE14 ------> FMC_D11 + PE15 ------> FMC_D12 + PD8 ------> FMC_D13 + PD9 ------> FMC_D14 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD15 ------> FMC_D1 + PG4 ------> FMC_BA0 + PG5 ------> FMC_BA1 + PG8 ------> FMC_SDCLK + PD0 ------> FMC_D2 + PD1 ------> FMC_D3 + PG15 ------> FMC_SDNCAS + PB5 ------> FMC_SDCKE1 + PB6 ------> FMC_SDNE1 + PE0 ------> FMC_NBL0 + PE1 ------> FMC_NBL1 + */ + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PD6 ------> SAI1_SD_A + */ + GPIO_InitStruct.Pin = CS_LRCK_Pin|CS_SCKE5_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = CS_SDIN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA2_Stream3; + hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; + hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one stream to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = CS_SDOUT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA2_Stream4; + hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; + hdma_sai1_b.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one stream to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PD6 ------> SAI1_SD_A + */ + HAL_GPIO_DeInit(GPIOE, CS_LRCK_Pin|CS_SCKE5_Pin); + + HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + + /* SAI1 DMA Deinit */ + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + + /* SAI1 DMA Deinit */ + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c new file mode 100644 index 00000000..21838a2f --- /dev/null +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -0,0 +1,281 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32f4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * + * COPYRIGHT(c) 2019 STMicroelectronics + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f4xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "device.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern DMA_HandleTypeDef hdma_adc3; +extern ADC_HandleTypeDef hadc3; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32F4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32f4xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line1 interrupt. + */ +void EXTI1_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI1_IRQn 0 */ + + /* USER CODE END EXTI1_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); + /* USER CODE BEGIN EXTI1_IRQn 1 */ + + /* USER CODE END EXTI1_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles ADC1, ADC2 and ADC3 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc3); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[15:10] interrupts. + */ +void EXTI15_10_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI15_10_IRQn 0 */ + + /* USER CODE END EXTI15_10_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10); + /* USER CODE BEGIN EXTI15_10_IRQn 1 */ + + /* USER CODE END EXTI15_10_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream1 global interrupt. + */ +void DMA2_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */ + + /* USER CODE END DMA2_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc3); + /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */ + + /* USER CODE END DMA2_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream3 global interrupt. + */ +void DMA2_Stream3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream3_IRQn 0 */ + + /* USER CODE END DMA2_Stream3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA2_Stream3_IRQn 1 */ + + /* USER CODE END DMA2_Stream3_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream4 global interrupt. + */ +void DMA2_Stream4_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream4_IRQn 0 */ + + /* USER CODE END DMA2_Stream4_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA2_Stream4_IRQn 1 */ + + /* USER CODE END DMA2_Stream4_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ +#ifdef USE_USBD_FS + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ +#endif + /* USER CODE END OTG_FS_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go HS global interrupt. + */ +void OTG_HS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_HS_IRQn 0 */ +#ifdef USE_USBD_HS + /* USER CODE END OTG_HS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); + /* USER CODE BEGIN OTG_HS_IRQn 1 */ +#endif + /* USER CODE END OTG_HS_IRQn 1 */ +} + +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/system_stm32f4xx.c b/OwlPedal2/Src/system_stm32f4xx.c new file mode 100644 index 00000000..adcddf9b --- /dev/null +++ b/OwlPedal2/Src/system_stm32f4xx.c @@ -0,0 +1,763 @@ +/** + ****************************************************************************** + * @file system_stm32f4xx.c + * @author MCD Application Team + * @version V2.6.1 + * @date 14-February-2017 + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f4xx_system + * @{ + */ + +/** @addtogroup STM32F4xx_System_Private_Includes + * @{ + */ + + +#include "stm32f4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */ +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ + || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) +/* #define DATA_IN_ExtSRAM */ +#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\ + STM32F412Zx || STM32F412Vx */ + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) +/* #define DATA_IN_ExtSDRAM */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\ + STM32F479xx */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00010000 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +uint32_t SystemCoreClock = 16000000; +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes + * @{ + */ + +#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) + static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting, vector table location and External memory + * configuration. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + +#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) + SystemInit_ExtMemCtl(); +#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value + * depends on the application requirements), user has to ensure that HSE_VALUE + * is same as the real frequency of the crystal used. Otherwise, this function + * may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N + SYSCLK = PLL_VCO / PLL_P + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; + pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; + + if (pllsource != 0) + { + /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + else + { + /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + + pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; + SystemCoreClock = pllvco/pllp; + break; + default: + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK frequency --------------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK frequency */ + SystemCoreClock >>= tmp; +} + +#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM) +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (SRAM/SDRAM) + * This SRAM/SDRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; + + register uint32_t tmpreg = 0, timeout = 0xFFFF; + register __IO uint32_t index; + + /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */ + RCC->AHB1ENR |= 0x000001F8; + + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x00CCC0CC; + GPIOD->AFR[1] = 0xCCCCCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xAAAA0A8A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xFFFF0FCF; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00CC0CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA828A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC3CF; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0xCCCCCCCC; + GPIOF->AFR[1] = 0xCCCCCCCC; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA800AAA; + /* Configure PFx pins speed to 50 MHz */ + GPIOF->OSPEEDR = 0xAA800AAA; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0xCCCCCCCC; + GPIOG->AFR[1] = 0xCCCCCCCC; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0xAAAAAAAA; + /* Configure PGx pins speed to 50 MHz */ + GPIOG->OSPEEDR = 0xAAAAAAAA; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + + /* Connect PHx pins to FMC Alternate function */ + GPIOH->AFR[0] = 0x00C0CC00; + GPIOH->AFR[1] = 0xCCCCCCCC; + /* Configure PHx pins in Alternate function mode */ + GPIOH->MODER = 0xAAAA08A0; + /* Configure PHx pins speed to 50 MHz */ + GPIOH->OSPEEDR = 0xAAAA08A0; + /* Configure PHx pins Output type to push-pull */ + GPIOH->OTYPER = 0x00000000; + /* No pull-up, pull-down for PHx pins */ + GPIOH->PUPDR = 0x00000000; + + /* Connect PIx pins to FMC Alternate function */ + GPIOI->AFR[0] = 0xCCCCCCCC; + GPIOI->AFR[1] = 0x00000CC0; + /* Configure PIx pins in Alternate function mode */ + GPIOI->MODER = 0x0028AAAA; + /* Configure PIx pins speed to 50 MHz */ + GPIOI->OSPEEDR = 0x0028AAAA; + /* Configure PIx pins Output type to push-pull */ + GPIOI->OTYPER = 0x00000000; + /* No pull-up, pull-down for PIx pins */ + GPIOI->PUPDR = 0x00000000; + +/*-- FMC Configuration -------------------------------------------------------*/ + /* Enable the FMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + + FMC_Bank5_6->SDCR[0] = 0x000019E4; + FMC_Bank5_6->SDTR[0] = 0x01115351; + + /* SDRAM initialization sequence */ + /* Clock enable command */ + FMC_Bank5_6->SDCMR = 0x00000011; + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Delay */ + for (index = 0; index<1000; index++); + + /* PALL command */ + FMC_Bank5_6->SDCMR = 0x00000012; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Auto refresh command */ + FMC_Bank5_6->SDCMR = 0x00000073; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* MRD register program */ + FMC_Bank5_6->SDCMR = 0x00046014; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Set refresh count */ + tmpreg = FMC_Bank5_6->SDRTR; + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); + + /* Disable write protection */ + tmpreg = FMC_Bank5_6->SDCR[0]; + FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001011; + FMC_Bank1->BTCR[3] = 0x00000201; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ +#if defined(STM32F469xx) || defined(STM32F479xx) + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001091; + FMC_Bank1->BTCR[3] = 0x00110212; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F469xx || STM32F479xx */ + + (void)(tmp); +} +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ +#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (SRAM/SDRAM) + * This SRAM/SDRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) +#if defined (DATA_IN_ExtSDRAM) + register uint32_t tmpreg = 0, timeout = 0xFFFF; + register __IO uint32_t index; + +#if defined(STM32F446xx) + /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface + clock */ + RCC->AHB1ENR |= 0x0000007D; +#else + /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface + clock */ + RCC->AHB1ENR |= 0x000001F8; +#endif /* STM32F446xx */ + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); + +#if defined(STM32F446xx) + /* Connect PAx pins to FMC Alternate function */ + GPIOA->AFR[0] |= 0xC0000000; + GPIOA->AFR[1] |= 0x00000000; + /* Configure PDx pins in Alternate function mode */ + GPIOA->MODER |= 0x00008000; + /* Configure PDx pins speed to 50 MHz */ + GPIOA->OSPEEDR |= 0x00008000; + /* Configure PDx pins Output type to push-pull */ + GPIOA->OTYPER |= 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOA->PUPDR |= 0x00000000; + + /* Connect PCx pins to FMC Alternate function */ + GPIOC->AFR[0] |= 0x00CC0000; + GPIOC->AFR[1] |= 0x00000000; + /* Configure PDx pins in Alternate function mode */ + GPIOC->MODER |= 0x00000A00; + /* Configure PDx pins speed to 50 MHz */ + GPIOC->OSPEEDR |= 0x00000A00; + /* Configure PDx pins Output type to push-pull */ + GPIOC->OTYPER |= 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOC->PUPDR |= 0x00000000; +#endif /* STM32F446xx */ + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x000000CC; + GPIOD->AFR[1] = 0xCC000CCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xA02A000A; + /* Configure PDx pins speed to 50 MHz */ + GPIOD->OSPEEDR = 0xA02A000A; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00000CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA800A; + /* Configure PEx pins speed to 50 MHz */ + GPIOE->OSPEEDR = 0xAAAA800A; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0xCCCCCCCC; + GPIOF->AFR[1] = 0xCCCCCCCC; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA800AAA; + /* Configure PFx pins speed to 50 MHz */ + GPIOF->OSPEEDR = 0xAA800AAA; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0xCCCCCCCC; + GPIOG->AFR[1] = 0xCCCCCCCC; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0xAAAAAAAA; + /* Configure PGx pins speed to 50 MHz */ + GPIOG->OSPEEDR = 0xAAAAAAAA; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) + /* Connect PHx pins to FMC Alternate function */ + GPIOH->AFR[0] = 0x00C0CC00; + GPIOH->AFR[1] = 0xCCCCCCCC; + /* Configure PHx pins in Alternate function mode */ + GPIOH->MODER = 0xAAAA08A0; + /* Configure PHx pins speed to 50 MHz */ + GPIOH->OSPEEDR = 0xAAAA08A0; + /* Configure PHx pins Output type to push-pull */ + GPIOH->OTYPER = 0x00000000; + /* No pull-up, pull-down for PHx pins */ + GPIOH->PUPDR = 0x00000000; + + /* Connect PIx pins to FMC Alternate function */ + GPIOI->AFR[0] = 0xCCCCCCCC; + GPIOI->AFR[1] = 0x00000CC0; + /* Configure PIx pins in Alternate function mode */ + GPIOI->MODER = 0x0028AAAA; + /* Configure PIx pins speed to 50 MHz */ + GPIOI->OSPEEDR = 0x0028AAAA; + /* Configure PIx pins Output type to push-pull */ + GPIOI->OTYPER = 0x00000000; + /* No pull-up, pull-down for PIx pins */ + GPIOI->PUPDR = 0x00000000; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ + +/*-- FMC Configuration -------------------------------------------------------*/ + /* Enable the FMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + + /* Configure and enable SDRAM bank1 */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCR[0] = 0x00001954; +#else + FMC_Bank5_6->SDCR[0] = 0x000019E4; +#endif /* STM32F446xx */ + FMC_Bank5_6->SDTR[0] = 0x01115351; + + /* SDRAM initialization sequence */ + /* Clock enable command */ + FMC_Bank5_6->SDCMR = 0x00000011; + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Delay */ + for (index = 0; index<1000; index++); + + /* PALL command */ + FMC_Bank5_6->SDCMR = 0x00000012; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Auto refresh command */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCMR = 0x000000F3; +#else + FMC_Bank5_6->SDCMR = 0x00000073; +#endif /* STM32F446xx */ + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* MRD register program */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCMR = 0x00044014; +#else + FMC_Bank5_6->SDCMR = 0x00046014; +#endif /* STM32F446xx */ + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Set refresh count */ + tmpreg = FMC_Bank5_6->SDRTR; +#if defined(STM32F446xx) + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1)); +#else + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); +#endif /* STM32F446xx */ + + /* Disable write protection */ + tmpreg = FMC_Bank5_6->SDCR[0]; + FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); +#endif /* DATA_IN_ExtSDRAM */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ + +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ + || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) + +#if defined(DATA_IN_ExtSRAM) +/*-- GPIOs Configuration -----------------------------------------------------*/ + /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ + RCC->AHB1ENR |= 0x00000078; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x00CCC0CC; + GPIOD->AFR[1] = 0xCCCCCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xAAAA0A8A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xFFFF0FCF; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00CC0CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA828A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC3CF; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0x00CCCCCC; + GPIOF->AFR[1] = 0xCCCC0000; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA000AAA; + /* Configure PFx pins speed to 100 MHz */ + GPIOF->OSPEEDR = 0xFF000FFF; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0x00CCCCCC; + GPIOG->AFR[1] = 0x000000C0; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0x00085AAA; + /* Configure PGx pins speed to 100 MHz */ + GPIOG->OSPEEDR = 0x000CAFFF; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + +/*-- FMC/FSMC Configuration --------------------------------------------------*/ + /* Enable the FMC/FSMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001011; + FMC_Bank1->BTCR[3] = 0x00000201; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ +#if defined(STM32F469xx) || defined(STM32F479xx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001091; + FMC_Bank1->BTCR[3] = 0x00110212; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F469xx || STM32F479xx */ +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\ + || defined(STM32F412Zx) || defined(STM32F412Vx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN); + /* Configure and enable Bank1_SRAM2 */ + FSMC_Bank1->BTCR[2] = 0x00001011; + FSMC_Bank1->BTCR[3] = 0x00000201; + FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF; +#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */ + +#endif /* DATA_IN_ExtSRAM */ +#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\ + STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */ + (void)(tmp); +} +#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usb_device.c b/OwlPedal2/Src/usb_device.c new file mode 100644 index 00000000..723305ee --- /dev/null +++ b/OwlPedal2/Src/usb_device.c @@ -0,0 +1,102 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_audio.h" + +/* USER CODE BEGIN Includes */ +#include "device.h" + +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef USBD_HANDLE; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&USBD_HANDLE, &USBD_DESC, USBD_HSFS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&USBD_HANDLE) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c new file mode 100644 index 00000000..9460a97a --- /dev/null +++ b/OwlPedal2/Src/usbd_conf.c @@ -0,0 +1,544 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +#include "usbd_audio.h" + +/* USER CODE BEGIN Includes */ +#include "device.h" +uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ +void SystemClock_Config(void); + +/* USER CODE BEGIN 0 */ +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ + +/* defined in stm32f4xx_hal_msp.c : + * void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) + * void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) + */ + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +{ + /* USER CODE BEGIN 3 */ + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ +#ifdef USE_USBD_FS + /* if (pdev->id == DEVICE_FS) { */ + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; +#endif + /* } else if (pdev->id == DEVICE_HS) { */ +#ifdef USE_USBD_HS + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; +#endif + /* } */ + USBD_AUDIO_SetFiFos(pdev->pData); + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transferred packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Received Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} + +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + +/** + * @brief Delays routine for the USB Device Library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Returns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c new file mode 100644 index 00000000..5afb6ed8 --- /dev/null +++ b/OwlPedal2/Src/usbd_desc.c @@ -0,0 +1,447 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ +#include "device.h" +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_FSHS 0xDADA +#define USBD_PRODUCT_STRING_FSHS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_FSHS "AUDIO Config" +#define USBD_INTERFACE_STRING_FSHS "AUDIO Interface" + +#define USB_SIZ_BOS_DESC 0x0C + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for HS. + * @{ + */ + +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +#if (USBD_LPM_ENABLED == 1) +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef USBD_DESC = +{ + USBD_FSHS_DeviceDescriptor +, USBD_FSHS_LangIDStrDescriptor +, USBD_FSHS_ManufacturerStrDescriptor +, USBD_FSHS_ProductStrDescriptor +, USBD_FSHS_SerialStrDescriptor +, USBD_FSHS_ConfigStrDescriptor +, USBD_FSHS_InterfaceStrDescriptor +#if (USBD_LPM_ENABLED == 1) +, USBD_FSHS_USR_BOSDescriptor +#endif /* (USBD_LPM_ENABLED == 1) */ +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ +#if (USBD_LPM_ENABLED == 1) + 0x01, /*bcdUSB */ /* changed to USB version 2.01 + in order to support LPM L1 suspend + resume test of USBCV3.0*/ +#else + 0x00, /*bcdUSB */ +#endif /* (USBD_LPM_ENABLED == 1) */ + + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FSHS), /*idProduct*/ + HIBYTE(USBD_PID_FSHS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/** BOS descriptor. */ +#if (USBD_LPM_ENABLED == 1) +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +__ALIGN_BEGIN uint8_t USBD_FSHS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +{ + 0x5, + USB_DESC_TYPE_BOS, + 0xC, + 0x0, + 0x1, /* 1 device capability */ + /* device capability */ + 0x7, + USB_DEVICE_CAPABITY_TYPE, + 0x2, + 0x2, /*LPM capability bit set */ + 0x0, + 0x0, + 0x0 +}; +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang identifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FSHS_DeviceDesc); + return USBD_FSHS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +#if (USBD_LPM_ENABLED == 1) +/** + * @brief Return the BOS descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FSHS_BOSDesc); + return (uint8_t*)USBD_FSHS_BOSDesc; +} +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/cube-update.sh b/OwlPedal2/cube-update.sh new file mode 100755 index 00000000..20094fec --- /dev/null +++ b/OwlPedal2/cube-update.sh @@ -0,0 +1,4 @@ +#!/bin/bash +git checkout Src/usb_device.c +git checkout Src/usbd_conf.c Inc/usbd_conf.h +rm -f Src/usbd_audio_if.c Inc/usbd_audio_if.h diff --git a/Source/ApplicationSettings.cpp b/Source/ApplicationSettings.cpp index ea2a695c..733c1a3b 100644 --- a/Source/ApplicationSettings.cpp +++ b/Source/ApplicationSettings.cpp @@ -39,6 +39,9 @@ void ApplicationSettings::reset(){ #ifdef USE_TLC5946 leds_brightness = LEDS_BRIGHTNESS; #endif +#ifdef OWL_PEDAL + expression_mode = EXPRESSION_MODE; +#endif } bool ApplicationSettings::settingsInFlash(){ diff --git a/Source/ApplicationSettings.h b/Source/ApplicationSettings.h index 0a7baa07..c16d8ab4 100644 --- a/Source/ApplicationSettings.h +++ b/Source/ApplicationSettings.h @@ -30,6 +30,9 @@ class ApplicationSettings { #ifdef USE_TLC5946 uint8_t leds_brightness; #endif +#ifdef OWL_PEDAL + uint8_t expression_mode; +#endif public: void init(); void reset(); diff --git a/Source/BootloaderStorage.cpp b/Source/BootloaderStorage.cpp index 9f575399..8d77cf53 100644 --- a/Source/BootloaderStorage.cpp +++ b/Source/BootloaderStorage.cpp @@ -18,13 +18,13 @@ BootloaderStorage::BootloaderStorage(){ bool BootloaderStorage::erase(){ eeprom_unlock(); // We expect bootloader to occupy 1 - 4 sectors. Currently OWL1 uses 2 sectors, OWL2 uses 4. - int ret = eeprom_erase_sector(FLASH_SECTOR_0); + int ret = eeprom_erase_sector(FLASH_SECTOR_0, FLASH_BANK_1); if (bootloader_sectors & OB_WRP_SECTOR_1) - ret |= eeprom_erase_sector(FLASH_SECTOR_1); + ret |= eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_1); if (bootloader_sectors & OB_WRP_SECTOR_2) - ret |= eeprom_erase_sector(FLASH_SECTOR_2); + ret |= eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); if (bootloader_sectors & OB_WRP_SECTOR_3) - ret |= eeprom_erase_sector(FLASH_SECTOR_3); + ret |= eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); eeprom_lock(); return ret == 0; } diff --git a/Source/CircularBuffer.h b/Source/CircularBuffer.h index 6da13988..aa82def1 100644 --- a/Source/CircularBuffer.h +++ b/Source/CircularBuffer.h @@ -4,23 +4,33 @@ #include #include // for memcpy -#ifdef DEBUG_CIRCULAR_BUFFER -#define FLOW_ASSERT(x, y) ASSERT(x, y) -#else +#ifndef FLOW_ASSERT #define FLOW_ASSERT(x, y) #endif +// #ifdef DEBUG_CIRCULAR_BUFFER +// #define FLOW_ASSERT(x, y) ASSERT(x, y) +// #else +// #define FLOW_ASSERT(x, y) +// // #define FLOW_ASSERT(x, y) if(!x){debugMessage(y, this->getReadCapacity(), this->getWriteCapacity());} +// #endif + template class CircularBuffer { protected: T* data; size_t size; - size_t writepos = 0; - size_t readpos = 0; + volatile size_t writepos = 0; + volatile size_t readpos = 0; public: CircularBuffer(): data(NULL), size(0){} CircularBuffer(T* data, size_t size): data(data), size(size){} + void setData(T* data, size_t len) { + this->data = data; + size = len; + } + size_t getSize() const { return size; } @@ -57,6 +67,16 @@ class CircularBuffer { data[index % size] = value; } + void overdub(T c){ + data[writepos++] += c; + if(writepos >= size) + writepos = 0; + } + + void overdubAt(size_t index, T value){ + data[index % size] += value; + } + T read(){ T c = data[readpos++]; if(readpos >= size) @@ -112,11 +132,9 @@ class CircularBuffer { return data+writepos; } - void moveWriteHead(size_t samples){ - FLOW_ASSERT(getWriteCapacity() < samples, "overflow"); - writepos += samples; - if(writepos >= size) - writepos -= size; + void moveWriteHead(int32_t samples){ + FLOW_ASSERT(getWriteCapacity() >= samples, "overflow"); + writepos = (writepos + samples) % size; } size_t getReadIndex(){ @@ -131,11 +149,9 @@ class CircularBuffer { return data+readpos; } - void moveReadHead(size_t samples){ + void moveReadHead(int32_t samples){ FLOW_ASSERT(getReadCapacity() < samples, "underflow"); - readpos += samples; - if(readpos >= size) - readpos -= size; + readpos = (readpos + samples) % size; } /** diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 8bd17b6c..b2d58bf7 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -6,199 +6,53 @@ #include #include "ProgramManager.h" -#include "CircularBuffer.h" - #ifdef USE_CS4271 #define HSAI_RX hsai_BlockB1 #define HSAI_TX hsai_BlockA1 #define HDMA_RX hdma_sai1_b #define HDMA_TX hdma_sai1_a -#else +#elif defined USE_PCM3168A #define HSAI_RX hsai_BlockA1 #define HSAI_TX hsai_BlockB1 #define HDMA_RX hdma_sai1_a #define HDMA_TX hdma_sai1_b +#elif defined USE_WM8731 +#define HDMA_RX hdma_i2s2_ext_rx +#define HDMA_TX hdma_i2s2_ext_rx // linked +#elif defined USE_ADS1294 +#define HDMA_TX hdma_spi1_rx #endif extern "C" { - uint16_t codec_blocksize = 0; + uint16_t codec_blocksize = AUDIO_BLOCK_SIZE; int32_t codec_rxbuf[CODEC_BUFFER_SIZE] DMA_RAM; int32_t codec_txbuf[CODEC_BUFFER_SIZE] DMA_RAM; extern DMA_HandleTypeDef HDMA_TX; extern DMA_HandleTypeDef HDMA_RX; -} - -CircularBuffer audio_rx_buffer(codec_rxbuf, CODEC_BUFFER_SIZE); -CircularBuffer audio_tx_buffer(codec_txbuf, CODEC_BUFFER_SIZE);; - -#ifdef USE_USBD_AUDIO -#include "usbd_audio.h" - -#if AUDIO_BITS_PER_SAMPLE == 32 -typedef int32_t audio_t; -#elif AUDIO_BITS_PER_SAMPLE == 16 -typedef int16_t audio_t; -#elif AUDIO_BITS_PER_SAMPLE == 8 -typedef int8_t audio_t; -#else -#error Invalid AUDIO_BITS_PER_SAMPLE -#endif - -static void update_rx_read_index(){ #if defined USE_CS4271 || defined USE_PCM3168A - // NDTR: the number of remaining data units in the current DMA Stream transfer. - // use HDMA_TX position in case we have stopped HDMA_RX - // todo: if(wet) then read position is incremented by audioCallback ? - size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); - // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) - // audio_rx_buffer.setReadIndex(pos & ~(AUDIO_CHANNELS-1)); - audio_rx_buffer.setReadIndex(pos); -#endif -} - -static void update_tx_write_index(){ -#if defined USE_CS4271 || defined USE_PCM3168A - // NDTR: the number of remaining data units in the current DMA Stream transfer. - size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); - // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) - // audio_tx_buffer.setWriteIndex(pos & ~(AUDIO_CHANNELS-1)); - audio_tx_buffer.setWriteIndex(pos); -#endif -} - -void usbd_audio_tx_start_callback(size_t rate, uint8_t channels){ -#if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 - update_tx_write_index(); - size_t pos = audio_tx_buffer.getWriteIndex(); // not always aligned to AUDIO_CHANNELS samples - // mask to full frame (assumes AUDIO_CHANNELS is a power of two) - pos &= ~(AUDIO_CHANNELS-1); - // position read head at one USB transfer block back from write head - pos -= AUDIO_CHANNELS*rate/1000; - // // position read head at half a ringbuffer distance from write head - // pos -= audio_tx_buffer.getSize()/2; - audio_tx_buffer.setReadIndex(pos); - - // // set read head at half a ringbuffer distance from write head - // update_tx_write_index(); - // size_t pos = audio_tx_buffer.getWriteIndex(); - // size_t len = audio_tx_buffer.getSize(); - // pos = (pos + len/2) % len; - // pos = (pos/AUDIO_CHANNELS)*AUDIO_CHANNELS; // round down to nearest frame - // audio_tx_buffer.setReadIndex(pos); -#ifdef DEBUG - printf("start tx %u %u %u\n", rate, channels, pos); -#endif + extern SAI_HandleTypeDef HSAI_RX; + extern SAI_HandleTypeDef HSAI_TX; #endif } -void usbd_audio_tx_stop_callback(){ -#if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 -#ifdef DEBUG - printf("stop tx\n"); -#endif -#endif -} +#ifdef USE_USBD_AUDIO +#include "usbd_audio.h" -void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ -#if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - // todo: if(wet) { disable RX dma } - __HAL_DMA_DISABLE(&HDMA_RX); // stop codec transfers - audio_rx_buffer.clear(); - update_rx_read_index(); - size_t pos = audio_rx_buffer.getWriteIndex(); - size_t len = audio_rx_buffer.getSize(); - pos = (pos + len/2) % len; - pos = (pos/AUDIO_CHANNELS)*AUDIO_CHANNELS; // round down to nearest frame - audio_rx_buffer.setWriteIndex(pos); - program.exitProgram(true); - owl.setOperationMode(STREAM_MODE); +void usbd_audio_mute_callback(int16_t gain){ + // todo! #ifdef DEBUG - printf("start rx %u %u %u\n", rate, channels, pos); -#endif + printf("mute %d\n", gain); #endif } -void usbd_audio_rx_stop_callback(){ -#if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers - audio_rx_buffer.clear(); - program.loadProgram(program.getProgramIndex()); - program.startProgram(true); - owl.setOperationMode(RUN_MODE); +void usbd_audio_gain_callback(int16_t gain){ + // codec_set_gain_in(gain); todo! #ifdef DEBUG - printf("stop rx\n"); -#endif -#endif -} - -static int32_t usbd_audio_rx_flow = 0; -size_t usbd_audio_rx_callback(uint8_t* data, size_t len){ -#if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - // copy audio to codec_txbuf aka audio_rx_buffer - update_rx_read_index(); - audio_t* src = (audio_t*)data; - size_t blocksize = len / (USBD_AUDIO_RX_CHANNELS*AUDIO_BYTES_PER_SAMPLE); - size_t available = audio_rx_buffer.getWriteCapacity()/AUDIO_CHANNELS; - if(available < blocksize){ - usbd_audio_rx_flow += blocksize-available; - // skip some frames start and end of this block - // src += (blocksize - available)*USBD_AUDIO_RX_CHANNELS/2; - blocksize = available; - len = blocksize*USBD_AUDIO_RX_CHANNELS*AUDIO_BYTES_PER_SAMPLE; - } - while(blocksize--){ - int32_t* dst = audio_rx_buffer.getWriteHead(); - size_t ch = USBD_AUDIO_RX_CHANNELS; - while(ch--) - *dst++ = AUDIO_SAMPLE_TO_INT32(*src++); - // should we leave in place or zero out any remaining channels? - memset(dst, 0, (AUDIO_CHANNELS-USBD_AUDIO_RX_CHANNELS)*sizeof(int32_t)); - audio_rx_buffer.moveWriteHead(AUDIO_CHANNELS); - } - // available = audio_rx_buffer.getWriteCapacity()*AUDIO_BYTES_PER_SAMPLE*USBD_AUDIO_RX_CHANNELS/AUDIO_CHANNELS; - // if(available < AUDIO_RX_PACKET_SIZE) - // return available; -#endif - return len; -} - -static int32_t usbd_audio_tx_flow = 0; -// expect a 1 in 10k sample underflow (-0.01% sample accuracy) -void usbd_audio_tx_callback(uint8_t* data, size_t len){ -#if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 - update_tx_write_index(); - size_t available = audio_tx_buffer.getReadCapacity()/AUDIO_CHANNELS; - size_t blocksize = len / (USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE); - if(available < blocksize){ - usbd_audio_tx_flow += blocksize-available; - blocksize = available; - len = blocksize*USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE; - } - audio_t* dst = (audio_t*)data; - while(blocksize--){ - int32_t* src = audio_tx_buffer.getReadHead(); - size_t ch = USBD_AUDIO_TX_CHANNELS; - while(ch--) - *dst++ = AUDIO_INT32_TO_SAMPLE(*src++); // shift, round, dither, clip, truncate, bitswap - audio_tx_buffer.moveReadHead(AUDIO_CHANNELS); - } - usbd_audio_write(data, len); + printf("gain %d\n", gain); #endif } #endif // USE_USBD_AUDIO -void usbd_audio_mute_callback(int16_t gain){ - // todo! -} - -void usbd_audio_gain_callback(int16_t gain){ - // codec_set_gain_in(gain); todo! -} - -uint32_t usbd_audio_get_rx_count(){ - return 0; // todo! -} - uint16_t Codec::getBlockSize(){ return codec_blocksize; } @@ -214,16 +68,16 @@ void Codec::init(){ // todo: else // audio_tx_buffer = CircularBuffer(codec_rxbuf, CODEC_BUFFER_SIZE); // audio_rx_buffer = CircularBuffer(codec_txbuf, CODEC_BUFFER_SIZE); - audio_tx_buffer.reset(); - audio_rx_buffer.reset(); + // audio_tx_buffer.reset(); + // audio_rx_buffer.reset(); codec_init(); } void Codec::reset(){ // todo: this is called when blocksize is changed stop(); - audio_tx_buffer.reset(); - audio_rx_buffer.reset(); + // audio_tx_buffer.reset(); + // audio_rx_buffer.reset(); start(); } @@ -260,7 +114,7 @@ float Codec::getAvg(){ return avg / CODEC_BUFFER_SIZE; } -void Codec::set(uint32_t value){ +void Codec::set(int32_t value){ for(int i=0; iCYCCNT)/ARM_CYCLES_PER_SAMPLE; } #ifdef USE_IIS3DWB @@ -342,8 +217,8 @@ void Codec::stop(){ void Codec::start(){ setInputGain(settings.audio_input_gain); setOutputGain(settings.audio_output_gain); - // codec_blocksize = min(CODEC_BUFFER_SIZE/4, settings.audio_blocksize); - codec_blocksize = CODEC_BUFFER_SIZE/4; + // codec_blocksize = min(AUDIO_BLOCK_SIZE, settings.audio_blocksize); + codec_blocksize = AUDIO_BLOCK_SIZE; HAL_StatusTypeDef ret; /* See STM32F405 Errata, I2S device limitations */ /* The I2S peripheral must be enabled when the external master sets the WS line at: */ @@ -355,7 +230,7 @@ void Codec::start(){ // configuration phase, the Size parameter means the number of 16-bit data length // in the transaction and when a 24-bit data frame or a 32-bit data frame is selected // the Size parameter means the number of 16-bit data length. - ret = HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t*)codec_txbuf, (uint16_t*)codec_rxbuf, codec_blocksize*4); + ret = HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t*)codec_txbuf, (uint16_t*)codec_rxbuf, codec_blocksize*AUDIO_CHANNELS*2); ASSERT(ret == HAL_OK, "Failed to start I2S DMA"); } @@ -387,14 +262,21 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { - extern SAI_HandleTypeDef HSAI_RX; - extern SAI_HandleTypeDef HSAI_TX; +#ifdef USE_CS4271 void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); } void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); } +#else // PCM3168A: TX is slave + void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ + audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); + } + void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ + audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); + } +#endif void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ error(CONFIG_ERROR, "SAI DMA Error"); } @@ -438,12 +320,5 @@ void Codec::resume(){ HAL_SAI_DMAResume(&HSAI_TX); } -extern "C" { - -// void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ -// } - -} - #endif /* USE_PCM3168A */ diff --git a/Source/Codec.h b/Source/Codec.h index c1b16c7a..597f469a 100644 --- a/Source/Codec.h +++ b/Source/Codec.h @@ -36,7 +36,7 @@ class Codec { void mute(bool doMute); void clear(); void txrx(); - void set(uint32_t value); + void set(int32_t value); void ramp(uint32_t max); void setInputGain(int8_t value); /* int8_t getOutputGain(); */ @@ -47,6 +47,7 @@ class Codec { int32_t getMax(); float getAvg(); uint16_t getBlockSize(); + size_t getSampleCounter(); }; extern Codec codec; diff --git a/Source/Graphics.cpp b/Source/Graphics.cpp index 85e7d591..35463e0c 100644 --- a/Source/Graphics.cpp +++ b/Source/Graphics.cpp @@ -2,11 +2,21 @@ #include "Graphics.h" #include "errorhandlers.h" #include "oled.h" +#include "callbacks.h" +#include "ProgramVector.h" -void Graphics::begin(SPI_HandleTypeDef *spi) { +Graphics::Graphics() : + screen(OLED_WIDTH, OLED_HEIGHT), + drawCallback(defaultDrawCallback) { + screen.clear(); +} + +void Graphics::begin(ParameterController* pc, SPI_HandleTypeDef *spi) { + params = pc; oled_init(spi); screen.setBuffer(pixelbuffer); screen.clear(); + reset(); display(); } @@ -15,32 +25,41 @@ void Graphics::display(){ } void Graphics::draw(){ - // drawCallback(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); - // // params.draw(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); - params.draw(screen); + params->draw(screen); } // static void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ // graphics.screen.setBuffer(pixels); // graphics.screen.clear(); -// graphics.params.draw(graphics.screen); +// graphics.params->draw(graphics.screen); // } -void Graphics::setCallback(void *callback){ - params.setCallback(callback); - // if(callback == NULL) - // drawCallback = defaultDrawCallback; - // else - // drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; +void Graphics::reset(){ + drawCallback = defaultDrawCallback; + params->reset(); } -Graphics::Graphics() : - screen(OLED_WIDTH, OLED_HEIGHT) - // drawCallback(defaultDrawCallback) -{ +void Graphics::setCallback(void *callback){ + if(callback == NULL) + drawCallback = defaultDrawCallback; + else + drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; } -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ - graphics.params.drawTitle(graphics.screen); - graphics.params.drawMessage(26, graphics.screen); +__weak void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ + // doDefaultDrawCallback(graphics.screen); + ScreenBuffer screen = graphics.screen; + + // draw title + screen.setTextSize(2); + screen.print(0, 16, graphics.params->getTitle()); + + // draw program message, if set + ProgramVector* pv = getProgramVector(); + if(pv != NULL && pv->message != NULL){ + screen.setTextSize(1); + screen.setTextWrap(true); + screen.print(0, 26, pv->message); + screen.setTextWrap(false); + } } diff --git a/Source/Graphics.h b/Source/Graphics.h index ff2e2f19..7d0113a2 100644 --- a/Source/Graphics.h +++ b/Source/Graphics.h @@ -4,30 +4,19 @@ #include #include "device.h" #include "ScreenBuffer.h" - -#if defined OWL_RACK -#include "BollardsParameterController.hpp" -#elif defined OWL_MAGUS -#include "MagusParameterController.hpp" -#elif defined OWL_PRISM -#include "PrismParameterController.hpp" -#elif defined OWL_EFFECTSBOX -#include "EffectsBoxParameterController.hpp" -#elif defined OWL_GENIUS -#include "GeniusParameterController.hpp" -#else #include "ParameterController.hpp" -#endif class Graphics { public: Graphics(); - void begin(SPI_HandleTypeDef *spi); + void begin(ParameterController* params, SPI_HandleTypeDef* spi); void display(); void draw(); - void setCallback(void *callback); - ParameterController params; + void reset(); + void setCallback(void* callback); ScreenBuffer screen; + ParameterController* params; + void (*drawCallback)(uint8_t* pixels, uint16_t width, uint16_t height); private: uint8_t pixelbuffer[OLED_BUFFER_SIZE]; }; diff --git a/Source/HAL_Encoders.c b/Source/HAL_Encoders.c index 81480512..5582f52b 100644 --- a/Source/HAL_Encoders.c +++ b/Source/HAL_Encoders.c @@ -11,31 +11,38 @@ SPI_HandleTypeDef* Encoders_SPIConfig; static int16_t rgENC_Values[7] = {0}; #ifdef STM32H7xx -static volatile uint16_t NOP_CNT = 600; +#define ENCODER_CS_DELAY_US 14 #else -static uint16_t NOP_CNT = 250; // 150 doesn't work in Release build +#define ENCODER_CS_DELAY_US 8 #endif +/* uint8_t ENCODER_CS_DELAY_US = 14; */ + +__STATIC_INLINE void DWT_Delay_us(volatile uint32_t microseconds) +{ +#ifndef DEBUG_DWT +#error "Need DWT enabled for microsecond delay" +#endif + uint32_t clk_cycle_start = DWT->CYCCNT; + /* Go to number of cycles for system */ + microseconds *= (HAL_RCC_GetHCLKFreq() / 1000000); + /* Delay till end */ + while ((DWT->CYCCNT - clk_cycle_start) < microseconds); +} //_____ Functions _____________________________________________________________________________________________________ // Port and Chip Setup void Encoders_readAll(void) { - volatile uint16_t x = NOP_CNT; - pbarCS(0); - while(--x){__NOP();} // TODO: microsecond delay using CYCCNT - // *** The minimum NOP delay for proper operation seems to be 150 *** + DWT_Delay_us(ENCODER_CS_DELAY_US); HAL_SPI_Receive(Encoders_SPIConfig, (uint8_t*)rgENC_Values, 14, 100); pbarCS(1); } void Encoders_readSwitches(void) { - volatile uint16_t x = NOP_CNT; - pbarCS(0); - while(--x){__NOP();} - // *** The minimum NOP delay for proper operation seems to be 150 *** + DWT_Delay_us(ENCODER_CS_DELAY_US); HAL_SPI_Receive(Encoders_SPIConfig, (uint8_t*)rgENC_Values, 2, 100); pbarCS(1); } @@ -52,3 +59,9 @@ void Encoders_init (SPI_HandleTypeDef *spiconfig) pbarRST(1); } +void Encoders_reset(void){ + pbarRST(0); + HAL_Delay(20); + pbarRST(1); +} + diff --git a/Source/HAL_Encoders.h b/Source/HAL_Encoders.h index d675cdd5..04454b27 100644 --- a/Source/HAL_Encoders.h +++ b/Source/HAL_Encoders.h @@ -13,6 +13,7 @@ void Encoders_readAll(void); void Encoders_readSwitches(void); void Encoders_init (SPI_HandleTypeDef *spiconfig); int16_t* Encoders_get(); +void Encoders_reset(void); #ifdef __cplusplus } diff --git a/Source/HAL_TLC5946.c b/Source/HAL_TLC5946.c index 894433a2..3bb82485 100644 --- a/Source/HAL_TLC5946.c +++ b/Source/HAL_TLC5946.c @@ -8,12 +8,15 @@ #define TLC_DEVICES 3 #endif -#define TLC_CHANNELS 16 +#define TLC_CHANNELS 16 #define TLC_DC_BYTES (TLC_CHANNELS * 3 / 4) #define TLC_GS_BYTES (TLC_CHANNELS * 3 / 2) +// Modes +#define TLC_MODE_GS 0 +#define TLC_MODE_DC 1 -static uint8_t rgGSbuf[TLC_DEVICES*TLC_GS_BYTES+1]; -static uint8_t rgDCbuf[TLC_DEVICES*TLC_DC_BYTES+1] = +static uint8_t rgGSbuf[TLC_DEVICES*TLC_GS_BYTES] = {0}; +static uint8_t rgDCbuf[TLC_DEVICES*TLC_DC_BYTES] = { 12, 48, 195, 12, 48, 195, 12, 48, 195, 12, 48, 195, // DC=3 Red 12, 48, 195, 12, 48, 195, 12, 48, 195, 12, 48, 195, // DC=3 Blue @@ -62,9 +65,9 @@ void TLC5946_SetOutput_DC(uint8_t ic, uint8_t led, uint8_t value) } // Set the same value on one or more TLC clips. This is not called outside of this file. -static void TLC5946_SetOutput_DC_Many(uint8_t* data, uint8_t num_values, uint8_t value) +static void TLC5946_SetOutput_DC_Many(uint8_t* data, size_t len, uint8_t value) { - uint8_t* last_data = data + num_values * 3 / 4; + uint8_t* last_data = data + len; uint8_t byte1 = value << 2 | value >> 4; uint8_t byte2 = value << 4 | value >> 2; uint8_t byte3 = value << 6 | value; @@ -80,6 +83,7 @@ void TLC5946_TxINTCallback(void) // Latch pulse pXLAT(1); /* pBLANK(1); */ + // XLAT pulse duration min 20nS pXLAT(0); #ifdef TLC_CONTINUOUS @@ -91,7 +95,6 @@ void TLC5946_TxINTCallback(void) void TLC5946_Refresh_GS(void) { // Update Grayscale - pMODE(Mode_GS); pXLAT(0); /* pBLANK(1); */ @@ -109,44 +112,42 @@ void TLC5946_Refresh_GS(void) void TLC5946_Refresh_DC(void) { - pMODE(Mode_DC); + pMODE(TLC_MODE_DC); pXLAT(0); - // Update Dot Correction HAL_SPI_Transmit(TLC5946_SPIConfig, (uint8_t*)rgDCbuf, TLC_DC_BYTES*TLC_DEVICES, 100); - // Latch pulse pXLAT(1); + HAL_Delay(1); // TH2 MODE-XLAT^ min 100nS + pMODE(TLC_MODE_GS); + pXLAT(0); } // _____ Magus Functions _____ void TLC5946_setRGB(uint8_t LED_ID, uint16_t val_R, uint16_t val_G, uint16_t val_B) { TLC5946_SetOutput_GS(0, rgLED_R[LED_ID-1], val_R); - TLC5946_SetOutput_GS(2, rgLED_G[LED_ID-1], val_G); TLC5946_SetOutput_GS(1, rgLED_B[LED_ID-1], val_B); + TLC5946_SetOutput_GS(2, rgLED_G[LED_ID-1], val_G); } void TLC5946_setRGB_DC(uint8_t val_R, uint8_t val_G, uint8_t val_B) { - TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_CHANNELS, val_R); - TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES, TLC_CHANNELS, val_G); - TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES * 2, TLC_CHANNELS, val_B); - - TLC5946_Refresh_DC(); + TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_DC_BYTES, val_R); + TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES, TLC_DC_BYTES, val_B); + TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES*2, TLC_DC_BYTES, val_G); } void TLC5946_setAll_DC(uint8_t value) { - TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_CHANNELS * TLC_DEVICES, value); - TLC5946_Refresh_DC(); + TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_DC_BYTES * TLC_DEVICES, value); } void TLC5946_setAll(uint16_t val_R, uint16_t val_G, uint16_t val_B){ for(int i=0; i<16; i++){ TLC5946_SetOutput_GS(0, i, val_R); - TLC5946_SetOutput_GS(2, i, val_G); TLC5946_SetOutput_GS(1, i, val_B); + TLC5946_SetOutput_GS(2, i, val_G); } } @@ -155,6 +156,5 @@ void TLC5946_init (SPI_HandleTypeDef *spiconfig) { // Copy SPI handle to local variable TLC5946_SPIConfig = spiconfig; - - // + pMODE(TLC_MODE_GS); } diff --git a/Source/HAL_TLC5946.h b/Source/HAL_TLC5946.h index 4fb6ba45..9a4567d8 100644 --- a/Source/HAL_TLC5946.h +++ b/Source/HAL_TLC5946.h @@ -8,10 +8,6 @@ extern "C" { #endif -// Modes -#define Mode_GS 0 -#define Mode_DC 1 - // Pin Control #define pXLAT(state) HAL_GPIO_WritePin(TLC_XLAT_GPIO_Port, TLC_XLAT_Pin, (GPIO_PinState)state) #define pMODE(state) HAL_GPIO_WritePin(TLC_MODE_GPIO_Port, TLC_MODE_Pin, (GPIO_PinState)state) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index b0e2f851..d438a30d 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -1,10 +1,13 @@ -#ifndef __ParameterController_hpp__ -#define __ParameterController_hpp__ +#ifndef __MagusParameterController_hpp__ +#define __MagusParameterController_hpp__ +#include +#include +#include #include "device.h" #include "errorhandlers.h" #include "ProgramVector.h" -// #include "HAL_Encoders.h" +#include "HAL_Encoders.h" #include "Owl.h" #include "OpenWareMidiControl.h" #include "PatchRegistry.h" @@ -17,12 +20,7 @@ #include "ScreenBuffer.h" #include "HAL_TLC5946.h" -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); - #define NOF_ENCODERS 6 -#define ENC_MULTIPLIER 6 // shift left by this many steps -#define SHOW_CALIBRATION_INFO // This flag renders current values in calibration menu -#define CALIBRATION_INFO_FLOAT // Display float values instead of raw integers #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) @@ -34,10 +32,96 @@ void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); #define abs(x) ((x)>0?(x):-(x)) #endif -#include "calibration.hpp" - extern VersionToken* bootloader_token; +#define PORT_UNI_INPUT 1 +#define PORT_UNI_OUTPUT 2 +#define PORT_BI_INPUT 3 +#define PORT_BI_OUTPUT 4 +void setPortMode(uint8_t index, uint8_t mode); +uint8_t getPortMode(uint8_t index); + +enum EncoderIdentifier { + ENCODER_L = 0, // top left + ENCODER_R, // top right + ENCODER_1, // bottom row + ENCODER_2, + ENCODER_3, + ENCODER_4, +}; + +enum EncoderButton { + ENCODER_BUTTON_L = 0b00000001, + ENCODER_BUTTON_R = 0b00000010, + ENCODER_BUTTON_1 = 0b00000100, + ENCODER_BUTTON_2 = 0b00001000, + ENCODER_BUTTON_3 = 0b00010000, + ENCODER_BUTTON_4 = 0b00100000, + ENCODER_BUTTON_1234 = 0b00111100, + ENCODER_BUTTON_ANY = 0b00111111, +}; + +enum EncoderSensitivity { + SENS_SUPER_FINE = 1, + SENS_FINE = 2, + SENS_STANDARD = 3, + SENS_COARSE = 4, + SENS_SUPER_COARSE = 5 +}; +static EncoderSensitivity encoder_sensitivity = SENS_FINE; +// Sensitivity is currently not stored in settings, but it's not reset either. + +enum DisplayMode { + STANDARD_DISPLAY_MODE, + PROGRESS_DISPLAY_MODE, + ERROR_DISPLAY_MODE, + SELECT_BLOCK_DISPLAY_MODE, + SELECT_GLOBAL_DISPLAY_MODE, + STATUS_DISPLAY_MODE, + CONFIG_PATCH_DISPLAY_MODE, + CONFIG_VOLUME_DISPLAY_MODE, + CONFIG_SENSITIVITY_DISPLAY_MODE, + CONFIG_LEDS_DISPLAY_MODE, + CONFIG_EXIT_DISPLAY_MODE, +}; +// DisplayMode displayMode; +void setDisplayMode(uint8_t mode); + +class Page { +protected: + // static constexpr int16_t encoder_sensitivity = 1; + static constexpr int16_t encoder_mask = 0x01; +public: + virtual void draw(ScreenBuffer& screen){} + virtual void enter(){} + virtual void exit(){} + virtual void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} + virtual void buttonsChanged(uint32_t current, uint32_t previous){} + // helper functions + static int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0 && (current & encoder_mask) == encoder_mask) + return 1; + if(delta < 0 && (current & encoder_mask) == encoder_mask) + return -1; + return 0; + } + static int16_t getContinuousEncoderValue(int16_t current, int16_t previous, int16_t scale){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0) + delta = scale << (delta/3); + else + delta = -scale << (-delta/3); + return delta; + } + static bool pressed(uint32_t bid, uint32_t current, uint32_t previous){ + return (current & bid) && !(previous & bid); + } + static bool released(uint32_t bid, uint32_t current, uint32_t previous){ + return !(current & bid) && (previous & bid); + } +}; + /* screen 128 x 64, font 5x7 4 blocks, 32px per each, 3-4 letters each @@ -47,85 +131,25 @@ press once to toggle mode: update > select turn to scroll through 4 functions press again to select parameter: select > update - -todo: -- update parameter / encoderChanged -- select parameter -- select global parameter -- select preset mode */ -template -class ParameterController { +class MagusParameterController : public ParameterController { public: - char title[11] = "Magus"; - - enum EncoderSensitivity { - SENS_SUPER_FINE = 0, - SENS_FINE = (ENC_MULTIPLIER / 2), - SENS_STANDARD = ENC_MULTIPLIER, - SENS_COARSE = (3 * ENC_MULTIPLIER / 2), - SENS_SUPER_COARSE = (ENC_MULTIPLIER * 2) - }; - EncoderSensitivity encoderSensitivity = SENS_STANDARD; - // Sensitivity is currently not stored in settings, but it's not reset either. - bool sensitivitySelected; - - int16_t parameters[SIZE]; + Page* page = NULL; + uint16_t buttons; int16_t encoders[NOF_ENCODERS]; // last seen encoder values - int16_t offsets[NOF_ENCODERS]; // last seen encoder values - int16_t user[SIZE]; // user set values (ie by encoder or MIDI) - char names[SIZE][12]; - // char blocknames[4][NOF_ENCODERS] = {"OSC", "FLT", "ENV", "LFO"} ; // 4 times up to 5 letters/32px + int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) uint8_t selectedBlock; uint8_t selectedPid[NOF_ENCODERS]; - enum DisplayMode { - STANDARD, SELECTBLOCKPARAMETER, SELECTGLOBALPARAMETER, CONTROL, ERROR - }; - DisplayMode displayMode; - - enum ControlMode { - PLAY, STATUS, PRESET, DATA, VOLUME, LEDS, CALIBRATE, EXIT, NOF_CONTROL_MODES - }; - ControlMode controlMode = PLAY; - bool saveSettings; - - bool resourceDelete; - bool resourceDeletePressed; // This is used to ensure that we don't delete current resourse on menu enter - - InputCalibration input_cal; - OutputCalibration output_cal; - BaseCalibration *current_cal; - BaseCalibration::CalibrationMode calibrationMode; - bool isCalibrationRunning; - bool isCalibrationModeSelected; - bool calibrationConfirm = false; //A flag used to track encoder presses. - bool continueCalibration = false; // Runs output calibration for several buffer - - const char controlModeNames[NOF_CONTROL_MODES][12] = { - " Play >", - "< Status >", - "< Preset >", - "< Data >", - "< Volume >", - "< LEDs >", - "< V/Oct " }; - ParameterController(){ - reset(); + MagusParameterController(){ + setDisplayMode(PROGRESS_DISPLAY_MODE); } + void reset(){ - saveSettings = false; - resourceDelete = false; - drawCallback = defaultDrawCallback; - for(int i=0; i> encoderSensitivity); + void changePage(Page* page){ + if(this->page != page){ + if(this->page != NULL) + this->page->exit(); + this->page = page; + page->enter(); + } } - - void draw(uint8_t* pixels, uint16_t width, uint16_t height){ - ScreenBuffer screen(width, height); - screen.setBuffer(pixels); - draw(screen); + + void drawMessage(int16_t y, ScreenBuffer& screen){ + ProgramVector* pv = getProgramVector(); + if(pv->message != NULL){ + screen.setTextSize(1); + screen.setTextWrap(true); + screen.print(0, y, pv->message); + screen.setTextWrap(false); + } } - void drawLoadProgress(uint8_t progress, ScreenBuffer &screen){ - // progress should be 0 - 127 - screen.drawRectangle(0, 30, 128, 20, WHITE); - screen.setCursor(32, 40); - screen.setTextSize(1); - screen.print("Uploading..."); - screen.fillRectangle(0, 44, progress, 5, WHITE); + void drawParameter(ScreenBuffer& screen){ + drawParameter(selectedPid[selectedBlock], 54, screen); } void drawParameter(int pid, int y, ScreenBuffer& screen){ @@ -181,6 +203,7 @@ class ParameterController { y -= 7; x += 64; screen.drawRectangle(x, y, max(1, min(64, parameters[pid]/64)), 6, WHITE); + screen.fillRectangle(x, y+1, max(1, min(64, user[pid]/64)), 4, WHITE); } void drawBlocks(ScreenBuffer& screen){ @@ -202,7 +225,7 @@ class ParameterController { if(selectedPid[0] > 0) screen.print(1, 24, names[selectedPid[0]-1]); screen.print(1, 24+10, names[selectedPid[0]]); - if(selectedPid[0] < SIZE-1) + if(selectedPid[0] < NOF_PARAMETERS-1) screen.print(1, 24+20, names[selectedPid[0]+1]); screen.invert(0, 25, 64, 10); } @@ -237,104 +260,198 @@ class ParameterController { int block = 2; for(int i=0; i<16; ++i){ // 4px high by up to 16px long rectangle, filled if selected - if(i == selectedPid[block]) + if(i == selectedPid[block]){ screen.fillRectangle(x, y, max(1, min(16, parameters[i]/255)), 4, WHITE); - else + }else{ screen.drawRectangle(x, y, max(1, min(16, parameters[i]/255)), 4, WHITE); + // screen.drawRectangle(x, y+1, max(1, min(16, user[i]/255)), 2, WHITE); + } x += 16; - if(i & 0x01) - block++; if(i == 7){ x = 0; y += 3; - block = 0; + block = 2; + }else if(i & 0x01){ + block++; } } } - - void drawPlay(ScreenBuffer& screen) { - int offset = 16; - screen.setTextSize(1); - screen.print(1, offset + 33, "Encoder sensitivity"); - screen.drawCircle(24, offset + 15, 8, WHITE); - screen.drawCircle(44, offset + 15, 8, WHITE); - screen.drawCircle(64, offset + 15, 8, WHITE); - screen.drawCircle(84, offset + 15, 8, WHITE); - screen.drawCircle(104, offset + 15, 8, WHITE); - - screen.fillCircle(24, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_FINE) - screen.fillCircle(44, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_STANDARD) - screen.fillCircle(64, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_COARSE) - screen.fillCircle(84, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_SUPER_COARSE) - screen.fillCircle(104, offset + 15, 6, WHITE); -} + void drawTitle(ScreenBuffer& screen){ + drawTitle(title, screen); + } - void drawStatus(ScreenBuffer& screen){ - int offset = 16; - screen.setTextSize(1); - // single row - screen.print(1, offset+8, "mem "); - ProgramVector* pv = getProgramVector(); - int mem = (int)(pv->heap_bytes_used)/1024; - if(mem > 999){ - screen.print(mem/1024); - screen.print("M"); - }else{ - screen.print(mem); - screen.print("k"); + void drawTitle(const char* title, ScreenBuffer& screen){ + // draw title + screen.setTextSize(2); + screen.print(0, 16, title); + } + + void draw(ScreenBuffer& screen){ + screen.clear(); + screen.setTextWrap(false); + page->draw(screen); + drawBlocks(screen); + } + + void setName(uint8_t pid, const char* name){ + ParameterController::setName(pid, name); +#ifdef OWL_MAGUS + if(pid < NOF_PARAMETERS){ + if(name[strnlen(name, 11)-1] == '>') + setPortMode(pid, PORT_UNI_OUTPUT); + else + setPortMode(pid, PORT_UNI_INPUT); } +#endif + } - // draw flash usage - int flash_used = storage.getUsedSize() / 1024; - int flash_total = storage.getTotalCapacity() / 1024; - screen.print(64, offset + 8, "flash "); - screen.print(flash_used * 100 / flash_total); - screen.print("%"); - screen.setCursor(64, offset + 17); - if (flash_used > 999) { - screen.print(flash_used / 1024); - screen.print("."); - screen.print((int)((flash_used % 1024) * 10 / 1024)); - screen.print("M/"); + bool isEncoderPushed(EncoderButton enc){ + return buttons & enc; + } + + void updateEncoders(int16_t* data, uint8_t size){ + if(buttons != data[0]){ + page->buttonsChanged(data[0], buttons); + buttons = data[0]; } - else { - screen.print(flash_used); - screen.print("k/"); + for(size_t i=0; iencoderChanged(i, value, encoders[i]); + encoders[i] = value; + } } - if (flash_total > 999) { - screen.print(flash_total / 1024); - screen.print("."); - screen.print((int)((flash_total % 1024) * 10 / 1024)); - screen.print("M"); + } + +// called by MIDI cc and/or from patch + void setValue(uint8_t pid, int16_t value){ + user[pid] = value; + // TODO: store values set from patch somewhere and multiply with user[] value for outputs + // graphics.params.updateOutput(i, getOutputValue(i)); + } + + // @param value is the modulation ADC value + void updateValue(uint8_t pid, int16_t value){ + // smoothing at apprx 50Hz + parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); + } + + int16_t getValue(uint8_t pid){ + return parameters[pid]; + } + + void updateOutput(uint8_t pid, int16_t value){ + parameters[pid] = max(0, min(4095, (((parameters[pid] + (user[pid]*value))>>12)>>1))); + } + + void changeValue(uint8_t enc, int16_t delta){ + user[selectedPid[enc]] = std::clamp(user[selectedPid[enc]] + delta, 0, 4095); + selectedBlock = enc; + } + + void changeAssignGlobal(uint8_t enc, int16_t delta){ + selectedPid[enc] = std::clamp(selectedPid[enc] + delta, 0, NOF_PARAMETERS-1); + selectedBlock = enc; + } + + void changeAssignBlock(uint8_t enc, int16_t delta){ + int8_t pid = selectedPid[enc] + delta; + uint8_t i = enc-2; + if(pid == i*2+2) + pid = i*2+8; // skip up + if(pid == i*2+7) + pid = i*2+1; // skip down + selectedPid[enc] = std::clamp((int)pid, i*2, i*2+9); + } +}; + +extern MagusParameterController params; + +class StandardPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + // Quick selection of global parameter by right encoder - without popover menu + params.changeAssignGlobal(ENCODER_L, getDiscreteEncoderValue(current, previous)); + }else{ + params.changeValue(encoder, getContinuousEncoderValue(current, previous, 40)); } - else { - screen.print(flash_total); - screen.print("k"); + } + void buttonsChanged(uint32_t current, uint32_t previous){ + switch(current){ + case ENCODER_BUTTON_L: + setDisplayMode(SELECT_GLOBAL_DISPLAY_MODE); + break; + case ENCODER_BUTTON_R: + setDisplayMode(STATUS_DISPLAY_MODE); + break; + case ENCODER_BUTTON_1: + params.selectedBlock = ENCODER_1; + setDisplayMode(SELECT_BLOCK_DISPLAY_MODE); + break; + case ENCODER_BUTTON_2: + params.selectedBlock = ENCODER_2; + setDisplayMode(SELECT_BLOCK_DISPLAY_MODE); + break; + case ENCODER_BUTTON_3: + params.selectedBlock = ENCODER_3; + setDisplayMode(SELECT_BLOCK_DISPLAY_MODE); + break; + case ENCODER_BUTTON_4: + params.selectedBlock = ENCODER_4; + setDisplayMode(SELECT_BLOCK_DISPLAY_MODE); + break; } + } + void draw(ScreenBuffer& screen){ + if(getErrorStatus()) + setDisplayMode(ERROR_DISPLAY_MODE); + params.drawParameter(screen); // display last changed parameter + // use callback to draw title and message + graphics.drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); + } +}; - // draw CPU load - screen.print(1, offset + 17, "cpu "); - screen.print((int)((pv->cycles_per_block) / pv->audio_blocksize) / 35); - screen.print("%"); - - // draw firmware version - screen.print(1, offset+26, getFirmwareVersion()); - if (bootloader_token->magic == BOOTLOADER_MAGIC){ - screen.print(" (bt."); - screen.print(getBootloaderVersion()); - screen.print(")"); +class ErrorPage : public Page { + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setErrorStatus(0); + } + void draw(ScreenBuffer& screen){ + if(getErrorStatus() == NO_ERROR){ + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + params.drawTitle("ERROR", screen); + drawError(screen); + drawStats(screen); } } - + + // void drawError(ScreenBuffer& screen){ + // if(getErrorMessage() != NULL){ + // params.drawTitle("ERROR", screen); + // screen.setTextSize(1); + // screen.setTextWrap(true); + // screen.print(0, 26, getErrorMessage()); + // screen.setTextWrap(false); + // } + // drawMessage(51, screen); + // } + + void drawError(ScreenBuffer& screen){ + screen.setTextSize(2); + screen.print(1, 16, "ERROR"); + screen.setTextSize(1); + if(getErrorMessage() != NULL) + screen.print(2, 25, getErrorMessage()); + if(getDebugMessage() != NULL) + screen.print(2, 32, getDebugMessage()); + } + void drawStats(ScreenBuffer& screen){ int offset = 0; screen.setTextSize(1); - // screen.clear(86, 0, 128-86, 16); // draw memory use // two columns @@ -352,97 +469,111 @@ class ParameterController { // draw CPU load screen.print(110, offset+8, "cpu"); screen.setCursor(110, offset+17); - screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/35); + screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/(ARM_CYCLES_PER_SAMPLE/100)); screen.print("%"); } +}; - void drawError(ScreenBuffer& screen){ - if(getErrorMessage() != NULL){ - screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, 26, getErrorMessage()); - screen.setTextWrap(false); +class SelectGlobalPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_L){ + // update selected global parameter + // TODO: add 'special' parameters: Volume, Freq, Gain, Gate + params.changeAssignGlobal(ENCODER_L, getDiscreteEncoderValue(current, previous)); } - drawMessage(51, screen); } - - void drawTitle(ScreenBuffer& screen){ - drawTitle(title, screen); + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(ENCODER_BUTTON_L)) + setDisplayMode(STANDARD_DISPLAY_MODE); + params.drawTitle(screen); + params.drawGlobalParameterNames(screen); } +}; - void drawTitle(const char* title, ScreenBuffer& screen){ - // draw title - screen.setTextSize(2); - screen.print(0, 16, title); +class SelectBlockPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + // if(params.isEncoderPushed(ENCODER_BUTTON_1234)){ + // if(params.isEncoderPushed(ENCODER_BUTTON_1234)){ + if(encoder == params.selectedBlock){ + // update selected block parameter + params.changeAssignBlock(encoder, getDiscreteEncoderValue(current, previous)); + } } - - void drawMessage(int16_t y, ScreenBuffer& screen){ - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL){ - screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, y, pv->message); - screen.setTextWrap(false); - } + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(EncoderButton(1<", screen); + int offset = 16; screen.setTextSize(1); - selected = min(selected, registry.getNumberOfPatches()-1); - if(selected > 1) { - screen.setCursor(1, 24); - screen.print((int)selected - 1); - screen.print("."); - screen.print(registry.getPatchName(selected - 1)); - }; - screen.setCursor(1, 24+10); - screen.print((int)selected); - screen.print("."); - screen.print(registry.getPatchName(selected)); - if(selected+1 < (int)registry.getNumberOfPatches()) { - screen.setCursor(1, 24+20); - screen.print((int)selected + 1); - screen.print("."); - screen.print(registry.getPatchName(selected+1)); + screen.print(1, offset + 33, "Encoder sensitivity"); + screen.drawCircle(24, offset + 15, 8, WHITE); + screen.drawCircle(44, offset + 15, 8, WHITE); + screen.drawCircle(64, offset + 15, 8, WHITE); + screen.drawCircle(84, offset + 15, 8, WHITE); + screen.drawCircle(104, offset + 15, 8, WHITE); + screen.fillCircle(24, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_FINE) + screen.fillCircle(44, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_STANDARD) + screen.fillCircle(64, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_COARSE) + screen.fillCircle(84, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_SUPER_COARSE) + screen.fillCircle(104, offset + 15, 6, WHITE); + } + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_SENSITIVITY_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + int16_t delta = getDiscreteEncoderValue(current, previous); + encoder_sensitivity = (EncoderSensitivity)std::clamp(encoder_sensitivity + delta, (int)SENS_SUPER_FINE, (int)SENS_SUPER_COARSE); } - screen.invert(0, 25, 128, 10); } +}; - void drawResourceNames(int selected, ScreenBuffer &screen) { - screen.setTextSize(1); - if (resourceDelete) - selected = min(selected, registry.getNumberOfResources()); - else - selected = min(selected, registry.getNumberOfResources() - 1); - if (resourceDelete && selected == 0) - screen.print(18, 24, "Delete:"); - if (selected > 0 && registry.getNumberOfResources() > 0) { - screen.setCursor(1, 24); - screen.print((int)selected); - screen.print("."); - screen.print(registry.getResourceName(selected)); - }; - if (selected < (int)registry.getNumberOfResources()) { - screen.setCursor(1, 24 + 10); - screen.print((int)selected + 1); - screen.print("."); - screen.print(registry.getResourceName(1 + selected)); - } - else if (resourceDelete) - screen.print(18, 24 + 10, "Exit"); - if (selected + 1 < (int)registry.getNumberOfResources()) { - screen.setCursor(1, 24 + 20); - screen.print((int)selected + 2); - screen.print("."); - screen.print(registry.getResourceName(2 + selected)); +class ConfigVolumePage : public Page { +public: + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_VOLUME_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + int16_t value = std::clamp(settings.audio_output_gain + getContinuousEncoderValue(current, previous, 1), 0, 127); + if(settings.audio_output_gain != value){ + settings.audio_output_gain = value; + codec.setOutputGain(value); + } } - if (resourceDelete) - screen.drawRectangle(0, 25, 128, 10, WHITE); - else - screen.invert(0, 25, 128, 10); } - - void drawVolume(uint8_t selected, ScreenBuffer& screen){ + void draw(ScreenBuffer& screen){ + params.drawTitle("< Volume >", screen); + drawVolume(screen); + } + void drawVolume(ScreenBuffer& screen){ screen.setTextSize(1); screen.print(1, 24 + 10, "Volume "); screen.print((int)settings.audio_output_gain); @@ -450,8 +581,44 @@ class ParameterController { screen.fillRectangle(64, 24 + 1 + 2, (int)settings.audio_output_gain >> 1, 4, WHITE); screen.invert(0, 24, 40, 10); } +}; - void drawLeds(uint8_t selected, ScreenBuffer& screen){ +class ConfigLedsPage : public Page { +public: + // void exit(){ + // extern uint8_t ENCODER_CS_DELAY_US; + // ENCODER_CS_DELAY_US = settings.leds_brightness; + // } + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_LEDS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + // todo: set red/green/blue individually with different encoders + int8_t value = std::clamp(settings.leds_brightness + getContinuousEncoderValue(current, previous, 1), 0, 63); + if(settings.leds_brightness != value){ + settings.leds_brightness = value; + TLC5946_setAll_DC(value); + TLC5946_Refresh_DC(); + } + } + } + void draw(ScreenBuffer& screen){ + // " Play >", + // "< Status >", + // "< Preset >", + // "< Data >", + // "< Volume >", + // "< LEDs", + params.drawTitle("< LEDs", screen); + drawLeds(screen); + } + + void drawLeds(ScreenBuffer& screen){ screen.setTextSize(1); screen.print(1, 24 + 10, "Level "); screen.print((int)settings.leds_brightness); @@ -459,598 +626,251 @@ class ParameterController { screen.fillRectangle(64, 24 + 1 + 2, (int)settings.leds_brightness, 4, WHITE); screen.invert(0, 24, 40, 10); } +}; - void drawCalibration(uint8_t selected, ScreenBuffer& screen){ - screen.setTextSize(1); - if (isCalibrationRunning) { - if (isCalibrationModeSelected) { - float input_multiplier = (float)(int32_t)settings.input_scalar / UINT16_MAX; - float input_offset = (float)(int32_t)settings.input_offset / UINT16_MAX; - float input_sample = current_cal->getInput(); - float input_voltage = (input_sample - input_offset) * input_multiplier; - - switch (current_cal->state){ - case BaseCalibration::CAL_LO: - if (calibrationMode == BaseCalibration::CAL_INPUT) { - screen.print(1, 24 + 10, "1V to IN1"); - } - else { - screen.print(1, 24 + 10, "OUT1 to IN1"); - screen.print(1, 24 + 20, "Voltage "); - screen.print(input_voltage); - } - screen.print(1, 24 + 30, "Sample "); - screen.print(input_sample); - break; - case BaseCalibration::CAL_HI: - if (calibrationMode == BaseCalibration::CAL_INPUT) { - screen.print(1, 24 + 10, "3V to IN1"); - } - else { - screen.print(1, 24 + 10, "OUT1 to IN1"); - screen.print(1, 24 + 20, "Voltage "); - screen.print(input_voltage); - } - screen.print(1, 24 + 30, "Sample "); - screen.print(input_sample); - break; - case BaseCalibration::CAL_DONE: - // Save or discard results - screen.print(1, 24, "Calibration results"); - screen.print(1, 24 + 10, "Scalar:"); - screen.print((float)current_cal->getScalar() / UINT16_MAX); - screen.print(1, 24 + 20, "Offset:"); - screen.print((float)current_cal->getOffset() / UINT16_MAX); - - screen.print(1, 24 + 30, "Save"); - screen.print(65, 24 + 30, "Discard"); - if (selected == BaseCalibration::CAL_SAVE) { - screen.invert(0, 24 + 20, 64, 10); - } - else { - screen.invert(64, 24 + 20, 64, 10); - } - break; - } - } - else { - // Select calibration mode - screen.print(1, 24, "Input"); - screen.print(49, 24, "Output"); - screen.print(97, 24, "Exit"); - switch (selected) { - case BaseCalibration::CAL_INPUT: - screen.invert(0, 14, 48, 10); - break; - case BaseCalibration::CAL_OUTPUT: - screen.invert(48, 14, 48, 10); - break; - default: - screen.invert(96, 14, 48, 10); - break; - } - } - } - else { - screen.print(1, 24, "Start calibration"); - #ifdef SHOW_CALIBRATION_INFO - // Not sure if this should be visible by default, but it helps while debugging - screen.invert(0, 14, 128, 10); - screen.print(29, 24 + 10, "Input"); - screen.print(78, 24 + 10, "Output"); - screen.print(1, 24 + 20, "Scl"); - - #ifdef CALIBRATION_INFO_FLOAT - screen.print(29, 24 + 20, msg_ftoa((float)((int32_t)settings.input_scalar) / UINT16_MAX, 10)); - screen.print(78, 24 + 20, msg_ftoa((float)((int32_t)settings.output_scalar) / UINT16_MAX, 10)); - #else - screen.print(29, 24 + 20, msg_itoa(settings.input_scalar, 10)); - screen.print(78, 24 + 20, msg_itoa(settings.output_scalar, 10)); - #endif // CALIBRATION_INFO_FLOAT - - screen.print(1, 24 + 30, "Off"); - - #ifdef CALIBRATION_INFO_FLOAT - screen.print(29, 24 + 30, msg_ftoa((float)((int32_t)settings.input_offset) / UINT16_MAX, 10)); - screen.print(78, 24 + 30, msg_ftoa((float)((int32_t)settings.output_offset) / UINT16_MAX, 10)); - #else - screen.print(29, 24 + 30, msg_itoa(settings.input_offset, 10)); - screen.print(78, 24 + 30, msg_itoa(settings.output_offset, 10)); - #endif // CALIBRATION_INFO_FLOAT - - screen.drawHorizontalLine(0, 24 + 10, 128, WHITE); - screen.drawHorizontalLine(0, 24 + 20, 128, WHITE); - screen.drawVerticalLine(27, 24, 30, WHITE); - screen.drawVerticalLine(76, 24, 30, WHITE); - #endif // SHOW_CALIBRATION_INFO - } +class SelectPatchPage : public Page { +public: + uint8_t patchselect; + void reset(){ + patchselect = program.getProgramIndex(); } - - void drawControlMode(ScreenBuffer& screen){ - switch(controlMode){ - case PLAY: - // drawMessage("push to exit ->", screen); - drawTitle(controlModeNames[controlMode], screen); - drawPlay(screen); - break; - case STATUS: - drawTitle(controlModeNames[controlMode], screen); - drawStatus(screen); - drawMessage(51, screen); - break; - case PRESET: - drawTitle(controlModeNames[controlMode], screen); - drawPresetNames(selectedPid[1], screen); - break; - case DATA: - drawTitle(controlModeNames[controlMode], screen); - drawResourceNames(selectedPid[1], screen); - break; - case VOLUME: - drawTitle(controlModeNames[controlMode], screen); - drawVolume(selectedPid[1], screen); - break; - case LEDS: - drawTitle(controlModeNames[controlMode], screen); - drawLeds(selectedPid[1], screen); - break; - case CALIBRATE: - drawTitle(controlModeNames[controlMode], screen); - drawCalibration(selectedPid[1], screen); - break; - case EXIT: - drawTitle("done", screen); - break; - default: - break; + void enter(){ + reset(); + } + // void exit(){ + // if(isEncoderPressed(ENCODER_BUTTON_L) && patchselect != program.getProgramIndex() && + // registry.hasPatch(patchselect)){ + // program.loadProgram(patchselect); + // program.resetProgram(false); + // } + // } // only change patch when exiting through ExitPatch + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + reset(); + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_PATCH_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + patchselect = std::clamp(patchselect + getDiscreteEncoderValue(current, previous), 1, (int)registry.getNumberOfPatches()-1); } - // todo! - // select: Scope, VU Meter, Patch Stats, Set Gain, Show MIDI, Reset Patch, Select Patch... } - void draw(ScreenBuffer& screen){ - screen.clear(); - screen.setTextWrap(false); - switch(displayMode){ - case STANDARD: - // draw most recently changed parameter - // drawParameter(selectedPid[selectedBlock], 44, screen); - if (owl.getOperationMode() == LOAD_MODE){ - drawLoadProgress(user[LOAD_INDICATOR_PARAMETER] * 127 / 4095, screen); - } - else { - drawParameter(selectedPid[selectedBlock], 54, screen); - } - // use callback to draw title and message - drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); - break; - case SELECTBLOCKPARAMETER: - drawTitle(screen); - drawBlockParameterNames(screen); - break; - case SELECTGLOBALPARAMETER: - drawTitle(screen); - drawGlobalParameterNames(screen); - break; - case CONTROL: - drawControlMode(screen); - break; - case ERROR: - drawTitle("ERROR", screen); - drawError(screen); - drawStats(screen); - break; + params.drawTitle("< Patch >", screen); + drawPresetNames(patchselect, screen); + } + void drawPresetNames(uint8_t selected, ScreenBuffer& screen){ + screen.setTextSize(1); + selected = min(selected, (int)registry.getNumberOfPatches()-1); + if(selected > 1) { + screen.setCursor(1, 24); + screen.print((int)selected - 1); + screen.print("."); + screen.print(registry.getPatchName(selected - 1)); + }; + screen.setCursor(1, 24+10); + screen.print((int)selected); + screen.print("."); + screen.print(registry.getPatchName(selected)); + if(selected+1 < (int)registry.getNumberOfPatches()) { + screen.setCursor(1, 24+20); + screen.print((int)selected + 1); + screen.print("."); + screen.print(registry.getPatchName(selected+1)); } - drawBlocks(screen); + screen.invert(0, 25, 128, 10); } +}; - void setName(uint8_t pid, const char* name){ - if(pid < SIZE){ - strncpy(names[pid], name, 11); -#ifdef OWL_MAGUS - if(names[pid][strnlen(names[pid], 11)-1] == '>') - setPortMode(pid, PORT_UNI_OUTPUT); - else - setPortMode(pid, PORT_UNI_INPUT); -#endif +class StatusPage : public Page { +public: + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(STATUS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); } } - - void setTitle(const char* str){ - strncpy(title, str, 10); - } - - uint8_t getSize(){ - return SIZE; - } - - void selectBlockParameter(uint8_t enc, int8_t pid){ - uint8_t i = enc-2; - if(pid == i*2+2) - pid = i*2+8; // skip up - if(pid == i*2+7) - pid = i*2+1; // skip down - selectedPid[enc] = max(i*2, min(i*2+9, pid)); - setEncoderValue(enc, user[selectedPid[enc]]); - } - - void selectGlobalParameter(int8_t pid){ - selectedPid[0] = max(0, min(SIZE-1, pid)); - setEncoderValue(0, user[selectedPid[0]]); - } - - void setControlMode(uint8_t value){ - controlMode = (ControlMode)value; - switch(controlMode){ - case PLAY: - case STATUS: - break; - case PRESET: - selectedPid[1] = settings.program_index; - break; - case DATA: - selectedPid[1] = 0; // Go to beginning of resource list - resourceDelete = false; - break; - case VOLUME: - selectedPid[1] = settings.audio_output_gain; // todo: get current - break; - case LEDS: - selectedPid[1] = settings.leds_brightness; - break; - case CALIBRATE: - selectedPid[1] = 2; - resetCalibration(); - break; - default: - break; - } + void draw(ScreenBuffer& screen){ + params.drawTitle(" Status >", screen); + drawStatus(screen); } - - void selectControlMode(int16_t value, bool pressed){ - if(pressed){ - switch(controlMode){ - case PLAY: - if (sensitivitySelected) { - controlMode = EXIT; - } - break; - case STATUS: - setErrorStatus(NO_ERROR); - break; - case PRESET: - // load preset - settings.program_index = selectedPid[1]; - program.loadProgram(settings.program_index); - program.resetProgram(false); - controlMode = EXIT; - break; - case DATA: { - if (resourceDelete) { - if (selectedPid[1] == registry.getNumberOfResources()){ - // Exit on last menu item (exit link after resources list) - resourceDelete = false; - resourceDeletePressed = false; - controlMode = EXIT; - } - else if (!resourceDeletePressed) { - // Delete resource unless it's protected by "__" prefix - resourceDeletePressed = true; - Resource* res = registry.getResource(selectedPid[1]); - if (res != NULL) { - if(res->getName()[0] == '_' && res->getName()[1] == '_'){ - debugMessage("Resource protected"); - } - else { - storage.eraseResource(res); - } - } - } - } - else { - resourceDelete = true; - resourceDeletePressed = true; - } - break; - } - case VOLUME: - controlMode = EXIT; - break; - case LEDS: - controlMode = EXIT; - break; - case CALIBRATE: - if (!calibrationConfirm) { - calibrationConfirm = true; - updateCalibration(); - } - break; - default: - break; - } + + void drawStatus(ScreenBuffer& screen){ + int offset = 16; + screen.setTextSize(1); + // single row + screen.print(1, offset+8, "mem "); + ProgramVector* pv = getProgramVector(); + int mem = (int)(pv->heap_bytes_used)/1024; + if(mem > 999){ + screen.print(mem/1024); + screen.print("M"); }else{ - if(controlMode == EXIT){ - displayMode = STANDARD; - sensitivitySelected = false; - if(saveSettings) - settings.saveToFlash(); - }else{ - int16_t delta = value - encoders[1]; - if(delta > 0 && controlMode+1 < NOF_CONTROL_MODES){ - setControlMode(controlMode+1); - }else if(delta < 0 && controlMode > 0){ - setControlMode(controlMode-1); - } - if (controlMode == CALIBRATE) { - if (continueCalibration) - updateCalibration(); - else - calibrationConfirm = false; - } - else if (controlMode == DATA && resourceDeletePressed) { - resourceDeletePressed = false; - } - encoders[1] = value; - } + screen.print(mem); + screen.print("k"); } - } - - void resetCalibration(){ - //selectedPid[1] = 0; - isCalibrationRunning = false; - isCalibrationModeSelected = false; - input_cal.reset(); - output_cal.reset(); - } - void updateCalibration(){ - continueCalibration = false; - // This function runs once every time when encoder is pressed. - if (isCalibrationRunning){ - if (isCalibrationModeSelected) { - if (current_cal->state == BaseCalibration::CAL_DONE) { - current_cal->results = (BaseCalibration::CalibrationResults)selectedPid[1]; - if (current_cal->results == BaseCalibration::CAL_SAVE) - current_cal->storeResults(); - resetCalibration(); - program.loadProgram(settings.program_index); - program.resetProgram(false); - } else{ - if (current_cal->readSample()) { - current_cal->nextState(); - } - else { - continueCalibration = true; - } - if (current_cal->isDone()) - current_cal->calibrate(); - } - } else { - isCalibrationModeSelected = true; - switch (selectedPid[1]){ - case 0: - program.exitProgram(false); - input_cal.reset(); - break; - case 1: - program.exitProgram(false); - output_cal.reset(); - break; - //case 2: - // controlMode = EXIT; - // break; - } - } - } - else{ - isCalibrationRunning = true; + // draw flash usage + int flash_used = storage.getUsedSize() / 1024; + int flash_total = storage.getTotalCapacity() / 1024; + screen.print(64, offset + 8, "flash "); + screen.print(flash_used * 100 / flash_total); + screen.print("%"); + screen.setCursor(64, offset + 17); + if (flash_used > 999) { + screen.print(flash_used / 1024); + screen.print("."); + screen.print((int)((flash_used % 1024) * 10 / 1024)); + screen.print("M/"); } - } - - void setControlModeValue(uint8_t value){ - bool sensitivityChanged = false; - switch(controlMode){ - case PLAY: - sensitivitySelected = true; - value = max((uint8_t)SENS_SUPER_FINE, min((uint8_t)SENS_SUPER_COARSE, value)); - if (value > (uint8_t)encoderSensitivity){ - encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity + ENC_MULTIPLIER / 2); - value = (uint8_t)encoderSensitivity; - sensitivityChanged = true; - } - else { - if (selectedPid[1] < encoderSensitivity) { - encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity - ENC_MULTIPLIER / 2); - value = (uint8_t)encoderSensitivity; - sensitivityChanged = true; - } - } - selectedPid[1] = value; - if (sensitivityChanged) { - for (int eid = 0; eid < NOF_ENCODERS; eid++) { - // We update encoders with previous values recalculated with different sensitivity - if (eid != 1) - setEncoderValue(eid, user[selectedPid[eid]]); - } - } - break; - case VOLUME: - selectedPid[1] = max(0, min(127, value)); - codec.setOutputGain(selectedPid[1]); - settings.audio_output_gain = selectedPid[1]; - saveSettings = true; - break; - case LEDS: - selectedPid[1] = max(0, min(63, value)); - TLC5946_setAll_DC(selectedPid[1]); - TLC5946_Refresh_DC(); - settings.leds_brightness = selectedPid[1]; - saveSettings = true; - break; - case PRESET: - selectedPid[1] = max(1, min(registry.getNumberOfPatches()-1, value)); - break; - case DATA: - if (resourceDelete) - selectedPid[1] = max(0, min(registry.getNumberOfResources(), value)); - else - selectedPid[1] = max(0, min(registry.getNumberOfResources() - 1, value)); - break; - case CALIBRATE: - if (isCalibrationRunning && !isCalibrationModeSelected) { - selectedPid[1] = max(0, min(value, 2)); - // calibration process is not running yet. - switch ((BaseCalibration::CalibrationMode)selectedPid[1]){ - case BaseCalibration::CAL_INPUT: - calibrationMode = BaseCalibration::CAL_INPUT; - current_cal = &input_cal; - break; - case BaseCalibration::CAL_OUTPUT: - calibrationMode = BaseCalibration::CAL_OUTPUT; - current_cal = &output_cal; - break; - } - } - else if (isCalibrationRunning && isCalibrationModeSelected && current_cal->state == BaseCalibration::CAL_DONE) { - selectedPid[1] = max(0, min(value, 1)); - } - break; - default: - break; + else { + screen.print(flash_used); + screen.print("k/"); } - } - - void updateEncoders(int16_t* data, uint8_t size){ - uint16_t pressed = data[0]; - - // update encoder 1 top right - int16_t value = data[2]; - if(displayMode == CONTROL){ - selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed - if(pressed&0x3c) // exit status mode if any other encoder is pressed - controlMode = EXIT; - // use delta value from encoder 0 top left, store in selectedPid[1] - int16_t delta = data[1] - encoders[0]; - if(delta > 0 && selectedPid[1] < 127) { - setControlModeValue(selectedPid[1]+1); - } - else { - if(delta < 0 && selectedPid[1] > 0) { - setControlModeValue(selectedPid[1]-1); - } - } - encoders[0] = data[1]; - return; // skip normal encoder processing - // todo: should update offsets so values aren't changed on exit + if (flash_total > 999) { + screen.print(flash_total / 1024); + screen.print("."); + screen.print((int)((flash_total % 1024) * 10 / 1024)); + screen.print("M"); } else { - if(pressed & (1 << 1)){ - displayMode = CONTROL; - controlMode = PLAY; - selectedPid[1] = encoderSensitivity; - } - encoders[1] = value; - - // update encoder 0 top left - value = data[1]; - if(pressed & (1<<0)){ - // update selected global parameter - // TODO: add 'special' parameters: Volume, Freq, Gain, Gate - displayMode = SELECTGLOBALPARAMETER; - int16_t delta = value - encoders[0]; - if(delta < 0) { - selectGlobalParameter(selectedPid[0]-1); - } - else { - if(delta > 0) { - selectGlobalParameter(selectedPid[0]+1); - } - selectedBlock = 0; - } - } - else{ - if(encoders[0] != value){ - selectedBlock = 0; - encoders[0] = value; - // We must update encoder value before calculating user value, otherwise - // previous value would be displayed - user[selectedPid[0]] = getEncoderValue(0); - } - if(displayMode == SELECTGLOBALPARAMETER) - displayMode = STANDARD; - } - encoders[0] = value; - - // update encoders 2-6 bottom row - for(uint8_t i=2; i 0) - selectBlockParameter(i, selectedPid[i]+1); - } - else{ - if(encoders[i] != value){ - selectedBlock = i; - encoders[i] = value; - // We must update encoder value before calculating user value, otherwise - // previous value would be displayed - user[selectedPid[i]] = getEncoderValue(i); - } - if(displayMode == SELECTBLOCKPARAMETER && selectedBlock == i) - displayMode = STANDARD; - } - encoders[i] = value; - } - if(displayMode == STANDARD && getErrorStatus() && getErrorMessage() != NULL) - displayMode = ERROR; + screen.print(flash_total); + screen.print("k"); } - } - // called by MIDI cc and/or from patch - void setValue(uint8_t pid, int16_t value){ - user[pid] = value; - // reset encoder value if associated through selectedPid to avoid skipping - for(int i=0; icycles_per_block) / pv->audio_blocksize) / 35); + screen.print("%"); - // @param value is the modulation ADC value - void updateValue(uint8_t pid, int16_t value){ - // smoothing at apprx 50Hz - parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); + // draw firmware version + screen.print(1, offset+26, getFirmwareVersion()); +#ifdef DEBUG_BOOTLOADER + if (bootloader_token->magic == BOOTLOADER_MAGIC) + screen.print(1, offset+35, getBootloaderVersion()); +#endif } +}; - void updateOutput(uint8_t pid, int16_t value){ - parameters[pid] = max(0, min(4095, (((parameters[pid] + (user[pid]*value))>>12)>>1))); +class ProgressPage : public Page { + void draw(ScreenBuffer& screen){ + drawLoadProgress(screen); } - - // void updateValues(uint16_t* data, uint8_t size){ - // for(int i=0; i<16; ++i) - // parameters[selectedPid[i]] = encoders[i] + data[i]; + void drawLoadProgress(ScreenBuffer &screen){ + extern char* progress_message; + extern uint16_t progress_counter; + screen.drawRectangle(0, 30, 128, 20, WHITE); + // if(progress_counter != 4095) + screen.fillRectangle(0, 44, progress_counter * 128 / 4095, 5, WHITE); + screen.setCursor(33, 40); + screen.setTextSize(1); + if(progress_message == NULL) + screen.print("Loading"); + else + screen.print(progress_message); + } + + // void drawLoadProgress(ScreenBuffer &screen){ + // extern char* progress_message; + // extern uint16_t progress_counter; + // // uint16_t progress_counter = user[LOAD_INDICATOR_PARAMETER]; + // if(progress_message != NULL && progress_counter != 4095){ + // // if(progress_counter && progress_counter != 4095){ + // screen.drawRectangle(0, 30, 128, 20, WHITE); + // screen.setCursor(32, 40); + // screen.setTextSize(1); + // screen.print(progress_message); + // screen.fillRectangle(0, 44, progress_counter * 128 / 4095, 5, WHITE); + // } // } +}; - void encoderChanged(uint8_t encoder, int32_t delta){ + // const char controlModeNames[NOF_CONTROL_MODES][12] = { + // " Play >", + // "< Status >", + // "< Preset >", + // "< Data >", + // "< Volume >", + // "< LEDs >", + // "< V/Oct " }; + +StandardPage standardPage; +ProgressPage progressPage; +SelectBlockPage selectBlockPage; +SelectGlobalPage selectGlobalPage; +StatusPage statusPage; +EncoderSensitivityPage sensitivityPage; +SelectPatchPage selectPatchPage; +ConfigVolumePage configVolumePage; +ConfigLedsPage configLedsPage; +ErrorPage errorPage; + +class ExitPage : public Page { +public: + void enter(){ + uint8_t patchselect = selectPatchPage.patchselect; + if(patchselect != program.getProgramIndex() && + registry.hasPatch(patchselect)){ + program.loadProgram(patchselect); + program.resetProgram(false); + } + } // todo: save settings if exited with ENCODER_BUTTON_R + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(ENCODER_BUTTON_ANY)){ + // leave configuration mode on release + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(40, 26, "exit"); + } } +}; - - void setCallback(void *callback){ - if(callback == NULL) - drawCallback = defaultDrawCallback; - else - drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; +ExitPage exitPage; + + +void setDisplayMode(uint8_t mode){ + switch(mode){ + case STANDARD_DISPLAY_MODE: + params.changePage(&standardPage); + break; + case PROGRESS_DISPLAY_MODE: + params.changePage(&progressPage); + break; + case SELECT_BLOCK_DISPLAY_MODE: + params.changePage(&selectBlockPage); + break; + case SELECT_GLOBAL_DISPLAY_MODE: + params.changePage(&selectGlobalPage); + break; + case STATUS_DISPLAY_MODE: + params.changePage(&statusPage); + break; + case CONFIG_PATCH_DISPLAY_MODE: + params.changePage(&selectPatchPage); + break; + case CONFIG_VOLUME_DISPLAY_MODE: + params.changePage(&configVolumePage); + break; + case CONFIG_SENSITIVITY_DISPLAY_MODE: + params.changePage(&sensitivityPage); + break; + case CONFIG_LEDS_DISPLAY_MODE: + params.changePage(&configLedsPage); + break; + case CONFIG_EXIT_DISPLAY_MODE: + params.changePage(&exitPage); + break; + case ERROR_DISPLAY_MODE: + params.changePage(&errorPage); + break; } - void (*drawCallback)(uint8_t*, uint16_t, uint16_t); -}; +} -#endif // __ParameterController_hpp__ +#endif // __MagusParameterController_hpp__ diff --git a/Source/MidiController.cpp b/Source/MidiController.cpp index 6552c9a8..a0c6a379 100644 --- a/Source/MidiController.cpp +++ b/Source/MidiController.cpp @@ -112,7 +112,8 @@ class SendResourceNamesTask : public BackgroundTask { Resource* resource = registry.getResource(state); if(resource) midi_tx.sendName(SYSEX_RESOURCE_NAME_COMMAND, state+MAX_NUMBER_OF_PATCHES, - resource->getName(), resource->getDataSize(), storage.getChecksum(resource)); + resource->getName(), resource->getDataSize(), + storage.getChecksum(resource)); state++; }else{ owl.setBackgroundTask(NULL); // end this task @@ -124,11 +125,12 @@ void MidiController::sendPatchName(uint8_t slot){ if(slot == 0){ PatchDefinition* def = registry.getPatchDefinition(); if(def) - sendName(SYSEX_PRESET_NAME_COMMAND, slot, def->getName(), def->getProgramSize(), 0); + sendName(SYSEX_PRESET_NAME_COMMAND, slot, def->getName(), def->getBinarySize(), 0); }else{ Resource* resource = registry.getPatch(slot-1); if(resource) - sendName(SYSEX_PRESET_NAME_COMMAND, slot, resource->getName(), resource->getDataSize(), storage.getChecksum(resource)); + sendName(SYSEX_PRESET_NAME_COMMAND, slot, resource->getName(), resource->getDataSize(), + storage.getChecksum(resource)); } } @@ -205,7 +207,7 @@ void MidiController::sendName(uint8_t cmd, uint8_t index, const char* name, size // make the numbers big-endian datasize = __REV(datasize); crc = __REV(crc); - size_t len = strnlen(name, 24); + size_t len = strnlen(name, sizeof(ResourceHeader::name)); uint8_t buf[len+3+5+5]; buf[0] = cmd; buf[1] = index; @@ -366,14 +368,13 @@ void MidiController::sendConfigurationSetting(const char* name, uint32_t value){ } void MidiController::sendDeviceId(){ - uint32_t* deviceId = (uint32_t*)UID_BASE; char buf[32]; buf[0] = SYSEX_DEVICE_ID; char* p = &buf[1]; - p = stpcpy(p, msg_itoa(deviceId[0], 16, 8)); + p = stpcpy(p, msg_itoa(HAL_GetUIDw0(), 16, 8)); p = stpcpy(p, ":"); - p = stpcpy(p, msg_itoa(deviceId[1], 16, 8)); + p = stpcpy(p, msg_itoa(HAL_GetUIDw1(), 16, 8)); p = stpcpy(p, ":"); - p = stpcpy(p, msg_itoa(deviceId[2], 16, 8)); + p = stpcpy(p, msg_itoa(HAL_GetUIDw2(), 16, 8)); sendSysEx((uint8_t*)buf, p-buf); } diff --git a/Source/MidiHandler.cpp b/Source/MidiHandler.cpp index 93132ac2..85a9e2e1 100644 --- a/Source/MidiHandler.cpp +++ b/Source/MidiHandler.cpp @@ -179,6 +179,12 @@ void MidiHandler::updateCodecSettings(){ #define HEXCODE(x) ((uint16_t)(((x)[1]<<8)|(x)[0])) +void MidiHandler::handleProgramMessage(uint8_t* data, uint16_t size){ + // we've received a message destined for the patch + data[size] = '\0'; // terminate string, overwriting 0xf7 + owl.handleMessage((const char*)data, size); +} + void MidiHandler::handleConfigurationCommand(uint8_t* data, uint16_t size){ if(size < 3) // size may be 3 or more depending on number of digits in value return; @@ -254,6 +260,11 @@ void MidiHandler::handleConfigurationCommand(uint8_t* data, uint16_t size){ case HEXCODE(SYSEX_CONFIGURATION_BUS_FORWARD_MIDI): settings.bus_forward_midi = value; break; +#endif +#ifdef OWL_PEDAL + case HEXCODE(SYSEX_CONFIGURATION_EXPRESSION_PEDAL): + settings.expression_mode = value; + break; #endif } } @@ -401,6 +412,9 @@ void MidiHandler::handleSysEx(uint8_t* data, uint16_t size){ case SYSEX_BOOTLOADER_COMMAND: jump_to_bootloader(); break; + case SYSEX_PROGRAM_MESSAGE: + handleProgramMessage(data+4, size-5); + break; case SYSEX_FIRMWARE_UPLOAD: handleFirmwareUploadCommand(data+1, size-2); break; diff --git a/Source/MidiHandler.h b/Source/MidiHandler.h index 1e54ab61..2fd60196 100644 --- a/Source/MidiHandler.h +++ b/Source/MidiHandler.h @@ -38,6 +38,7 @@ class MidiHandler { void handleSettingsResetCommand(uint8_t* data, uint16_t size); void handleSettingsStoreCommand(uint8_t* data, uint16_t size); void handleDeviceResetCommand(uint8_t* data, uint16_t size); + void handleProgramMessage(uint8_t* data, uint16_t size); void runProgram(); }; diff --git a/Source/MidiStreamReader.cpp b/Source/MidiStreamReader.cpp index a4020aba..3b13deb4 100644 --- a/Source/MidiStreamReader.cpp +++ b/Source/MidiStreamReader.cpp @@ -2,6 +2,7 @@ #include "errorhandlers.h" MidiMessage MidiStreamReader::read(unsigned char data){ + // todo: realtime bytes can appear anywhere in the stream if(pos == size || status == READY_STATUS) clear(); buffer[pos++] = data; diff --git a/Source/OpenWareMidiControl.h b/Source/OpenWareMidiControl.h index dc63a482..066f0e22 100644 --- a/Source/OpenWareMidiControl.h +++ b/Source/OpenWareMidiControl.h @@ -95,6 +95,7 @@ enum PatchButtonId { #define SYSEX_CONFIGURATION_BUS_ENABLE "BE" #define SYSEX_CONFIGURATION_BUS_FORWARD_MIDI "BM" #define SYSEX_CONFIGURATION_BOOTLOADER_LOCK "BL" +#define SYSEX_CONFIGURATION_EXPRESSION_PEDAL "EP" enum OpenWareMidiSysexCommand { SYSEX_PRESET_NAME_COMMAND = 0x01, diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 929ecfc3..c1384891 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -19,14 +19,6 @@ #include "Storage.h" #include "PatchRegistry.h" -#ifdef OWL_BIOSIGNALS -#include "ads.h" -#ifdef USE_KX122 -#include "kx122.h" -#endif -#include "ble_midi.h" -#endif - #if defined USE_RGB_LED #include "rainbow.h" #endif /* USE_RGB_LED */ @@ -53,7 +45,7 @@ ApplicationSettings settings; Codec codec; #endif #ifdef USE_ADC -uint16_t adc_values[NOF_ADC_VALUES] DMA_RAM; +uint16_t adc_values[NOF_ADC_VALUES] DMA_RAM = {}; #endif #ifdef USE_DAC extern DAC_HandleTypeDef hdac; @@ -76,39 +68,6 @@ void midiSetOutputChannel(int8_t channel){ midi_tx.setOutputChannel(channel); } -__weak void initLed(){ - // Initialise RGB LED PWM timers -#if defined OWL_TESSERACT - extern TIM_HandleTypeDef htim2; - extern TIM_HandleTypeDef htim3; - // Red - HAL_TIM_Base_Start(&htim2); - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); - // Green - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); - // Blue - HAL_TIM_Base_Start(&htim3); - HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); -#elif defined OWL_BIOSIGNALS -#ifdef USE_LED_PWM - extern TIM_HandleTypeDef htim1; - HAL_TIM_Base_Start(&htim1); - HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); - HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); - HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3); -#else - /*Configure GPIO pin : LED_GREEN_Pin, LED_RED_Pin */ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LED_GREEN_Pin | LED_RED_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED_GREEN_GPIO_Port, &GPIO_InitStruct); -#endif -#endif -} - - extern "C" { void HAL_GPIO_EXTI_Callback(uint16_t pin){ @@ -126,11 +85,15 @@ void Owl::setup(void){ IWDG1->KR = 0x5555; // ensure watchdog register write is allowed IWDG1->PR = 0x05; // prescaler 128 IWDG1->RLR = 0x753; // reload 8 seconds + while(IWDG1->SR != 0x00u); // wait to count down + IWDG1->KR = 0xaaaa; // reset the watchdog timer #else IWDG->KR = 0xCCCC; // Enable IWDG and turn on LSI IWDG->KR = 0x5555; // ensure watchdog register write is allowed IWDG->PR = 0x05; // prescaler 128 IWDG->RLR = 0x753; // reload 8 seconds + while(IWDG->SR != 0x00u); // wait to count down + IWDG->KR = 0xaaaa; // reset the watchdog timer #endif #endif #ifdef USE_BKPSRAM @@ -151,8 +114,6 @@ void Owl::setup(void){ codec.setOutputGain(settings.audio_output_gain); #endif /* USE_CODEC */ - program.startManager(); - #ifdef USE_DAC HAL_DAC_Start(&hdac, DAC_CHANNEL_1); HAL_DAC_Start(&hdac, DAC_CHANNEL_2); @@ -178,6 +139,8 @@ void Owl::setup(void){ bus_setup(); bus_set_input_channel(settings.midi_input_channel); #endif /* USE_DIGITALBUS */ + + program.startManager(); // calls bootstrap, loads patch } #ifdef USE_DIGITALBUS @@ -204,26 +167,28 @@ void updateLed(){ } #endif /*USE_RGB_LED */ -OperationMode Owl::getOperationMode(){ +uint8_t Owl::getOperationMode(){ return operationMode; } -void Owl::setOperationMode(OperationMode mode){ - OperationMode old_mode = operationMode; - operationMode = mode; - onChangeMode(mode, old_mode); +void Owl::setOperationMode(uint8_t mode){ + if(mode != operationMode){ + uint8_t old_mode = operationMode; + // make sure this is set before calling onChangeMode + operationMode = mode; + onChangeMode(mode, old_mode); + } } void Owl::loop(){ + if(!program.isProgramRunning()){ + midi_tx.transmit(); + midi_rx.receive(); // push queued up MIDI messages through to patch + } #ifdef USE_DIGITALBUS busstatus = bus_status(); #endif -#ifdef OLED_DMA - // When using OLED_DMA this must delay for a minimum amount to allow screen to update - vTaskDelay(xFrequency); -#else vTaskDelayUntil(&xLastWakeTime, xFrequency); -#endif #ifdef USE_IWDG #ifdef STM32H7xx IWDG1->KR = 0xaaaa; // reset the watchdog timer (if enabled) @@ -253,7 +218,6 @@ void jump_to_bootloader(void){ // extern USBD_HandleTypeDef USBD_HANDLE; // USBD_DeInit(&USBD_HANDLE); // #endif - *OWLBOOT_MAGIC_ADDRESS = OWLBOOT_MAGIC_NUMBER; #ifdef USE_BKPSRAM extern RTC_HandleTypeDef hrtc; HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0); @@ -264,13 +228,13 @@ void jump_to_bootloader(void){ #else RCC->CIR = 0x00000000; #endif + *OWLBOOT_MAGIC_ADDRESS = OWLBOOT_MAGIC_NUMBER; NVIC_SystemReset(); /* Shouldn't get here */ while(1); } void device_reset(){ - *OWLBOOT_MAGIC_ADDRESS = 0; #ifdef USE_BKPSRAM extern RTC_HandleTypeDef hrtc; HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0); @@ -281,6 +245,7 @@ void device_reset(){ #else RCC->CIR = 0x00000000; #endif + *OWLBOOT_MAGIC_ADDRESS = 0; NVIC_SystemReset(); /* Shouldn't get here */ while(1); @@ -312,8 +277,7 @@ const char* getDeviceName(){ static char name[22]; static char* ptr = 0; if(ptr == 0){ - uint32_t* id = (uint32_t*)UID_BASE; // get a pointer to the 96-bit unique device id - unsigned int hash = id[0]^id[1]^id[2]; // hash into 32-bit value + uint32_t hash = HAL_GetUIDw0() ^ HAL_GetUIDw1() ^ HAL_GetUIDw2(); // hash into 32-bit value hash = (hash>>16)^(hash&0xffff); // hash into 16-bit value char* p = stpcpy(name, "OWL-" HARDWARE_VERSION "-"); stpcpy(p, msg_itoa(hash, 16)); @@ -321,3 +285,15 @@ const char* getDeviceName(){ } return ptr; } + +void Owl::setMessageCallback(void* callback){ + messageCallback = (void (*)(const char* msg, size_t len))callback; +} + +/** + * This method should not be called from an irq handler + */ +void Owl::handleMessage(const char* msg, size_t len){ + if(messageCallback != NULL) + messageCallback(msg, len); +} diff --git a/Source/Owl.h b/Source/Owl.h index b6b950f6..69d343bb 100644 --- a/Source/Owl.h +++ b/Source/Owl.h @@ -38,15 +38,6 @@ extern "C" { void midiSetInputChannel(int8_t channel); void midiSetOutputChannel(int8_t channel); - -#ifdef OWL_MAGUS -#define PORT_UNI_INPUT 1 -#define PORT_UNI_OUTPUT 2 -#define PORT_BI_INPUT 3 -#define PORT_BI_OUTPUT 4 - void setPortMode(uint8_t index, uint8_t mode); - uint8_t getPortMode(uint8_t index); -#endif /* OWL_MAGUS */ int16_t getParameterValue(uint8_t index); void setParameterValue(uint8_t ch, int16_t value); @@ -72,15 +63,18 @@ class BackgroundTask { class Owl { private: - volatile OperationMode operationMode = STARTUP_MODE; + volatile uint8_t operationMode = STARTUP_MODE; BackgroundTask* backgroundTask = NULL; + void (*messageCallback)(const char* msg, size_t len) = NULL; public: void setup(); void loop(); - OperationMode getOperationMode(); - void setOperationMode(OperationMode mode); + uint8_t getOperationMode(); + void setOperationMode(uint8_t mode); void setBackgroundTask(BackgroundTask* bt); + void setMessageCallback(void* callback); + void handleMessage(const char* msg, size_t len); }; extern Owl owl; diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index bc25c830..3f12f501 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -5,147 +5,57 @@ #include "errorhandlers.h" #include "ProgramVector.h" -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif -#ifndef abs -#define abs(x) ((x)>0?(x):-(x)) -#endif - -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); - -/* shows a single parameter selected and controlled with a single encoder - */ -template class ParameterController { +protected: + char title[11]; + int16_t parameters[NOF_PARAMETERS]; + char names[NOF_PARAMETERS][12]; public: - char title[11] = "Prism"; - int16_t parameters[SIZE]; - char names[SIZE][12]; - int8_t selected = 0; - ParameterController(){ - reset(); - } - void setTitle(const char* str){} - void reset(){ - drawCallback = defaultDrawCallback; - for(int i=0; i= 8) + names[i][c++] = '@'+(i/8); + names[i][c++] = 'A'+(i%8); + names[i][c] = '\0'; parameters[i] = 0; } } - void draw(uint8_t* pixels, uint16_t width, uint16_t height){ - ScreenBuffer screen(width, height); - screen.setBuffer(pixels); - draw(screen); - } - - void draw(ScreenBuffer& screen){ - screen.clear(); - if(sw1()){ - drawStats(screen); - // todo: show patch name and next/previous patch - }else if(sw2()){ - screen.setTextSize(1); - screen.print(2, 0, names[selected]); - screen.setTextSize(3); - screen.setCursor(30, 20); - screen.print(parameters[selected]/41); // assuming parameter value [0-4095] - screen.print("%"); - }else if(getErrorStatus() != NO_ERROR && getErrorMessage() != NULL){ - screen.setTextSize(1); - screen.print(2, 20, getErrorMessage()); - }else{ - drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); - screen.setTextSize(1); - screen.print(2, 56, names[selected]); - screen.print(": "); - screen.print((int)parameters[selected]/41); - } - } - - void drawStats(ScreenBuffer& screen){ - screen.setTextSize(1); - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL) - screen.print(2, 36, pv->message); - screen.print(2, 46, "cpu/mem: "); - float percent = (pv->cycles_per_block/pv->audio_blocksize) / (float)ARM_CYCLES_PER_SAMPLE; - screen.print((int)(percent*100)); - screen.print("% "); - screen.print((int)(pv->heap_bytes_used)/1024); - screen.print("kB"); - } - - void encoderChanged(uint8_t encoder, int32_t delta){ - if(encoder == 0){ - if(sw2()){ - if(delta > 1) - selected = min(SIZE-1, selected+1); - else if(delta < 1) - selected = max(0, selected-1); - }else{ - parameters[selected] += delta*10; - parameters[selected] = min(4095, max(0, parameters[selected])); - } - } // todo: change patch with enc1/sw1 - } - void setName(uint8_t pid, const char* name){ - if(pid < SIZE) + virtual void draw(ScreenBuffer& screen) = 0; + /* Update parameters with encoders */ + virtual void updateEncoders(int16_t* data, uint8_t size) = 0; + /* Update parameters with ADC values */ + virtual void updateValues(int16_t* values, size_t len){}; + virtual void setValue(uint8_t pid, int16_t value){ + parameters[pid] = value; + } + const char* getName(uint8_t pid){ + if(pid < NOF_PARAMETERS) + return names[pid]; + return ""; + } + // bool isInput(uint8_t pid) + // bool isBipolar(uint8_t pid) + virtual void setName(uint8_t pid, const char* name){ + // todo : set direction (input/output), type (parameter/button) + if(pid < NOF_PARAMETERS) strncpy(names[pid], name, 11); } - uint8_t getSize(){ - return SIZE; + int16_t getValue(uint8_t pid){ + return parameters[pid]; } - void setValue(uint8_t ch, int16_t value){ - parameters[ch] = value; - } - - void drawMessage(int16_t y, ScreenBuffer& screen){ - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL){ - screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, y, pv->message); - screen.setTextWrap(false); - } - } - - void drawTitle(ScreenBuffer& screen){ - drawTitle(title, screen); - } - - void drawTitle(const char* title, ScreenBuffer& screen){ - // draw title - screen.setTextSize(2); - screen.print(1, 17, title); - } - - void setCallback(void *callback){ - if(callback == NULL) - drawCallback = defaultDrawCallback; - else - drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; - } - -private: - void (*drawCallback)(uint8_t*, uint16_t, uint16_t); - bool tr1(){ - return HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_11) != GPIO_PIN_SET; + int16_t* getParameters(){ + return parameters; } - bool tr2(){ - return HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_10) != GPIO_PIN_SET; + size_t getSize(){ + return NOF_PARAMETERS; } - bool sw1(){ - return HAL_GPIO_ReadPin(GPIOG, GPIO_PIN_14) != GPIO_PIN_SET; + void setTitle(const char* str){ + strncpy(title, str, sizeof(title)-1); } - bool sw2(){ - return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) != GPIO_PIN_SET; + const char* getTitle(){ + return title; } -}; +}; #endif // __ParameterController_hpp__ diff --git a/Source/PatchDefinition.hpp b/Source/PatchDefinition.hpp index 92a40901..b35b5e50 100644 --- a/Source/PatchDefinition.hpp +++ b/Source/PatchDefinition.hpp @@ -16,34 +16,35 @@ class PatchDefinition { typedef void (*ProgramFunction)(void); ProgramFunction programFunction = NULL; uint32_t* linkAddress; - uint32_t* jumpAddress; + uint32_t binarySize; uint32_t programSize; - char programName[24]; + char programName[20]; // ResourceHeader::name is char[20] Resource* sourceResource = NULL; void* sourceAddress = NULL; bool load(ProgramHeader* header, uint32_t sz){ + binarySize = sz; + // check we've got an entry function + if(header->magic != 0xDADAC0DE) + return false; linkAddress = header->linkAddress; programSize = (uint32_t)header->endAddress - (uint32_t)header->linkAddress; - if(header->magic != 0xDADAC0DE || sz != programSize) - return false; stackBase = header->stackBegin; stackSize = (uint32_t)header->stackEnd - (uint32_t)header->stackBegin; - jumpAddress = header->jumpAddress; programVector = header->programVector; strlcpy(programName, header->programName, sizeof(programName)); - programFunction = (ProgramFunction)jumpAddress; + programFunction = (ProgramFunction)header->jumpAddress; return true; } public: PatchDefinition() {} void copy(){ if(sourceResource){ - storage.readResource(sourceResource, linkAddress, 0, programSize); + storage.readResource(sourceResource, linkAddress, 0, binarySize); sourceResource = NULL; }else if(sourceAddress){ if(linkAddress != sourceAddress) - memmove(linkAddress, sourceAddress, programSize); + memmove(linkAddress, sourceAddress, binarySize); sourceAddress = NULL; } } @@ -82,7 +83,8 @@ class PatchDefinition { return false; } bool isValid(){ - // check we've got an entry function + // if(binarySize != programSize) + // return false; if(programFunction == NULL || programVector == NULL) return false; extern char _PATCHRAM, _PATCHRAM_SIZE; @@ -97,12 +99,18 @@ class PatchDefinition { } void run(){ // check magic - if((*(uint32_t*)linkAddress) == 0xDADAC0DE) + if((*(uint32_t*)linkAddress) == 0xDADAC0DE){ + if(binarySize < programSize) // blank out bss area + memset(linkAddress+binarySize, 0, programSize - binarySize); programFunction(); + } } uint32_t getProgramSize(){ return programSize; } + uint32_t getBinarySize(){ + return binarySize; + } uint32_t* getLinkAddress(){ return linkAddress; } diff --git a/Source/PatchRegistry.cpp b/Source/PatchRegistry.cpp index 914ddb5f..f6a126a5 100644 --- a/Source/PatchRegistry.cpp +++ b/Source/PatchRegistry.cpp @@ -88,5 +88,5 @@ bool PatchRegistry::loadProgram(uint8_t index){ } bool PatchRegistry::loadProgram(void* address, uint32_t length){ - return patchDefinition.load(address, length) && patchDefinition.isValid(); + return patchDefinition.load(address, length) && patchDefinition.isValid(); } diff --git a/Source/Pin.h b/Source/Pin.h index 0a3086c4..12702c5d 100644 --- a/Source/Pin.h +++ b/Source/Pin.h @@ -38,11 +38,7 @@ class Pin { port->BSRR = (1<<(pin+16U)); } void set(bool on){ - port->BSRR = (1<<(pin+16U*!on)); - // if(on) - // high(pin); - // else - // low(pin); + port->BSRR = (1<<(pin+(16U*!on))); } void toggle(){ port->ODR ^= 1<* volatile usbd_rx = NULL; +CircularBuffer* volatile usbd_tx = NULL; +static uint32_t usbd_audio_rx_count = 0; + +/* Get number of samples transmitted since previous request */ +uint32_t usbd_audio_get_rx_count(){ + // return 0; + uint32_t pos = usbd_audio_rx_count + codec.getSampleCounter(); + usbd_audio_rx_count = 0; + return pos; +} + +void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ + usbd_tx = (CircularBuffer*)cb; + // usbd_tx->reset(); + // usbd_tx->clear(); + // usbd_tx->moveWriteHead(usbd_tx->getSize()/2); +} + +void usbd_audio_tx_stop_callback(){ + usbd_tx = NULL; +#ifdef DEBUG + printf("stop tx\n"); +#endif +} + +void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ + usbd_rx = (CircularBuffer*)cb; + // usbd_rx->reset(); + // usbd_rx->clear(); + // usbd_rx->moveReadHead(usbd_rx->getSize()/2); + usbd_audio_rx_count = 0; +#ifdef DEBUG + printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); +#endif +} + +void usbd_audio_rx_stop_callback(){ + usbd_rx = NULL; +#ifdef DEBUG + printf("stop rx\n"); +#endif +} + +void usbd_rx_convert(int32_t* dst, size_t len){ + CircularBuffer* rx = usbd_rx; + if(rx){ + usbd_audio_rx_count += len; + size_t cap = rx->getReadCapacity(); + if(cap < len){ + // rx buffer underflow + memset(dst+cap, 0, (len - cap)*sizeof(int32_t)); + len = cap; +#ifdef DEBUG_USBD_AUDIO + debugMessage("rx unf", (int)(len - cap)); +#endif + } +#if USBD_AUDIO_RX_CHANNELS == AUDIO_CHANNELS +#if AUDIO_BITS_PER_SAMPLE == 32 + rx->read(dst, len); +#else + while(len--) + *dst++ = AUDIO_SAMPLE_TO_INT32(rx->read()); +#endif +#else /* USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS */ + len /= AUDIO_CHANNELS; + while(len--){ +#if AUDIO_BITS_PER_SAMPLE == 32 + rx->read(dst, USBD_AUDIO_RX_CHANNELS); + dst += AUDIO_CHANNELS; +#else + audio_t* src = rx->getReadHead(); + for(int ch=0; chmoveReadHead(USBD_AUDIO_RX_CHANNELS); + dst += AUDIO_CHANNELS - USBD_AUDIO_RX_CHANNELS; +#endif + } +#endif + } +} + +void usbd_tx_convert(int32_t* src, size_t len){ + CircularBuffer* tx = usbd_tx; + if(tx){ + size_t cap = tx->getWriteCapacity() - USBD_AUDIO_TX_CHANNELS; + // leave a bit of space to prevent wrapping read/write pointers + if(cap < len){ + // tx buffer overflow + len = cap; +#ifdef DEBUG_USBD_AUDIO + debugMessage("tx ovf", (int)(len - cap)); +#endif + } +#if USBD_AUDIO_TX_CHANNELS == AUDIO_CHANNELS +#if AUDIO_BITS_PER_SAMPLE == 32 + tx->write(src, len); +#else + while(len--) + tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); +#endif +#else /* USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS */ + len /= AUDIO_CHANNELS; + while(len--){ +#if AUDIO_BITS_PER_SAMPLE == 32 + tx->write(src, USBD_AUDIO_TX_CHANNELS); + src += AUDIO_CHANNELS; +#else + audio_t* dst = tx->getWriteHead(); + for(int ch=0; chmoveWriteHead(USBD_AUDIO_TX_CHANNELS); + src += AUDIO_CHANNELS - USBD_AUDIO_TX_CHANNELS; #endif + } +#endif + } +} + +#endif /* USE_USBD_AUDIO */ // FreeRTOS low priority numbers denote low priority tasks. // The idle task has priority zero (tskIDLE_PRIORITY). @@ -35,6 +161,7 @@ #define MANAGER_TASK_PRIORITY (AUDIO_TASK_PRIORITY | portPRIVILEGE_BIT) // audio and manager task priority must be the same so that the program can stop itself in case of errors #define FLASH_TASK_PRIORITY 1 // allow default task to run when FLASH task yields +#define SCREEN_TASK_PRIORITY 3 // less than AUDIO_TASK_PRIORITY, more than osPriorityNormal (which is probably 1) #define PROGRAMSTACK_SIZE (PROGRAM_TASK_STACK_SIZE*sizeof(portSTACK_TYPE)) // size in bytes @@ -54,6 +181,9 @@ static TaskHandle_t managerTask = NULL; static TaskHandle_t utilityTask = NULL; static StaticTask_t audioTaskBuffer; static uint8_t PROGRAMSTACK[PROGRAMSTACK_SIZE] CCM_RAM; // use CCM if available +#ifdef USE_SCREEN +static TaskHandle_t screenTask = NULL; +#endif #ifdef USE_ADC extern uint16_t adc_values[NOF_ADC_VALUES]; @@ -76,12 +206,6 @@ void audioCallback(int32_t* rx, int32_t* tx, uint16_t size){ pv->audio_input = rx; pv->audio_output = tx; pv->audio_blocksize = size; -#ifdef FASCINATION_MACHINE - extern uint32_t ledstatus; - static float audio_envelope_lambda = 0.999995f; - static float audio_envelope = 0.0; - audio_envelope = audio_envelope*audio_envelope_lambda + (1.0f-audio_envelope_lambda)*abs(pv->audio_output[0])*(1.0f/INT16_MAX); -#endif if(audioTask != NULL){ BaseType_t yield; // wake up audio task @@ -103,7 +227,7 @@ void onProgramStatus(ProgramVectorAudioStatus status){ __weak int16_t getParameterValue(uint8_t pid){ if(pid < NOF_PARAMETERS) #ifdef USE_SCREEN - return graphics.params.parameters[pid]; + return graphics.params->getValue(pid); #else return parameter_values[pid]; #endif @@ -114,8 +238,7 @@ __weak int16_t getParameterValue(uint8_t pid){ __weak void setParameterValue(uint8_t pid, int16_t value){ if(pid < NOF_PARAMETERS) #ifdef USE_SCREEN - graphics.params.setValue(pid, value); - // graphics.params.parameters[pid] = value; + graphics.params->setValue(pid, value); #else parameter_values[pid] = value; #endif @@ -140,21 +263,29 @@ void setButtonValue(uint8_t ch, uint8_t value){ /* called by the program when a block has been processed */ void onProgramReady(){ - midi_tx.transmit(); ProgramVector* pv = getProgramVector(); +#ifdef USE_USBD_AUDIO_TX + // after patch runs: convert patch output to USBD audio tx + usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); +#endif +#ifdef USE_USBD_AUDIO_RX + // after patch runs: convert USBD audio rx to DAC (overwriting patch output) + usbd_rx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); +#endif #ifdef DEBUG_DWT pv->cycles_per_block = DWT->CYCCNT; #endif - /* Block indefinitely */ - // uint32_t ulNotifiedValue = + /* Block indefinitely (released by audioCallback) */ ulTaskNotifyTake(pdTRUE, portMAX_DELAY); #ifdef DEBUG_DWT DWT->CYCCNT = 0; #endif - midi_rx.receive(); // push queued up MIDI messages through to patch + // push queued up MIDI messages through to patch + midi_tx.transmit(); + midi_rx.receive(); #ifdef USE_ADC #ifdef USE_SCREEN - updateParameters(graphics.params.parameters, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); + updateParameters(graphics.params->getParameters(), NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); #else updateParameters(parameter_values, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); #endif @@ -174,7 +305,7 @@ void onProgramReady(){ // called from program void onSetPatchParameter(uint8_t pid, int16_t value){ // #ifdef USE_SCREEN -// graphics.params.setDynamicValue(ch, value); +// graphics.params->setDynamicValue(ch, value); // #else // parameter_values[ch] = value; // #endif @@ -196,7 +327,7 @@ void onSetButton(uint8_t bid, uint16_t state, uint16_t samples){ // called from program void onRegisterPatchParameter(uint8_t id, const char* name){ #ifdef USE_SCREEN - graphics.params.setName(id, name); + graphics.params->setName(id, name); #endif /* USE_SCREEN */ midi_tx.sendPatchParameterName((PatchParameterId)id, name); } @@ -204,7 +335,7 @@ void onRegisterPatchParameter(uint8_t id, const char* name){ // called from program void onRegisterPatch(const char* name, uint8_t inputChannels, uint8_t outputChannels){ #if defined USE_SCREEN - graphics.params.setTitle(name); + graphics.params->setTitle(name); #endif /* OWL_MAGUS */ } @@ -212,8 +343,8 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->hardware_version = HARDWARE_ID; pv->checksum = PROGRAM_VECTOR_CHECKSUM; #ifdef USE_SCREEN - pv->parameters_size = graphics.params.getSize(); - pv->parameters = graphics.params.parameters; + pv->parameters_size = graphics.params->getSize(); + pv->parameters = graphics.params->getParameters(); #else pv->parameters_size = NOF_PARAMETERS; pv->parameters = parameter_values; @@ -222,7 +353,7 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ #ifdef USE_CODEC pv->audio_blocksize = codec.getBlockSize(); #else - pv->audio_blocksize = CODEC_BLOCKSIZE; + pv->audio_blocksize = AUDIO_BLOCK_SIZE; #endif pv->buttons = button_values; pv->registerPatch = onRegisterPatch; @@ -240,22 +371,24 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->encoderChangedCallback = NULL; #endif #ifdef PROGRAM_VECTOR_V13 - extern char _PATCHRAM_END; + extern uint8_t _PATCHRAM, _PATCHRAM_END, _PATCHRAM_SIZE; uint8_t* end = (uint8_t*)def->getStackBase(); // program end - uint32_t remain = (uint32_t)&_PATCHRAM_END - (uint32_t)def->getStackBase(); // space left + uint32_t remain = &_PATCHRAM_END - end; // space left + if(end < &_PATCHRAM || remain > (uint32_t)&_PATCHRAM_SIZE) // sanity check + remain = 0; // prevent errors if program stack is not linked to PATCHRAM #ifdef USE_CCM_RAM extern char _CCMRAM, _CCMRAM_SIZE; #endif #ifdef USE_PLUS_RAM - extern char _PLUSRAM, _PLUSRAM_END, _PLUSRAM_SIZE; - extern char _PATCHRAM, _PATCHRAM_SIZE; + extern uint8_t _PLUSRAM, _PLUSRAM_END, _PLUSRAM_SIZE; uint8_t* plusend = (uint8_t*)&_PLUSRAM; uint32_t plusremain = (uint32_t)&_PLUSRAM_SIZE; if(def->getLinkAddress() == (uint32_t*)&_PLUSRAM){ end = (uint8_t*)&_PATCHRAM; - remain = (uint32_t)&_PATCHRAM_SIZE; + remain = (uint32_t)&_PATCHRAM_SIZE; // use all of PATCHRAM for heap plusend = (uint8_t*)def->getStackBase(); - plusremain = (uint32_t)&_PLUSRAM_END - (uint32_t)def->getStackBase(); + plusremain = def->getStackSize(); + plusremain = &_PLUSRAM_END - plusend; } #endif #ifdef USE_EXTERNAL_RAM @@ -281,11 +414,10 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->heapSegments = (MemorySegment*)heapSegments; #ifdef USE_WM8731 pv->audio_format = AUDIO_FORMAT_24B16_2X; -#elif defined OWL_BIOSIGNALS || defined OWL_NOCTUA - pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; -#else +#elif AUDIO_CHANNELS == 2 pv->audio_format = AUDIO_FORMAT_24B32; - // pv->audio_format = AUDIO_FORMAT_24B32_2X; +#else + pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; #endif #endif /* PROGRAM_VECTOR_V13 */ pv->message = NULL; @@ -376,29 +508,46 @@ void sendResourceTask(void* p){ __weak void onStartProgram(){ #ifdef USE_SCREEN - graphics.params.reset(); -#endif -#ifndef USE_SCREEN + graphics.reset(); +#else memset(parameter_values, 0, sizeof(parameter_values)); #endif } +#ifdef USE_SCREEN +void runScreenTask(void* p){ + TickType_t xLastWakeTime; + TickType_t xFrequency; + xFrequency = SCREEN_LOOP_SLEEP_MS / portTICK_PERIOD_MS; + xLastWakeTime = xTaskGetTickCount(); + for(;;){ + vTaskDelayUntil(&xLastWakeTime, xFrequency); + onScreenDraw(); + graphics.draw(); + graphics.display(); + } +} +#endif // USE_SCREEN + void runAudioTask(void* p){ PatchDefinition* def = getPatchDefinition(); if(def->isValid()){ def->copy(); ProgramVector* pv = def->getProgramVector(); updateProgramVector(pv, def); - onStartProgram(); programVector = pv; setErrorStatus(NO_ERROR); owl.setOperationMode(RUN_MODE); + onStartProgram(); #ifdef USE_CODEC codec.clear(); #endif // zero-fill heap memory for(size_t i=0; i<5 && pv->heapSegments[i].location != NULL; ++i) memset(pv->heapSegments[i].location, 0, pv->heapSegments[i].size); + // memory barriers for dynamically loaded code + __DSB(); + __ISB(); // run program def->run(); } @@ -462,6 +611,7 @@ void runManagerTask(void* p){ graphics.setCallback(NULL); #endif /* USE_SCREEN */ midi_rx.setCallback(NULL); + owl.setMessageCallback(NULL); vTaskDelete(audioTask); audioTask = NULL; #ifdef USE_CODEC @@ -513,8 +663,8 @@ ProgramManager::ProgramManager(){ #ifdef DEBUG_DWT // DWT cycle count enable CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; -#ifdef OWL_ARCH_F7 - DWT->LAR = 0xC5ACCE55; // enable debug access: required on F7 +#ifdef STM32H7xx + DWT->LAR = 0xC5ACCE55; // enable debug access: required on M7 #endif DWT->CYCCNT = 0; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; @@ -522,11 +672,10 @@ ProgramManager::ProgramManager(){ } void ProgramManager::startManager(){ - // updateProgramVector(getProgramVector(), NULL); -// #ifdef USE_SCREEN -// xTaskCreate(runScreenTask, "Screen", SCREEN_TASK_STACK_SIZE, NULL, SCREEN_TASK_PRIORITY, &screenTask); -// #endif xTaskCreate(runManagerTask, "Manager", MANAGER_TASK_STACK_SIZE, NULL, MANAGER_TASK_PRIORITY, &managerTask); +#ifdef USE_SCREEN + xTaskCreate(runScreenTask, "Screen", SCREEN_TASK_STACK_SIZE, NULL, SCREEN_TASK_PRIORITY, &screenTask); +#endif } void ProgramManager::notifyManagerFromISR(uint32_t ulValue){ @@ -582,11 +731,19 @@ void ProgramManager::updateProgramIndex(uint8_t index){ void ProgramManager::loadDynamicProgram(void* address, uint32_t length){ if(registry.loadProgram(address, length)) updateProgramIndex(0); + else + error(PROGRAM_ERROR, "Load failed"); } void ProgramManager::loadProgram(uint8_t pid){ - if(patchindex != pid && registry.loadProgram(pid)) - updateProgramIndex(pid); + if(patchindex != pid && registry.hasPatch(pid)){ + if(registry.loadProgram(pid)) + updateProgramIndex(pid); + else + error(PROGRAM_ERROR, "Load failed"); + }else{ + owl.setOperationMode(CONFIGURE_MODE); + } } #ifdef DEBUG_STACK @@ -631,10 +788,14 @@ uint8_t ProgramManager::getProgramIndex(){ return patchindex; } +bool ProgramManager::isProgramRunning(){ + return audioTask != NULL; +} + extern "C" { void vApplicationMallocFailedHook(void) { - program.exitProgram(false); error(PROGRAM_ERROR, "malloc failed"); + program.exitProgram(false); } void vApplicationIdleHook(void) { } @@ -644,7 +805,7 @@ extern "C" { /* Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called from PendSV ISR if a stack overflow is detected. */ - vTaskDelete(pxTask); + // vTaskDelete(pxTask); // seems to just get stuck if(pxTask == utilityTask) utilityTask = NULL; if(pxTask == audioTask) @@ -673,7 +834,6 @@ void ProgramManager::saveToFlash(uint8_t sector, void* address, uint32_t length) } uint16_t getSampleCounter(){ - // does not work: always returns values <= 5 - // return DMA_GetCurrDataCounter(DMA2_Stream0); - return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; + // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; + return codec.getSampleCounter() / AUDIO_CHANNELS; } diff --git a/Source/ProgramManager.h b/Source/ProgramManager.h index e02fcd3c..b0b92ddc 100644 --- a/Source/ProgramManager.h +++ b/Source/ProgramManager.h @@ -46,6 +46,7 @@ class ProgramManager { uint32_t getCyclesPerBlock(); uint32_t getHeapMemoryUsed(); uint8_t getProgramIndex(); + bool isProgramRunning(); private: void updateProgramIndex(uint8_t index); }; diff --git a/Source/ResourceHeader.h b/Source/ResourceHeader.h index 9e9db65a..1ae5e0bb 100644 --- a/Source/ResourceHeader.h +++ b/Source/ResourceHeader.h @@ -8,7 +8,7 @@ #endif struct ResourceHeader { - uint32_t magic; // 0xDADADEED for resources, 0xDADAC0DE for patches + uint32_t magic; // 0xDADADEED for resources uint32_t size; char name[20]; uint32_t flags; diff --git a/Source/ScreenBuffer.h b/Source/ScreenBuffer.h index 2f400661..d8599470 100644 --- a/Source/ScreenBuffer.h +++ b/Source/ScreenBuffer.h @@ -29,8 +29,8 @@ typedef uint16_t Colour; #define CYAN 0x07FF #define MAGENTA 0xFFE0 #define WHITE 0xFFFF -#else -#error "Invalid configuration" +#elif defined USE_SCREEN +#error "Invalid screen configuration" #endif class ScreenBuffer { diff --git a/Source/SerialBuffer.hpp b/Source/SerialBuffer.hpp index 3a773fc4..18deda2f 100644 --- a/Source/SerialBuffer.hpp +++ b/Source/SerialBuffer.hpp @@ -42,14 +42,12 @@ class SerialBuffer { } void push(T c){ - buffer[writepos++] = c; - if(writepos >= size) - writepos = 0; + buffer[writepos] = c; + writepos = (writepos + 1) % size; } T pull(){ - T c = buffer[readpos++]; - if(readpos >= size) - readpos = 0; + T c = buffer[readpos]; + readpos = (readpos + 1) % size; return c; } @@ -99,9 +97,7 @@ class SerialBuffer { void incrementReadHead(size_t len){ // ASSERT((readpos >= writepos && readpos+len <= size) || // (readpos < writepos && readpos+len <= writepos), "uart rx underflow"); - readpos += len; - if(readpos >= size) - readpos -= size; + readpos = (readpos + len) % size; } bool notEmpty(){ return writepos != readpos; diff --git a/Source/ServiceCall.cpp b/Source/ServiceCall.cpp index 27204e8b..341415b8 100644 --- a/Source/ServiceCall.cpp +++ b/Source/ServiceCall.cpp @@ -7,6 +7,8 @@ #include "Storage.h" #include "Owl.h" +#include "cmsis_os.h" + #ifdef USE_FFT_TABLES #include "arm_const_structs.h" #endif /* USE_FFT_TABLES */ @@ -141,7 +143,7 @@ static int handleLoadResource(void** params, int len){ // We require offset to be aligned to 4 bytes if (res != NULL && !(offset & 0b11)) { if (*buffer == NULL) { - // Buffer pointer not given, so we will update value refenced by max_size with + // Buffer pointer not given, so we will update value referenced by max_size with // actual resource size here *max_size = res->getDataSize() - offset; if(res->isMemoryMapped()) @@ -223,6 +225,13 @@ static int handleRegisterCallback(void** params, int len){ ret = OWL_SERVICE_OK; } #endif /* USE_MIDI_CALLBACK */ +#ifdef USE_MESSAGE_CALLBACK + if(strncmp(SYSTEM_FUNCTION_MESSAGE, name, 3) == 0){ + // void (*messageCallback)(const char* msg, size_t len); + owl.setMessageCallback(callback); + ret = OWL_SERVICE_OK; + } +#endif /* USE_MESSAGE_CALLBACK */ } return ret; } diff --git a/Source/ServiceCall.h b/Source/ServiceCall.h index a272fbed..c3342e4e 100644 --- a/Source/ServiceCall.h +++ b/Source/ServiceCall.h @@ -13,6 +13,7 @@ #define SYSTEM_TABLE_POW "SPW" #define SYSTEM_FUNCTION_DRAW "DRW" #define SYSTEM_FUNCTION_MIDI "MDI" +#define SYSTEM_FUNCTION_MESSAGE "MSG" #define OWL_SERVICE_VERSION OWL_SERVICE_VERSION_V1 diff --git a/Source/Storage.cpp b/Source/Storage.cpp index 94d6d362..3a0f0f6b 100644 --- a/Source/Storage.cpp +++ b/Source/Storage.cpp @@ -126,9 +126,9 @@ uint32_t Storage::getChecksum(Resource* resource){ uint32_t crc = 0; if(resource->isMemoryMapped()){ crc = crc32(resource->getData(), resource->getDataSize(), 0); - }else{ #ifdef USE_SPI_FLASH - uint8_t data[64]; // read chunk of bytes at a time + }else{ + uint8_t data[32]; // read chunk of bytes at a time uint32_t address = resource->getAddress() + sizeof(ResourceHeader); uint32_t end = address + resource->getDataSize(); // uint32_t start = address; diff --git a/Source/TakeoverControls.h b/Source/TakeoverControls.h new file mode 100644 index 00000000..810dc4b9 --- /dev/null +++ b/Source/TakeoverControls.h @@ -0,0 +1,40 @@ +#include + +template +class TakeoverControls { +private: + value_t values[SIZE]; + bool takeover[SIZE]; +public: + TakeoverControls(){ + reset(true); + } + value_t get(uint8_t index){ + return values[index]; + } + void set(uint8_t index, value_t value){ + values[index] = value; + } + void update(uint8_t index, value_t value, value_t threshold){ + if(takeover[index]){ + values[index] = value; + }else if(abs(values[index] - value) < threshold){ + takeover[index] = true; + values[index] = value; + } + } + bool taken(uint8_t index){ + return takeover[index]; + } + /** + * If @param state is true, then the control is taken. + * If the control is taken it reflects the current knob setting. + */ + void reset(uint8_t index, bool state){ + takeover[index] = state; + } + void reset(bool state){ + for(size_t i=0; iCCR1 = 1023 - ((rgb>>20)&0x3ff); TIM3->CCR4 = 1023 - ((rgb>>10)&0x3ff); TIM2->CCR2 = 1023 - ((rgb>>00)&0x3ff); -#elif defined OWL_BIOSIGNALS - if(led == 0){ -#ifdef USE_LED_PWM - rgb &= COLOUR_LEVEL5; // turn down intensity - TIM1->CCR1 = 1023 - ((rgb>>20)&0x3ff); // red - TIM1->CCR3 = 1023 - ((rgb>>10)&0x3ff); // green - TIM1->CCR2 = 1023 - ((rgb>>00)&0x3ff); // blue -#else - switch(rgb){ // sinking current - case RED_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); - break; - case GREEN_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); - break; - case YELLOW_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); - break; - case NO_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); - break; - } -#endif - }else if(led == 1){ - if(rgb == NO_COLOUR) - HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_RESET); - else - HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET); - } -#endif // OWL_BIOSIGNALS +#endif // OWL_TESSERACT } +void onError(int8_t code, const char* msg){ +#if defined OWL_PEDAL || defined OWL_MODULAR || defined OWL_BIOSIGNALS + setLed(0, RED_COLOUR); +#endif + owl.setOperationMode(ERROR_MODE); +} __weak void onChangePin(uint16_t pin){ switch(pin){ -#ifdef OWL_BIOSIGNALS - case ADC_DRDY_Pin: { - ads_drdy(); - break; - } -#ifdef USE_KX122 - case ACC_INT1_Pin: { - kx122_drdy(); - break; - } -#endif -#endif #ifdef PUSHBUTTON_Pin case PUSHBUTTON_Pin: { bool isSet = !(PUSHBUTTON_GPIO_Port->IDR & PUSHBUTTON_Pin); @@ -394,4 +366,10 @@ __weak void updateParameters(int16_t* parameter_values, size_t parameter_len, ui // parameter_values[3] = 4095-adc_values[3]; #endif #endif +#ifdef FASCINATION_MACHINE + extern uint32_t ledstatus; + static float audio_envelope_lambda = 0.999995f; + static float audio_envelope = 0.0; + audio_envelope = audio_envelope*audio_envelope_lambda + (1.0f-audio_envelope_lambda)*abs(pv->audio_output[0])*(1.0f/INT16_MAX); +#endif } diff --git a/Source/callbacks.h b/Source/callbacks.h index b92a3189..d1fc40b2 100644 --- a/Source/callbacks.h +++ b/Source/callbacks.h @@ -1,6 +1,8 @@ #ifndef __CALLBACKS_H__ #define __CALLBACKS_H__ + #include +#include "device.h" #ifdef __cplusplus extern "C" { @@ -17,24 +19,25 @@ extern "C" { /** functions with weak declarations that can be defined by subprojects * to implement device specific behaviour */ - void setup(void); - void loop(void); - void initLed(); + void onSetup(); + void onLoop(); void setLed(uint8_t led, uint32_t rgb); void setButtonValue(uint8_t ch, uint8_t value); void setAnalogValue(uint8_t ch, int16_t value); void setGateValue(uint8_t bid, int16_t value); void onChangePin(uint16_t pin); - void onChangeMode(OperationMode new_mode, OperationMode old_mode); + void onChangeMode(uint8_t new_mode, uint8_t old_mode); + void onStartProgram(); + void onError(int8_t code, const char* msg); // sets a progress bar (if available) to a value from 0 to 4095 void setProgress(uint16_t value, const char* reason); - void onResourceUpdate(void); + void onResourceUpdate(); void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len); - int16_t getParameterValue(uint8_t pid); - void setParameterValue(uint8_t pid, int16_t value); - - void onStartProgram(); +#ifdef USE_SCREEN + void onScreenDraw(); + void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); +#endif #ifdef __cplusplus } /* extern C */ diff --git a/Source/cs4272.c b/Source/cs4272.c index 42eddbd4..a3e8b270 100644 --- a/Source/cs4272.c +++ b/Source/cs4272.c @@ -40,6 +40,9 @@ void codec_reset(){ #else codec_write(CODEC_ADC_CTRL, 0x10 | 0x03 ); // hp filters disabled #endif +#ifdef CODEC_DAC_INVERT + codec_write(CODEC_DAC_CTRL, CODEC_DAC_CTRL_INV_POL_AB); // invert DAC signal +#endif } void codec_init(){ diff --git a/Source/cs4272.h b/Source/cs4272.h index 33565314..905b8fd6 100644 --- a/Source/cs4272.h +++ b/Source/cs4272.h @@ -3,7 +3,6 @@ #include #include "device.h" -#include "Codec.h" // Section 8.1 Mode Control #define CODEC_MODE_CTRL1_REG (uint8_t)0x01 @@ -13,13 +12,16 @@ #define CODEC_MC_SERIAL_FORMAT(x) (uint8_t)(((x) & 0x07) << 0) // Section 8.2 DAC Control -#define CODEC_DAC_CONTROL_REG (uint8_t)0x02 +#define CODEC_DAC_CTRL (uint8_t)0x02 #define CODEC_DAC_CTRL_AUTO_MUTE (uint8_t)0x80 #define CODEC_DAC_CTRL_FILTER_SEL (uint8_t)0x40 #define CODEC_DAC_CTRL_DE_EMPHASIS(x) (uint8_t)(((x) & 0x03) << 4) #define CODEC_DAC_CTRL_VOL_RAMP_UP (uint8_t)0x08 #define CODEC_DAC_CTRL_VOL_RAMP_DN (uint8_t)0x04 #define CODEC_DAC_CTRL_INV_POL(x) (uint8_t)(((x) & 0x03) << 0) +#define CODEC_DAC_CTRL_INV_POL_AB (uint8_t)(0x03) +#define CODEC_DAC_CTRL_INV_POL_A (uint8_t)(0x02) +#define CODEC_DAC_CTRL_INV_POL_B (uint8_t)(0x01) // Section 8.3 DAC Volume and Mixing #define CODEC_DAC_VOL_REG (uint8_t)0x03 diff --git a/Source/device.h b/Source/device.h index 0cb3427f..e75b01be 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,12 +3,14 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.0.0" +#define FIRMWARE_VERSION "v22.2.0" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 #define FLASH_DEFAULT_FLAGS RESOURCE_PORT_MAPPED +#ifndef SPI_FLASH_HSPI #define SPI_FLASH_HSPI hspi1 +#endif #define EXTERNAL_STORAGE_SIZE (8*1024*1024) #else #define MAX_SPI_FLASH_HEADERS 0 @@ -41,6 +43,7 @@ #define MIDI_OUTPUT_BUFFER_SIZE 1024 #define MIDI_INPUT_BUFFER_SIZE 64 #define MIDI_SYSEX_BUFFER_SIZE 256 +#define USE_MESSAGE_CALLBACK #ifndef USBD_MAX_POWER #define USBD_MAX_POWER 100 // 200mA @@ -57,6 +60,7 @@ #endif #define DEBUG_DWT + /* #define DEBUG_STACK */ #define DEBUG_STORAGE /* #define DEBUG_BOOTLOADER */ @@ -134,7 +138,6 @@ #define AUDIO_SAMPLINGRATE 48000 #endif #define AUDIO_BLOCK_SIZE CODEC_BLOCKSIZE /* size in samples of a single channel audio block */ -#define AUDIO_MAX_BLOCK_SIZE (CODEC_BUFFER_SIZE/4) #define USBD_AUDIO_RX_FREQ AUDIO_SAMPLINGRATE #define USBD_AUDIO_TX_FREQ AUDIO_SAMPLINGRATE @@ -149,6 +152,10 @@ #define MAIN_LOOP_SLEEP_MS 2 #endif +#ifndef SCREEN_LOOP_SLEEP_MS +#define SCREEN_LOOP_SLEEP_MS 40 /* 40mS = 25 fps */ +#endif + #ifndef LOAD_INDICATOR_PARAMETER #define LOAD_INDICATOR_PARAMETER PARAMETER_A #endif @@ -159,6 +166,7 @@ #define PROGRAM_TASK_STACK_SIZE (4*1024/sizeof(portSTACK_TYPE)) #define MANAGER_TASK_STACK_SIZE (1*1024/sizeof(portSTACK_TYPE)) +#define SCREEN_TASK_STACK_SIZE (2*1024/sizeof(portSTACK_TYPE)) #ifndef ARM_CYCLES_PER_SAMPLE #define ARM_CYCLES_PER_SAMPLE (168000000/AUDIO_SAMPLINGRATE) /* 168MHz / 48kHz */ @@ -170,11 +178,11 @@ #define USE_EXTERNAL_RAM #endif -#ifndef NO_CCM_RAM -#define USE_CCM_RAM -#define CCM_RAM __attribute__ ((section (".ccmdata"))) -#else +#ifdef NO_CCM_RAM #define CCM_RAM +#else +#define USE_CCM_RAM +#define CCM_RAM __attribute__ ((section (".ccmdata"))) #endif #ifndef DMA_RAM diff --git a/Source/eepromcontrol.c b/Source/eepromcontrol.c index 29e546dd..cbbf72a7 100644 --- a/Source/eepromcontrol.c +++ b/Source/eepromcontrol.c @@ -23,12 +23,10 @@ int eeprom_get_error() { return HAL_FLASH_GetError(); } -int eeprom_erase_sector(uint32_t sector) { +int eeprom_erase_sector(uint32_t sector, uint32_t bank) { FLASH_EraseInitTypeDef cfg; cfg.TypeErase = FLASH_TYPEERASE_SECTORS; -#ifndef OWL_ARCH_F7 - cfg.Banks = FLASH_BANK_1; -#endif + cfg.Banks = bank; cfg.Sector = sector; cfg.NbSectors = 1; cfg.VoltageRange = FLASH_VOLTAGE_RANGE_3; @@ -90,65 +88,71 @@ void eeprom_unlock(){ int eeprom_erase_address(uint32_t address){ int ret = 0; if(address < ADDR_FLASH_SECTOR_1){ - eeprom_erase_sector(FLASH_SECTOR_0); + eeprom_erase_sector(FLASH_SECTOR_0, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_1 - ADDR_FLASH_SECTOR_0; }else if(address < ADDR_FLASH_SECTOR_2){ - eeprom_erase_sector(FLASH_SECTOR_1); + eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_2 - ADDR_FLASH_SECTOR_1; }else if(address < ADDR_FLASH_SECTOR_3){ - eeprom_erase_sector(FLASH_SECTOR_2); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_3 - ADDR_FLASH_SECTOR_2; }else if(address < ADDR_FLASH_SECTOR_4){ - eeprom_erase_sector(FLASH_SECTOR_3); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_4 - ADDR_FLASH_SECTOR_3; }else if(address < ADDR_FLASH_SECTOR_5){ - eeprom_erase_sector(FLASH_SECTOR_4); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_5 - ADDR_FLASH_SECTOR_4; }else if(address < ADDR_FLASH_SECTOR_6){ - eeprom_erase_sector(FLASH_SECTOR_5); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_6 - ADDR_FLASH_SECTOR_5; }else if(address < ADDR_FLASH_SECTOR_7){ - eeprom_erase_sector(FLASH_SECTOR_6); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_7 - ADDR_FLASH_SECTOR_6; -#ifdef FLASH_SECTOR_8 +#ifdef STM32H7xx }else if(address < ADDR_FLASH_SECTOR_8){ - eeprom_erase_sector(FLASH_SECTOR_7); + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_8 - ADDR_FLASH_SECTOR_7; }else if(address < ADDR_FLASH_SECTOR_9){ - eeprom_erase_sector(FLASH_SECTOR_8); + eeprom_erase_sector(FLASH_SECTOR_0, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_9 - ADDR_FLASH_SECTOR_8; }else if(address < ADDR_FLASH_SECTOR_10){ - eeprom_erase_sector(FLASH_SECTOR_9); + eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_10 - ADDR_FLASH_SECTOR_9; }else if(address < ADDR_FLASH_SECTOR_11){ - eeprom_erase_sector(FLASH_SECTOR_10); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_11 - ADDR_FLASH_SECTOR_10; -#ifdef ADDR_FLASH_SECTOR_12 }else if(address < ADDR_FLASH_SECTOR_12){ - eeprom_erase_sector(FLASH_SECTOR_11); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_12 - ADDR_FLASH_SECTOR_11; }else if(address < ADDR_FLASH_SECTOR_13){ - eeprom_erase_sector(FLASH_SECTOR_12); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_13 - ADDR_FLASH_SECTOR_12; }else if(address < ADDR_FLASH_SECTOR_14){ - eeprom_erase_sector(FLASH_SECTOR_13); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_14 - ADDR_FLASH_SECTOR_13; }else if(address < ADDR_FLASH_SECTOR_15){ - eeprom_erase_sector(FLASH_SECTOR_14); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_15 - ADDR_FLASH_SECTOR_14; - }else if(address < FLASH_END){ - eeprom_erase_sector(FLASH_SECTOR_15); - ret = FLASH_END - ADDR_FLASH_SECTOR_15; -#else /* define FLASH_SECTOR_12 */ - }else if(address < FLASH_END){ - eeprom_erase_sector(FLASH_SECTOR_11); - ret = FLASH_END - ADDR_FLASH_SECTOR_11; -#endif /* define FLASH_SECTOR_12 */ + }else if(address < ADDR_FLASH_SECTOR_END){ + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_2); + ret = ADDR_FLASH_SECTOR_END - ADDR_FLASH_SECTOR_15; #else - }else if(address < FLASH_END){ - eeprom_erase_sector(FLASH_SECTOR_7); - ret = FLASH_END - ADDR_FLASH_SECTOR_7; -#endif /* define FLASH_SECTOR_8 */ + }else if(address < ADDR_FLASH_SECTOR_8){ + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_8 - ADDR_FLASH_SECTOR_7; + }else if(address < ADDR_FLASH_SECTOR_9){ + eeprom_erase_sector(FLASH_SECTOR_8, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_9 - ADDR_FLASH_SECTOR_8; + }else if(address < ADDR_FLASH_SECTOR_10){ + eeprom_erase_sector(FLASH_SECTOR_9, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_10 - ADDR_FLASH_SECTOR_9; + }else if(address < ADDR_FLASH_SECTOR_11){ + eeprom_erase_sector(FLASH_SECTOR_10, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_11 - ADDR_FLASH_SECTOR_10; + }else if(address < ADDR_FLASH_SECTOR_END){ + eeprom_erase_sector(FLASH_SECTOR_11, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_END - ADDR_FLASH_SECTOR_11; +#endif } return ret; } diff --git a/Source/eepromcontrol.h b/Source/eepromcontrol.h index 151cec3c..ab7230f7 100644 --- a/Source/eepromcontrol.h +++ b/Source/eepromcontrol.h @@ -35,6 +35,7 @@ #define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbyte */ #define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbyte */ #endif +#define ADDR_FLASH_SECTOR_END ((uint32_t)(FLASH_END + 1)) #ifdef __cplusplus extern "C" { @@ -47,7 +48,7 @@ int eeprom_write_byte(uint32_t address, uint8_t data); int eeprom_erase(uint32_t address, uint32_t size); int eeprom_wait(); - int eeprom_erase_sector(uint32_t sector); + int eeprom_erase_sector(uint32_t sector, uint32_t bank); /* * Functions to lock/unlock pages will perform system reset unless flash is already in desired state */ diff --git a/Source/errorhandlers.c b/Source/errorhandlers.c index 8c532f78..69282a00 100644 --- a/Source/errorhandlers.c +++ b/Source/errorhandlers.c @@ -12,10 +12,8 @@ const char* errormsg = 0; void error(int8_t code, const char* reason){ setErrorMessage(code, reason); /* assert_param(0); */ -#if defined OWL_PEDAL || defined OWL_MODULAR || defined OWL_BIOSIGNALS if(code != NO_ERROR) - setLed(0, RED_COLOUR); -#endif + onError(code, reason); #ifdef DEBUG // assuming semihosting enabled if(reason != NULL) @@ -51,44 +49,16 @@ void NMI_Handler(void){ void MemManage_Handler(void){ errorcode = MEM_ERROR; -#ifdef DEBUG - volatile unsigned int hfsr = SCB->MMFAR; - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)hfsr; - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } void BusFault_Handler(void){ errorcode = BUS_ERROR; -#ifdef DEBUG - volatile unsigned int hfsr = SCB->BFAR; - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)hfsr; - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } void UsageFault_Handler(void){ errorcode = USAGE_ERROR; -#ifdef DEBUG - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } @@ -96,107 +66,8 @@ void DebugMon_Handler(void){ for(;;); } -/** - * @see http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html - */ -#if 0 -void prvGetRegistersFromStack(uint32_t *pulFaultStackAddress) { -/* These are volatile to try and prevent the compiler/linker optimising them -away as the variables never actually get used. If the debugger won't show the -values of the variables, make them global my moving their declaration outside -of this function. */ - volatile uint32_t r0; - volatile uint32_t r1; - volatile uint32_t r2; - volatile uint32_t r3; - volatile uint32_t r12; - volatile uint32_t lr; /* Link register. */ - volatile uint32_t pc; /* Program counter. */ - volatile uint32_t psr;/* Program status register. */ - - r0 = pulFaultStackAddress[0]; - r1 = pulFaultStackAddress[1]; - r2 = pulFaultStackAddress[2]; - r3 = pulFaultStackAddress[3]; - - r12 = pulFaultStackAddress[4]; - lr = pulFaultStackAddress[5]; - pc = pulFaultStackAddress[6]; - psr = pulFaultStackAddress[7]; - - /* When the following line is hit, the variables contain the register values. */ - for (;;); -} - -The fault handler implementation calls a function called - prvGetRegistersFromStack(). -static void HardFault_Handler(void) { - __asm volatile ( - " tst lr, #4 \n" - " ite eq \n" - " mrseq r0, msp \n" - " mrsne r0, psp \n" - " ldr r1, [r0, #24] \n" - " ldr r2, handler2_address_const \n" - " bx r2 \n" - " handler2_address_const: .word prvGetRegistersFromStack \n" - ); -} -#endif - -/* - HardFault_Handler from http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/ -*/ -#if 0 -void HardFault_Handler(void) __attribute__((naked)); - -void HardFault_Handler(void) { -/* HardFault_Handler: */ - __asm("TST LR, #4"); - __asm("ITE EQ"); - __asm("MRSEQ R0, MSP"); - __asm("MRSNE R0, PSP"); - __asm("B hard_fault_handler_c"); -} - -void hard_fault_handler_c (unsigned int * hardfault_args){ - volatile unsigned int stacked_r0; - volatile unsigned int stacked_r1; - volatile unsigned int stacked_r2; - volatile unsigned int stacked_r3; - volatile unsigned int stacked_r12; - volatile unsigned int stacked_lr; - volatile unsigned int stacked_pc; - volatile unsigned int stacked_psr; - - stacked_r0 = ((unsigned long) hardfault_args[0]); - stacked_r1 = ((unsigned long) hardfault_args[1]); - stacked_r2 = ((unsigned long) hardfault_args[2]); - stacked_r3 = ((unsigned long) hardfault_args[3]); - - stacked_r12 = ((unsigned long) hardfault_args[4]); - stacked_lr = ((unsigned long) hardfault_args[5]); - stacked_pc = ((unsigned long) hardfault_args[6]); - stacked_psr = ((unsigned long) hardfault_args[7]); -} -#endif - -/* -see -https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/ -*/ void HardFault_Handler(void){ errorcode = HARDFAULT_ERROR; -#ifdef DEBUG - volatile unsigned int hfsr = SCB->HFSR; - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)hfsr; - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } @@ -221,44 +92,3 @@ void PVD_IRQHandler(void) { void FPU_IRQHandler(void){ assert_failed(0, 0); } - -/* - -void UART4_IRQHandler(void){ - assert_failed(0, 0); -} - -void UART5_IRQHandler(void){ - assert_failed(0, 0); -} - -void USART6_IRQHandler(void){ - assert_failed(0, 0); -} - -void USART3_IRQHandler(void){ - assert_failed(0, 0); -} -void USART2_IRQHandler(void){ - assert_failed(0, 0); -} -void USART1_IRQHandler(void){ - assert_failed(0, 0); -} - -void FLASH_IRQHandler(void){ - assert_failed(0, 0); -} - -void TIM8_UP_TIM13_IRQHandler(void){ - assert_failed(0, 0); -} - -void TIM8_TRG_COM_TIM14_IRQHandler(void){ - assert_failed(0, 0); -} - -void TIM8_CC_IRQHandler(void){ - assert_failed(0, 0); -} -*/ diff --git a/Source/flash.c b/Source/flash.c new file mode 100644 index 00000000..c36e9c78 --- /dev/null +++ b/Source/flash.c @@ -0,0 +1,550 @@ +#include "flash.h" +#include "main.h" +#include "qspi.h" + +/* #define QSPI_TIMEOUT HAL_QPSI_TIMEOUT_DEFAULT_VALUE */ +#define QSPI_TIMEOUT 50000 + +#define QSPIHandle hqspi +extern QSPI_HandleTypeDef QSPIHandle; + +volatile uint8_t CmdCplt, RxCplt, TxCplt, StatusMatch; + +static void QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi, bool nv); +static void QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi); +static void QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi); + +/* Buffer used for transmission */ + +QSPI_CommandTypeDef sCommand; +QSPI_MemoryMappedTypeDef sMemMappedCfg; + +/* + Single bit wide commands start with an instruction and may provide an address + or data, all sent only on the SI signal. Data may be sent back to the host + serially on the SO signal. This is referenced as a 1-1-1 command protocol for + single bit width instruction, single bit width address and modifier, single bit + data. + */ +void flash_init(){ + QSPIHandle.Instance = QUADSPI; + /* QSPI clock = 480MHz / (1+9) = 48MHz */ + /* QSPI clock = 480MHz / (1+4) = 96MHz */ + QSPIHandle.Init.ClockPrescaler = 9; + /* QSPIHandle.Init.ClockPrescaler = 4; // 4 and 5 don't work? 8 works */ +/* #define IS_QSPI_FIFO_THRESHOLD(THR) (((THR) > 0U) && ((THR) <= 32U)) */ + QSPIHandle.Init.FifoThreshold = 4; + QSPIHandle.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; + QSPIHandle.Init.FlashSize = 22; // 2^(22+1) = 8M / 64Mbit + QSPIHandle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; + QSPIHandle.Init.ClockMode = QSPI_CLOCK_MODE_0; + + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; // QSPI_ALTERNATE_BYTES_8_BITS + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS; + /* Initialize QuadSPI ------------------------------------------------ */ + HAL_QSPI_DeInit(&QSPIHandle); + if (HAL_QSPI_Init(&QSPIHandle) != HAL_OK) + { + Error_Handler(); + } + if( HAL_QSPI_SetFifoThreshold(&QSPIHandle, 16) != HAL_OK) + { + Error_Handler(); + } +} + +int flash_read_register(int instruction){ + QSPI_CommandTypeDef cmd; + /* Initialize the read flag status register command */ + cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE; + cmd.Instruction = instruction; + cmd.AddressMode = QSPI_ADDRESS_NONE; + cmd.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + cmd.DataMode = QSPI_DATA_1_LINE; + cmd.DummyCycles = 0; + cmd.NbData = 1; + cmd.DdrMode = QSPI_DDR_MODE_DISABLE; + cmd.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + + if (HAL_QSPI_Command(&QSPIHandle, &cmd, QSPI_TIMEOUT) != HAL_OK) + return -1; + + uint8_t value; + /* Reception of the data */ + if (HAL_QSPI_Receive(&QSPIHandle, &value, QSPI_TIMEOUT) != HAL_OK) + return -1; + + return value; +} + +int flash_status(){ + // Read Status Register 1 (RDSR1 05h) + // Read Status Register 2 (RDSR2 07h) + // Read Configuration Register 1 (RDCR1 35h) + // Read Configuration Register 2 (RDCR2 15h) + // Read Configuration Register 3 (RDCR3 33h) + /* It is possible to read CR1V, CR2V and CR3V continuously by providing multiples of eight clock cycles. */ + return flash_read_register(0x35); +} + +int flash_quad_mode(uint8_t cr1, uint8_t cr2){ //, uint8_t cr3){ + uint8_t data[3] = {0x00, cr1, cr2}; + QSPI_CommandTypeDef cmd; + /* QSPI_WriteEnable(&QSPIHandle, false); // WRENV */ + + // WRENV + cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE; + cmd.Instruction = 0x50; + cmd.AddressMode = QSPI_ADDRESS_NONE; + cmd.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + cmd.DataMode = QSPI_DATA_NONE; + cmd.DummyCycles = 0; + cmd.DdrMode = QSPI_DDR_MODE_DISABLE; + cmd.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + if (HAL_QSPI_Command(&QSPIHandle, &cmd, QSPI_TIMEOUT) != HAL_OK) + return -1; + + // WRR + cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE; + cmd.Instruction = 0x01; // WRR + cmd.AddressMode = QSPI_ADDRESS_NONE; + cmd.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + cmd.DataMode = QSPI_DATA_1_LINE; + cmd.DummyCycles = 0; + cmd.DdrMode = QSPI_DDR_MODE_DISABLE; + cmd.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + cmd.NbData = sizeof(data); + if (HAL_QSPI_Command(&QSPIHandle, &cmd, QSPI_TIMEOUT) != HAL_OK) + return -1; + if (HAL_QSPI_Transmit(&QSPIHandle, data, QSPI_TIMEOUT) != HAL_OK) + return -1; + return 0; + /* + WRENV 0x50 + WRR 0x01 + WRAR 0x71 + The Write Enable Volatile (WRENV) command must be written prior to Write Register (WRR) command that modifies volatile registers data. + */ +} + +int flash_erase(uint32_t address, uint32_t size){ + /* Enable write operations ------------------------------------------- */ + QSPI_WriteEnable(&QSPIHandle, true); + + /* Erasing Sequence -------------------------------------------------- */ + sCommand.Instruction = SECTOR_ERASE_CMD; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.NbData = 0; + int remain = size; + while(remain > 0){ + sCommand.Address = address; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + address += QSPI_ERASE_BLOCK_SIZE; + remain -= QSPI_ERASE_BLOCK_SIZE; + } + return 0; +} + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif + +int flash_write_page(uint32_t address, void* data, uint32_t size){ + /* Enable write operations ----------------------------------------- */ + QSPI_WriteEnable(&QSPIHandle, true); + + /* Writing Sequence ------------------------------------------------ */ + sCommand.Instruction = QUAD_IN_FAST_PROG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.DummyCycles = 0; + sCommand.Address = address; + sCommand.NbData = size; + + // To use Quad Page Program the Quad Enable Bit in the Configuration Register must be set (QUAD=1). A Write Enable command must be executed before the device will accept the QPP command (Status Register 1, WEL=1). + + // SPI alternative + sCommand.Instruction = PAGE_PROG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_1_LINE; + + /* The Page Program command accepts from 1-byte up to 256 consecutive bytes of data (page) to be programmed in one operation. */ + + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + if (HAL_QSPI_Transmit(&QSPIHandle, data, QSPI_TIMEOUT) != HAL_OK) + return -1; + return 0; +} + +int flash_write_block(uint32_t address, void* data, uint32_t size){ + size_t pages = (size+QSPI_FLASH_PAGE_SIZE-1)/QSPI_FLASH_PAGE_SIZE; + uint8_t* source = (uint8_t*)data; + int ret = 0; + while(ret == 0 && pages--){ + flash_wait(); + ret = flash_write_page(address, source, min(QSPI_FLASH_PAGE_SIZE, size)); + address += QSPI_FLASH_PAGE_SIZE; + source += QSPI_FLASH_PAGE_SIZE; + size -= QSPI_FLASH_PAGE_SIZE; + } + return ret; +} + +int flash_qpi_mode(bool quad){ + /* The recommended procedure for moving to QPI mode is to first use the QPIEN (38h) command, the WRR or WRAR command can also set CR2V[3] = 1, QPI mode + QPI CR2V[3]: This bit controls the expected instruction width for all commands. This volatile QPI configuration bit enables the + device to enter and exit QPI mode during normal operation. When this bit is set to QPI mode, the QUAD mode is active, independent + of the setting of QIO mode (CR1V[1]). When this bit is cleared to legacy SPI mode, the QUAD bit is not affected. The QPI CR2V[3] + bit can also be set to “1” by the QPIEN (38h) command and set to “0” by the QPIEX (F5h) command. + + The enter QPI Mode (QPIEN) command enables the QPI mode by setting the volatile QPI bit (CR2V[3] = 1). The time required to enter QPI Mode is tQEN, 1.5uS, no other commands are allowed during the tQEN transition time to QPI mode. + */ + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.NbData = 0; + if(quad){ + // enable quad mode QPIEN + sCommand.Instruction = ENTER_QUAD_CMD; + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + }else{ + // exit quad mode QPIEX + sCommand.Instruction = EXIT_QUAD_CMD; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + } + volatile size_t counter = 10000; + while(counter--) + __NOP(); + return 0; +} + +int flash_read_mode(int mode){ +/* Configure Volatile Configuration register (with new dummy cycles) */ + /* QSPI_DummyCyclesCfg(&QSPIHandle); */ + + // defaults for all modes + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.AddressSize = QSPI_ADDRESS_32_BITS; + sCommand.DummyCycles = 8; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.AlternateBytes = 0xA0; // Continuous read feature is enabled if the mode bits value is Axh. + + switch(mode){ + case -111: // SPI read 1-1-1 + sCommand.Instruction = QSPI_FLASH_CMD_FAST_READ; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + break; + case -112: // Dual out fast read 1-1-2 + sCommand.Instruction = QSPI_FLASH_CMD_DOR; + sCommand.DataMode = QSPI_DATA_2_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + break; + case -114: // Quad out read 1-1-4 + sCommand.Instruction = QSPI_FLASH_CMD_QOR; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + break; + case -122: // Dual I/O 1-2-2, mode cycles 4 + sCommand.Instruction = QSPI_FLASH_CMD_DIOR; + sCommand.AddressMode = QSPI_ADDRESS_2_LINES; + sCommand.DataMode = QSPI_DATA_2_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_2_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case -144: // Quad I/O read 1-4-4, mode cycles 2 + sCommand.Instruction = QSPI_FLASH_CMD_QIOR; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case -444: // Quad I/O 4-4-4, mode cycles 2 + // QSPI read + sCommand.Instruction = QSPI_FLASH_CMD_QIOR; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case 111: // SPI read 1-1-1 + sCommand.Instruction = QSPI_FLASH_CMD_4FAST_READ; + break; + case 112: // Dual out fast read 1-1-2 + sCommand.Instruction = QSPI_FLASH_CMD_4DOR; + sCommand.DataMode = QSPI_DATA_2_LINES; + break; + case 122: // Dual I/O 1-2-2, mode cycles 4 + sCommand.Instruction = QSPI_FLASH_CMD_4DIOR; + sCommand.AddressMode = QSPI_ADDRESS_2_LINES; + sCommand.DataMode = QSPI_DATA_2_LINES; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_2_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case 114: // Quad out 1-1-4 + sCommand.Instruction = QSPI_FLASH_CMD_4QOR; + sCommand.DataMode = QSPI_DATA_4_LINES; + break; + case 144: // Quad I/O 1-4-4, mode cycles 2 + // QSPI read + sCommand.Instruction = QSPI_FLASH_CMD_4QIOR; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case 444: // Quad I/O 4-4-4, mode cycles 2 + // QSPI read + sCommand.Instruction = QSPI_FLASH_CMD_4QIOR; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + default: + return -1; + } + return 0; +} + +int flash_read_block(int mode, uint32_t address, void* data, uint32_t size){ + flash_read_mode(mode); + sCommand.Address = address; + sCommand.NbData = size; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + if (HAL_QSPI_Receive(&QSPIHandle, data, QSPI_TIMEOUT) != HAL_OK) + return -1; + return 0; +} + +int flash_wait(){ + while(QSPIHandle.State == HAL_QSPI_STATE_BUSY) + HAL_Delay(10); + /* return QSPIHandle.State == HAL_QSPI_STATE; */ + /* while(CmdCplt != 0) */ + /* HAL_Delay(10); */ + /* CmdCplt = 0; */ + /* StatusMatch = 0; */ + /* /\* Configure automatic polling mode to wait for end of erase or write *\/ */ + QSPI_AutoPollingMemReady(&QSPIHandle); + /* while(StatusMatch != 0) */ + /* HAL_Delay(10); */ + /* return 0; */ + return HAL_QSPI_GetError(&QSPIHandle); +} + +int flash_memory_map(int mode){ + + if(mode == 114 || mode == 144 || + mode == -114 || mode == -144){ + flash_quad_mode(0x02, 0x60); + flash_qpi_mode(false); + }else if(mode == 444 || mode == -444){ + flash_quad_mode(0x02, 0x68); + flash_qpi_mode(true); + }else{ + flash_quad_mode(0x00, 0x60); + flash_qpi_mode(false); + } + + flash_read_mode(mode); + sMemMappedCfg.TimeOutPeriod = 0; + sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE; + if (HAL_QSPI_MemoryMapped(&QSPIHandle, &sCommand, &sMemMappedCfg) != HAL_OK) + return -1; + return 0; +} + +/** + * @brief Command completed callbacks. + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_CmdCpltCallback(QSPI_HandleTypeDef *hqspi) +{ + CmdCplt++; +} + +/** + * @brief Rx Transfer completed callbacks. + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_RxCpltCallback(QSPI_HandleTypeDef *hqspi) +{ + RxCplt++; +} + +/** + * @brief Tx Transfer completed callbacks. + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_TxCpltCallback(QSPI_HandleTypeDef *hqspi) +{ + CmdCplt++; + TxCplt++; +} + +/** + * @brief Status Match callbacks + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_StatusMatchCallback(QSPI_HandleTypeDef *hqspi) +{ + StatusMatch++; +} + +/** + * @brief This function send a Write Enable and wait it is effective. + * @param hqspi: QSPI handle + * @retval None + */ +static void QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi, bool nv) +{ + QSPI_CommandTypeDef sCommand; + QSPI_AutoPollingTypeDef sConfig; + + /* Enable write operations ------------------------------------------ */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = nv ? 0x06 : 0x50; // WRITE_ENABLE_CMD; + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + + if (HAL_QSPI_Command(hqspi, &sCommand, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + /* Configure automatic polling mode to wait for write enabling ---- */ + sConfig.Match = 0x02; + sConfig.Mask = 0x02; + sConfig.MatchMode = QSPI_MATCH_MODE_AND; + sConfig.StatusBytesSize = 1; + sConfig.Interval = 0x10; + sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; + + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_1_LINE; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief This function read the SR of the memory and wait the EOP. + * @param hqspi: QSPI handle + * @retval None + */ +static void QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi) +{ + QSPI_CommandTypeDef sCommand; + QSPI_AutoPollingTypeDef sConfig; + + /* Configure automatic polling mode to wait for memory ready ------ */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + + sConfig.Match = 0x00; + sConfig.Mask = 0x01; + sConfig.MatchMode = QSPI_MATCH_MODE_AND; + sConfig.StatusBytesSize = 1; + sConfig.Interval = 0x10; + sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief This function configure the dummy cycles on memory side. + * @param hqspi: QSPI handle + * @retval None + */ +static void QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi) +{ + QSPI_CommandTypeDef sCommand; + uint8_t reg; + + /* Read Volatile Configuration register --------------------------- */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = READ_VOL_CFG_REG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.NbData = 1; + + if (HAL_QSPI_Command(hqspi, &sCommand, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + if (HAL_QSPI_Receive(hqspi, ®, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + /* Enable write operations ---------------------------------------- */ + QSPI_WriteEnable(hqspi, false); + + /* Write Volatile Configuration register (with new dummy cycles) -- */ + sCommand.Instruction = WRITE_VOL_CFG_REG_CMD; + MODIFY_REG(reg, 0xF0, (DUMMY_CLOCK_CYCLES_READ_QUAD << POSITION_VAL(0xF0))); + + if (HAL_QSPI_Command(hqspi, &sCommand, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + if (HAL_QSPI_Transmit(hqspi, ®, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } +} diff --git a/Source/flash.h b/Source/flash.h new file mode 100644 index 00000000..56d69eb5 --- /dev/null +++ b/Source/flash.h @@ -0,0 +1,28 @@ +#ifndef __FLASH_H +#define __FLASH_H + +#include +#include + +#define QSPI_FLASH_BASE 0x90000000 +#define QSPI_FLASH_SIZE (8*1024*1024) // 8M / 64Mbit + +#ifdef __cplusplus + extern "C" { +#endif + + void flash_init(); + int flash_status(); + int flash_quad_mode(uint8_t, uint8_t); + int flash_qpi_mode(bool qpi); + int flash_write_block(uint32_t address, void* data, uint32_t size); + int flash_read_block(int mode, uint32_t address, void* data, uint32_t size); + int flash_wait(); + int flash_erase(uint32_t address, uint32_t size); + int flash_memory_map(int mode); + +#ifdef __cplusplus +} +#endif + +#endif /* __EEPROM_CONTROL_H */ diff --git a/Source/hardware_ids.h b/Source/hardware_ids.h index f202a288..6c40aeca 100644 --- a/Source/hardware_ids.h +++ b/Source/hardware_ids.h @@ -19,6 +19,7 @@ #define GENIUS_HARDWARE 0x20 #define OWL_PEDAL_HARDWARE 0x21 #define OWL_MODULAR_HARDWARE 0x22 +#define XIBECA_HARDWARE 0x23 #define OTHER_HARDWARE 0xf0 #endif /* __HARDWARE_IDS_H */ diff --git a/Source/message.h b/Source/message.h index 614594cf..45220d9c 100644 --- a/Source/message.h +++ b/Source/message.h @@ -24,6 +24,7 @@ #endif void debugMessage(const char* msg); + const char* getDebugMessage(); void error(int8_t code, const char* reason); void assert_failed(uint8_t* location, uint32_t line); @@ -62,4 +63,4 @@ void assert_failed(const char* msg, const char* location, int line); #endif -#endif /* __MESSAG£_H */ +#endif /* __MESSAGE_H */ diff --git a/Source/pcm3168a.c b/Source/pcm3168a.c index c7e1bc36..a5f7752a 100644 --- a/Source/pcm3168a.c +++ b/Source/pcm3168a.c @@ -70,15 +70,28 @@ void codec_init(){ delay(10); codec_write(64, 0b11000001); // Normal operation, Single rate - codec_write(65, 0b00000110); // Power Save Enable, Slave mode, 24-bit I2S mode TDM format - /* codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format */ /* Register: DAC Control 1 */ - codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format + codec_write(65, 0b00000110); // Power Save Enable, Slave mode, 24-bit I2S mode TDM format + /* codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format */ + /* codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format */ /* codec_write(65, 0b10000111); // 24-bit left-justified mode TDM format */ + + /* Register: DAC Control 2 */ +#if AUDIO_CHANNELS == 4 + codec_write(66, 0b11000000); // disable DAC channels 7/8 and 5/6 +#elif AUDIO_CHANNELS == 6 + codec_write(66, 0b10000000); // disable DAC channels 7/8 +/* These bits control the DAC operation mode. In operation disable mode, the DAC output is cut off from DIN with a fade-out */ +/* sequence, and the internal DAC data is reset. DAC output is forced into VCOMDA if PSMDA = 1, or DAC output is forced */ +/* into AGNDDA and goes into a power-down state if PSMDA = 0. For normal operating mode, a fade-in sequence is */ +/* applied on the DAC output in resume process. The serial mode control is effective during operation disable mode */ +#endif /* Register: DAC Output Phase */ - /* codec_write(67, 0xff); // phase invert all DAC channels */ +#ifdef CODEC_DAC_INVERT + codec_write(67, 0xff); // phase invert all DAC channels +#endif /* Register: DAC Soft Mute Control */ /* codec_write(68, 0xff); // enable soft mute for all DAC channels */ @@ -87,6 +100,7 @@ void codec_init(){ /* Each DAC channel (VOUTx) has a digital attenuator function. The attenuation level can be set from 0 dB to –100 dB in */ /* 0.5-dB steps, and also can be set to infinite attenuation (mute). The attenuation level change from current value to target */ /* value is performed by incrementing or decrementing with s-curve responses and a time set by ATSPDA. */ + codec_write(70, 0b10000000); // ATMDDA=1 All channels with preset (independent) data + master (common) data in decibel number /* Data formats, see Table 11 p.33 */ @@ -95,16 +109,25 @@ void codec_init(){ codec_write(81, 0b00000110); // Slave mode 24-bit I2S mode TDM format /* codec_write(81, 0b00000111); // Slave mode 24-bit left-justified mode TDM format */ + uint8_t value; +#if AUDIO_CHANNELS == 4 + value = 0b01000000; // disable ADC channels 5/6 +#else + value = 0b00000000; +#endif #ifndef CODEC_HP_FILTER - /* Register: ADC Control 2 */ - codec_write(82, 0b00000111); // disable HPF for all ADC channels + value |= 0b00000111; // disable HPF for all ADC channels #endif + /* Register: ADC Control 2 */ + codec_write(82, value); /* Register: ADC Input Configuration */ - /* codec_write(83, 0b00111111); // singled ended inputs on all ADC channels */ + codec_write(83, 0b00111111); // singled ended inputs on all ADC channels - /* Register: ADC Input Phase */ - /* codec_write(83, 0b00111111); // phase invert all ADC channels */ + /* Register: ADC Input Phase */ +#ifdef CODEC_ADC_INVERT + codec_write(84, 0b00111111); // phase invert all ADC channels +#endif /* Register: ADC Overflow Flag */ /* ADC Overflow flag (read-only) */ @@ -116,6 +139,7 @@ void codec_init(){ /* Each ADC channel has a digital attenuator function with 20-dB gain. The attenuation level can be set from 20 dB to –100 */ /* dB in 0.5-dB steps, and also can be set to infinite attenuation (mute). The attenuation level change from current value to */ /* target value is performed by increment or decrement with s-curve response and time set by ATSPAD. */ + codec_write(87, 0b1000000); // ATMDAD=1 All channels with preset (independent) data + master (common) data in decibel number /* codec_reset(); */ @@ -139,7 +163,7 @@ void codec_mute(bool mute){ void codec_set_gain_in(int8_t level){ /* Register 88: ADC Digital attenuation level setting */ uint8_t value = level+128; - codec_write(88, value); // + codec_write(88, value); // set master attenuation level ATAD0[7:0] } /** @@ -148,6 +172,6 @@ void codec_set_gain_in(int8_t level){ void codec_set_gain_out(int8_t level){ /* Register 71: DAC Digital attenuation level setting */ uint8_t value = level+128; - codec_write(71, value); // + codec_write(71, value); // set master attenuation level ATDA0[7:0] } diff --git a/Source/qint.h b/Source/qint.h index 7afe8ba8..fb38ea5d 100644 --- a/Source/qint.h +++ b/Source/qint.h @@ -14,10 +14,10 @@ #define Q7_CLIP(a) ((a) > Q7_MAX ? Q7_MAX : (a) < Q7_MIN ? Q7_MIN : (a)) #define Q15_CLIP(a) ((a) > Q15_MAX ? Q15_MAX : (a) < Q15_MIN ? Q15_MIN : (a)) #define Q31_CLIP(a) ((a) > Q31_MAX ? Q31_MAX : (a) < Q31_MIN ? Q31_MIN : (a)) -#define Q15_MUL_Q15(a,b) Q15_CLIP(((q63_t)(a)*(b))>>15) +#define Q15_MUL_Q15(a,b) Q15_CLIP(((q31_t)(a)*(b))>>15) #define Q31_MUL_Q31(a,b) Q31_CLIP(((q63_t)(a)*(b))>>31) #define FLOAT_TO_Q7(a) Q7_CLIP((q15_t)((a)*128.0f)) -#define FLOAT_TO_Q15(a) Q15_CLIP((q63_t)((a)*32768.0f)) +#define FLOAT_TO_Q15(a) Q15_CLIP((q31_t)((a)*32768.0f)) #define FLOAT_TO_Q31(a) Q31_CLIP((q63_t)((a)*2147483648.0f)) #endif diff --git a/Source/sdram-as4cXm32.c b/Source/sdram-as4cXm32.c new file mode 100644 index 00000000..f4c71c1f --- /dev/null +++ b/Source/sdram-as4cXm32.c @@ -0,0 +1,64 @@ +#include +#include "sdram.h" + +/** + * Alliance Memory DRAM 256Mbits, 3.3V, 8Mx32 AS4C8M32SA-6BIN + */ + +#define SDRAM_MODEREG_BURST_LENGTH_2 (1 << 0) +#define SDRAM_MODEREG_BURST_LENGTH_4 (1 << 1) +#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL (0 << 3) +#define SDRAM_MODEREG_CAS_LATENCY_3 ((1 << 4) | (1 << 5)) +#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE (1 << 9) +#define SDRAM_MODEREG_WRITEBURST_MODE_PROG_BURST (0 << 9) + +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram){ + FMC_SDRAM_CommandTypeDef Command; + + __IO uint32_t tmpmrd = 0; + /* Step 3: Configure a clock configuration enable command */ + Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 1; + Command.ModeRegisterDefinition = 0; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Step 4: Insert 100 ms delay */ + HAL_Delay(100); + + /* Step 5: Configure a PALL (precharge all) command */ + Command.CommandMode = FMC_SDRAM_CMD_PALL; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 1; + Command.ModeRegisterDefinition = 0; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Step 6 : Configure a Auto-Refresh command */ + Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 4; + Command.ModeRegisterDefinition = 0; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Step 7: Program the external memory mode register */ + tmpmrd = SDRAM_MODEREG_BURST_LENGTH_4 + | SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL + | SDRAM_MODEREG_CAS_LATENCY_3 + | SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; + Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 1; + Command.ModeRegisterDefinition = tmpmrd; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Set refresh rate */ + HAL_SDRAM_ProgramRefreshRate(hsdram, 0x81A - 20); +} diff --git a/Source/seps114a.c b/Source/seps114a.c index 0d62360a..842cbba2 100644 --- a/Source/seps114a.c +++ b/Source/seps114a.c @@ -46,13 +46,8 @@ #define SEPS114A_RGB_POL 0xE1 #define SEPS114A_DISPLAY_MODE_CONTROL 0xE5 -#ifdef OLED_SOFT_CS #define setCS() setPin(OLED_CS_GPIO_Port, OLED_CS_Pin) #define clearCS() clearPin(OLED_CS_GPIO_Port, OLED_CS_Pin) -#else -#define setCS() -#define clearCS() -#endif #define setDC() setPin(OLED_DC_GPIO_Port, OLED_DC_Pin) #define clearDC() clearPin(OLED_DC_GPIO_Port, OLED_DC_Pin) #define clearRST() clearPin(OLED_RST_GPIO_Port, OLED_RST_Pin); diff --git a/Source/ssd1309.c b/Source/ssd1309.c index 055f1729..e47e408f 100644 --- a/Source/ssd1309.c +++ b/Source/ssd1309.c @@ -1,8 +1,9 @@ // _____ Includes ______________________________________________________________________ +#include #include "oled.h" #include "device.h" +#include "message.h" #include "errorhandlers.h" -#include /* static void NopDelay(uint32_t nops){ */ /* while (nops--) */ @@ -21,44 +22,71 @@ #define pDC_Clr() HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET) #define pCS_Clr() HAL_GPIO_WritePin(OLED_CS_GPIO_Port, OLED_CS_Pin, GPIO_PIN_RESET) -#define OLED_DAT 1 -#define OLED_CMD 0 - // _____ Prototypes ____________________________________________________________________ static void OLED_writeCMD(const uint8_t* data, uint16_t length); // _____ Variables _____________________________________________________________________ -static const uint8_t OLED_initSequence[] = -{ +#define SCREEN_OFFSET 0 +static const uint8_t OLED_initSequence[] = + { +#ifdef SSD1306 + 0xAE, // Display off + 0xD5, // Set display clock divider + 0x80, + 0xA8, // Set multiplex + 0x3F, + 0xD3, // Set display offset + SCREEN_OFFSET, + 0x40, // Set start line to zero + 0x8D, // Set charge pump + 0x14, + 0x20, 0x01, // Vertical addressing mode +#ifdef OLED_UPSIDE_DOWN + 0xa0, + 0xc1, +#else + 0xa1, + 0xc8, +#endif + 0xDA, // Set Comm pins + 0x12, + 0x81, // Set contrast + 0xCF, + 0xd9, // Set precharge + 0xF1, + 0xDB, // Set Vcom detect + 0x30,//40, + 0xA4, // Allow display resume + 0xA6, // Set normal display + 0xAF // Display On +#else 0xfd, 0x12, // Command unlock 0xae, // Display off 0xd5, 0xa0, // Clock divide ratio / Oscillator Frequency 0xa8, 0x3f, // Multiplex ratio 64 // Scan direction: c0: scan dir normal, c8: reverse #ifdef OLED_UPSIDE_DOWN + 0xa0, 0xc1, #else + 0xa1, 0xc8, #endif 0xd3, 0x00, // Display offset 0x40, // Start line // Segment re-map: a0: col0 -> SEG0, a1: col127 -> SEG0 -#ifdef OLED_UPSIDE_DOWN - 0xa0, -#else - 0xa1, -#endif 0xda, 0x12, // COM pins 0x81, 0xcf, // Contrast control: 0 to 0xff. Current increases with contrast. 0xd9, 0x22, // Pre-charge period 0xdb, 0x34, // VCOMH deselect level - /* 0xa4, // Entire display on/off */ - 0xa6, // Normal / inverse display + /* 0xa4, // Entire display on/off : A4 / A5 */ + 0xa6, // Normal / inverse display : A6 / A7 0x20, 0x01, // Vertical addressing mode 0x21, 0x00, 0x7f, // Set column address 0x22, 0x00, 0x07, // Set page address 0xaf, // Display on /* 0xa6, // Set Normal/Inverse Display */ +#endif }; /* static unsigned char* OLED_Buffer; */ @@ -81,9 +109,9 @@ static void OLED_writeCMD(const uint8_t* data, uint16_t length) void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi){ if(hspi->ErrorCode == HAL_SPI_ERROR_OVR){ __HAL_SPI_CLEAR_OVRFLAG(hspi); - error(RUNTIME_ERROR, "SPI OVR"); + debugMessage("SPI OVR"); }else{ - assert_param(0); + error(RUNTIME_ERROR, "SPI Error"); } } diff --git a/Source/usbd_audio.c b/Source/usbd_audio.cpp similarity index 69% rename from Source/usbd_audio.c rename to Source/usbd_audio.cpp index e42b9caf..50259ada 100644 --- a/Source/usbd_audio.c +++ b/Source/usbd_audio.cpp @@ -17,12 +17,30 @@ #include "usbd_conf.h" #include "usbd_ctlreq.h" +#ifdef DEBUG_USBD_AUDIO +#include "message.h" +int usbd_tx_flow = 0; +int usbd_rx_flow = 0; +int usbd_tx_capacity = 0; +int usbd_rx_capacity = 0; +#endif + +// #ifdef DEBUG +// #define FLOW_ASSERT(x, y) if(!(x)){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} +// #endif +#include "CircularBuffer.h" +#include "Codec.h" + +// todo: not static/global; move the buffers out of this compilation unit +CircularBuffer rx_buffer; +CircularBuffer tx_buffer; + #define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16)) #define AUDIO_FREQ_FROM_DATA(bytes) ((((uint32_t)((bytes)[2]))<<16)|(((uint32_t)((bytes)[1]))<<8)|(((uint32_t)((bytes)[0])))) #define AUDIO_FREQ_TO_DATA(frq , bytes) do{ \ - (bytes)[0]= (uint8_t)(frq); \ - (bytes)[1]= (uint8_t)(((frq) >> 8)); \ - (bytes)[2]= (uint8_t)(((frq) >> 16)); \ + (bytes)[0] = (uint8_t)(frq); \ + (bytes)[1] = (uint8_t)(((frq) >> 8)); \ + (bytes)[2] = (uint8_t)(((frq) >> 16)); \ }while(0); @@ -85,29 +103,23 @@ USBD_ClassTypeDef USBD_AUDIO = }; -#if 1 +#ifdef USE_USBD_RX_FB -#define FB_REFRESH 5 /* Feedback refresh rate 2^(10-FB_REFRESH) */ -#define FB_RATE (1<<(10-FB_REFRESH)) +#define FB_REFRESH 4 /* Feedback refresh rate */ +#define FB_RATE (1<> 2; - buf[1] = freq >> 10; - buf[2] = freq >> 18; + // convert sample rate to 10.14 format + rate = (rate / 1000.0f) * (1<<14); + AUDIO_FREQ_TO_DATA(rate, buf); } - -uint8_t fb_data[3]; - #endif -#if defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI +#if defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 // bInterfaceNumber #define AUDIO_TX_IF 0x02 #define AUDIO_MIDI_IF 0x03 @@ -116,25 +128,51 @@ uint8_t fb_data[3]; #define AUDIO_TX_EP 0x82 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x83 -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - 2*USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE - AUDIO_TX_MAX_PACKET_SIZE) +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_AUDIO_TX #define AUDIO_RX_IF 0x01 #define AUDIO_TX_IF 0x02 #define AUDIO_RX_EP 0x01 #define AUDIO_FB_EP 0x81 #define AUDIO_TX_EP 0x82 -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - 2*USBD_MIN_FIFO_SIZE - AUDIO_TX_MAX_PACKET_SIZE) +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 #define AUDIO_MIDI_IF 0x02 #define AUDIO_RX_EP 0x01 #define AUDIO_FB_EP 0x81 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - 2*USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE) +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI +#define AUDIO_RX_IF 0x01 // bInterfaceNumber +#define AUDIO_TX_IF 0x02 +#define AUDIO_MIDI_IF 0x03 +#define AUDIO_RX_EP 0x01 // bEndpointAddress +#define AUDIO_TX_EP 0x81 +#define MIDI_RX_EP 0x02 +#define MIDI_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE - AUDIO_TX_MAX_PACKET_SIZE) +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX +#define AUDIO_RX_IF 0x01 +#define AUDIO_TX_IF 0x02 +#define AUDIO_RX_EP 0x01 +#define AUDIO_TX_EP 0x81 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE - AUDIO_TX_MAX_PACKET_SIZE) +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI +#define AUDIO_RX_IF 0x01 +#define AUDIO_MIDI_IF 0x02 +#define AUDIO_RX_EP 0x01 +#define MIDI_RX_EP 0x02 +#define MIDI_TX_EP 0x81 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE) #elif defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI #define AUDIO_TX_IF 0x01 #define AUDIO_MIDI_IF 0x02 #define AUDIO_TX_EP 0x81 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE - AUDIO_TX_MAX_PACKET_SIZE) #else #define AUDIO_RX_IF 0x01 #define AUDIO_TX_IF 0x01 @@ -146,9 +184,30 @@ uint8_t fb_data[3]; #define MIDI_TX_EP 0x81 #endif +#if defined USE_USBD_RX and defined USE_USBD_TX and defined USE_USBD_MIDI and USBD_MAX_NUM_INTERFACES < 4 +#error "Insufficient USBD interfaces configured" +#endif + +#if AUDIO_RX_FIFO_SIZE < (AUDIO_RX_MAX_PACKET_SIZE + 2*USBD_MIN_FIFO_SIZE) +#pragma message "USBD RX FIFO small" +#endif +#if AUDIO_RX_FIFO_SIZE < USBD_MIN_FIFO_SIZE +#error "USBD RX FIFO too small" +#endif + +#ifdef USE_USBD_AUDIO_FEATURES +#define USBD_AUDIO_RX_AF_DESC_LEN (8+USBD_AUDIO_RX_CHANNELS) +#else +#define USBD_AUDIO_RX_AF_DESC_LEN 0 +#endif + #ifdef USE_USBD_AUDIO_RX -#define USBD_AUDIO_RX_AC_DESC_LEN 30 +#define USBD_AUDIO_RX_AC_DESC_LEN (21+USBD_AUDIO_RX_AF_DESC_LEN) +#ifdef USE_USBD_RX_FB #define USBD_AUDIO_RX_AS_DESC_LEN 61 +#else +#define USBD_AUDIO_RX_AS_DESC_LEN 52 +#endif #define USBD_AUDIO_RX_NUM_INTERFACES 1 #else #define USBD_AUDIO_RX_AC_DESC_LEN 0 @@ -156,8 +215,14 @@ uint8_t fb_data[3]; #define USBD_AUDIO_RX_NUM_INTERFACES 0 #endif +#ifdef USE_USBD_AUDIO_FEATURES +#define USBD_AUDIO_TX_AF_DESC_LEN (8+USBD_AUDIO_TX_CHANNELS) +#else +#define USBD_AUDIO_TX_AF_DESC_LEN 0 +#endif + #ifdef USE_USBD_AUDIO_TX -#define USBD_AUDIO_TX_AC_DESC_LEN 21 +#define USBD_AUDIO_TX_AC_DESC_LEN (21+USBD_AUDIO_TX_AF_DESC_LEN) #define USBD_AUDIO_TX_AS_DESC_LEN 52 #define USBD_AUDIO_TX_NUM_INTERFACES 1 #else @@ -174,6 +239,15 @@ uint8_t fb_data[3]; #define USBD_MIDI_NUM_INTERFACES 0 #endif +#if AUDIO_CHANNELS >= 4 +#define USBD_AUDIO_CHANNEL_CONFIG 0x0603 /* Side L/R and Front L/R */ +#elif AUDIO_CHANNELS >= 2 +#define USBD_AUDIO_CHANNEL_CONFIG 0x0003 /* L/R */ +#else +#define USBD_AUDIO_CHANNEL_CONFIG 0x0000 /* Unassigned */ +#endif + + // not including Audio Control AC interface #define AUDIO_NUM_INTERFACES (USBD_AUDIO_RX_NUM_INTERFACES+USBD_AUDIO_TX_NUM_INTERFACES+USBD_MIDI_NUM_INTERFACES) @@ -188,8 +262,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL /* Configuration 1 */ 0x09, /* bLength */ 0x02, /* bDescriptorType */ - LOBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ - HIBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ + LOBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ + HIBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ (AUDIO_NUM_INTERFACES+1), /* bNumInterfaces (+1 for AC Interface) */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ @@ -243,43 +317,61 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x01, // bTerminalID 0x01, // wTerminalType USBD_AUDIO_TERMINAL_IO_USB_STREAMING 0x0101 0x01, // wTerminalType - 0x00, // bAssocTerminal - USBD_AUDIO_RX_CHANNELS, // bNrChannels -#if USBD_AUDIO_RX_CHANNELS == 1 - 0x00, // wChannelConfig 0x00 sets Mono, no position bits -#else - 0x03, // wChannelConfig 0x03 sets stereo channels left and right -#endif - 0x00, // wChannelConfig + 0x03, // bAssocTerminal + USBD_AUDIO_RX_CHANNELS, // bNrChannels + LOBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig + HIBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig 0x00, // iChannelNames 0x00, // iTerminal Unused /* 12 byte */ +#ifdef USE_USBD_AUDIO_FEATURES /* Feature Unit Descriptor*/ - 0x09, // bLength + USBD_AUDIO_RX_AF_DESC_LEN, // bLength 0x24, // bDescriptorType 0x06, // bDescriptorSubtype 0x02, // bUnitID 0x01, // bSourceID 0x01, // bControlSize - 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME - 0, // bmaControls(1) + AUDIO_CONTROL_REQ_FU_MUTE, // bmaControls(0) Master + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(1) Channel 1 +#if USBD_AUDIO_RX_CHANNELS > 1 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(2) Channel 2 +#if USBD_AUDIO_RX_CHANNELS > 2 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(3) Channel 3 +#if USBD_AUDIO_RX_CHANNELS > 3 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(4) Channel 4 +#endif +#endif +#endif 0x00, // iTerminal - /* 09 byte */ + /* 8 + ch byte */ /* Output Terminal Descriptor */ 0x09, // bLength 0x024, // bDescriptorType 0x03, // bDescriptorSubtype - 0x03, // bTerminalID + 0x03, // bTerminalID 0x01, // wTerminalType 0x0301 - 0x03, // wTerminalType 0x0301 - 0x00, // bAssocTerminal + 0x03, // wTerminalType + 0x01, // bAssocTerminal 0x02, // bSourceID 0x00, // iTerminal /* 09 byte */ - - // 12+9+9 = 30 bytes +#else + /* Output Terminal Descriptor */ + 0x09, // bLength + 0x024, // bDescriptorType + 0x03, // bDescriptorSubtype + 0x03, // bTerminalID + 0x01, // wTerminalType 0x0301 + 0x03, // wTerminalType + 0x01, // bAssocTerminal + 0x01, // bSourceID + 0x00, // iTerminal + /* 09 byte */ +#endif + // 12+10+9 = 31 bytes #endif #ifdef USE_USBD_AUDIO_TX @@ -287,29 +379,63 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x0C, // Size of the descriptor, in bytes 0x24, // bDescriptorType CS_INTERFACE Descriptor Type 0x24 0x02, // bDescriptorSubtype INPUT_TERMINAL descriptor subtype 0x02 - 0x01, // bTerminalID ID of this Terminal. + 0x04, // bTerminalID ID of this Terminal. 0x01, // wTerminalType 0x02, // wTerminalType Terminal is Microphone (0x0201) - 0x00, // bAssocTerminal No association - USBD_AUDIO_TX_CHANNELS, // bNrChannels - 0x03, // wChannelConfig - 0x00, // wChannelConfig Mono sets no position bits + 0x06, // bAssocTerminal + USBD_AUDIO_TX_CHANNELS, // bNrChannels + LOBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig + HIBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig 0x00, // iChannelNames Unused 0x00, // iTerminal Unused /* 12 bytes */ +#ifdef USE_USBD_AUDIO_FEATURES + /* Feature Unit Descriptor*/ + USBD_AUDIO_TX_AF_DESC_LEN, // bLength + 0x24, // bDescriptorType + 0x06, // bDescriptorSubtype + 0x05, // bUnitID + 0x04, // bSourceID + 0x01, // bControlSize + AUDIO_CONTROL_REQ_FU_MUTE, // bmaControls(0) Master + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(1) Channel 1 +#if USBD_AUDIO_TX_CHANNELS > 1 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(2) Channel 2 +#if USBD_AUDIO_TX_CHANNELS > 2 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(3) Channel 3 +#if USBD_AUDIO_TX_CHANNELS > 3 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(4) Channel 4 +#endif +#endif +#endif + 0x00, // iTerminal + /* 8 + ch byte */ + + /* USB Microphone Output Terminal Descriptor */ + 0x09, // Size of the descriptor, in bytes (bLength) + 0x24, // bDescriptorType + 0x03, // bDescriptorSubtype + 0x06, // bTerminalID + 0x01, 0x01, // wTerminalType 0x0101 USB Streaming + 0x04, // bAssocTerminal + 0x05, // From Input Terminal.(bSourceID) + 0x00, // unused (iTerminal) + /* 9 bytes */ +#else /* USB Microphone Output Terminal Descriptor */ 0x09, // Size of the descriptor, in bytes (bLength) 0x24, // bDescriptorType 0x03, // bDescriptorSubtype - 0x02, // bTerminalID - 0x01, 0x01, // wTerminalType - 0x00, // bAssocTerminal - 0x01, // From Input Terminal.(bSourceID) + 0x06, // bTerminalID + 0x01, 0x01, // wTerminalType 0x0101 USB Streaming + 0x04, // bAssocTerminal + 0x04, // From Input Terminal.(bSourceID) 0x00, // unused (iTerminal) /* 9 bytes */ +#endif - // 12+9 = 21 bytes + // 12+10+9 = 31 bytes #endif #ifdef USE_USBD_AUDIO_RX @@ -330,7 +456,11 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL USB_DESC_TYPE_INTERFACE, /* bDescriptorType 0x04 */ AUDIO_RX_IF, /* bInterfaceNumber */ 0x01, /* bAlternateSetting */ +#ifdef USE_USBD_RX_FB 0x02, /* bNumEndpoints */ +#else + 0x01, /* bNumEndpoints */ +#endif 0x01, /* bInterfaceClass */ 0x02, /* bInterfaceSubClass */ 0x00, /* bInterfaceProtocol */ @@ -352,7 +482,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x24, /* bDescriptorType */ 0x02, /* bDescriptorSubtype */ 0x01, /* bFormatType */ - USBD_AUDIO_RX_CHANNELS, /* bNrChannels */ + USBD_AUDIO_RX_CHANNELS, /* bNrChannels */ AUDIO_BYTES_PER_SAMPLE, /* bSubFrameSize */ AUDIO_BITS_PER_SAMPLE, /* bBitResolution */ 0x01, /* bSamFreqType only one frequency supported */ @@ -360,39 +490,55 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL /* 11 byte */ /* USB Play data ep */ +#ifdef USE_USBD_RX_FB /* Standard AS Isochronous asynchronous Audio Data Endpoint Descriptor*/ 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, /* bmAttributes */ - LOBYTE(AUDIO_RX_PACKET_SIZE), /* wMaxPacketSize in bytes */ - HIBYTE(AUDIO_RX_PACKET_SIZE), + LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ + HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval */ 0x00, /* bRefresh */ AUDIO_FB_EP, /* bSynchAddress */ /* 09 byte */ +#else + 0x09, /* bLength */ + USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ + AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, /* bmAttributes */ + LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ + HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), + 0x01, /* bInterval */ + 0x00, /* bRefresh */ + 0x00, /* bSynchAddress */ + /* 09 byte */ +#endif /* Class-Specific AS Isochronous Audio Data Endpoint Descriptor*/ 0x07, /* bLength */ 0x25, /* bDescriptorType */ 0x01, /* bDescriptor */ - 0x00, /* bmAttributes 0x01: Sampling Frequency control. See UAC Spec 1.0 p.62 */ + // USBD_AUDIO_AS_CONTROL_SAMPLING_FREQUENCY /* bmAttributes 0x01: Sampling Frequency control. See UAC Spec 1.0 p.62 */ + 0x00, /* bmAttributes */ 0x00, /* bLockDelayUnits */ 0x00, /* wLockDelay */ 0x00, /* 07 byte */ +#ifdef USE_USBD_RX_FB /* Endpoint 2 - Standard Descriptor - See UAC Spec 1.0 p.63 4.6.2.1 Standard AS Isochronous Synch Endpoint Descriptor */ 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_FB_EP, /* bEndpointAddress */ - USBD_EP_TYPE_ISOC, /* bmAttributes */ - LOBYTE(AUDIO_RX_PACKET_SIZE), /* wMaxPacketSize */ - HIBYTE(AUDIO_RX_PACKET_SIZE), - 0x01, /* bInterval 1ms */ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_NOSYNC, /* bmAttributes */ + LOBYTE(AUDIO_FB_PACKET_SIZE), /* wMaxPacketSize */ + HIBYTE(AUDIO_FB_PACKET_SIZE), + 0x01, /* bInterval : Must be set to 1 */ FB_REFRESH, /* bRefresh SOF_RATE */ - 0x00, /* bSynchAddress */ + 0x00, /* bSynchAddress : Must be reset to zero */ /* 09 byte*/ +#endif // 9+9+7+11+9+7+9 = 61 bytes #endif /*USE_USBD_AUDIO_RX */ @@ -426,7 +572,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x07, // Size of the descriptor, in bytes (bLength) 0x24, // bDescriptorType 0x01, // bDescriptorSubtype - 0x02, // Unit ID of the Output Terminal.(bTerminalLink) + 0x06, // Unit ID of the Output Terminal.(bTerminalLink) 0x00, // Interface delay. (bDelay) 0x01, 0x00, // PCM Format (wFormatTag) See 'USB Audio Data formats' @@ -437,7 +583,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x24, // bDescriptorType 0x02, // bDescriptorSubtype 0x01, // FORMAT_TYPE_I. (bFormatType) - USBD_AUDIO_TX_CHANNELS , // Audio channels.(bNrChannels) + USBD_AUDIO_TX_CHANNELS, // Audio channels.(bNrChannels) AUDIO_BYTES_PER_SAMPLE, // Two bytes per audio subframe.(bSubFrameSize) AUDIO_BITS_PER_SAMPLE, // 16 bits per sample.(bBitResolution) 0x01, // One frequency supported. (bSamFreqType) @@ -448,10 +594,11 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, // Size of the descriptor, in bytes (bLength) 0x05, // ENDPOINT descriptor (bDescriptorType) AUDIO_TX_EP, // IN Endpoint 1. (bEndpointAddress) - /* USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, // bmAttributes */ - USBD_EP_TYPE_ISOC, // bmAttributes - LOBYTE(AUDIO_TX_PACKET_SIZE), // wMaxPacketSize in bytes - HIBYTE(AUDIO_TX_PACKET_SIZE), + // BADD 4.2.3: Basic Audio Functions shall support the same Synchronization Type on all of their streaming endpoints. Only Synchronous or Asynchronous Synchronization Types are allowed. + // USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, // bmAttributes + USBD_EP_TYPE_ISOC, // bmAttributes (device not recognised in Windows if sync or async) + LOBYTE(AUDIO_TX_MAX_PACKET_SIZE), // wMaxPacketSize in bytes + HIBYTE(AUDIO_TX_MAX_PACKET_SIZE), 0x01, // Polling interval 1kHz. (bInterval) 0x00, // Unused. (bRefresh) 0x00, // Unused. (bSynchAddress) @@ -650,22 +797,11 @@ static uint8_t USBD_AUDIO_Init (USBD_HandleTypeDef *pdev, haudio->rx_alt_setting = 0; haudio->midi_alt_setting = 0; haudio->volume = 0; - -#ifdef USE_USBD_AUDIO_TX_FALSE - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); - haudio->audio_tx_active = 1; - haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); +#ifdef USE_USBD_AUDIO_RX + rx_buffer.setData((audio_t*)haudio->audio_rx_buffer, AUDIO_RX_TOTAL_BUF_SIZE/sizeof(audio_t)); #endif - -#ifdef USE_USBD_AUDIO_RX_FALSE - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_PACKET_SIZE); - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_FB_EP, USBD_EP_TYPE_ISOC, AUDIO_FB_PACKET_SIZE); - haudio->audio_rx_active = 0; - haudio->fb_soffn = USB_SOF_NUMBER(); - /* Prepare OUT endpoint to receive first packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); - usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); +#ifdef USE_USBD_AUDIO_TX + tx_buffer.setData((audio_t*)haudio->audio_tx_buffer, AUDIO_TX_TOTAL_BUF_SIZE/sizeof(audio_t)); #endif #ifdef USE_USBD_MIDI @@ -695,7 +831,9 @@ static uint8_t USBD_AUDIO_DeInit (USBD_HandleTypeDef *pdev, #ifdef USE_USBD_AUDIO_RX USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_RX_EP); +#ifdef USE_USBD_RX_FB USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_FB_EP); +#endif haudio->audio_rx_active = 0; usbd_audio_rx_stop_callback(); #endif @@ -732,17 +870,25 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, if(new_alt == 0){ // close old USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_RX_EP); +#ifdef USE_USBD_RX_FB USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_FB_EP); - AUDIO_OUT_StopAndReset(pdev); +#endif + haudio->audio_rx_active = 0; + usbd_audio_rx_stop_callback(); + // AUDIO_OUT_StopAndReset(pdev); }else{ // open new - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_PACKET_SIZE); + USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_MAX_PACKET_SIZE); +#ifdef USE_USBD_RX_FB USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_FB_EP, USBD_EP_TYPE_ISOC, AUDIO_FB_PACKET_SIZE); haudio->fb_soffn = USB_SOF_NUMBER(); +#endif /* haudio->bit_depth = 16U; // alt 1 */ AUDIO_OUT_Restart(pdev); } +#ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +#endif haudio->rx_alt_setting = new_alt; } break; @@ -757,12 +903,20 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, haudio->audio_tx_active = 0; }else{ // open new - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); + USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_MAX_PACKET_SIZE); haudio->audio_tx_active = 1; haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS); + tx_buffer.reset(); + tx_buffer.clear(); + tx_buffer.moveWriteHead(AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); + usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS, &tx_buffer); /* send first audio data */ - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); + usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, AUDIO_TX_PACKET_SIZE); +#ifdef DEBUG_USBD_AUDIO + usbd_tx_flow = 0; + debugMessage("tx"); +#endif } haudio->tx_alt_setting = new_alt; } @@ -910,17 +1064,49 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, USBD_AUDIO_HandleTypeDef *haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; (void)haudio; switch(epnum | 0x80){ -#ifdef USE_USBD_AUDIO_RX +#ifdef USE_USBD_RX_FB case AUDIO_FB_EP: haudio->fb_soffn = USB_SOF_NUMBER(); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, (uint8_t*)fb_data, 3U); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); break; #endif #ifdef USE_USBD_AUDIO_TX - case AUDIO_TX_EP: + case AUDIO_TX_EP: { haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + // decide if we should send one set of samples more or less than expected + size_t len = AUDIO_TX_PACKET_SIZE/sizeof(audio_t); + size_t capacity = tx_buffer.getReadCapacity(); + capacity += codec.getSampleCounter(); +#ifdef DEBUG_USBD_AUDIO + usbd_tx_capacity = capacity; +#endif + if(capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + // read capacity too low: slow down + len -= USBD_AUDIO_TX_CHANNELS; +#ifdef DEBUG_USBD_AUDIO + usbd_tx_flow -= 1; +#endif + }else if(tx_buffer.getSize() - capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + // write capacity too low: speed up + len += USBD_AUDIO_TX_CHANNELS; +#ifdef DEBUG_USBD_AUDIO + usbd_tx_flow += 1; +#endif + } + if(capacity < len){ + // tx buffer underflow +#ifdef DEBUG_USBD_AUDIO + debugMessage("tx unf", (int)(len - capacity)); + usbd_tx_flow -= 1000; +#endif + memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); + tx_buffer.read((audio_t*)haudio->audio_tx_transmit, capacity); + }else{ + tx_buffer.read((audio_t*)haudio->audio_tx_transmit, len); + } + usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, len*sizeof(audio_t)); break; + } #endif #ifdef USE_USBD_MIDI case MIDI_TX_EP: @@ -944,26 +1130,28 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; - if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { // todo: should AUDIO_CONTROL_REQ match the bUnitID of IN/OUT feature? + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_MUTE: { /* Current mute state */ uint8_t mute = 0; USBD_CtlSendData(pdev, &mute, 1); }; - break; - case AUDIO_CONTROL_REQ_FU_VOL: { - /* Current volume. See UAC Spec 1.0 p.77 */ - USBD_CtlSendData(pdev, (uint8_t*)&haudio->volume, 2); - }; - break; - } - } else if ((req->bmRequest & 0x1f) == AUDIO_STREAMING_REQ) { - if (HIBYTE(req->wValue) == AUDIO_STREAMING_REQ_FREQ_CTRL) { - /* Current frequency */ - AUDIO_FREQ_TO_DATA(haudio->frequency, haudio->control.data) - USBD_CtlSendData(pdev, haudio->control.data, 3); + break; + case AUDIO_CONTROL_REQ_FU_VOL: { + /* Current volume. See UAC Spec 1.0 p.77 */ + USBD_CtlSendData(pdev, (uint8_t*)&haudio->volume, 2); + }; + break; } + // } else if ((req->bmRequest & 0x1f) == AUDIO_STREAMING_REQ) { + // if (HIBYTE(req->wValue) == AUDIO_STREAMING_REQ_FREQ_CTRL) { + // /* Current frequency */ + // AUDIO_FREQ_TO_DATA(haudio->frequency, haudio->control.data) + // USBD_CtlSendData(pdev, haudio->control.data, 3); + // } } } @@ -977,6 +1165,8 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* static void AUDIO_REQ_GetMax(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_max = USBD_AUDIO_VOL_MAX; @@ -1002,6 +1192,8 @@ static void AUDIO_REQ_GetMax(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req */ static void AUDIO_REQ_GetMin(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { @@ -1028,6 +1220,8 @@ static void AUDIO_REQ_GetMin(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req */ static void AUDIO_REQ_GetRes(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { @@ -1080,6 +1274,8 @@ static uint8_t USBD_AUDIO_EP0_RxReady (USBD_HandleTypeDef *pdev) #if 1 if (haudio->control.cmd == AUDIO_REQ_SET_CUR) { /* In this driver, to simplify code, only SET_CUR request is managed */ if (haudio->control.req_type == AUDIO_CONTROL_REQ) { + // uint8_t bUnit = haudio->control.req_type; + // if (bUnit == 0x02 || bUnit == 0x05) { USBD_DbgLog("CONTROL_REQ 0x%x 0x%x", haudio->control.cs, haudio->control.data[0]); switch (haudio->control.cs) { /* Mute Control */ @@ -1099,7 +1295,7 @@ static uint8_t USBD_AUDIO_EP0_RxReady (USBD_HandleTypeDef *pdev) } } else if (haudio->control.req_type == AUDIO_STREAMING_REQ) { USBD_DbgLog("STREAMING_REQ 0x%x 0x%x", haudio->control.cs, haudio->control.data[0]); -#ifdef USE_USBD_AUDIO_RX +#ifdef USE_USBD_AUDIO_RX_FALSE // todo! if (haudio->control.cs == AUDIO_STREAMING_REQ_FREQ_CTRL) { /* Frequency Control */ uint32_t new_freq = AUDIO_FREQ_FROM_DATA(haudio->control.data); @@ -1176,16 +1372,28 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { /* SOF (Start of Frame) Every millisecond the USB host transmits a special SOF (start of frame) token, containing an 11-bit incrementing frame number in place of a device address. This is used to synchronize isochronous and interrupt data transfers. */ USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; -#ifdef USE_USBD_AUDIO_RX +#if 0 // defined USE_USBD_RX_FB static uint32_t sof_count = 0; - if(haudio->audio_rx_active && ++sof_count == FB_RATE){ - sof_count = 0; + if(haudio->audio_rx_active){ + if(++sof_count == FB_RATE){ + sof_count = 0; // number of samples since last request (or 0 if unknown) - uint32_t samples = usbd_audio_get_rx_count(); - if(samples != 0){ - samples <<= (14 - FB_REFRESH); // convert to n.14 format - AUDIO_FREQ_TO_DATA(samples, fb_data); // pack into 3 bytes + uint32_t samples = usbd_audio_get_rx_count(); // across channels and fb rate + if(samples != 0){ + // if(abs(samples - USBD_AUDIO_RX_FREQ*FB_RATE*USBD_AUDIO_RX_CHANNELS/1000) < 8){ + samples *= (1<<14); // convert to n.14 format + samples /= USBD_AUDIO_RX_CHANNELS * FB_RATE; +#ifdef DEBUG_USBD_AUDIO + usbd_rx_capacity = samples - 786432; +#endif + // AUDIO_FREQ_TO_DATA(samples, haudio->fb_data.buf); // pack into 3 bytes (todo: make this atomic) + // } + } } + // transmit on every SOF if audio_rx_active + // USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); + // }else{ + // sof_count = 0; } #endif return USBD_OK; @@ -1208,27 +1416,29 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep /* - EPENA = 1 (in OTG_DOEPCTLx) */ USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; - uint16_t current_sof; - current_sof = USB_SOF_NUMBER(); - -#ifdef USE_USBD_AUDIO_RX - // todo: fix this to work for FB and TX endpoints + uint16_t current_sof = USB_SOF_NUMBER(); +#ifdef USE_USBD_RX_FB if(pdev->ep_in[AUDIO_FB_EP & 0xFU].is_used && - IS_ISO_IN_INCOMPLETE_EP(AUDIO_FB_EP & 0xFU, current_sof, haudio->fb_soffn)){ + IS_ISO_IN_INCOMPLETE_EP(AUDIO_FB_EP & 0x0FU, current_sof, haudio->fb_soffn)){ USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_FB_EP); USBD_LL_FlushEP(pdev, AUDIO_FB_EP); - haudio->fb_soffn = USB_SOF_NUMBER(); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, 3U); + haudio->fb_soffn = current_sof; + USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); + // debugMessage("isocfb", current_sof); } #endif #ifdef USE_USBD_AUDIO_TX if(pdev->ep_in[AUDIO_TX_EP & 0xFU].is_used && - IS_ISO_IN_INCOMPLETE_EP(AUDIO_TX_EP & 0xFU, current_sof, haudio->tx_soffn)){ + IS_ISO_IN_INCOMPLETE_EP(AUDIO_TX_EP & 0x0FU, current_sof, haudio->tx_soffn)){ USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_TX_EP); USBD_LL_FlushEP(pdev, AUDIO_TX_EP); - haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + haudio->tx_soffn = current_sof; + // debugMessage("isoctx", current_sof); + // host has not collected data + // let's not increment readhead + // todo: write same amount of data as last time + usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, AUDIO_TX_PACKET_SIZE); } #endif return USBD_OK; @@ -1243,7 +1453,6 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep */ static uint8_t USBD_AUDIO_IsoOutIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum) { - return USBD_OK; } @@ -1254,39 +1463,88 @@ static uint8_t USBD_AUDIO_IsoOutIncomplete (USBD_HandleTypeDef *pdev, uint8_t e * @param epnum: endpoint index * @retval status */ -static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, - uint8_t epnum) -{ +static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { USBD_AUDIO_HandleTypeDef *haudio; haudio = (USBD_AUDIO_HandleTypeDef*) pdev->pClassData; (void)haudio; + switch(epnum){ #ifdef USE_USBD_AUDIO_RX - if(epnum == AUDIO_RX_EP){ - uint32_t len; - if(haudio->audio_rx_active == 0){ - haudio->audio_rx_active = 1; - usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); - len = AUDIO_RX_PACKET_SIZE; - /* send first synchro data */ - get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, 3U); + case AUDIO_RX_EP:{ + // if(haudio->audio_rx_active == 0){ + // // todo: see if we can move this to AUDIO_OUT_Restart and remove the conditional around rx_active + // haudio->audio_rx_active = 1; + // usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); + // usbd_rx_flow = 0; + // rx_buffer.reset(); + // rx_buffer.clear(); + // rx_buffer.moveWriteHead(2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); + // debugMessage("rx"); + // } + size_t len = USBD_LL_GetRxDataSize(pdev, AUDIO_RX_EP) / sizeof(audio_t); + // we are required to support null packets: len may be zero + + size_t capacity = rx_buffer.getWriteCapacity(); + capacity += codec.getSampleCounter(); +#ifdef DEBUG_USBD_AUDIO + usbd_rx_capacity = capacity; +#endif + + if(capacity < len){ + // rx buffer overflow + len = capacity; +#ifdef DEBUG_USBD_AUDIO + debugMessage("rx ovf", (int)(len - capacity)); + usbd_rx_flow += 100000; +#endif + } +#ifdef USE_USBD_RX_FB + // in asynch / adaptive mode, we have no control over the number of samples transferred + // instead we update the feedback value + capacity -= len; + if(capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + // write capacity too small: slow down +#ifdef DEBUG_USBD_AUDIO + usbd_rx_flow += 1000; +#endif + haudio->fb_data.val = 0x0c0000 - 0x4000; + }else if(capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ +#ifdef DEBUG_USBD_AUDIO + usbd_rx_flow += 1; +#endif + haudio->fb_data.val = 0x0c0000 - 0x2000; + // 0x2000 == 0.5<<14, one half sample per frame + }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + // read capacity too small: speed up +#ifdef DEBUG_USBD_AUDIO + usbd_rx_flow -= 1; +#endif + haudio->fb_data.val = 0x0c0000 + 0x2000; + }else if(rx_buffer.getSize() - capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ +#ifdef DEBUG_USBD_AUDIO + usbd_rx_flow -= 1000; +#endif + haudio->fb_data.val = 0x0c0000 + 0x4000; }else{ - len = USBD_LL_GetRxDataSize(pdev, epnum); + haudio->fb_data.val = 0x0c0000; // 48 * 16384 } - len = usbd_audio_rx_callback(haudio->audio_rx_buffer, len); +#endif + rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len); /* Prepare Out endpoint to receive next audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, len); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); + break; } #endif /* USE_USBD_AUDIO_RX */ #ifdef USE_USBD_MIDI - if(epnum == MIDI_RX_EP){ + case MIDI_RX_EP:{ /* Forward data to midi callback */ uint32_t len = USBD_LL_GetRxDataSize(pdev, epnum); usbd_midi_rx(haudio->midi_rx_buffer, len); /* Prepare Out endpoint to receive next packet */ USBD_LL_PrepareReceive(pdev, MIDI_RX_EP, haudio->midi_rx_buffer, MIDI_RX_PACKET_SIZE); + break; } #endif + } return USBD_OK; } @@ -1303,10 +1561,13 @@ static void AUDIO_OUT_StopAndReset(USBD_HandleTypeDef* pdev) USBD_DbgLog("AUDIO_OUT_StopAndReset %lu", haudio->frequency); haudio->audio_rx_active = 0; +#ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +#endif +#ifdef USE_USBD_AUDIO_RX USBD_LL_FlushEP(pdev, AUDIO_RX_EP); usbd_audio_rx_stop_callback(); - /* ((USBD_AUDIO_ItfTypeDef*)pdev->pUserData)->DeInit(0); */ +#endif } /** @@ -1321,15 +1582,38 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) /* AUDIO_OUT_StopAndReset(pdev); */ haudio->audio_rx_active = 0; - USBD_LL_FlushEP(pdev, AUDIO_FB_EP); - USBD_LL_FlushEP(pdev, AUDIO_RX_EP); +// #ifdef USE_USBD_RX_FB +// USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +// #endif +// #ifdef USE_USBD_AUDIO_RX +// USBD_LL_FlushEP(pdev, AUDIO_RX_EP); +// #endif /* Prepare Out endpoint to receive first audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); + +#ifdef USE_USBD_RX_FB + USBD_LL_FlushEP(pdev, AUDIO_FB_EP); + /* send first explicit feedback data */ + get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, haudio->fb_data.buf); + haudio->fb_soffn = USB_SOF_NUMBER(); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); +#endif + + // moved from USBD_AUDIO_DataOut + haudio->audio_rx_active = 1; + usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); +#ifdef DEBUG_USBD_AUDIO + usbd_rx_flow = 0; + debugMessage("rx"); +#endif + rx_buffer.reset(); + rx_buffer.clear(); + rx_buffer.moveWriteHead(-AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); /* get_usb_full_speed_rate(haudio->frequency, fb_data); // reset to new frequency */ - /* usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); */ + /* usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); */ /* ((USBD_AUDIO_ItfTypeDef*)pdev->pUserData)->Init(haudio->frequency, VOL_PERCENT(haudio->volume), 0); */ } #endif /* USE_USBD_AUDIO_RX */ @@ -1360,33 +1644,30 @@ uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef *pdev, } uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd){ -#if defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x40); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); - HAL_PCDEx_SetTxFiFo(hpcd, 3, 0x20); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#elif defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#else - HAL_PCDEx_SetRxFiFo(hpcd, 0xa0); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x40); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); + // HAL_PCDEx_SetTxFiFo() must be called after HAL_PCDEx_SetRxFiFo(). + // HAL_PCDEx_SetTxFiFo() must be called in the order of the endpoint number. + // Size is represented in terms of 4-byte words. Minimum: 16 words, maximum: 256 words + // The total of FIFO sizes should be no more than the 1.25 Kbytes USB RAM + // Total 0x140 words / 1280 bytes available for rx and tx fifos + // The FIFO is used optimally when used TxFIFOs are allocated in the top + // of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. + // When DMA is used 3n * FIFO locations should be reserved for internal DMA registers + // STM32H7 A dedicated 4-Kbyte RAM can be divided into 1 shared RxFIFO and up to 9 TxFIFOs + HAL_PCDEx_SetRxFiFo(hpcd, AUDIO_RX_FIFO_SIZE/4); + HAL_PCDEx_SetTxFiFo(hpcd, 0x00, USBD_MIN_FIFO_SIZE/4); // control i/f + +#if defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB + HAL_PCDEx_SetTxFiFo(hpcd, AUDIO_FB_EP & 0x0f, USBD_MIN_FIFO_SIZE/4); #endif - /* total 0x140 words available for rx and tx fifos */ + +#if defined USE_USBD_AUDIO_TX + HAL_PCDEx_SetTxFiFo(hpcd, AUDIO_TX_EP & 0x0f, AUDIO_TX_MAX_PACKET_SIZE/4); +#endif + +#if defined USE_USBD_MIDI + HAL_PCDEx_SetTxFiFo(hpcd, MIDI_TX_EP & 0x0f, MIDI_TX_PACKET_SIZE/4); +#endif + return USBD_OK; } diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 42386a19..134804ef 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -28,27 +28,47 @@ #define AUDIO_IN_STREAMING_CTRL 0x03 #define AUDIO_OUT_STREAMING_CTRL 0x04 -#define AUDIO_RX_PACKET_SIZE (uint16_t)(((USBD_AUDIO_RX_FREQ * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /1000)) -#define AUDIO_TX_PACKET_SIZE (uint16_t)(((USBD_AUDIO_TX_FREQ * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /1000)) +#define AUDIO_RX_SAMPLES_PER_MS (USBD_AUDIO_RX_FREQ / 1000) +#define AUDIO_RX_PACKET_SIZE (AUDIO_RX_SAMPLES_PER_MS * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) +#define AUDIO_RX_MAX_PACKET_SIZE (AUDIO_RX_PACKET_SIZE + USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) + #define AUDIO_FB_PACKET_SIZE 3U - -/* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure - that it is an even number and higher than 3 */ -#define AUDIO_RX_PACKET_NUM 1 -#define AUDIO_TX_PACKET_NUM 1 -/* Total size of the audio transfer buffer */ -#define AUDIO_RX_TOTAL_BUF_SIZE ((size_t)(AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM)) -/* Total size of the IN (i.e. microphopne) transfer buffer */ -#define AUDIO_TX_TOTAL_BUF_SIZE ((size_t)(AUDIO_TX_PACKET_SIZE * AUDIO_TX_PACKET_NUM)) + +#define AUDIO_TX_SAMPLES_PER_MS (USBD_AUDIO_TX_FREQ / 1000) +#define AUDIO_TX_PACKET_SIZE (AUDIO_TX_SAMPLES_PER_MS * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) +#define AUDIO_TX_MAX_PACKET_SIZE (AUDIO_TX_PACKET_SIZE + USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) + +/* Number of sub-packets in the audio transfer buffer. */ +#define AUDIO_RX_PACKET_NUM 5 +#define AUDIO_TX_PACKET_NUM 5 + +/* Total size of the OUT audio transfer buffer */ +#define AUDIO_RX_TOTAL_BUF_SIZE (AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM) +/* Total size of the IN transfer buffer */ +#define AUDIO_TX_TOTAL_BUF_SIZE (AUDIO_TX_PACKET_SIZE * AUDIO_TX_PACKET_NUM) #define MIDI_TX_PACKET_SIZE 0x40 #define MIDI_RX_PACKET_SIZE 0x40 - + +#ifdef STM32H7xx +#define USBD_TOTAL_FIFO_SIZE 0x1000 /* 4k FIFO buffers on H7 */ +#else +#define USBD_TOTAL_FIFO_SIZE 0x500 /* 1.25k FIFO buffers on F4 */ +#endif +#define USBD_MIN_FIFO_SIZE 0x40 + +/* Isochronous Synchronisation Type */ #define USBD_EP_ATTR_ISOC_NOSYNC 0x00 /* no synchro */ #define USBD_EP_ATTR_ISOC_ASYNC 0x04 /* synchronisation by feedback */ #define USBD_EP_ATTR_ISOC_ADAPT 0x08 /* adaptative synchronisation */ #define USBD_EP_ATTR_ISOC_SYNC 0x0C /* synchronous mode */ +/* Isochronous Usage Type */ +#define USBD_EP_ATTR_ISOC_DATA 0x00 /* Data Endpoint */ +#define USBD_EP_ATTR_ISOC_FB 0x10 /* Feedback Endpoint */ +#define USBD_EP_ATTR_ISOC_IMPL_FB 0x20 /* Implicit Feedback Data Endpoint */ + + /* Class-Specific AS Isochronous Audio Data Endpoint Descriptor bmAttributes */ #define USBD_AUDIO_AS_CONTROL_SAMPLING_FREQUENCY 0x0001 /* D0 = 1*/ #define USBD_AUDIO_AS_CONTROL_PITCH 0x0002 /* D1 = 1*/ @@ -82,6 +102,15 @@ #endif +#if AUDIO_BITS_PER_SAMPLE == 8 +typedef int8_t audio_t; +#elif AUDIO_BITS_PER_SAMPLE == 16 +typedef int16_t audio_t; +#elif AUDIO_BITS_PER_SAMPLE == 32 +typedef int32_t audio_t; +#else +#error "Unsupported AUDIO_BITS_PER_SAMPLE" +#endif /** @defgroup USBD_CORE_Exported_TypesDefinitions * @{ @@ -98,20 +127,26 @@ } USBD_AUDIO_ControlTypeDef; - - typedef struct { uint8_t ac_alt_setting, tx_alt_setting, rx_alt_setting, midi_alt_setting; #ifdef USE_USBD_AUDIO_TX uint8_t audio_tx_buffer[AUDIO_TX_TOTAL_BUF_SIZE]; + uint8_t audio_tx_transmit[AUDIO_TX_MAX_PACKET_SIZE]; volatile uint8_t audio_tx_active; volatile uint16_t tx_soffn; #endif #ifdef USE_USBD_AUDIO_RX uint8_t audio_rx_buffer[AUDIO_RX_TOTAL_BUF_SIZE]; + uint8_t audio_rx_transmit[AUDIO_RX_MAX_PACKET_SIZE]; volatile uint8_t audio_rx_active; +#ifdef USE_USBD_RX_FB volatile uint16_t fb_soffn; + union { + uint8_t buf[3]; + uint32_t val; + } fb_data; +#endif #endif #ifdef USE_USBD_MIDI uint8_t midi_rx_buffer[MIDI_RX_PACKET_SIZE]; @@ -130,10 +165,10 @@ extern USBD_ClassTypeDef USBD_AUDIO; uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef *pdev, void *fops); uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); -void usbd_audio_tx_start_callback(size_t rate, uint8_t channels); +void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb); void usbd_audio_tx_stop_callback(); void usbd_audio_tx_callback(uint8_t* data, size_t len); -void usbd_audio_rx_start_callback(size_t rate, uint8_t channels); +void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb); void usbd_audio_rx_stop_callback(); size_t usbd_audio_rx_callback(uint8_t* data, size_t len); void usbd_audio_mute_callback(int16_t gain); diff --git a/Source/usbh_midi.cpp b/Source/usbh_midi.cpp index 3fa7532e..3124e7ad 100644 --- a/Source/usbh_midi.cpp +++ b/Source/usbh_midi.cpp @@ -3,6 +3,11 @@ #include "midi.h" #include "SerialBuffer.hpp" +/** + * USB Host MIDI Driver + * Based on code by Xavier Halgand @MrBlueXav + */ + extern "C" { static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost); @@ -29,8 +34,6 @@ extern "C" { }; void usbh_midi_push(); - - void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); } static SerialBuffer rxbuffer; @@ -38,12 +41,9 @@ static MIDI_HandleTypeDef staticMidiHandle; static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost){ USBH_StatusTypeDef status = USBH_FAIL ; - uint8_t interface = 0; - MIDI_HandleTypeDef *MIDI_Handle; - //USB_MIDI_ChangeConnectionState(0); - interface = USBH_FindInterface(phost, USB_AUDIO_CLASS, USB_MIDISTREAMING_SUBCLASS, 0xFF); + uint8_t interface = USBH_FindInterface(phost, USB_AUDIO_CLASS, USB_MIDISTREAMING_SUBCLASS, 0xFF); USBH_DbgLog ("USBH InterfaceInit 0x%x", interface); if(interface == 0xFF){ @@ -52,8 +52,9 @@ static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost){ status = USBH_FAIL; }else{ USBH_SelectInterface (phost, interface); - phost->pActiveClass->pData = &staticMidiHandle; - MIDI_Handle = &staticMidiHandle; + MIDI_HandleTypeDef* MIDI_Handle = &staticMidiHandle; + memset(MIDI_Handle, 0, sizeof(staticMidiHandle)); + phost->pActiveClass->pData = MIDI_Handle; if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].bEndpointAddress & 0x80){ MIDI_Handle->InEp = (phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].bEndpointAddress); @@ -112,24 +113,24 @@ static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost){ */ USBH_StatusTypeDef USBH_MIDI_InterfaceDeInit (USBH_HandleTypeDef *phost){ USBH_DbgLog ("USBH InterfaceDeInit"); - MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; - - if ( MIDI_Handle->OutPipe){ - USBH_ClosePipe(phost, MIDI_Handle->OutPipe); - USBH_FreePipe (phost, MIDI_Handle->OutPipe); - MIDI_Handle->OutPipe = 0; /* Reset the Channel as Free */ - } + if(phost->pActiveClass->pData){ + MIDI_HandleTypeDef* MIDI_Handle = (MIDI_HandleTypeDef*)phost->pActiveClass->pData; - if ( MIDI_Handle->InPipe){ - USBH_ClosePipe(phost, MIDI_Handle->InPipe); - USBH_FreePipe (phost, MIDI_Handle->InPipe); - MIDI_Handle->InPipe = 0; /* Reset the Channel as Free */ - } + if ( MIDI_Handle->OutPipe){ + USBH_ClosePipe(phost, MIDI_Handle->OutPipe); + USBH_FreePipe (phost, MIDI_Handle->OutPipe); + MIDI_Handle->OutPipe = 0; /* Reset the Channel as Free */ + } + + if ( MIDI_Handle->InPipe){ + USBH_ClosePipe(phost, MIDI_Handle->InPipe); + USBH_FreePipe (phost, MIDI_Handle->InPipe); + MIDI_Handle->InPipe = 0; /* Reset the Channel as Free */ + } - if(phost->pActiveClass->pData){ - /* statically allocated in init + /* statically allocated USBH_free (phost->pActiveClass->pData); */ - phost->pActiveClass->pData = 0; + phost->pActiveClass->pData = NULL; } return USBH_OK; @@ -164,12 +165,14 @@ USBH_StatusTypeDef USBH_MIDI_Stop(USBH_HandleTypeDef *phost){ return USBH_OK; } -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state){ - MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; - if(urb_state == URB_DONE && chnum == MIDI_Handle->InPipe && - MIDI_Handle->state == MIDI_TRANSFER_DATA){ - size_t len = USBH_LL_GetLastXferSize(phost, MIDI_Handle->InPipe); - USBH_MIDI_ReceiveCallback(phost, MIDI_Handle->pRxData, len); +extern "C"{ + void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state){ + MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; + if(urb_state == URB_DONE && chnum == MIDI_Handle->InPipe && + MIDI_Handle->state == MIDI_TRANSFER_DATA){ + size_t len = USBH_LL_GetLastXferSize((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->InPipe); + USBH_MIDI_ReceiveCallback((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->pRxData, len); + } } } @@ -211,6 +214,14 @@ static USBH_StatusTypeDef USBH_MIDI_Process (USBH_HandleTypeDef *phost){ * @retval USBH Status */ static USBH_StatusTypeDef USBH_MIDI_SOFProcess (USBH_HandleTypeDef *phost){ + MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; + + USBH_URBStateTypeDef URB_Status = USBH_LL_GetURBState(phost, MIDI_Handle->InPipe); + if(URB_Status == USBH_URB_STALL) { + USBH_DbgLog("USBH URB Stall"); + if (USBH_ClrFeature(phost, MIDI_Handle->InEp) == USBH_OK) + MIDI_Handle->state = MIDI_TRANSFER_DATA; + } return USBH_OK; } @@ -396,6 +407,7 @@ void usbh_midi_tx(uint8_t* buffer, uint32_t length){ } void USBH_MIDI_TransmitCallback(USBH_HandleTypeDef *phost){ + // tx complete callback // get ready to send some data } diff --git a/Tools/dist.sh b/Tools/dist.sh index 576e4d25..b727cc3e 100755 --- a/Tools/dist.sh +++ b/Tools/dist.sh @@ -1,10 +1,12 @@ #!/bin/bash mkdir -p dist # make syx files -for nm in Lich Wizard Alchemist Magus Witch +for nm in Alchemist Wizard Magus Lich Witch OwlPedal2 do make -C $nm clean all sysex && cp $nm/Build/$nm.syx dist done # make OWL Pedal and OWL Modular bin and syx files make -C OwlPedal PLATFORM=Pedal clean all sysex && cp OwlPedal/Build/OwlPedal.{syx,bin} dist make -C OwlPedal PLATFORM=Modular clean all sysex && cp OwlPedal/Build/OwlModular.{syx,bin} dist +make -C MidiBootOwl PLATFORM=Pedal clean all sysex && cp MidiBootOwl/Build/MidiBoot-Pedal.{syx,bin} dist +make -C MidiBootOwl PLATFORM=Modular clean all sysex && cp MidiBootOwl/Build/MidiBoot-Modular.{syx,bin} dist diff --git a/Tools/makeprojects.py b/Tools/makeprojects.py index 4a702b62..498c6d3c 100755 --- a/Tools/makeprojects.py +++ b/Tools/makeprojects.py @@ -13,9 +13,10 @@ } ], 'MidiBoot': [ - 'Alchemist', 'Wizard', 'Magus', 'Lich', 'Noctua', - 'BioSignals', 'Witch' - #'Effectsbox' - won't build bootloader + 'Alchemist', 'Wizard', 'Magus', 'Lich', 'Witch', + { 'OwlPedal2': ['Pedal=OwlPedal2'] } + # 'Noctua', 'BioSignals', not needed + # 'Effectsbox' won't build bootloader ], 'MidiBoot3': [ 'Genius' diff --git a/Witch/Inc/hardware.h b/Witch/Inc/hardware.h index 68f13857..f74483ef 100644 --- a/Witch/Inc/hardware.h +++ b/Witch/Inc/hardware.h @@ -11,13 +11,18 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_FS +#define USBD_HSFS DEVICE_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS #define USE_USB_HOST diff --git a/Witch/Inc/stm32f4xx_hal_conf.h b/Witch/Inc/stm32f4xx_hal_conf.h index 504cfb66..e620013c 100644 --- a/Witch/Inc/stm32f4xx_hal_conf.h +++ b/Witch/Inc/stm32f4xx_hal_conf.h @@ -76,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -94,11 +95,11 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** @@ -114,7 +115,7 @@ * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -122,11 +123,11 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** @@ -135,7 +136,7 @@ * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -145,8 +146,8 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U @@ -166,6 +167,7 @@ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ @@ -213,20 +215,20 @@ /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ @@ -444,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ diff --git a/Witch/Inc/usbd_conf.h b/Witch/Inc/usbd_conf.h index 4efc673d..27e21fa6 100644 --- a/Witch/Inc/usbd_conf.h +++ b/Witch/Inc/usbd_conf.h @@ -79,7 +79,7 @@ /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 1U +#define USBD_SELF_POWERED 0U /*---------- -----------*/ /****************************************/ @@ -95,14 +95,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -158,6 +157,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/Witch/Inc/usbd_desc.h b/Witch/Inc/usbd_desc.h index 122f582b..90f8968c 100644 --- a/Witch/Inc/usbd_desc.h +++ b/Witch/Inc/usbd_desc.h @@ -17,7 +17,7 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ @@ -30,7 +30,7 @@ #include "usbd_def.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY @@ -41,7 +41,7 @@ * @brief Usb device descriptors module. * @{ */ - + /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants * @brief Constants. * @{ @@ -105,7 +105,7 @@ */ /** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef FS_Desc; +extern USBD_DescriptorsTypeDef USBD_DESC; /* USER CODE BEGIN EXPORTED_VARIABLES */ diff --git a/Witch/Makefile b/Witch/Makefile index 0997a6e0..49f18cf6 100644 --- a/Witch/Makefile +++ b/Witch/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp include $(OPENWARE)/Hardware/sources.mk diff --git a/Witch/Src/Witch.cpp b/Witch/Src/Witch.cpp index 4ca1baae..62fdd2fb 100644 --- a/Witch/Src/Witch.cpp +++ b/Witch/Src/Witch.cpp @@ -9,8 +9,11 @@ #include "OpenWareMidiControl.h" #include "Codec.h" #include "ApplicationSettings.h" +#include "TakeoverControls.h" #include "qint.h" #include "Pin.h" +#include "usb_device.h" +#include "usb_host.h" #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) @@ -48,45 +51,6 @@ Pin sw3(SW3_GPIO_Port, SW3_Pin); Pin sw4(SW4_GPIO_Port, SW4_Pin); Pin sw5(SW5_GPIO_Port, SW5_Pin); -template -class TakeoverControls { -private: - value_t values[SIZE]; - bool takeover[SIZE]; -public: - TakeoverControls(){ - reset(true); - } - value_t get(uint8_t index){ - return values[index]; - } - void set(uint8_t index, value_t value){ - values[index] = value; - } - void update(uint8_t index, value_t value, value_t threshold){ - if(takeover[index]){ - values[index] = value; - }else if(abs(values[index] - value) < threshold){ - takeover[index] = true; - values[index] = value; - } - } - bool taken(uint8_t index){ - return takeover[index]; - } - /** - * If @param state is true, then the control is taken. - * If the control is taken it reflects the current knob setting. - */ - void reset(uint8_t index, bool state){ - takeover[index] = state; - } - void reset(bool state){ - for(size_t i=0; i takeover; int16_t dac_values[2] = {0, 0}; bool button_led_values[4] = {false}; @@ -119,12 +83,12 @@ bool updatePin(size_t bid, Pin pin){ setButtonValue(bid+3, state); setLed(bid+6, state ? RED_COLOUR : NO_COLOUR); }else if(owl.getOperationMode() == CONFIGURE_MODE && state){ - if(patchselect == bid){ - if(registry.hasPatch(bid+4)) - patchselect = bid+4; - }else{ - if(registry.hasPatch(bid)) - patchselect = bid; + if(patchselect == bid && registry.hasPatch(bid+4)){ + patchselect = bid+4; + }else if(registry.hasPatch(bid)){ + patchselect = bid; + }else if(registry.hasPatch(bid+4)){ + patchselect = bid+4; } } return state; @@ -438,7 +402,7 @@ void onStartProgram(){ memset(button_led_values, 0, sizeof(button_led_values)); // reset leds } -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ if(new_mode == CONFIGURE_MODE){ // entering config mode HAL_GPIO_WritePin(TR_OUT1_GPIO_Port, TR_OUT1_Pin, GPIO_PIN_SET); @@ -465,12 +429,11 @@ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ counter = 0; } -void setup(){ +void onSetup(){ initLed(); HAL_GPIO_WritePin(LEDPWM_GPIO_Port, LEDPWM_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(TR_OUT1_GPIO_Port, TR_OUT1_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(TR_OUT2_GPIO_Port, TR_OUT2_Pin, GPIO_PIN_SET); - owl.setup(); for(size_t i=5; i<9; ++i){ takeover.set(i, CV_ATTENUATION_DEFAULT); takeover.reset(i, false); @@ -478,13 +441,18 @@ void setup(){ takeover.set(9, settings.audio_output_gain<<5); takeover.reset(9, false); patchselect = program.getProgramIndex(); + + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + + /* init code for USB_HOST */ + MX_USB_HOST_Init(); } -void loop(void){ +void onLoop(){ MX_USB_HOST_Process(); // todo: enable PWR management static bool sw4_state = false; if(sw4_state != !sw4.get()) sw4_state = updatePin(4, sw4); update_preset(); - owl.loop(); } diff --git a/Witch/Src/main.c b/Witch/Src/main.c index dbedf604..a9734381 100644 --- a/Witch/Src/main.c +++ b/Witch/Src/main.c @@ -8,8 +8,6 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" -#include "usb_device.h" -#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -54,6 +52,9 @@ TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim4; TIM_HandleTypeDef htim13; +PCD_HandleTypeDef hpcd_USB_OTG_FS; +HCD_HandleTypeDef hhcd_USB_OTG_HS; + SDRAM_HandleTypeDef hsdram1; osThreadId defaultTaskHandle; @@ -64,6 +65,7 @@ osThreadId defaultTaskHandle; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); +void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_ADC3_Init(void); @@ -77,6 +79,8 @@ static void MX_TIM1_Init(void); static void MX_TIM3_Init(void); static void MX_TIM4_Init(void); static void MX_TIM13_Init(void); +static void MX_USB_OTG_FS_PCD_Init(void); +static void MX_USB_OTG_HS_HCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -115,6 +119,9 @@ int main(void) /* Configure the system clock */ SystemClock_Config(); +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + /* USER CODE BEGIN SysInit */ /*Configure GPIO pin Output Level */ @@ -136,6 +143,8 @@ int main(void) MX_TIM3_Init(); MX_TIM4_Init(); MX_TIM13_Init(); + MX_USB_OTG_FS_PCD_Init(); + MX_USB_OTG_HS_HCD_Init(); /* USER CODE BEGIN 2 */ GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -229,7 +238,6 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Macro to configure SAI1BlockB clock source selection */ @@ -270,11 +278,22 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI; PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; PeriphClkInitStruct.PLLSAIDivQ = 1; - PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -831,6 +850,75 @@ static void MX_TIM13_Init(void) } +/** + * @brief USB_OTG_FS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_FS_PCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_FS_Init 0 */ + + /* USER CODE END USB_OTG_FS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_FS_Init 1 */ + + /* USER CODE END USB_OTG_FS_Init 1 */ + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_FS_Init 2 */ + + /* USER CODE END USB_OTG_FS_Init 2 */ + +} + +/** + * @brief USB_OTG_HS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_HS_HCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_HS_Init 0 */ + + /* USER CODE END USB_OTG_HS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_HS_Init 1 */ + + /* USER CODE END USB_OTG_HS_Init 1 */ + hhcd_USB_OTG_HS.Instance = USB_OTG_HS; + hhcd_USB_OTG_HS.Init.Host_channels = 12; + hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; + hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hhcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE; + hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_HS_Init 2 */ + + /* USER CODE END USB_OTG_HS_Init 2 */ + +} + /** * Enable DMA controller clock */ @@ -1043,10 +1131,10 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(SW4_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0); + HAL_NVIC_SetPriority(EXTI1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI1_IRQn); - HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0); + HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI2_IRQn); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); @@ -1067,11 +1155,6 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); - - /* init code for USB_HOST */ - MX_USB_HOST_Init(); /* USER CODE BEGIN 5 */ setup(); diff --git a/Witch/Src/stm32f4xx_hal_msp.c b/Witch/Src/stm32f4xx_hal_msp.c index 4ad07d73..633a42d6 100644 --- a/Witch/Src/stm32f4xx_hal_msp.c +++ b/Witch/Src/stm32f4xx_hal_msp.c @@ -297,11 +297,21 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) */ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) { + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hrtc->Instance==RTC) { /* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE END RTC_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */ @@ -674,6 +684,153 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) } +/** +* @brief PCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USB_OTG_FS interrupt Init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } + +} + +/** +* @brief HCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hhcd: HCD handle pointer +* @retval None +*/ +void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hhcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + /* USB_OTG_HS interrupt Init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 8, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } + +} + +/** +* @brief PCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) +{ + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); + + /* USB_OTG_FS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } + +} + +/** +* @brief HCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hhcd: HCD handle pointer +* @retval None +*/ +void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hhcd) +{ + if(hhcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); + + /* USB_OTG_HS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } + +} + static uint32_t FMC_Initialized = 0; static void HAL_FMC_MspInit(void){ @@ -921,7 +1078,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; @@ -968,7 +1125,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; @@ -1002,6 +1159,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -1014,6 +1172,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -1024,6 +1183,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -1032,6 +1192,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/Witch/Src/stm32f4xx_it.c b/Witch/Src/stm32f4xx_it.c index 2909c4cc..47283a10 100644 --- a/Witch/Src/stm32f4xx_it.c +++ b/Witch/Src/stm32f4xx_it.c @@ -73,13 +73,13 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_adc3; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; extern SAI_HandleTypeDef hsai_BlockB1; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ diff --git a/Witch/Src/usb_device.c b/Witch/Src/usb_device.c index 95ded99c..723305ee 100644 --- a/Witch/Src/usb_device.c +++ b/Witch/Src/usb_device.c @@ -27,6 +27,8 @@ #include "usbd_audio.h" /* USER CODE BEGIN Includes */ +#include "device.h" + /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -40,7 +42,7 @@ /* USER CODE END PFP */ /* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; +USBD_HandleTypeDef USBD_HANDLE; /* * -- Insert your variables declaration here -- @@ -67,19 +69,19 @@ void MX_USB_DEVICE_Init(void) /* USER CODE END USB_DEVICE_Init_PreTreatment */ /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + if (USBD_Init(&USBD_HANDLE, &USBD_DESC, USBD_HSFS) != USBD_OK) { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } diff --git a/Witch/Src/usb_host.c b/Witch/Src/usb_host.c index 548b78d6..0cf7ad2b 100644 --- a/Witch/Src/usb_host.c +++ b/Witch/Src/usb_host.c @@ -25,9 +25,15 @@ #include "usbh_core.h" /* USER CODE BEGIN Includes */ -#include "usbh_midi.h" #include "device.h" +#include "message.h" #include "errorhandlers.h" +#ifdef USE_USBH_MIDI +#include "usbh_midi.h" +#endif +#ifdef USE_USBH_HID +#include "usbh_hid.h" +#endif /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -62,6 +68,10 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); */ /* USER CODE BEGIN 1 */ +void USBH_HID_EventCallback(USBH_HandleTypeDef *phost){ + debugMessage("HID"); +} + /* * Background task */ @@ -77,6 +87,19 @@ void MX_USB_HOST_Process() /* MX_USB_HOST_Init(); */ /* Appli_state = APPLICATION_IDLE; */ /* } */ + USBH_HandleTypeDef *phost = &HUSB_HOST; + /* if(USBH_HID_GetDeviceType(phost) == HID_KEYBOARD){ */ + /* HID_KEYBD_Info_TypeDef* pinfo = USBH_HID_GetKeybdInfo(phost); */ + /* if(pinfo != NULL){ */ + /* uint8_t c = USBH_HID_GetASCIICode(pinfo); */ + /* // or c = pinfo->keys[0]; */ + /* if(c >= 32 && c <= 126) { // readable ascii */ + /* char* msg = "char[ ]"; */ + /* msg[5] = c; */ + /* debugMessage(msg); */ + /* } */ + /* } */ + /* } */ } /* USER CODE END 1 */ @@ -96,16 +119,27 @@ void MX_USB_HOST_Init(void) { Error_Handler(); } +#ifdef USE_USBH_MIDI if (USBH_RegisterClass(&HUSB_HOST, USBH_MIDI_CLASS) != USBH_OK) { Error_Handler(); } +#endif +#ifdef USE_USBH_HID + if (USBH_RegisterClass(&HUSB_HOST, USBH_HID_CLASS) != USBH_OK) + { + Error_Handler(); + } +#endif if (USBH_Start(&HUSB_HOST) != USBH_OK) { Error_Handler(); } /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ - + +#ifdef STM32H7xx + HAL_PWREx_EnableUSBVoltageDetector(); +#endif /* USER CODE END USB_HOST_Init_PostTreatment */ } @@ -127,22 +161,26 @@ static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) case HOST_USER_CLASS_ACTIVE: if(Appli_state == APPLICATION_START){ +#ifdef USE_USBH_MIDI usbh_midi_begin(); +#endif Appli_state = APPLICATION_READY; } break; case HOST_USER_DISCONNECTION: Appli_state = APPLICATION_DISCONNECT; +#ifdef USE_USBH_MIDI usbh_midi_reset(); +#endif break; case HOST_USER_UNRECOVERED_ERROR: - phost->Control.state = CTRL_SETUP; - phost->RequestState = CMD_SEND; + /* phost->Control.state = CTRL_SETUP; */ + /* phost->RequestState = CMD_SEND; */ Appli_state = APPLICATION_DISCONNECT; /* usbh_midi_reset(); // reset and hope for the best */ - USBH_LL_ResetPort(&USBH_HANDLE); + /* USBH_LL_ResetPort(&USBH_HANDLE); */ error(USB_ERROR, "USB Host error"); break; diff --git a/Witch/Src/usbd_conf.c b/Witch/Src/usbd_conf.c index 15eb9fd3..9460a97a 100644 --- a/Witch/Src/usbd_conf.c +++ b/Witch/Src/usbd_conf.c @@ -25,6 +25,8 @@ #include "usbd_def.h" #include "usbd_core.h" +#include "usbd_audio.h" + /* USER CODE BEGIN Includes */ #include "device.h" uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); @@ -39,7 +41,9 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -63,85 +67,18 @@ USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ -/* MSP Init */ -void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - - /* USER CODE END USB_OTG_FS_MspInit 0 */ - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA10 ------> USB_OTG_FS_ID - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - GPIO_InitStruct.Pin = USBD_VBUS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - - /* USER CODE END USB_OTG_FS_MspInit 1 */ - } -} - -void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) -{ - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA10 ------> USB_OTG_FS_ID - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ - } -} +/* defined in stm32f4xx_hal_msp.c : + * void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) + * void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) + */ /** * @brief Setup stage callback * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); } @@ -152,11 +89,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } @@ -167,11 +100,7 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } @@ -181,11 +110,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); } @@ -195,12 +120,8 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ +{ USBD_SpeedTypeDef speed = USBD_SPEED_FULL; if ( hpcd->Init.speed == PCD_SPEED_HIGH) @@ -228,11 +149,7 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* Inform USB library that core enters in suspend Mode. */ USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); @@ -253,11 +170,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* USER CODE BEGIN 3 */ /* USER CODE END 3 */ @@ -270,11 +183,7 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -285,11 +194,7 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -299,11 +204,7 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -313,11 +214,7 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -333,44 +230,20 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { - /* Init USB Ip. */ - if (pdev->id == DEVICE_FS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_FS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_FS; - - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler( ); - } - -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) - /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); - } +#ifdef USE_USBD_FS + /* if (pdev->id == DEVICE_FS) { */ + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; +#endif + /* } else if (pdev->id == DEVICE_HS) { */ +#ifdef USE_USBD_HS + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; +#endif + /* } */ + USBD_AUDIO_SetFiFos(pdev->pData); return USBD_OK; } @@ -387,12 +260,12 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) hal_status = HAL_PCD_DeInit(pdev->pData); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** - * @brief Starts the low level portion of the device driver. + * @brief Starts the low level portion of the device driver. * @param pdev: Device handle * @retval USBD status */ @@ -400,11 +273,11 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_Start(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - + + usb_status = USBD_Get_USB_Status(hal_status); + return usb_status; } @@ -419,9 +292,9 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_Stop(pdev->pData); - + usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -441,7 +314,7 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -458,10 +331,10 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -474,12 +347,12 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -492,12 +365,12 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -510,12 +383,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -527,14 +400,14 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; - + if((ep_addr & 0x80) == 0x80) { - return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { - return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } @@ -548,12 +421,12 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); - + usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -561,7 +434,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a * @param pdev: Device handle * @param ep_addr: Endpoint number * @param pbuf: Pointer to data to be sent - * @param size: Data size + * @param size: Data size * @retval USBD status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) @@ -570,10 +443,10 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -590,23 +463,44 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** - * @brief Returns the last transfered packet size. + * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint number - * @retval Recived Data Size + * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms @@ -618,7 +512,7 @@ void USBD_LL_Delay(uint32_t Delay) } /** - * @brief Retuns the USB status depending on the HAL status: + * @brief Returns the USB status depending on the HAL status: * @param hal_status: HAL status * @retval USB status */ diff --git a/Witch/Src/usbd_desc.c b/Witch/Src/usbd_desc.c index d6466ccc..085c5823 100644 --- a/Witch/Src/usbd_desc.c +++ b/Witch/Src/usbd_desc.c @@ -25,7 +25,7 @@ #include "usbd_conf.h" /* USER CODE BEGIN INCLUDE */ -const char* getDeviceName(); +#include "device.h" /* USER CODE END INCLUDE */ /* Private typedef -----------------------------------------------------------*/ @@ -66,10 +66,10 @@ const char* getDeviceName(); #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xDADA -#define USBD_PRODUCT_STRING_FS "OWL-WITCH" -#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" -#define USBD_INTERFACE_STRING_FS "AUDIO Interface" +#define USBD_PID_FSHS 0xDADA +#define USBD_PRODUCT_STRING_FSHS "OWL-WITCH" +#define USBD_CONFIGURATION_STRING_FSHS "AUDIO Config" +#define USBD_INTERFACE_STRING_FSHS "AUDIO Interface" #define USB_SIZ_BOS_DESC 0x0C @@ -111,19 +111,20 @@ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for FS. + * @brief Private functions declaration for HS. * @{ */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + #if (USBD_LPM_ENABLED == 1) -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); #endif /* (USBD_LPM_ENABLED == 1) */ /** @@ -135,17 +136,17 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{ */ -USBD_DescriptorsTypeDef FS_Desc = +USBD_DescriptorsTypeDef USBD_DESC = { - USBD_FS_DeviceDescriptor -, USBD_FS_LangIDStrDescriptor -, USBD_FS_ManufacturerStrDescriptor -, USBD_FS_ProductStrDescriptor -, USBD_FS_SerialStrDescriptor -, USBD_FS_ConfigStrDescriptor -, USBD_FS_InterfaceStrDescriptor + USBD_FSHS_DeviceDescriptor +, USBD_FSHS_LangIDStrDescriptor +, USBD_FSHS_ManufacturerStrDescriptor +, USBD_FSHS_ProductStrDescriptor +, USBD_FSHS_SerialStrDescriptor +, USBD_FSHS_ConfigStrDescriptor +, USBD_FSHS_InterfaceStrDescriptor #if (USBD_LPM_ENABLED == 1) -, USBD_FS_USR_BOSDescriptor +, USBD_FSHS_USR_BOSDescriptor #endif /* (USBD_LPM_ENABLED == 1) */ }; @@ -153,7 +154,7 @@ USBD_DescriptorsTypeDef FS_Desc = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ /** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /*bLength */ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ @@ -164,6 +165,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = #else 0x00, /*bcdUSB */ #endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ @@ -171,8 +173,8 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_FS), /*idProduct*/ - HIBYTE(USBD_PID_FS), /*idProduct*/ + LOBYTE(USBD_PID_FSHS), /*idProduct*/ + HIBYTE(USBD_PID_FSHS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -181,24 +183,23 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ }; -/* USB_DeviceDescriptor */ /** BOS descriptor. */ #if (USBD_LPM_ENABLED == 1) #if defined ( __ICCARM__ ) /* IAR Compiler */ #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { 0x5, USB_DESC_TYPE_BOS, 0xC, 0x0, - 0x1, /* 1 device capability*/ - /* device capability*/ + 0x1, /* 1 device capability */ + /* device capability */ 0x7, USB_DEVICE_CAPABITY_TYPE, 0x2, - 0x2, /* LPM capability bit set*/ + 0x2, /*LPM capability bit set */ 0x0, 0x0, 0x0 @@ -218,7 +219,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -256,11 +257,11 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_DeviceDesc); - return USBD_FS_DeviceDesc; + *length = sizeof(USBD_FSHS_DeviceDesc); + return USBD_FSHS_DeviceDesc; } /** @@ -269,7 +270,7 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = sizeof(USBD_LangIDDesc); @@ -278,19 +279,19 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /** * @brief Return the product string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer */ -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -301,7 +302,7 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); @@ -314,7 +315,7 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = USB_SIZ_STRING_SERIAL; @@ -322,9 +323,10 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); - /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ - - /* USER CODE END USBD_FS_SerialStrDescriptor */ + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; } @@ -334,15 +336,15 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -353,15 +355,15 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -373,11 +375,11 @@ uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_BOSDesc); - return (uint8_t*)USBD_FS_BOSDesc; + *length = sizeof(USBD_FSHS_BOSDesc); + return (uint8_t*)USBD_FSHS_BOSDesc; } #endif /* (USBD_LPM_ENABLED == 1) */ diff --git a/Witch/Src/usbh_conf.c b/Witch/Src/usbh_conf.c index 06cfc8b1..2c7b45d4 100644 --- a/Witch/Src/usbh_conf.c +++ b/Witch/Src/usbh_conf.c @@ -35,11 +35,10 @@ /* USER CODE END PV */ -HCD_HandleTypeDef hhcd_USB_OTG_HS; +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END 0 */ @@ -60,7 +59,7 @@ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); *******************************************************************************/ /* MSP Init */ -void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) +__weak void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hcdHandle->Instance==USB_OTG_HS) @@ -93,7 +92,7 @@ void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) } } -void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) +__weak void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) { if(hcdHandle->Instance==USB_OTG_HS) { @@ -155,14 +154,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle @@ -450,12 +448,6 @@ USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe */ USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) { - - /* USER CODE BEGIN 0 */ -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); - - /* USER CODE END 0*/ - if (phost->id == HOST_HS) { if (state == 0) @@ -475,7 +467,7 @@ void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URB /* USER CODE END DRIVE_LOW_CHARGE_FOR_HS */ } } - HAL_Delay(200); + /* HAL_Delay(200); */ return USBH_OK; } diff --git a/Witch/Witch.ioc b/Witch/Witch.ioc index aa75b622..92c6bc7f 100644 --- a/Witch/Witch.ioc +++ b/Witch/Witch.ioc @@ -1,788 +1,765 @@ #MicroXplorer Configuration settings - do not modify -PB13.GPIOParameters=GPIO_Label -SH.FMC_D0_DA0.ConfNb=1 -SH.FMC_A8.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SH.FMC_A0.ConfNb=1 -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -PG8.Signal=FMC_SDCLK -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -RCC.RTCFreq_Value=32000 -PD2.GPIOParameters=GPIO_Label -SH.FMC_SDNWE.ConfNb=1 -SH.S_TIM1_CH1.ConfNb=1 -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=54000000 -USB_DEVICE.PID_AUDIO_FS=0xDADA -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configENABLE_FPU=1 -SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -NVIC.EXTI1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -PF7.Signal=ADC3_IN5 -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -RCC.I2C4Freq_Value=54000000 -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=FMC_SDNE1 -SPI1.CalculateBaudRate=42.0 MBits/s -ADC3.ScanConvMode=ENABLE -PD0.Signal=FMC_D2_DA2 -PD8.Signal=FMC_D13_DA13 -PE1.Signal=FMC_NBL1 -RCC.USART3Freq_Value=54000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Full_Duplex_Master -PA8.Locked=true -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS -PB12.GPIO_Label=LEDPWM -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.2 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -ProjectManager.BackupPrevious=false -PC4.GPIO_Label=FLASH_HOLD -TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -PE9.Signal=FMC_D6_DA6 -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Host_FS -PB1.GPIO_Label=SW2 -PE4.GPIO_Label=CS_LRCK -PF10.Locked=true -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS -PA8.Signal=S_TIM1_CH1 +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -ADC3.SamplingTime-36\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PC15/OSC32_OUT.Locked=true -USB_OTG_HS.IPParameters=VirtualMode-Host_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -ProjectManager.HalAssertFull=true -Mcu.Package=LQFP144 -PB9.Signal=GPIO_Input -PB1.Signal=GPXTI1 -PA5.Locked=true -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 -PB9.GPIO_PuPd=GPIO_PULLUP -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -PF7.Locked=true -ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true -RCC.APB1TimFreq_Value=84000000 -FMC.RowCycleDelay2=6 -FMC.RowCycleDelay1=6 -PF10.Mode=IN8 -USB_OTG_FS.IPParameters=VirtualMode -ADC3.Rank-34\#ChannelRegularConversion=4 -PF9.GPIO_PuPd=GPIO_PULLUP -SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -PA4.GPIO_Label=DAC1 -PD15.Signal=FMC_D1_DA1 -RCC.PLLSAIQCLKFreq_Value=50000000 -SH.FMC_D3_DA3.ConfNb=1 -Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PA6.GPIOParameters=GPIO_Label -USB_DEVICE.VID-AUDIO_FS=0x1209 +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_0 +ADC3.Channel-36\#ChannelRegularConversion=ADC_CHANNEL_1 +ADC3.Channel-37\#ChannelRegularConversion=ADC_CHANNEL_2 +ADC3.Channel-38\#ChannelRegularConversion=ADC_CHANNEL_3 ADC3.Channel-39\#ChannelRegularConversion=ADC_CHANNEL_5 -Mcu.Pin80=PD2 -PD6.GPIOParameters=GPIO_Label -Mcu.Pin81=PD6 -SH.FMC_A4.0=FMC_A4,12b-sda1 -ProjectManager.ProjectFileName=Witch.ioc -SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PD1 -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=98 -Mcu.Pin73=PA14 -PC11.Locked=true -Mcu.Pin74=PA15 -Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE -Mcu.Pin71=PA12 -Mcu.Pin72=PA13 -Mcu.Pin77=PC12 -PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PD0 -Mcu.Pin75=PC10 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=PC11 -FREERTOS.INCLUDE_vTaskDelayUntil=1 -Mcu.Pin70=PA11 -PC2.Signal=ADCx_IN12 -PH1/OSC_OUT.GPIOParameters=GPIO_Label -RCC.VCOSAIOutputFreq_ValueQ=25000000 -Mcu.Pin68=PA8 -Mcu.Pin69=PA9 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PG4 -Mcu.Pin63=PG5 -Mcu.Pin60=PD14 -Mcu.Pin61=PD15 -Mcu.Pin66=PC8 -Mcu.Pin67=PC9 -Mcu.Pin64=PG8 -Mcu.Pin65=PC6 -PF8.GPIO_Label=LEDPWM4 -PC3.GPIOParameters=GPIO_Label -PD10.Signal=FMC_D15_DA15 -PB8.GPIO_Label=LEDPWM3 -PA15.Locked=true -PA8.GPIO_Label=LEDPWM6 -Mcu.Pin59=PD10 -SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PD8 -Mcu.Pin58=PD9 -Mcu.Pin51=PB10 -RCC.USART6Freq_Value=108000000 -Mcu.Pin52=PB11 -Mcu.Pin50=PE15 -Mcu.Pin55=PB14 -Mcu.Pin56=PB15 -Mcu.Pin53=PB12 -Mcu.Pin54=PB13 -PB9.Locked=true -PB11.GPIOParameters=GPIO_Label -Mcu.Pin48=PE13 -Mcu.Pin49=PE14 -Mcu.Pin46=PE11 -Mcu.Pin47=PE12 -TIM13.IPParameters=Channel,Prescaler,Period -PB14.Signal=USB_OTG_HS_DM -PA5.Signal=COMP_DAC2_group -Mcu.Pin40=PG0 -Mcu.Pin41=PG1 -Mcu.Pin44=PE9 -Mcu.Pin45=PE10 -Mcu.Pin42=PE7 -Mcu.Pin43=PE8 -TIM13.Period=1023 -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 -FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PF13 -Mcu.Pin38=PF14 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin35=PF11 -Mcu.Pin36=PF12 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.ADCx_IN0.ConfNb=1 -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PF15 -Mcu.Pin30=PC4 -Mcu.Pin33=PB1 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin34=PB2/BOOT1 -Mcu.Pin31=PC5 -Mcu.Pin32=PB0 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -PC10.GPIOParameters=GPIO_Label -PC9.GPIOParameters=GPIO_Label -PF9.GPIOParameters=GPIO_PuPd,GPIO_Label -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA4 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin27=PA5 -Mcu.Pin24=PA2 -Mcu.Pin25=PA3 -Mcu.Pin28=PA6 -Mcu.Pin29=PA7 -Mcu.Pin22=PA0/WKUP -Mcu.Pin23=PA1 -Mcu.Pin20=PC2 -ADC3.SamplingTime-37\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin21=PC3 -PA5.GPIO_Label=DAC2 -NVIC.ForceEnableDMAVector=true -Dma.ADC3.2.PeriphInc=DMA_PINC_DISABLE -PA14.GPIOParameters=GPIO_Label -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK -PC12.GPIO_Label=TR_OUT1 -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PF10 -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH0/OSC_IN +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE +ADC3.DMAContinuousRequests=ENABLE +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PF8 -Mcu.Pin14=PF9 -PF10.GPIOParameters=GPIO_Label -Mcu.Pin19=PC1 -Mcu.Pin17=PH1/OSC_OUT -Mcu.Pin18=PC0 -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF7 -Mcu.Pin10=PF4 -PE3.Signal=SAI1_SD_B -ADC3.Rank-33\#ChannelRegularConversion=3 -PC15/OSC32_OUT.Signal=GPIO_Output -PF4.Signal=FMC_A4 -SH.GPXTI1.ConfNb=1 -PD2.Signal=GPIO_Output ADC3.EnableAnalogWatchDog=false -Mcu.Family=STM32F4 +ADC3.ExternalTrigConv=ADC_SOFTWARE_START +ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion,Rank-36\#ChannelRegularConversion,Channel-36\#ChannelRegularConversion,SamplingTime-36\#ChannelRegularConversion,Rank-37\#ChannelRegularConversion,Channel-37\#ChannelRegularConversion,SamplingTime-37\#ChannelRegularConversion,Rank-38\#ChannelRegularConversion,Channel-38\#ChannelRegularConversion,SamplingTime-38\#ChannelRegularConversion,Rank-39\#ChannelRegularConversion,Channel-39\#ChannelRegularConversion,SamplingTime-39\#ChannelRegularConversion +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=9 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 +ADC3.Rank-34\#ChannelRegularConversion=4 +ADC3.Rank-35\#ChannelRegularConversion=5 +ADC3.Rank-36\#ChannelRegularConversion=6 +ADC3.Rank-37\#ChannelRegularConversion=7 ADC3.Rank-38\#ChannelRegularConversion=8 -FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -ProjectManager.MainLocation=Src -PA6.Mode=Full_Duplex_Master -SH.FMC_A6.ConfNb=1 -USB_DEVICE.CLASS_NAME_FS=AUDIO -SH.FMC_A8.0=FMC_A8,12b-sda1 -PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -ProjectManager.KeepUserCode=true -ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_0 -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -SAI1.FrameLength-SAI_A_AsyncSlave=64 +ADC3.Rank-39\#ChannelRegularConversion=9 +ADC3.Resolution=ADC_RESOLUTION_12B +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-36\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-37\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-38\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-39\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.2.FIFOMode=DMA_FIFOMODE_DISABLE Dma.ADC3.2.Instance=DMA2_Stream0 -SAI1.FrameLength-SAI_B_SyncSlave=64 -PC5.Locked=true -PA11.Mode=Device_Only -PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -PD2.Locked=true -SH.FMC_A11.0=FMC_A11,12b-sda1 -PC1.Locked=true -PB13.GPIO_Label=USBH_PWR_FAULT -PB15.Signal=USB_OTG_HS_DP -SH.S_TIM13_CH1.0=TIM13_CH1,PWM Generation1 CH1 -PG11.Signal=GPIO_Output -PG15.Signal=FMC_SDNCAS -SH.COMP_DAC2_group.0=DAC_OUT2,DAC_OUT2 -SH.GPXTI2.0=GPIO_EXTI2 -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -Mcu.IP4=FREERTOS -Mcu.IP5=NVIC -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DMA -Mcu.IP3=FMC -PA15.GPIO_Label=LEDSW1 -Mcu.IP0=ADC3 -Mcu.IP1=DAC -PE4.GPIOParameters=GPIO_Label -TIM1.Prescaler=100 -PF9.Locked=true -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -RCC.SDMMCFreq_Value=216000000 +Dma.ADC3.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.2.MemInc=DMA_MINC_ENABLE +Dma.ADC3.2.Mode=DMA_CIRCULAR +Dma.ADC3.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.2.PeriphInc=DMA_PINC_DISABLE Dma.ADC3.2.Priority=DMA_PRIORITY_LOW -PB1.GPIO_PuPd=GPIO_PULLUP -SH.ADCx_IN3.0=ADC3_IN3,IN3 -ProjectManager.PreviousToolchain=TrueSTUDIO -TIM3.Period=1023 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -PA8.GPIOParameters=GPIO_Label -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE,configENABLE_FPU -Dma.SAI1_B.1.Instance=DMA2_Stream4 +Dma.ADC3.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=SAI1_A +Dma.Request1=SAI1_B +Dma.Request2=ADC3 +Dma.RequestsNb=3 +Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.0.Instance=DMA2_Stream1 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE -TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -FREERTOS.configUSE_PREEMPTION=0 -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 +Dma.SAI1_B.1.Instance=DMA2_Stream4 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE,configENABLE_FPU +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configENABLE_FPU=1 +FREERTOS.configTOTAL_HEAP_SIZE=4096 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=true +Mcu.Family=STM32F4 +Mcu.IP0=ADC3 +Mcu.IP1=DAC Mcu.IP10=SPI4 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:true -Mcu.IP12=TIM1 Mcu.IP11=SYS -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -PC15/OSC32_OUT.GPIOParameters=GPIO_Label -Mcu.IP18=USB_OTG_FS -PH1/OSC_OUT.GPIO_Label=OSC2 -Mcu.IP17=USB_HOST -Mcu.IP19=USB_OTG_HS -Mcu.IP14=TIM4 +Mcu.IP12=TIM1 Mcu.IP13=TIM3 -Mcu.IP16=USB_DEVICE +Mcu.IP14=TIM4 Mcu.IP15=TIM13 -RCC.VCOInputFreq_Value=1000000 -PA14.Mode=Serial_Wire -TIM3.Prescaler=100 -PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP -PF11.Signal=FMC_SDNRAS -PC11.GPIO_Label=LEDSW3 -PB5.Mode=SdramChipSelect2_1 -PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1 -PB0.Locked=true -PA13.GPIOParameters=GPIO_Label -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-WITCH -Dma.ADC3.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PA6.Signal=SPI1_MISO -PG11.Locked=true -Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -ProjectManager.ToolChainLocation= -PA15.Signal=GPIO_Output -PF8.Signal=S_TIM13_CH1 -Mcu.Pin95=VP_TIM13_VS_ClockSourceINT -Mcu.Pin96=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin93=VP_RTC_VS_RTC_Activate -Mcu.Pin94=VP_SYS_VS_Systick -SH.ADCx_IN1.0=ADC3_IN1,IN1 -Mcu.Pin97=VP_USB_HOST_VS_USB_HOST_AUDIO_HS -Dma.Request2=ADC3 -Dma.Request1=SAI1_B -ADC3.Rank-32\#ChannelRegularConversion=2 -Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE -Mcu.Pin91=PE1 -Mcu.Pin92=VP_FREERTOS_VS_CMSIS_V1 -PG11.GPIO_Label=LEDSW4 -PC5.Signal=GPIO_Output -Mcu.Pin90=PE0 -PE7.Signal=FMC_D4_DA4 -PD6.Signal=SAI1_SD_A -SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS -Dma.Request0=SAI1_A -Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH -PE2.GPIO_Label=CS_SCK -Mcu.Pin84=PG15 -Mcu.Pin85=PB3 +Mcu.IP16=USB_OTG_FS +Mcu.IP17=USB_OTG_HS +Mcu.IP2=DMA +Mcu.IP3=FMC +Mcu.IP4=FREERTOS +Mcu.IP5=NVIC +Mcu.IP6=RCC +Mcu.IP7=RTC +Mcu.IP8=SAI1 +Mcu.IP9=SPI1 +Mcu.IPNb=18 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF9 +Mcu.Pin15=PF10 +Mcu.Pin16=PH0/OSC_IN +Mcu.Pin17=PH1/OSC_OUT +Mcu.Pin18=PC0 +Mcu.Pin19=PC1 +Mcu.Pin2=PE4 +Mcu.Pin20=PC2 +Mcu.Pin21=PC3 +Mcu.Pin22=PA0/WKUP +Mcu.Pin23=PA1 +Mcu.Pin24=PA2 +Mcu.Pin25=PA3 +Mcu.Pin26=PA4 +Mcu.Pin27=PA5 +Mcu.Pin28=PA6 +Mcu.Pin29=PA7 +Mcu.Pin3=PE5 +Mcu.Pin30=PC4 +Mcu.Pin31=PC5 +Mcu.Pin32=PB0 +Mcu.Pin33=PB1 +Mcu.Pin34=PB2/BOOT1 +Mcu.Pin35=PF11 +Mcu.Pin36=PF12 +Mcu.Pin37=PF13 +Mcu.Pin38=PF14 +Mcu.Pin39=PF15 +Mcu.Pin4=PE6 +Mcu.Pin40=PG0 +Mcu.Pin41=PG1 +Mcu.Pin42=PE7 +Mcu.Pin43=PE8 +Mcu.Pin44=PE9 +Mcu.Pin45=PE10 +Mcu.Pin46=PE11 +Mcu.Pin47=PE12 +Mcu.Pin48=PE13 +Mcu.Pin49=PE14 +Mcu.Pin5=PC15/OSC32_OUT +Mcu.Pin50=PE15 +Mcu.Pin51=PB10 +Mcu.Pin52=PB11 +Mcu.Pin53=PB12 +Mcu.Pin54=PB13 +Mcu.Pin55=PB14 +Mcu.Pin56=PB15 +Mcu.Pin57=PD8 +Mcu.Pin58=PD9 +Mcu.Pin59=PD10 +Mcu.Pin6=PF0 +Mcu.Pin60=PD14 +Mcu.Pin61=PD15 +Mcu.Pin62=PG4 +Mcu.Pin63=PG5 +Mcu.Pin64=PG8 +Mcu.Pin65=PC6 +Mcu.Pin66=PC8 +Mcu.Pin67=PC9 +Mcu.Pin68=PA8 +Mcu.Pin69=PA9 +Mcu.Pin7=PF1 +Mcu.Pin70=PA11 +Mcu.Pin71=PA12 +Mcu.Pin72=PA13 +Mcu.Pin73=PA14 +Mcu.Pin74=PA15 +Mcu.Pin75=PC10 +Mcu.Pin76=PC11 +Mcu.Pin77=PC12 +Mcu.Pin78=PD0 +Mcu.Pin79=PD1 +Mcu.Pin8=PF2 +Mcu.Pin80=PD2 +Mcu.Pin81=PD6 Mcu.Pin82=PG9 Mcu.Pin83=PG11 -PA3.Signal=ADCx_IN3 -Mcu.Pin88=PB8 -Mcu.Pin89=PB9 +Mcu.Pin84=PG15 +Mcu.Pin85=PB3 Mcu.Pin86=PB5 Mcu.Pin87=PB6 -SH.FMC_A3.ConfNb=1 -VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate -ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.I2SFreq_Value=96000000 -USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_HS,VirtualModeHS,USBH_MAX_NUM_CONFIGURATION-AUDIO_HS,USBH_MAX_NUM_ENDPOINTS-AUDIO_HS,USBH_MAX_NUM_SUPPORTED_CLASS-AUDIO_HS,USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS -Dma.ADC3.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -SH.ADCx_IN13.0=ADC3_IN13,IN13 +Mcu.Pin88=PB8 +Mcu.Pin89=PB9 +Mcu.Pin9=PF3 +Mcu.Pin90=PE0 +Mcu.Pin91=PE1 +Mcu.Pin92=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin93=VP_RTC_VS_RTC_Activate +Mcu.Pin94=VP_SYS_VS_Systick +Mcu.Pin95=VP_TIM13_VS_ClockSourceINT +Mcu.PinsNb=96 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:false\:true\:true +NVIC.EXTI9_5_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:false\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0/WKUP.Signal=ADCx_IN0 +PA1.Signal=ADCx_IN1 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13.GPIOParameters=GPIO_Label +PA13.GPIO_Label=SWDIO +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.GPIOParameters=GPIO_Label +PA14.GPIO_Label=SWCLK +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA15.GPIOParameters=GPIO_Label +PA15.GPIO_Label=LEDSW1 +PA15.Locked=true +PA15.Signal=GPIO_Output +PA2.Signal=ADCx_IN2 +PA3.Signal=ADCx_IN3 +PA4.GPIOParameters=GPIO_Label +PA4.GPIO_Label=DAC1 +PA4.Locked=true +PA4.Signal=COMP_DAC1_group +PA5.GPIOParameters=GPIO_Label +PA5.GPIO_Label=DAC2 +PA5.Locked=true +PA5.Signal=COMP_DAC2_group +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA8.GPIOParameters=GPIO_Label +PA8.GPIO_Label=LEDPWM6 +PA8.Locked=true +PA8.Signal=S_TIM1_CH1 +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB1.GPIO_Label=SW2 +PB1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB1.GPIO_PuPd=GPIO_PULLUP +PB1.Locked=true +PB1.Signal=GPXTI1 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_CS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_RST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB12.GPIOParameters=GPIO_Label +PB12.GPIO_Label=LEDPWM +PB12.Locked=true +PB12.Signal=GPIO_Output +PB13.GPIOParameters=GPIO_Label +PB13.GPIO_Label=USBH_PWR_FAULT +PB13.Locked=true +PB13.Signal=GPIO_Input +PB14.Mode=Host_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Host_FS +PB15.Signal=USB_OTG_HS_DP +PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB2/BOOT1.GPIO_Label=SW1 +PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPXTI2 +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 PB8.GPIOParameters=GPIO_Label -Dma.SAI1_B.1.Mode=DMA_CIRCULAR -RCC.UART7Freq_Value=54000000 -PC9.GPIO_Label=LEDPWM5 -NVIC.SavedSvcallIrqHandlerGenerated=true -Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH -PC11.Signal=GPIO_Output -PC8.Signal=S_TIM3_CH3 -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -ADC3.SamplingTime-39\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PB12.Locked=true -ProjectManager.DeletePrevious=true -USB_HOST.USBH_MAX_NUM_SUPPORTED_CLASS-AUDIO_HS=4 -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3 -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PRODUCT_STRING_AUDIO_FS -RCC.FamilyName=M +PB8.GPIO_Label=LEDPWM3 +PB8.Locked=true +PB8.Signal=S_TIM4_CH3 PB9.GPIOParameters=GPIO_PuPd,GPIO_Label -PA13.Signal=SYS_JTMS-SWDIO -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -PA9.Mode=Activate_VBUS -SH.FMC_A15_BA1.ConfNb=1 -PB2/BOOT1.Signal=GPXTI2 -SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 -ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PB10.GPIO_Label=CS_CS -Dma.SAI1_A.0.Mode=DMA_CIRCULAR -SH.S_TIM13_CH1.ConfNb=1 -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3 -PC5.GPIOParameters=GPIO_Label -PE2.GPIOParameters=GPIO_Label -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=SW5 -TIM4.Prescaler=100 -PA1.Signal=ADCx_IN1 -SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -SH.S_TIM4_CH3.ConfNb=1 -RCC.VCOI2SOutputFreq_Value=192000000 -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Witch -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Host_FS -RCC.UART4Freq_Value=54000000 -SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=6.0.1 -SH.ADCx_IN2.ConfNb=1 -PE5.Mode=SAI_A_AsyncSlave +PB9.GPIO_Label=SW4 +PB9.GPIO_PuPd=GPIO_PULLUP +PB9.Locked=true +PB9.Signal=GPIO_Input +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label PC1.GPIO_Label=ADC3 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF1.Signal=FMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -Mcu.IP8=SAI1 -Mcu.IP9=SPI1 -Mcu.IP6=RCC -Mcu.IP7=RTC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -RCC.SYSCLKFreq_VALUE=168000000 -ADC3.Channel-38\#ChannelRegularConversion=ADC_CHANNEL_3 -KeepUserPlacement=true -USB_HOST.USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS=512 -SH.GPXTI9.ConfNb=1 -NVIC.EXTI9_5_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -ADC3.Rank-35\#ChannelRegularConversion=5 -PC6.GPIOParameters=GPIO_Label -RCC.HSI_VALUE=16000000 -PH0/OSC_IN.GPIO_Label=OSC1 -SH.S_TIM3_CH4.ConfNb=1 -RCC.PLLQ=7 -RCC.PLLM=25 -RCC.PLLN=336 -PB2/BOOT1.Locked=true -PC8.Locked=true -SH.FMC_D8_DA8.ConfNb=1 -ADC3.NbrOfConversionFlag=1 -Dma.ADC3.2.FIFOMode=DMA_FIFOMODE_DISABLE -PB12.Signal=GPIO_Output -PG11.GPIOParameters=GPIO_Label -USB_OTG_HS.VirtualMode-Host_FS=Host_FS -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -RCC.USART1Freq_Value=108000000 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -USB_HOST.USBH_MAX_NUM_ENDPOINTS-AUDIO_HS=10 -FMC.RCDDelay1=2 -SPI1.VirtualType=VM_MASTER +PC1.Locked=true +PC1.Signal=ADCx_IN11 +PC10.GPIOParameters=GPIO_Label +PC10.GPIO_Label=LEDSW2 +PC10.Locked=true +PC10.Signal=GPIO_Output +PC11.GPIOParameters=GPIO_Label +PC11.GPIO_Label=LEDSW3 +PC11.Locked=true +PC11.Signal=GPIO_Output +PC12.GPIOParameters=GPIO_Label +PC12.GPIO_Label=TR_OUT1 PC12.Locked=true -TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period -SH.GPXTI9.0=GPIO_EXTI9 -PG4.Signal=FMC_A14_BA0 -RCC.PLLCLKFreq_Value=168000000 PC12.Signal=GPIO_Output -PA14.GPIO_Label=SWCLK -FMC.LoadToActiveDelay1=2 -PC6.GPIO_Label=LEDPWM1 -VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +PC15/OSC32_OUT.GPIOParameters=GPIO_Label +PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 PC3.Locked=true -PA6.GPIO_Label=FLASH_MISO -PB13.Signal=GPIO_Input -PD6.GPIO_Label=CS_SDIN -PinOutPanel.RotationAngle=0 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -PE6.GPIO_Label=CS_SDA -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -PE2.Mode=TX_Only_Simplex_Unidirect_Master -PB2/BOOT1.GPIO_Label=SW1 -SH.FMC_D10_DA10.ConfNb=1 -PB6.Mode=SdramChipSelect2_1 -PH1/OSC_OUT.Signal=RCC_OSC_OUT PC3.Signal=ADCx_IN13 -RCC.SAI2Freq_Value=50000000 -PE5.Signal=SAI1_SCK_A -PF10.GPIO_Label=ADC4 -PB13.Locked=true -Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PA4.Locked=true -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -MxDb.Version=DB.6.0.0 -PB0.GPIOParameters=GPIO_Label -SAI1.SlotNumber-SAI_A_AsyncSlave=2 -SH.ADCx_IN1.ConfNb=1 -ADC3.Channel-37\#ChannelRegularConversion=ADC_CHANNEL_2 -SH.FMC_D15_DA15.ConfNb=1 -ADC3.ContinuousConvMode=ENABLE -Dma.ADC3.2.Direction=DMA_PERIPH_TO_MEMORY -ADC3.Rank-36\#ChannelRegularConversion=6 -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion,Rank-36\#ChannelRegularConversion,Channel-36\#ChannelRegularConversion,SamplingTime-36\#ChannelRegularConversion,Rank-37\#ChannelRegularConversion,Channel-37\#ChannelRegularConversion,SamplingTime-37\#ChannelRegularConversion,Rank-38\#ChannelRegularConversion,Channel-38\#ChannelRegularConversion,SamplingTime-38\#ChannelRegularConversion,Rank-39\#ChannelRegularConversion,Channel-39\#ChannelRegularConversion,SamplingTime-39\#ChannelRegularConversion -SH.ADCx_IN11.ConfNb=1 -PE2.Signal=SPI4_SCK -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -TIM4.Period=1023 -PF3.Signal=FMC_A3 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -PE10.Signal=FMC_D7_DA7 -RCC.MCO2PinFreq_Value=168000000 -PC8.GPIOParameters=GPIO_Label -PF8.GPIOParameters=GPIO_Label -SH.COMP_DAC1_group.ConfNb=1 -PA5.GPIOParameters=GPIO_Label -SH.FMC_A1.0=FMC_A1,12b-sda1 -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.CECFreq_Value=32786.88524590164 -ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -TIM1.Period=1023 -PB10.GPIOParameters=GPIO_Label -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -ProjectManager.CustomerFirmwarePackage= PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -SH.COMP_DAC2_group.ConfNb=1 -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -SH.FMC_A1.ConfNb=1 -PA15.GPIOParameters=GPIO_Label -PG9.GPIO_PuPd=GPIO_PULLUP -PG9.Locked=true -PG9.Signal=GPXTI9 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PC6.GPIOParameters=GPIO_Label +PC6.GPIO_Label=LEDPWM1 +PC6.Locked=true PC6.Signal=S_TIM3_CH1 -PB11.GPIO_Label=CS_RST +PC8.GPIOParameters=GPIO_Label +PC8.GPIO_Label=LEDPWM2 +PC8.Locked=true +PC8.Signal=S_TIM3_CH3 +PC9.GPIOParameters=GPIO_Label +PC9.GPIO_Label=LEDPWM5 +PC9.Locked=true +PC9.Signal=S_TIM3_CH4 +PD0.Signal=FMC_D2_DA2 PD1.Signal=FMC_D3_DA3 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -PC11.GPIOParameters=GPIO_Label -ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 -ADC3.Resolution=ADC_RESOLUTION_12B -TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 -SH.FMC_A3.0=FMC_A3,12b-sda1 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -TIM13.Channel=TIM_CHANNEL_1 -TIM4.IPParameters=Channel-PWM Generation3 CH3,Prescaler,Period -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -USB_HOST.VirtualModeHS=Audio -PC6.Locked=true -PA9.Signal=USB_OTG_FS_VBUS -Dma.ADC3.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -ADC3.NbrOfConversion=9 -PB10.Signal=GPIO_Output -Dma.ADC3.2.Mode=DMA_CIRCULAR -FREERTOS.MEMORY_ALLOCATION=2 -ProjectManager.LastFirmware=true -Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE -VP_TIM13_VS_ClockSourceINT.Mode=Enable_Timer +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_Label +PD2.GPIO_Label=TR_OUT2 +PD2.Locked=true +PD2.Signal=GPIO_Output +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 PE15.Signal=FMC_D12_DA12 -TIM13.Prescaler=100 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 PE8.Signal=FMC_D5_DA5 -PC2.GPIOParameters=GPIO_Label -RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation3 CH3,Channel-PWM Generation1 CH1,Prescaler,Period -ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PA13.Mode=Serial_Wire -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -ProjectManager.FreePins=true -SH.FMC_NBL1.ConfNb=1 -RCC.RTCHSEDivFreq_Value=12500000 -ProjectManager.UnderRoot=false -SH.FMC_D7_DA7.ConfNb=1 -Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PA4.Signal=COMP_DAC1_group -PB5.Signal=FMC_SDCKE1 -ADC3.Rank-37\#ChannelRegularConversion=7 -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -ADC3.Channel-36\#ChannelRegularConversion=ADC_CHANNEL_1 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.Locked=true +PF7.Mode=IN5 +PF7.Signal=ADC3_IN5 +PF8.GPIOParameters=GPIO_Label +PF8.GPIO_Label=LEDPWM4 PF8.Locked=true -SH.S_TIM3_CH1.ConfNb=1 -ProjectManager.ComputerToolchain=false +PF8.Signal=S_TIM13_CH1 +PF9.GPIOParameters=GPIO_PuPd,GPIO_Label +PF9.GPIO_Label=SW5 +PF9.GPIO_PuPd=GPIO_PULLUP +PF9.Locked=true PF9.Signal=GPIO_Input -PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PC3.GPIO_Label=ADC1 -SH.FMC_D12_DA12.ConfNb=1 -RCC.I2C2Freq_Value=54000000 -PB0.Signal=GPIO_Output -SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B -Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE -PA7.GPIOParameters=GPIO_Label -PC1.Signal=ADCx_IN11 -PB12.GPIOParameters=GPIO_Label -Dma.SAI1_A.0.Instance=DMA2_Stream1 -PD2.GPIO_Label=TR_OUT2 -Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG11.GPIOParameters=GPIO_Label +PG11.GPIO_Label=LEDSW4 +PG11.Locked=true +PG11.Signal=GPIO_Output +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG9.GPIO_Label=SW3 +PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG9.GPIO_PuPd=GPIO_PULLUP +PG9.Locked=true +PG9.Signal=GPXTI9 PH0/OSC_IN.GPIOParameters=GPIO_Label -Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -SH.GPXTI1.0=GPIO_EXTI1 -RCC.SAI1Freq_Value=50000000 -RCC.CortexFreq_Value=168000000 -SH.FMC_A2.ConfNb=1 -Mcu.UserName=STM32F427ZITx -SH.ADCx_IN2.0=ADC3_IN2,IN2 -PC10.Locked=true -PC10.Signal=GPIO_Output -SPI4.Direction=SPI_DIRECTION_2LINES -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,9-MX_DAC_Init-DAC-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_RTC_Init-RTC-false-HAL-true,12-MX_USB_HOST_Init-USB_HOST-false-HAL-false,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true,16-MX_TIM13_Init-TIM13-false-HAL-true -ADC3.SamplingTime-38\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PA0/WKUP.Signal=ADCx_IN0 -PC9.Locked=true -PB0.GPIO_Label=FLASH_WP -RCC.PLLI2SRCLKFreq_Value=96000000 -ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.USART2Freq_Value=54000000 -PB11.Signal=GPIO_Output -ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -RCC.SAI_BClocksFreq_Value=25000000 -ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.I2C3Freq_Value=54000000 -USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS -SH.FMC_A7.0=FMC_A7,12b-sda1 -PA12.Signal=USB_OTG_FS_DP -Mcu.UserConstants= -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -Mcu.ThirdPartyNb=0 +PH0/OSC_IN.GPIO_Label=OSC1 PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.GPIOParameters=GPIO_Label +PH1/OSC_OUT.GPIO_Label=OSC2 +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=1 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain=TrueSTUDIO +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Witch.ioc +ProjectManager.ProjectName=Witch +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,9-MX_DAC_Init-DAC-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_RTC_Init-RTC-false-HAL-true,12-MX_USB_HOST_Init-USB_HOST-false-HAL-false,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true,16-MX_TIM13_Init-TIM13-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=20 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 RCC.SPDIFRXFreq_Value=96000000 -PB1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 +RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SH.ADCx_IN0.0=ADC3_IN0,IN0 +SH.ADCx_IN0.ConfNb=1 +SH.ADCx_IN1.0=ADC3_IN1,IN1 +SH.ADCx_IN1.ConfNb=1 +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.ADCx_IN2.0=ADC3_IN2,IN2 +SH.ADCx_IN2.ConfNb=1 +SH.ADCx_IN3.0=ADC3_IN3,IN3 SH.ADCx_IN3.ConfNb=1 -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF0 -Mcu.Pin7=PF1 -NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 -RCC.VCOSAIOutputFreq_Value=100000000 +SH.COMP_DAC1_group.0=DAC_OUT1,DAC_OUT1 +SH.COMP_DAC1_group.ConfNb=1 +SH.COMP_DAC2_group.0=DAC_OUT2,DAC_OUT2 +SH.COMP_DAC2_group.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -Mcu.Pin5=PC15/OSC32_OUT -ADC3.InjNumberOfConversion=0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.RPDelay2=2 -FMC.RPDelay1=2 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -PE13.Signal=FMC_D10_DA10 -File.Version=6 -SH.ADCx_IN13.ConfNb=1 -SH.FMC_D5_DA5.ConfNb=1 -PB3.GPIOParameters=GPIO_Label SH.FMC_D2_DA2.ConfNb=1 -PB8.Locked=true -SH.ADCx_IN0.0=ADC3_IN0,IN0 -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -PH1/OSC_OUT.Mode=HSE-External-Oscillator -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=3 -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -FREERTOS.configTOTAL_HEAP_SIZE=4096 -ProjectManager.ProjectName=Witch -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 -RCC.LSI_VALUE=32000 -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 -PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -VP_TIM13_VS_ClockSourceINT.Signal=TIM13_VS_ClockSourceINT +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS -PC4.Locked=true -PF0.Signal=FMC_A0 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 SH.FMC_NBL0.ConfNb=1 -PE3.Mode=SAI_B_SyncSlave -PC2.GPIO_Label=ADC2 -PB3.Locked=true -PB3.GPIO_Label=FLASH_SCK -SH.COMP_DAC1_group.0=DAC_OUT1,DAC_OUT1 -ADC3.DiscontinuousConvMode=DISABLE -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PA7.Mode=Full_Duplex_Master -PB9.GPIO_Label=SW4 -PC10.GPIO_Label=LEDSW2 -ProjectManager.NoMain=false -SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate -USB_DEVICE.VirtualModeFS=Audio_FS -USB_HOST.USBH_MAX_NUM_CONFIGURATION-AUDIO_HS=4 -PG1.Signal=FMC_A11 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE -PC8.GPIO_Label=LEDPWM2 -PC12.GPIOParameters=GPIO_Label -PF7.Mode=IN5 -SH.ADCx_IN12.0=ADC3_IN12,IN12 -ProjectManager.TargetToolchain=Makefile +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI1.0=GPIO_EXTI1 +SH.GPXTI1.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SH.S_TIM13_CH1.0=TIM13_CH1,PWM Generation1 CH1 +SH.S_TIM13_CH1.ConfNb=1 +SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 +SH.S_TIM1_CH1.ConfNb=1 +SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1 +SH.S_TIM3_CH1.ConfNb=1 +SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3 SH.S_TIM3_CH3.ConfNb=1 -SH.FMC_D1_DA1.ConfNb=1 -RCC.VcooutputI2SQ=96000000 -PF2.Signal=FMC_A2 -PC2.Locked=true -ProjectManager.RegisterCallBack= -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PB1.Locked=true -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH -PG9.GPIO_Label=SW3 -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -PH0/OSC_IN.Signal=RCC_OSC_IN -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=84000000 -SH.FMC_D13_DA13.ConfNb=1 -PF10.Signal=ADC3_IN8 -Dma.ADC3.2.MemInc=DMA_MINC_ENABLE -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=656.25 KBits/s -PA4.GPIOParameters=GPIO_Label -PE6.Signal=SPI4_MOSI -ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -Mcu.Name=STM32F427Z(G-I)Tx -PA2.Signal=ADCx_IN2 -PA13.GPIO_Label=SWDIO -PD14.Signal=FMC_D0_DA0 -PB3.Signal=SPI1_SCK -PA7.GPIO_Label=FLASH_MOSI -PA12.Mode=Device_Only -Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY -PC5.GPIO_Label=FLASH_nCS -ADC3.Rank-39\#ChannelRegularConversion=9 -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -PA14.Signal=SYS_JTCK-SWCLK -PB8.Signal=S_TIM4_CH3 -PE3.GPIO_Label=CS_SDOUT -PC9.Signal=S_TIM3_CH4 -RCC.APB1Freq_Value=42000000 -PB11.Locked=true -ProjectManager.DeviceId=STM32F427ZITx -ProjectManager.LibraryCopy=1 SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -ADC3.Rank-31\#ChannelRegularConversion=1 -PB1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PA7.Signal=SPI1_MOSI +SH.S_TIM3_CH4.ConfNb=1 +SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3 +SH.S_TIM4_CH3.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period +TIM1.Period=1023 +TIM1.Prescaler=100 +TIM13.Channel=TIM_CHANNEL_1 +TIM13.IPParameters=Channel,Prescaler,Period +TIM13.Period=1023 +TIM13.Prescaler=100 +TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation3 CH3,Channel-PWM Generation1 CH1,Prescaler,Period +TIM3.Period=1023 +TIM3.Prescaler=100 +TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM4.IPParameters=Channel-PWM Generation3 CH3,Prescaler,Period +TIM4.Period=1023 +TIM4.Prescaler=100 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Host_FS +USB_OTG_HS.VirtualMode-Host_FS=Host_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_TIM13_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM13_VS_ClockSourceINT.Signal=TIM13_VS_ClockSourceINT +board=Witch diff --git a/Wizard/Inc/hardware.h b/Wizard/Inc/hardware.h index 3a7190a8..0e8e6682 100644 --- a/Wizard/Inc/hardware.h +++ b/Wizard/Inc/hardware.h @@ -6,6 +6,8 @@ #define HARDWARE_VERSION "Wizard" /* #define FASCINATION_MACHINE */ +#define USE_SPI_FLASH + #ifndef OWL_EUROWIZARD #define USE_USBD_HS #define USBD_HANDLE hUsbDeviceHS @@ -23,11 +25,16 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_MODE_BUTTON #define MODE_BUTTON_PIN SW5_Pin diff --git a/Wizard/Inc/usbd_conf.h b/Wizard/Inc/usbd_conf.h index 0d55589d..41419242 100644 --- a/Wizard/Inc/usbd_conf.h +++ b/Wizard/Inc/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ diff --git a/Wizard/Makefile b/Wizard/Makefile index 36d82d3e..7f84f1c9 100644 --- a/Wizard/Makefile +++ b/Wizard/Makefile @@ -12,7 +12,7 @@ C_SRC += $(OPENWARE)/Source/usb_device.c C_SRC += $(OPENWARE)/Source/usbd_desc.c C_SRC += $(OPENWARE)/Source/usbd_conf.c C_SRC += $(OPENWARE)/Source/usbh_conf.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp include $(OPENWARE)/Hardware/sources.mk diff --git a/Wizard/Src/Wizard.cpp b/Wizard/Src/Wizard.cpp index 04e0ad2a..287ca5ab 100644 --- a/Wizard/Src/Wizard.cpp +++ b/Wizard/Src/Wizard.cpp @@ -78,11 +78,11 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* // } } -void setup(){ + +void onSetup(){ HAL_GPIO_WritePin(TRIG_OUT_GPIO_Port, TRIG_OUT_Pin, GPIO_PIN_RESET); // Trigger out off initLed(); setLed(0, NO_COLOUR); - owl.setup(); #ifdef USE_USB_HOST // enable USB Host power @@ -90,7 +90,7 @@ void setup(){ #endif } -void loop(void){ +void onLoop(){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ @@ -102,5 +102,4 @@ void loop(void){ } #endif owl_mode_button(); - owl.loop(); } diff --git a/Wizard/usbd-fs/usbh_conf.c b/Wizard/usbd-fs/usbh_conf.c index e25ce68c..5f98c60b 100644 --- a/Wizard/usbd-fs/usbh_conf.c +++ b/Wizard/usbd-fs/usbh_conf.c @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -156,14 +155,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Wizard/usbd-hs/usbh_conf.c b/Wizard/usbd-hs/usbh_conf.c index 4cf9fe87..8959765d 100644 --- a/Wizard/usbd-hs/usbh_conf.c +++ b/Wizard/usbd-hs/usbh_conf.c @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -156,14 +155,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Xibeca/Core/Inc/FreeRTOSConfig.h b/Xibeca/Core/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..36d0599c --- /dev/null +++ b/Xibeca/Core/Inc/FreeRTOSConfig.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/* + * FreeRTOS Kernel V10.2.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configENABLE_FPU 0 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Xibeca/Core/Inc/XibecaParameterController.hpp b/Xibeca/Core/Inc/XibecaParameterController.hpp new file mode 100644 index 00000000..7b87b44b --- /dev/null +++ b/Xibeca/Core/Inc/XibecaParameterController.hpp @@ -0,0 +1,211 @@ +#ifndef __XibecaParameterController_hpp__ +#define __XibecaParameterController_hpp__ + +#include +#include +#include "device.h" +#include "errorhandlers.h" +#include "ProgramVector.h" +#include "VersionToken.h" +#include "ScreenBuffer.h" +#include "Owl.h" +#include "ParameterController.hpp" +#ifdef USE_DIGITALBUS +#include "DigitalBusReader.h" +extern DigitalBusReader bus; +#endif + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif +#ifndef max +#define max(a,b) ((a)>(b)?(a):(b)) +#endif +#ifndef abs +#define abs(x) ((x)>0?(x):-(x)) +#endif + +extern VersionToken* bootloader_token; + +#define NOF_ENCODERS 4 + +void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); + +/* shows a single parameter selected and controlled with a single encoder + */ +class XibecaParameterController : public ParameterController { +public: + char title[11] = "Xibeca"; + int16_t encoders[NOF_ENCODERS]; // last seen encoder values + int16_t parameters[NOF_PARAMETERS]; + char names[NOF_PARAMETERS][12]; + int8_t selected = 0; + XibecaParameterController(){ + reset(); + } + void setTitle(const char* str){ + strncpy(title, str, 10); + } + void reset(){ + drawCallback = defaultDrawCallback; + for(int i=0; i 2) + screen.print(1, y-30, names[selected-3]); + if(selected > 1) + screen.print(1, y-20, names[selected-2]); + if(selected > 0) + screen.print(1, y-10, names[selected-1]); + screen.print(1, y, names[selected]); + if(selected < size-1) + screen.print(1, y+10, names[selected+1]); + if(selected < size-2) + screen.print(1, y+20, names[selected+2]); + if(selected < size-3) + screen.print(1, y+30, names[selected+3]); + screen.invert(0, y-9, screen.getWidth(), 10); + } + + void drawGlobalParameterNames(int y, ScreenBuffer& screen){ + drawParameterNames(y, 0, names, NOF_PARAMETERS, screen); + } + + void drawStats(ScreenBuffer& screen){ + screen.setTextSize(1); + ProgramVector* pv = getProgramVector(); + if(pv->message != NULL) + screen.print(2, 16, pv->message); + screen.print(2, 26, "cpu/mem: "); + float percent = (pv->cycles_per_block/pv->audio_blocksize) / (float)ARM_CYCLES_PER_SAMPLE; + screen.print((int)(percent*100)); + screen.print("% "); + screen.print((int)(pv->heap_bytes_used)/1024); + screen.print("kB"); + + // draw firmware version + screen.print(1, 36, getFirmwareVersion()); + if (bootloader_token->magic == BOOTLOADER_MAGIC){ + screen.print(" bt."); + screen.print(getBootloaderVersion()); + } +#ifdef USE_DIGITALBUS + screen.print(1, 56, "Bus: "); + screen.print(bus.getStatusString()); + screen.print(" "); + extern uint32_t bus_tx_packets, bus_rx_packets; + screen.print((int)bus_tx_packets); + screen.print("/"); + screen.print((int)bus_rx_packets); + if (bus.getStatus() == BUS_STATUS_CONNECTED) { + screen.print(", "); + screen.print(bus.getPeers()); + screen.print(" peers"); + } +#endif + } + + void updateEncoders(int16_t* data, uint8_t size){ + if(data[0] != encoders[0]){ + encoderChanged(0, data[0] - encoders[0]); + encoders[0] = data[0]; + } + if(data[1] != encoders[1]){ + encoderChanged(1, data[1] - encoders[1]); + encoders[1] = data[1]; + } + } + void encoderChanged(uint8_t encoder, int32_t delta){ + if(encoder == 0){ + if(sw2()){ + if(delta > 1) + selected = min(NOF_PARAMETERS-1, selected+1); + else if(delta < 1) + selected = max(0, selected-1); + }else{ + parameters[selected] += delta*10; + parameters[selected] = min(4095, max(0, parameters[selected])); + } + } // todo: change patch with enc1/sw1 + } + void setName(uint8_t pid, const char* name){ + if(pid < NOF_PARAMETERS) + strncpy(names[pid], name, 11); + } + uint8_t getSize(){ + return NOF_PARAMETERS; + } + void setValue(uint8_t ch, int16_t value){ + parameters[ch] = value; + } + + void drawMessage(int16_t y, ScreenBuffer& screen){ + ProgramVector* pv = getProgramVector(); + if(pv->message != NULL){ + screen.setTextSize(1); + screen.setTextWrap(true); + screen.print(0, y, pv->message); + screen.setTextWrap(false); + } + } + + void drawTitle(ScreenBuffer& screen){ + drawTitle(title, screen); + } + + void drawTitle(const char* title, ScreenBuffer& screen){ + // draw title + screen.setTextSize(2); + screen.print(1, 17, title); + } + + void setCallback(void *callback){ + if(callback == NULL) + drawCallback = defaultDrawCallback; + else + drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; + } + +private: + void (*drawCallback)(uint8_t*, uint16_t, uint16_t); + bool sw1(){ + return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) != GPIO_PIN_SET; + } + bool sw2(){ + return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) != GPIO_PIN_SET; + } +}; + +#endif // __XibecaParameterController_hpp__ diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h new file mode 100644 index 00000000..0f116bf4 --- /dev/null +++ b/Xibeca/Core/Inc/hardware.h @@ -0,0 +1,65 @@ +#include "main.h" +#include "stm32h7xx_hal.h" + +#define OWL_XIBECA +#define HARDWARE_ID XIBECA_HARDWARE +#define HARDWARE_VERSION "Xibeca" +/* #define NO_EXTERNAL_RAM */ +/* #define NO_CCM_RAM */ +#define DMA_RAM __attribute__ ((section (".dmadata"))) +#define USE_PLUS_RAM +/* #define USE_ICACHE */ +/* #define USE_DCACHE */ + +#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ +#define MAIN_LOOP_SLEEP_MS 20 + +#define USE_SCREEN +#define OLED_UPSIDE_DOWN +#define SSD1309 +#define SSD1306 +#define OLED_SPI hspi3 + +// todo: quad SPI +/* #define USE_SPI_FLASH */ + +#define USE_CODEC +#define USE_PCM3168A +/* #define CODEC_HP_FILTER */ +#define CODEC_SPI hspi2 + +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 8 +/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ +/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define USBD_AUDIO_RX_CHANNELS 4 +#define USBD_AUDIO_TX_CHANNELS 4 + +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_TX // microphone +/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_FS +#define USBD_HANDLE hUsbDeviceFS +/* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ + +/* #define USE_UART_MIDI_RX */ +/* #define USE_UART_MIDI_TX */ +/* #define UART_MIDI_HANDLE huart2 */ +/* #define UART_MIDI_RX_BUFFER_SIZE 256 */ + +#define AUDIO_SAMPLINGRATE 48000 + +#define USE_ADC +#define ADC_PERIPH hadc1 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 + +#define NOF_ADC_VALUES 4 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (2+4) diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h new file mode 100644 index 00000000..ee56745a --- /dev/null +++ b/Xibeca/Core/Inc/main.h @@ -0,0 +1,126 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define FLASH_DQ2_Pin GPIO_PIN_2 +#define FLASH_DQ2_GPIO_Port GPIOE +#define OLED_CS_Pin GPIO_PIN_14 +#define OLED_CS_GPIO_Port GPIOG +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC +#define EXTI13_Pin GPIO_PIN_13 +#define EXTI13_GPIO_Port GPIOC +#define EXTI13_EXTI_IRQn EXTI15_10_IRQn +#define EXTI14_Pin GPIO_PIN_14 +#define EXTI14_GPIO_Port GPIOC +#define EXTI14_EXTI_IRQn EXTI15_10_IRQn +#define FLASH_NCS_Pin GPIO_PIN_6 +#define FLASH_NCS_GPIO_Port GPIOG +#define FLASH_DQ3_Pin GPIO_PIN_6 +#define FLASH_DQ3_GPIO_Port GPIOF +#define ADC_RST_Pin GPIO_PIN_3 +#define ADC_RST_GPIO_Port GPIOG +#define FLASH_CLK_Pin GPIO_PIN_10 +#define FLASH_CLK_GPIO_Port GPIOF +#define FLASH_DQ1_Pin GPIO_PIN_9 +#define FLASH_DQ1_GPIO_Port GPIOF +#define FLASH_DQ0_Pin GPIO_PIN_8 +#define FLASH_DQ0_GPIO_Port GPIOF +#define ADC1_Pin GPIO_PIN_0 +#define ADC1_GPIO_Port GPIOC +#define ADC5_Pin GPIO_PIN_1 +#define ADC5_GPIO_Port GPIOC +#define ADC_SPI_MISO_Pin GPIO_PIN_2 +#define ADC_SPI_MISO_GPIO_Port GPIOC +#define ADC_SPI_MOSI_Pin GPIO_PIN_3 +#define ADC_SPI_MOSI_GPIO_Port GPIOC +#define OLED_RST_Pin GPIO_PIN_4 +#define OLED_RST_GPIO_Port GPIOA +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOA +#define ADC4_Pin GPIO_PIN_5 +#define ADC4_GPIO_Port GPIOC +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOB +#define ADC7_Pin GPIO_PIN_0 +#define ADC7_GPIO_Port GPIOB +#define ADC_SPI_CLK_Pin GPIO_PIN_10 +#define ADC_SPI_CLK_GPIO_Port GPIOB +#define ADC_SPI_NCS_Pin GPIO_PIN_11 +#define ADC_SPI_NCS_GPIO_Port GPIOB +/* USER CODE BEGIN Private defines */ + +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC + +#define ADC_NCS_Pin ADC_SPI_NCS_Pin +#define ADC_NCS_GPIO_Port ADC_SPI_NCS_GPIO_Port + +#define ADC_RESET_Pin ADC_RST_Pin +#define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Inc/stm32h7xx_hal_conf.h b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h new file mode 100644 index 00000000..6348633e --- /dev/null +++ b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_CONF_H +#define STM32H7xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_FDCAN_MODULE_ENABLED */ +/* #define HAL_FMAC_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +/* #define HAL_CORDIC_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_OTFDEC_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_HRTIM_MODULE_ENABLED */ +/* #define HAL_HSEM_MODULE_ENABLED */ +/* #define HAL_GFXMMU_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_OPAMP_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +#define HAL_LPTIM_MODULE_ENABLED +/* #define HAL_LTDC_MODULE_ENABLED */ +#define HAL_QSPI_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/* #define HAL_SWPMI_MODULE_ENABLED */ +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_MDIOS_MODULE_ENABLED */ +/* #define HAL_PSSI_MODULE_ENABLED */ +/* #define HAL_DTS_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_MDMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_HSEM_MODULE_ENABLED + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal oscillator (CSI) default value. + * This value is the default CSI value after Reset. + */ +#if !defined (CSI_VALUE) + #define CSI_VALUE (4000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (64000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSI_VALUE) + #define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000UL /*!< Value of the External clock in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define USE_SD_TRANSCEIVER 0U /*!< use uSD Transceiver */ +#define USE_SPI_CRC 0U /*!< use CRC in SPI */ + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U /* CORDIC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_DTS_REGISTER_CALLBACKS 0U /* DTS register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ +#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U /* FMAC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U /* GFXMMU register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U /* OSPI register callback disabled */ +#define USE_HAL_OTFDEC_REGISTER_CALLBACKS 0U /* OTFDEC register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################### Ethernet Configuration ######################### */ +#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ +#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ + +#define ETH_MAC_ADDR0 (0x02UL) +#define ETH_MAC_ADDR1 (0x00UL) +#define ETH_MAC_ADDR2 (0x00UL) +#define ETH_MAC_ADDR3 (0x00UL) +#define ETH_MAC_ADDR4 (0x00UL) +#define ETH_MAC_ADDR5 (0x00UL) + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32h7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32h7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32h7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_MDMA_MODULE_ENABLED + #include "stm32h7xx_hal_mdma.h" +#endif /* HAL_MDMA_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32h7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32h7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32h7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32h7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32h7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DTS_MODULE_ENABLED + #include "stm32h7xx_hal_dts.h" +#endif /* HAL_DTS_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32h7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32h7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32h7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32h7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED + #include "stm32h7xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32h7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32h7xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CORDIC_MODULE_ENABLED + #include "stm32h7xx_hal_cordic.h" +#endif /* HAL_CORDIC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32h7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32h7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32h7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32h7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32h7xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FMAC_MODULE_ENABLED + #include "stm32h7xx_hal_fmac.h" +#endif /* HAL_FMAC_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32h7xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_HSEM_MODULE_ENABLED + #include "stm32h7xx_hal_hsem.h" +#endif /* HAL_HSEM_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32h7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32h7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32h7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32h7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32h7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED + #include "stm32h7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED + #include "stm32h7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32h7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32h7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32h7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32h7xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32h7xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_OTFDEC_MODULE_ENABLED +#include "stm32h7xx_hal_otfdec.h" +#endif /* HAL_OTFDEC_MODULE_ENABLED */ + +#ifdef HAL_PSSI_MODULE_ENABLED + #include "stm32h7xx_hal_pssi.h" +#endif /* HAL_PSSI_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32h7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32h7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RAMECC_MODULE_ENABLED + #include "stm32h7xx_hal_ramecc.h" +#endif /* HAL_RAMECC_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32h7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32h7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32h7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32h7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32h7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32h7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32h7xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32h7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32h7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32h7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32h7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32h7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32h7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32h7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32h7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32h7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h new file mode 100644 index 00000000..8bfa4d85 --- /dev/null +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -0,0 +1,74 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32H7xx_IT_H +#define __STM32H7xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void SysTick_Handler(void); +void EXTI2_IRQHandler(void); +void DMA1_Stream0_IRQHandler(void); +void DMA1_Stream1_IRQHandler(void); +void DMA1_Stream2_IRQHandler(void); +void DMA1_Stream3_IRQHandler(void); +void ADC_IRQHandler(void); +void EXTI9_5_IRQHandler(void); +void TIM4_IRQHandler(void); +void EXTI15_10_IRQHandler(void); +void SPI3_IRQHandler(void); +void SAI1_IRQHandler(void); +void QUADSPI_IRQHandler(void); +void OTG_FS_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32H7xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp new file mode 100644 index 00000000..826b53ec --- /dev/null +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -0,0 +1,329 @@ +#include "Owl.h" +#include "device.h" +#include "errorhandlers.h" +#include "Pin.h" +#include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" +#include "XibecaParameterController.hpp" +#include "message.h" + +#if 0 +#define XIBECA_PIN3 GPIOD, GPIO_PIN_2 +#define XIBECA_PIN4 GPIOG, GPIO_PIN_10 +#define XIBECA_PIN5 GPIOC, GPIO_PIN_9 +#define XIBECA_PIN6 GPIOC, GPIO_PIN_8 +#define XIBECA_PIN7 GPIOC, GPIO_PIN_13 +#define XIBECA_PIN8 GPIOI, GPIO_PIN_11 +#define XIBECA_PIN9 GPIOC, GPIO_PIN_14 +#define XIBECA_PIN10 GPIOA, GPIO_PIN_0 +#define XIBECA_PIN11 GPIOH, GPIO_PIN_4 +#define XIBECA_PIN12 GPIOC, GPIO_PIN_15 +#define XIBECA_PIN13 GPIOA, GPIO_PIN_7 +#define XIBECA_PIN14 GPIOA, GPIO_PIN_3 + +#define PUSH_A_Pin GPIO_PIN_0 +#define PUSH_A_GPIO_Port GPIOA +#define PUSH_B_Pin GPIO_PIN_4 +#define PUSH_B_GPIO_Port GPIOB +#define PUSH_C_Pin GPIO_PIN_6 +#define PUSH_C_GPIO_Port GPIOA +#define PUSH_D_Pin GPIO_PIN_4 +#define PUSH_D_GPIO_Port GPIOC + +#define PUSH_TUNE_Pin GPIO_PIN_10 +#define PUSH_TUNE_GPIO_Port GPIOG +#define PUSH_MOD_Pin GPIO_PIN_15 +#define PUSH_MOD_GPIO_Port GPIOC +#define PUSH_NOTES_Pin GPIO_PIN_13 +#define PUSH_NOTES_GPIO_Port GPIOB +#define PUSH_CV_Pin GPIO_PIN_14 +#define PUSH_CV_GPIO_Port GPIOB +#endif + +#define SYNC_OUT_A_Pin GPIO_PIN_2 +#define SYNC_OUT_A_GPIO_Port GPIOD +#define SYNC_OUT_B_Pin GPIO_PIN_9 +#define SYNC_OUT_B_GPIO_Port GPIOC +#define SYNC_OUT_C_Pin GPIO_PIN_13 +#define SYNC_OUT_C_GPIO_Port GPIOC +#define SYNC_OUT_D_Pin GPIO_PIN_14 +#define SYNC_OUT_D_GPIO_Port GPIOC + +#ifdef USE_SCREEN +#include "Graphics.h" +Graphics graphics; +#endif +static XibecaParameterController params; + +#define ENCODER_TIM1 htim4 +extern TIM_HandleTypeDef ENCODER_TIM1; + +// void updateEncoders(){ +// static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; +// int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); +// int16_t delta = value - encoder_values[0]; +// if(delta) +// graphics.params.encoderChanged(0, delta); +// encoder_values[0] = value; +// value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM2); +// delta = value - encoder_values[1]; +// if(delta) +// graphics.params.encoderChanged(1, delta); +// encoder_values[1] = value; +// } +// updateEncoders(); + +extern "C" void onResourceUpdate(void); + +void onResourceUpdate(void){ +} + +Pin led_tune(GPIOC, GPIO_PIN_8); +Pin led_mod(GPIOA, GPIO_PIN_3); +Pin led_notes(GPIOA, GPIO_PIN_7); +Pin led_cv(GPIOH, GPIO_PIN_4); +Pin led_a(GPIOI, GPIO_PIN_11); +Pin led_b(GPIOG, GPIO_PIN_13); +Pin led_c(GPIOA, GPIO_PIN_5); +Pin led_d(GPIOB, GPIO_PIN_0); +Pin led_options(GPIOB, GPIO_PIN_6); + +Pin push_tune(GPIOG, GPIO_PIN_10); +Pin push_mod(GPIOC, GPIO_PIN_15); +Pin push_notes(GPIOB, GPIO_PIN_13); +Pin push_cv(GPIOB, GPIO_PIN_14); +Pin push_a(GPIOA, GPIO_PIN_0); +Pin push_b(GPIOB, GPIO_PIN_4); +Pin push_c(GPIOA, GPIO_PIN_6); +Pin push_d(GPIOC, GPIO_PIN_4); +Pin push_options(GPIOB, GPIO_PIN_5); +Pin push_enc(GPIOB, GPIO_PIN_12); + +// Pin led_d(PIN30_GPIO_Port, PIN30_Pin); +// Pin led_d(XIBECA_PIN30); + +// Pin hard_sync_a(PIN17_GPIO_Port, PIN17_Pin); +// Pin hard_sync_b(PIN19_GPIO_Port, PIN19_Pin); +// Pin hard_sync_c(PIN21_GPIO_Port, PIN21_Pin); +// Pin hard_sync_d(PIN22_GPIO_Port, PIN22_Pin); + +Pin hard_sync_a(GPIOG, GPIO_PIN_12); +Pin hard_sync_b(GPIOA, GPIO_PIN_15); +Pin hard_sync_c(GPIOC, GPIO_PIN_6); +Pin hard_sync_d(GPIOD, GPIO_PIN_7); + +void setLed(uint8_t led, uint32_t rgb){ + bool value = rgb; + switch(led){ + case 1: + led_tune.set(value); + break; + case 2: + led_mod.set(value); + break; + case 3: + led_notes.set(value); + break; + case 4: + led_cv.set(value); + break; + case 5: + led_a.set(value); + break; + case 6: + led_b.set(value); + break; + case 7: + led_c.set(value); + break; + case 8: + led_d.set(value); + break; + case 9: + led_options.set(value); + break; + } +} + +uint16_t adc = 0; +extern "C"{ + void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ + adc = hadc->State; + // + } + void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc){ + error(CONFIG_ERROR, "ADC error"); + } +} + +#define MIN_PERIOD ((AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / 32000) +#define MAX_PERIOD ((AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / 20) +static uint32_t periods[4] = {}; +void updatePeriod(uint8_t idx){ + static uint32_t times[4] = {}; + uint32_t previous = times[idx]; + uint32_t now = DWT->CYCCNT; + if(now > previous){ + uint32_t elapsed = now - previous; + if(elapsed > MIN_PERIOD && elapsed < MAX_PERIOD){ + periods[idx] = elapsed; + // AUDIO_SAMPLINGRATE + // ARM_CYCLES_PER_SAMPLE + setParameterValue(PARAMETER_BB + idx, (AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / elapsed); + // led_tune.toggle(); + } + } + times[idx] = now; +} + +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; +} + +void onChangePin(uint16_t pin){ + switch(pin){ + // case PUSH_TUNE_Pin: + // break; + // case PUSH_MOD_Pin: + // break; + // case PUSH_NOTES_Pin: + // break; + // case PUSH_CV_Pin: + // break; + // case PUSH_A_Pin: + // break; + // case PUSH_B_Pin: + // break; + // case PUSH_C_Pin: + // break; + // case PUSH_D_Pin: + // break; + case SYNC_OUT_A_Pin: + updatePeriod(0); + break; + case SYNC_OUT_B_Pin: + updatePeriod(1); + break; + case SYNC_OUT_C_Pin: + updatePeriod(2); + break; + case SYNC_OUT_D_Pin: + updatePeriod(3); + break; + } +} + +void setGateValue(uint8_t ch, int16_t value){ + int idx = 1 + ch - BUTTON_A; + setLed(idx, value ? RED_COLOUR : NO_COLOUR); + switch(ch){ + case BUTTON_E: + hard_sync_a.set(value ? true : false); + break; + case BUTTON_F: + hard_sync_b.set(value ? true : false); + break; + case BUTTON_G: + hard_sync_c.set(value ? true : false); + break; + case BUTTON_H: + hard_sync_d.set(value ? true : false); + break; + } + // switch(ch){ + // setLed(1, value ? RED_COLOUR : NO_COLOUR); + // break; + // case BUTTON_B: + // setLed(2, value ? RED_COLOUR : NO_COLOUR); + // break; + // case BUTTON_C: + // setLed(3, value ? RED_COLOUR : NO_COLOUR); + // break; + // case BUTTON_D: + // setLed(4, value ? RED_COLOUR : NO_COLOUR); + // break; + // } +} + +void setup(){ + // DWT cycle count enable + // do it here because DEBUG_DWT is disabled + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + DWT->CYCCNT = 0; + DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; + + // __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); + __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, 2048); + HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); + + led_tune.outputMode(); + led_mod.outputMode(); + led_notes.outputMode(); + led_cv.outputMode(); + led_a.outputMode(); + led_b.outputMode(); + led_c.outputMode(); + led_d.outputMode(); + led_options.outputMode(); + + hard_sync_a.outputMode(); + hard_sync_b.outputMode(); + hard_sync_c.outputMode(); + hard_sync_d.outputMode(); + + push_tune.inputMode(); + push_mod.inputMode(); + push_notes.inputMode(); + push_cv.inputMode(); + push_a.inputMode(); + push_b.inputMode(); + push_c.inputMode(); + push_d.inputMode(); + push_options.inputMode(); + push_enc.inputMode(); + + push_tune.setPull(PIN_PULL_UP); + push_mod.setPull(PIN_PULL_UP); + push_notes.setPull(PIN_PULL_UP); + push_cv.setPull(PIN_PULL_UP); + push_a.setPull(PIN_PULL_UP); + push_b.setPull(PIN_PULL_UP); + push_c.setPull(PIN_PULL_UP); + push_d.setPull(PIN_PULL_UP); + push_options.setPull(PIN_PULL_UP); + push_enc.setPull(PIN_PULL_UP); + +#ifdef USE_SCREEN + HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off + extern SPI_HandleTypeDef OLED_SPI; + graphics.begin(¶ms, &OLED_SPI); +#endif + + owl.setup(); +} + +void loop(void){ + + led_tune.set(!push_tune.get()); + led_mod.set(!push_mod.get()); + led_notes.set(!push_notes.get()); + led_cv.set(!push_cv.get()); + led_options.set(!push_options.get()); + led_a.set(!push_a.get()); + led_b.set(!push_b.get()); + led_c.set(!push_c.get()); + led_d.set(!push_d.get()); + + setButtonValue(BUTTON_A, !push_enc.get()); + setParameterValue(PARAMETER_BA, __HAL_TIM_GET_COUNTER(&ENCODER_TIM1) / 2); + +#ifdef USE_SCREEN + graphics.draw(); + graphics.display(); +#endif /* USE_SCREEN */ + + owl.loop(); +} diff --git a/Xibeca/Core/Src/freertos.c b/Xibeca/Core/Src/freertos.c new file mode 100644 index 00000000..4a5debed --- /dev/null +++ b/Xibeca/Core/Src/freertos.c @@ -0,0 +1,106 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c new file mode 100644 index 00000000..1ffdf427 --- /dev/null +++ b/Xibeca/Core/Src/main.c @@ -0,0 +1,1223 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" +#include "usb_device.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "device.h" +#include "errorhandlers.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc1; +DMA_HandleTypeDef hdma_adc1; + +LPTIM_HandleTypeDef hlptim1; + +QSPI_HandleTypeDef hqspi; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi2; +SPI_HandleTypeDef hspi3; +DMA_HandleTypeDef hdma_spi3_tx; + +TIM_HandleTypeDef htim2; +TIM_HandleTypeDef htim3; +TIM_HandleTypeDef htim4; + +UART_HandleTypeDef huart5; +UART_HandleTypeDef huart7; + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +void PeriphCommonClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_QUADSPI_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_ADC1_Init(void); +static void MX_SPI2_Init(void); +static void MX_SPI3_Init(void); +static void MX_TIM2_Init(void); +static void MX_TIM3_Init(void); +static void MX_TIM4_Init(void); +static void MX_UART5_Init(void); +static void MX_UART7_Init(void); +static void MX_LPTIM1_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +void setup(void); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif +#ifdef USE_ICACHE + /* Enable I-Cache-------------------------------------------------------------*/ + /* After reset, you must invalidate each cache before enabling (SCB_EnableICache) it. */ + SCB_InvalidateICache(); + SCB_EnableICache(); +#endif +#ifdef USE_DCACHE + /* Enable D-Cache-------------------------------------------------------------*/ + /* Before enabling the data cache, you must invalidate the entire data cache (SCB_InvalidateDCache), because external memory might have changed from when the cache was disabled. */ + SCB_InvalidateDCache(); + SCB_EnableDCache(); +#endif + + /* Enable D2 domain SRAM Clocks */ + /* presumably done in SystemInit by setting DATA_IN_D2_SRAM ? */ + /* should be started before libc_init_array and LoopCopyData in startup.s */ + /* __HAL_RCC_D2SRAM1_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM2_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM3_CLK_ENABLE(); */ + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_QUADSPI_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_ADC1_Init(); + MX_SPI2_Init(); + MX_SPI3_Init(); + MX_TIM2_Init(); + MX_TIM3_Init(); + MX_TIM4_Init(); + MX_UART5_Init(); + MX_UART7_Init(); + MX_LPTIM1_Init(); + /* USER CODE BEGIN 2 */ + +#ifdef USE_EXTERNAL_RAM + SDRAM_Initialization_Sequence(&hsdram1); +#endif + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 1024); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Supply configuration update enable + */ + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); + + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Macro to configure the PLL clock source + */ + __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 1; + RCC_OscInitStruct.PLL.PLLN = 120; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 5; + RCC_OscInitStruct.PLL.PLLR = 2; + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 + |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1|RCC_PERIPHCLK_SPI3 + |RCC_PERIPHCLK_SPI2; + PeriphClkInitStruct.PLL2.PLL2M = 1; + PeriphClkInitStruct.PLL2.PLL2N = 18; + PeriphClkInitStruct.PLL2.PLL2P = 6; + PeriphClkInitStruct.PLL2.PLL2Q = 2; + PeriphClkInitStruct.PLL2.PLL2R = 2; + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 6144; + PeriphClkInitStruct.PLL3.PLL3M = 7; + PeriphClkInitStruct.PLL3.PLL3N = 172; + PeriphClkInitStruct.PLL3.PLL3P = 2; + PeriphClkInitStruct.PLL3.PLL3Q = 2; + PeriphClkInitStruct.PLL3.PLL3R = 2; + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC1 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC1_Init(void) +{ + + /* USER CODE BEGIN ADC1_Init 0 */ + + /* USER CODE END ADC1_Init 0 */ + + ADC_MultiModeTypeDef multimode = {0}; + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC1_Init 1 */ + + /* USER CODE END ADC1_Init 1 */ + /** Common config + */ + hadc1.Instance = ADC1; + hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; + hadc1.Init.LowPowerAutoWait = DISABLE; + hadc1.Init.ContinuousConvMode = ENABLE; + hadc1.Init.NbrOfConversion = 4; + hadc1.Init.DiscontinuousConvMode = DISABLE; + hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR; + hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; + hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; + hadc1.Init.OversamplingMode = DISABLE; + if (HAL_ADC_Init(&hadc1) != HAL_OK) + { + Error_Handler(); + } + /** Configure the ADC multi-mode + */ + multimode.Mode = ADC_MODE_INDEPENDENT; + if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_10; + sConfig.Rank = ADC_REGULAR_RANK_1; + sConfig.SamplingTime = ADC_SAMPLETIME_387CYCLES_5; + sConfig.SingleDiff = ADC_SINGLE_ENDED; + sConfig.OffsetNumber = ADC_OFFSET_NONE; + sConfig.Offset = 0; + sConfig.OffsetSignedSaturation = DISABLE; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_14; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_5; + sConfig.Rank = ADC_REGULAR_RANK_3; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_8; + sConfig.Rank = ADC_REGULAR_RANK_4; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC1_Init 2 */ + + /* USER CODE END ADC1_Init 2 */ + +} + +/** + * @brief LPTIM1 Initialization Function + * @param None + * @retval None + */ +static void MX_LPTIM1_Init(void) +{ + + /* USER CODE BEGIN LPTIM1_Init 0 */ + + /* USER CODE END LPTIM1_Init 0 */ + + /* USER CODE BEGIN LPTIM1_Init 1 */ + + /* USER CODE END LPTIM1_Init 1 */ + hlptim1.Instance = LPTIM1; + hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; + hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; + hlptim1.Init.UltraLowPowerClock.Polarity = LPTIM_CLOCKPOLARITY_RISING; + hlptim1.Init.UltraLowPowerClock.SampleTime = LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION; + hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; + hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH; + hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; + hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL; + hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; + hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; + if (HAL_LPTIM_Init(&hlptim1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN LPTIM1_Init 2 */ + + /* USER CODE END LPTIM1_Init 2 */ + +} + +/** + * @brief QUADSPI Initialization Function + * @param None + * @retval None + */ +static void MX_QUADSPI_Init(void) +{ + + /* USER CODE BEGIN QUADSPI_Init 0 */ + + /* USER CODE END QUADSPI_Init 0 */ + + /* USER CODE BEGIN QUADSPI_Init 1 */ + + /* USER CODE END QUADSPI_Init 1 */ + /* QUADSPI parameter configuration*/ + hqspi.Instance = QUADSPI; + hqspi.Init.ClockPrescaler = 9; + hqspi.Init.FifoThreshold = 4; + hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; + hqspi.Init.FlashSize = 22; + hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; + hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; + hqspi.Init.FlashID = QSPI_FLASH_ID_1; + hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; + if (HAL_QSPI_Init(&hqspi) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN QUADSPI_Init 2 */ + + /* USER CODE END QUADSPI_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_RX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; + hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.PdmInit.Activation = DISABLE; + hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockA1.FrameInit.FrameLength = 256; + hsai_BlockA1.FrameInit.ActiveFrameLength = 128; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 8; + hsai_BlockA1.SlotInit.SlotActive = 0x0000FFFF; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + hsai_BlockB1.Init.PdmInit.Activation = DISABLE; + hsai_BlockB1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockB1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockB1.FrameInit.FrameLength = 256; + hsai_BlockB1.FrameInit.ActiveFrameLength = 128; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 8; + hsai_BlockB1.SlotInit.SlotActive = 0x0000FFFF; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI2 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI2_Init(void) +{ + + /* USER CODE BEGIN SPI2_Init 0 */ + + /* USER CODE END SPI2_Init 0 */ + + /* USER CODE BEGIN SPI2_Init 1 */ + + /* USER CODE END SPI2_Init 1 */ + /* SPI2 parameter configuration*/ + hspi2.Instance = SPI2; + hspi2.Init.Mode = SPI_MODE_MASTER; + hspi2.Init.Direction = SPI_DIRECTION_2LINES; + hspi2.Init.DataSize = SPI_DATASIZE_8BIT; + hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH; + hspi2.Init.CLKPhase = SPI_PHASE_2EDGE; + hspi2.Init.NSS = SPI_NSS_SOFT; + hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; + hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi2.Init.TIMode = SPI_TIMODE_DISABLE; + hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi2.Init.CRCPolynomial = 0x0; + hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI2_Init 2 */ + + /* USER CODE END SPI2_Init 2 */ + +} + +/** + * @brief SPI3 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI3_Init(void) +{ + + /* USER CODE BEGIN SPI3_Init 0 */ + + /* USER CODE END SPI3_Init 0 */ + + /* USER CODE BEGIN SPI3_Init 1 */ + + /* USER CODE END SPI3_Init 1 */ + /* SPI3 parameter configuration*/ + hspi3.Instance = SPI3; + hspi3.Init.Mode = SPI_MODE_MASTER; + hspi3.Init.Direction = SPI_DIRECTION_2LINES_TXONLY; + hspi3.Init.DataSize = SPI_DATASIZE_8BIT; + hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi3.Init.NSS = SPI_NSS_SOFT; + hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; + hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi3.Init.TIMode = SPI_TIMODE_DISABLE; + hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi3.Init.CRCPolynomial = 0x0; + hspi3.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi3) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI3_Init 2 */ + + /* USER CODE END SPI3_Init 2 */ + +} + +/** + * @brief TIM2 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM2_Init(void) +{ + + /* USER CODE BEGIN TIM2_Init 0 */ + + /* USER CODE END TIM2_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM2_Init 1 */ + + /* USER CODE END TIM2_Init 1 */ + htim2.Instance = TIM2; + htim2.Init.Prescaler = 0; + htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + htim2.Init.Period = 4294967295; + htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM2_Init 2 */ + + /* USER CODE END TIM2_Init 2 */ + +} + +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 0; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 65535; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + +} + +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 0; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 65535; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI12; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 4; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 4; + if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + +} + +/** + * @brief UART5 Initialization Function + * @param None + * @retval None + */ +static void MX_UART5_Init(void) +{ + + /* USER CODE BEGIN UART5_Init 0 */ + + /* USER CODE END UART5_Init 0 */ + + /* USER CODE BEGIN UART5_Init 1 */ + + /* USER CODE END UART5_Init 1 */ + huart5.Instance = UART5; + huart5.Init.BaudRate = 115200; + huart5.Init.WordLength = UART_WORDLENGTH_8B; + huart5.Init.StopBits = UART_STOPBITS_1; + huart5.Init.Parity = UART_PARITY_NONE; + huart5.Init.Mode = UART_MODE_TX_RX; + huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart5.Init.OverSampling = UART_OVERSAMPLING_16; + huart5.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart5.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart5.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart5) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart5, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart5, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart5) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART5_Init 2 */ + + /* USER CODE END UART5_Init 2 */ + +} + +/** + * @brief UART7 Initialization Function + * @param None + * @retval None + */ +static void MX_UART7_Init(void) +{ + + /* USER CODE BEGIN UART7_Init 0 */ + + /* USER CODE END UART7_Init 0 */ + + /* USER CODE BEGIN UART7_Init 1 */ + + /* USER CODE END UART7_Init 1 */ + huart7.Instance = UART7; + huart7.Init.BaudRate = 115200; + huart7.Init.WordLength = UART_WORDLENGTH_8B; + huart7.Init.StopBits = UART_STOPBITS_1; + huart7.Init.Parity = UART_PARITY_NONE; + huart7.Init.Mode = UART_MODE_TX_RX; + huart7.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart7.Init.OverSampling = UART_OVERSAMPLING_16; + huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart7.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart7) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart7, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart7, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart7) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART7_Init 2 */ + + /* USER CODE END UART7_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA1_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA1_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn); + /* DMA1_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); + /* DMA1_Stream2_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); + /* DMA1_Stream3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK1; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; // 8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; // 1; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + /* hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; // PERIOD_2; */ + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; // DISABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; // 16; + SdramTiming.ExitSelfRefreshDelay = 7; // 16; + SdramTiming.SelfRefreshTime = 4; // 16; + SdramTiming.RowCycleDelay = 8; // 16; + SdramTiming.WriteRecoveryTime = 3; // 16; + SdramTiming.RPDelay = 1; // 0 causes assertion error; // 16; + SdramTiming.RCDDelay = 10; // 16; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOI_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOG, OLED_CS_Pin|ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOI, GPIO_PIN_11, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOA, OLED_RST_Pin|GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PB8 PB4 PB9 PB2 + PB12 PB13 PB14 PB15 */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_CS_Pin */ + GPIO_InitStruct.Pin = OLED_CS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_CS_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PG13 PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pins : PD7 PD6 PD5 PD4 + PD3 PD11 */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_3|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pin : PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : PG10 */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_DC_Pin */ + GPIO_InitStruct.Pin = OLED_DC_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 PC8 */ + GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9|GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PI8 */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /*Configure GPIO pin : PD2 */ + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PA10 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_5; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : PI11 */ + GPIO_InitStruct.Pin = GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /*Configure GPIO pin : PC15 */ + GPIO_InitStruct.Pin = GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PH4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_RST_Pin */ + GPIO_InitStruct.Pin = ADC_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PH6 PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pins : PA0 PA6 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_RST_Pin */ + GPIO_InitStruct.Pin = OLED_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PA3 PA7 */ + GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_SPI_NCS_Pin */ + GPIO_InitStruct.Pin = ADC_SPI_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_SPI_NCS_GPIO_Port, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + /* USER CODE BEGIN 5 */ + + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + } + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/startup_stm32h743xx.s b/Xibeca/Core/Src/startup_stm32h743xx.s new file mode 100644 index 00000000..2b1034a6 --- /dev/null +++ b/Xibeca/Core/Src/startup_stm32h743xx.s @@ -0,0 +1,749 @@ +/** + ****************************************************************************** + * @file startup_stm32h743xx.s + * @author MCD Application Team + * @brief STM32H743xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Call the clock system intitialization function.*/ + bl SystemInit + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word RNG_IRQHandler /* Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word SAI2_IRQHandler /* SAI2 */ + .word QUADSPI_IRQHandler /* QUADSPI */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word OTG_FS_EP1_OUT_IRQHandler /* USB OTG FS End Point 1 Out */ + .word OTG_FS_EP1_IN_IRQHandler /* USB OTG FS End Point 1 In */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word HRTIM1_Master_IRQHandler /* HRTIM Master Timer global Interrupt */ + .word HRTIM1_TIMA_IRQHandler /* HRTIM Timer A global Interrupt */ + .word HRTIM1_TIMB_IRQHandler /* HRTIM Timer B global Interrupt */ + .word HRTIM1_TIMC_IRQHandler /* HRTIM Timer C global Interrupt */ + .word HRTIM1_TIMD_IRQHandler /* HRTIM Timer D global Interrupt */ + .word HRTIM1_TIME_IRQHandler /* HRTIM Timer E global Interrupt */ + .word HRTIM1_FLT_IRQHandler /* HRTIM Fault global Interrupt */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word SAI3_IRQHandler /* SAI3 global Interrupt */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word JPEG_IRQHandler /* JPEG global Interrupt */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak RNG_IRQHandler + .thumb_set RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak SAI2_IRQHandler + .thumb_set SAI2_IRQHandler,Default_Handler + + .weak QUADSPI_IRQHandler + .thumb_set QUADSPI_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_OUT_IRQHandler + .thumb_set OTG_FS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_IN_IRQHandler + .thumb_set OTG_FS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak HRTIM1_Master_IRQHandler + .thumb_set HRTIM1_Master_IRQHandler,Default_Handler + + .weak HRTIM1_TIMA_IRQHandler + .thumb_set HRTIM1_TIMA_IRQHandler,Default_Handler + + .weak HRTIM1_TIMB_IRQHandler + .thumb_set HRTIM1_TIMB_IRQHandler,Default_Handler + + .weak HRTIM1_TIMC_IRQHandler + .thumb_set HRTIM1_TIMC_IRQHandler,Default_Handler + + .weak HRTIM1_TIMD_IRQHandler + .thumb_set HRTIM1_TIMD_IRQHandler,Default_Handler + + .weak HRTIM1_TIME_IRQHandler + .thumb_set HRTIM1_TIME_IRQHandler,Default_Handler + + .weak HRTIM1_FLT_IRQHandler + .thumb_set HRTIM1_FLT_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SAI3_IRQHandler + .thumb_set SAI3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak JPEG_IRQHandler + .thumb_set JPEG_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c new file mode 100644 index 00000000..3bb186c8 --- /dev/null +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -0,0 +1,1250 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_hal_msp.c + * @brief This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc1; + +extern DMA_HandleTypeDef hdma_spi3_tx; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ +/** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspInit 0 */ + + /* USER CODE END ADC1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC12_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PA2 ------> ADC1_INP14 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + GPIO_InitStruct.Pin = ADC1_Pin|ADC5_Pin|ADC4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADC2_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC3_Pin|ADC7_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* ADC1 DMA Init */ + /* ADC1 Init */ + hdma_adc1.Instance = DMA1_Stream3; + hdma_adc1.Init.Request = DMA_REQUEST_ADC1; + hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc1.Init.Mode = DMA_CIRCULAR; + hdma_adc1.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC1_MspInit 1 */ + + /* USER CODE END ADC1_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ + + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC12_CLK_DISABLE(); + + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PA2 ------> ADC1_INP14 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC5_Pin|ADC4_Pin); + + HAL_GPIO_DeInit(ADC2_GPIO_Port, ADC2_Pin); + + HAL_GPIO_DeInit(GPIOB, ADC3_Pin|ADC7_Pin); + + /* ADC1 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ + } + +} + +/** +* @brief LPTIM MSP Initialization +* This function configures the hardware resources used in this example +* @param hlptim: LPTIM handle pointer +* @retval None +*/ +void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hlptim->Instance==LPTIM1) + { + /* USER CODE BEGIN LPTIM1_MspInit 0 */ + + /* USER CODE END LPTIM1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1; + PeriphClkInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_LPTIM1_CLK_ENABLE(); + + __HAL_RCC_GPIOG_CLK_ENABLE(); + /**LPTIM1 GPIO Configuration + PG12 ------> LPTIM1_IN1 + PG11 ------> LPTIM1_IN2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_LPTIM1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* USER CODE BEGIN LPTIM1_MspInit 1 */ + + /* USER CODE END LPTIM1_MspInit 1 */ + } + +} + +/** +* @brief LPTIM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hlptim: LPTIM handle pointer +* @retval None +*/ +void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* hlptim) +{ + if(hlptim->Instance==LPTIM1) + { + /* USER CODE BEGIN LPTIM1_MspDeInit 0 */ + + /* USER CODE END LPTIM1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_LPTIM1_CLK_DISABLE(); + + /**LPTIM1 GPIO Configuration + PG12 ------> LPTIM1_IN1 + PG11 ------> LPTIM1_IN2 + */ + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_12|GPIO_PIN_11); + + /* USER CODE BEGIN LPTIM1_MspDeInit 1 */ + + /* USER CODE END LPTIM1_MspDeInit 1 */ + } + +} + +/** +* @brief QSPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspInit 0 */ + + /* USER CODE END QUADSPI_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_QSPI; + PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_QSPI_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + GPIO_InitStruct.Pin = FLASH_DQ2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(FLASH_DQ2_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(FLASH_NCS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ3_Pin|FLASH_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ1_Pin|FLASH_DQ0_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* QUADSPI interrupt Init */ + HAL_NVIC_SetPriority(QUADSPI_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(QUADSPI_IRQn); + /* USER CODE BEGIN QUADSPI_MspInit 1 */ + + /* USER CODE END QUADSPI_MspInit 1 */ + } + +} + +/** +* @brief QSPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi) +{ + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspDeInit 0 */ + + /* USER CODE END QUADSPI_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_QSPI_CLK_DISABLE(); + + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + HAL_GPIO_DeInit(FLASH_DQ2_GPIO_Port, FLASH_DQ2_Pin); + + HAL_GPIO_DeInit(FLASH_NCS_GPIO_Port, FLASH_NCS_Pin); + + HAL_GPIO_DeInit(GPIOF, FLASH_DQ3_Pin|FLASH_CLK_Pin|FLASH_DQ1_Pin|FLASH_DQ0_Pin); + + /* QUADSPI interrupt DeInit */ + HAL_NVIC_DisableIRQ(QUADSPI_IRQn); + /* USER CODE BEGIN QUADSPI_MspDeInit 1 */ + + /* USER CODE END QUADSPI_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspInit 0 */ + + /* USER CODE END SPI2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI2_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + GPIO_InitStruct.Pin = ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC_SPI_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(ADC_SPI_CLK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI2_MspInit 1 */ + + /* USER CODE END SPI2_MspInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspInit 0 */ + + /* USER CODE END SPI3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC10 ------> SPI3_SCK + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* SPI3 DMA Init */ + /* SPI3_TX Init */ + hdma_spi3_tx.Instance = DMA1_Stream2; + hdma_spi3_tx.Init.Request = DMA_REQUEST_SPI3_TX; + hdma_spi3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_spi3_tx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_spi3_tx.Init.MemInc = DMA_MINC_ENABLE; + hdma_spi3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_spi3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_spi3_tx.Init.Mode = DMA_NORMAL; + hdma_spi3_tx.Init.Priority = DMA_PRIORITY_LOW; + hdma_spi3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_spi3_tx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hspi,hdmatx,hdma_spi3_tx); + + /* SPI3 interrupt Init */ + HAL_NVIC_SetPriority(SPI3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspInit 1 */ + + /* USER CODE END SPI3_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspDeInit 0 */ + + /* USER CODE END SPI2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI2_CLK_DISABLE(); + + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + HAL_GPIO_DeInit(GPIOC, ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin); + + HAL_GPIO_DeInit(ADC_SPI_CLK_GPIO_Port, ADC_SPI_CLK_Pin); + + /* USER CODE BEGIN SPI2_MspDeInit 1 */ + + /* USER CODE END SPI2_MspDeInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspDeInit 0 */ + + /* USER CODE END SPI3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI3_CLK_DISABLE(); + + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC10 ------> SPI3_SCK + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_10); + + /* SPI3 DMA DeInit */ + HAL_DMA_DeInit(hspi->hdmatx); + + /* SPI3 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspDeInit 1 */ + + /* USER CODE END SPI3_MspDeInit 1 */ + } + +} + +/** +* @brief TIM_Encoder MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim_encoder->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspInit 0 */ + + /* USER CODE END TIM2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM2_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM2_MspInit 1 */ + + /* USER CODE END TIM2_MspInit 1 */ + } + else if(htim_encoder->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspInit 0 */ + + /* USER CODE END TIM3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**TIM3 GPIO Configuration + PC7 ------> TIM3_CH2 + PC6 ------> TIM3_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM3_MspInit 1 */ + + /* USER CODE END TIM3_MspInit 1 */ + } + else if(htim_encoder->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + + __HAL_RCC_GPIOD_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* TIM4 interrupt Init */ + HAL_NVIC_SetPriority(TIM4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(TIM4_IRQn); + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } + +} + +/** +* @brief TIM_Encoder MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) +{ + if(htim_encoder->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspDeInit 0 */ + + /* USER CODE END TIM2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM2_CLK_DISABLE(); + + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15|GPIO_PIN_1); + + /* USER CODE BEGIN TIM2_MspDeInit 1 */ + + /* USER CODE END TIM2_MspDeInit 1 */ + } + else if(htim_encoder->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspDeInit 0 */ + + /* USER CODE END TIM3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM3_CLK_DISABLE(); + + /**TIM3 GPIO Configuration + PC7 ------> TIM3_CH2 + PC6 ------> TIM3_CH1 + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7|GPIO_PIN_6); + + /* USER CODE BEGIN TIM3_MspDeInit 1 */ + + /* USER CODE END TIM3_MspDeInit 1 */ + } + else if(htim_encoder->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_13|GPIO_PIN_12); + + /* TIM4 interrupt DeInit */ + HAL_NVIC_DisableIRQ(TIM4_IRQn); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } + +} + +/** +* @brief UART MSP Initialization +* This function configures the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspInit 0 */ + + /* USER CODE END UART5_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART5; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART5_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF14_UART5; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN UART5_MspInit 1 */ + + /* USER CODE END UART5_MspInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspInit 0 */ + + /* USER CODE END UART7_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART7; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART7_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF11_UART7; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF7_UART7; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN UART7_MspInit 1 */ + + /* USER CODE END UART7_MspInit 1 */ + } + +} + +/** +* @brief UART MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspDeInit 0 */ + + /* USER CODE END UART5_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART5_CLK_DISABLE(); + + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN UART5_MspDeInit 1 */ + + /* USER CODE END UART5_MspDeInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspDeInit 0 */ + + /* USER CODE END UART7_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART7_CLK_DISABLE(); + + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7); + + /* USER CODE BEGIN UART7_MspDeInit 1 */ + + /* USER CODE END UART7_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC; + PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOI, GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOH, GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA1_Stream0; + hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; + hdma_sai1_a.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA1_Stream1; + hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; + hdma_sai1_b.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_7); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c new file mode 100644 index 00000000..2015fed9 --- /dev/null +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -0,0 +1,296 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32h7xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; +extern QSPI_HandleTypeDef hqspi; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; +extern DMA_HandleTypeDef hdma_spi3_tx; +extern SPI_HandleTypeDef hspi3; +extern TIM_HandleTypeDef htim4; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32H7xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32h7xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream0 global interrupt. + */ +void DMA1_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream0_IRQn 0 */ + + /* USER CODE END DMA1_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA1_Stream0_IRQn 1 */ + + /* USER CODE END DMA1_Stream0_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream1 global interrupt. + */ +void DMA1_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream1_IRQn 0 */ + + /* USER CODE END DMA1_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA1_Stream1_IRQn 1 */ + + /* USER CODE END DMA1_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream2 global interrupt. + */ +void DMA1_Stream2_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ + + /* USER CODE END DMA1_Stream2_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_spi3_tx); + /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ + + /* USER CODE END DMA1_Stream2_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream3 global interrupt. + */ +void DMA1_Stream3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream3_IRQn 0 */ + + /* USER CODE END DMA1_Stream3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc1); + /* USER CODE BEGIN DMA1_Stream3_IRQn 1 */ + + /* USER CODE END DMA1_Stream3_IRQn 1 */ +} + +/** + * @brief This function handles ADC1 and ADC2 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + +/** + * @brief This function handles TIM4 global interrupt. + */ +void TIM4_IRQHandler(void) +{ + /* USER CODE BEGIN TIM4_IRQn 0 */ + + /* USER CODE END TIM4_IRQn 0 */ + HAL_TIM_IRQHandler(&htim4); + /* USER CODE BEGIN TIM4_IRQn 1 */ + + /* USER CODE END TIM4_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[15:10] interrupts. + */ +void EXTI15_10_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI15_10_IRQn 0 */ + + /* USER CODE END EXTI15_10_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14); + /* USER CODE BEGIN EXTI15_10_IRQn 1 */ + + /* USER CODE END EXTI15_10_IRQn 1 */ +} + +/** + * @brief This function handles SPI3 global interrupt. + */ +void SPI3_IRQHandler(void) +{ + /* USER CODE BEGIN SPI3_IRQn 0 */ + + /* USER CODE END SPI3_IRQn 0 */ + HAL_SPI_IRQHandler(&hspi3); + /* USER CODE BEGIN SPI3_IRQn 1 */ + + /* USER CODE END SPI3_IRQn 1 */ +} + +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + +/** + * @brief This function handles QUADSPI global interrupt. + */ +void QUADSPI_IRQHandler(void) +{ + /* USER CODE BEGIN QUADSPI_IRQn 0 */ + + /* USER CODE END QUADSPI_IRQn 0 */ + HAL_QSPI_IRQHandler(&hqspi); + /* USER CODE BEGIN QUADSPI_IRQn 1 */ + + /* USER CODE END QUADSPI_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/system_stm32h7xx.c b/Xibeca/Core/Src/system_stm32h7xx.c new file mode 100644 index 00000000..9ae8b842 --- /dev/null +++ b/Xibeca/Core/Src/system_stm32h7xx.c @@ -0,0 +1,402 @@ +/** + ****************************************************************************** + * @file system_stm32h7xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32h7xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock, it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx_system + * @{ + */ + +/** @addtogroup STM32H7xx_System_Private_Includes + * @{ + */ + +#include "stm32h7xx.h" +#include +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (CSI_VALUE) + #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ +#define DATA_IN_D2_SRAM + +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 64000000; + uint32_t SystemD2Clock = 64000000; + const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting and vector table location + * configuration. + * @param None + * @retval None + */ +void SystemInit (void) +{ +#if defined (DATA_IN_D2_SRAM) + __IO uint32_t tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + + /* Increasing the CPU frequency */ + if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + + /* Set HSION bit */ + RCC->CR |= RCC_CR_HSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */ + RCC->CR &= 0xEAF6ED7FU; + + /* Decreasing the number of wait states because of lower CPU frequency */ + if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + +#if defined(D3_SRAM_BASE) + /* Reset D1CFGR register */ + RCC->D1CFGR = 0x00000000; + + /* Reset D2CFGR register */ + RCC->D2CFGR = 0x00000000; + + /* Reset D3CFGR register */ + RCC->D3CFGR = 0x00000000; +#else + /* Reset CDCFGR1 register */ + RCC->CDCFGR1 = 0x00000000; + + /* Reset CDCFGR2 register */ + RCC->CDCFGR2 = 0x00000000; + + /* Reset SRDCFGR register */ + RCC->SRDCFGR = 0x00000000; +#endif + /* Reset PLLCKSELR register */ + RCC->PLLCKSELR = 0x02020200; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x01FF0000; + /* Reset PLL1DIVR register */ + RCC->PLL1DIVR = 0x01010280; + /* Reset PLL1FRACR register */ + RCC->PLL1FRACR = 0x00000000; + + /* Reset PLL2DIVR register */ + RCC->PLL2DIVR = 0x01010280; + + /* Reset PLL2FRACR register */ + + RCC->PLL2FRACR = 0x00000000; + /* Reset PLL3DIVR register */ + RCC->PLL3DIVR = 0x01010280; + + /* Reset PLL3FRACR register */ + RCC->PLL3FRACR = 0x00000000; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000; + +#if (STM32H7_DEV_ID == 0x450UL) + /* dual core CM7 or single core line */ + if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) + { + /* if stm32h7 revY*/ + /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ + *((__IO uint32_t*)0x51008108) = 0x000000001U; + } +#endif + +#if defined (DATA_IN_D2_SRAM) + /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock (AHB SRAM clock) */ +#if defined(RCC_AHB2ENR_D2SRAM3EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); +#elif defined(RCC_AHB2ENR_D2SRAM2EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN); +#else + RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); +#endif /* RCC_AHB2ENR_D2SRAM3EN */ + + tmpreg = RCC->AHB2ENR; + (void) tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* + * Disable the FMC bank1 (enabled after reset). + * This, prevents CPU speculation access on this bank which blocks the use of FMC during + * 24us. During this time the others FMC master (such as LTDC) cannot use it! + */ + FMC_Bank1_R->BTCR[0] = 0x000030D2; + + /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ + extern char _ISR_VECTOR; + SCB->VTOR = (uint32_t)&_ISR_VECTOR; + +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock , it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*) + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*), + * HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors. + * + * (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 64 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 25 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; + uint32_t common_system_clock; + float_t fracn1, pllvco; + + + /* Get SYSCLK source -------------------------------------------------------*/ + + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */ + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + + case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */ + common_system_clock = CSI_VALUE; + break; + + case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */ + common_system_clock = HSE_VALUE; + break; + + case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC); + pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ; + pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos); + fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3)); + + if (pllm != 0U) + { + switch (pllsource) + { + case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ + + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + + break; + + case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ + pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ + pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + default: + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + } + pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ; + common_system_clock = (uint32_t)(float_t)(pllvco/(float_t)pllp); + } + else + { + common_system_clock = 0U; + } + break; + + default: + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + } + + /* Compute SystemClock frequency --------------------------------------------------*/ +#if defined (RCC_D1CFGR_D1CPRE) + tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); + +#else + tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU)); + +#endif + +#if defined(DUAL_CORE) && defined(CORE_CM4) + SystemCoreClock = SystemD2Clock; +#else + SystemCoreClock = common_system_clock; +#endif /* DUAL_CORE && CORE_CM4 */ +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/test-qspi.h b/Xibeca/Core/Src/test-qspi.h new file mode 100644 index 00000000..50054980 --- /dev/null +++ b/Xibeca/Core/Src/test-qspi.h @@ -0,0 +1,68 @@ + +#include "flash.h" + +static int cmp(void* a, void* b, size_t len){ + uint8_t* lhs = (uint8_t*)a; + uint8_t* rhs = (uint8_t*)b; + while(len--){ + if(*lhs++ != *rhs++) + return -1; + } + return 0; +} + +int setError(const char* msg){ + error(CONFIG_ERROR, msg); + return -1; +} +int flashExternal(uint8_t* source, size_t size, int sector, uint32_t address){ + flash_init(); + int memloc = sector*128*1024; + // size_t size = getSize(); + // uint8_t* source = getData(); + // uint32_t address = QSPI_FLASH_BASE+memloc; + if(address < QSPI_FLASH_BASE || address+size > QSPI_FLASH_BASE+QSPI_FLASH_SIZE) + return setError("Invalid QSPI FLASH sector or size"); + if(flash_erase(memloc, size) != 0) + return setError("QSPI Flash erase failed"); + flash_wait(); + if(flash_write_block(memloc, source, size) != 0) + return setError("QSPI Flash write failed"); + flash_wait(); + flash_memory_map(122); + if(cmp((void*)address, source, size) != 0) + return setError("QSPI FLASH verify failed"); + return 0; +} + +extern "C" { + void HAL_QSPI_ErrorCallback(QSPI_HandleTypeDef *hqspi){ + debugMessage("QSPI Error", (int)hqspi->ErrorCode); + } + void HAL_QSPI_AbortCpltCallback(QSPI_HandleTypeDef *hqspi){ + debugMessage("QSPI Abort", (int)hqspi->ErrorCode); + } +} + + +const char flashdata[] = "This is the new data."; + +#ifdef DEBUG +#include +#endif + +void setup(){ + printf("QSPI flash test: %s.\n", flashdata); + + flashExternal((uint8_t*)flashdata, sizeof(flashdata), 0, QSPI_FLASH_BASE); + + // flash_reset(); + flash_init(); + int fs1 = flash_status(); + flash_memory_map(-122); + int fs2 = flash_status(); + // flash_memory_map(-444); +#ifdef DEBUG + printf("FLASH %s %d %d.\n", (const char*)QSPI_FLASH_BASE, fs1, fs2); +#endif +} diff --git a/Xibeca/Makefile b/Xibeca/Makefile new file mode 100644 index 00000000..869a580e --- /dev/null +++ b/Xibeca/Makefile @@ -0,0 +1,49 @@ +PROJECT = Xibeca +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +LDSCRIPT = $(OPENWARE)/Hardware/xibeca.ld +include $(OPENWARE)/Hardware/owl3.mk + +C_SRC = $(wildcard Core/Src/*.c) +CPP_SRC = $(wildcard Core/Src/*.cpp) +C_SRC += $(OPENWARE)/Source/pcm3168a.c +C_SRC += $(OPENWARE)/Source/usbd_audio.c +# C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/sdram-as4cXm32.c + +C_SRC += $(OPENWARE)/Source/ssd1309.c +CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp +CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp +CPP_SRC += $(OPENWARE)/Source/Graphics.cpp + +# CPP_SRC += $(OPENWARE)/Source/uart.cpp +# CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp + +S_SRC = $(BUILDROOT)/Core/Src/startup_stm32h743xx.s + +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usb_device.c +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usbd_desc.c +C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c + +# CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp +# C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c +# C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c + +C_SRC += $(OPENWARE)/Source/flash.c + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_SAI) +# C_SRC += $(C_SRC_DAC) +C_SRC += $(C_SRC_SDRAM) +C_SRC += $(C_SRC_USBD) +# C_SRC += $(C_SRC_USBH) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_I2C) +C_SRC += $(C_SRC_QSPI) +C_SRC += $(C_SRC_MDMA) + +include $(OPENWARE)/Hardware/h7.mk diff --git a/Xibeca/USB_DEVICE/App/usb_device.c b/Xibeca/USB_DEVICE/App/usb_device.c new file mode 100644 index 00000000..9b34c972 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usb_device.c @@ -0,0 +1,100 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" + +/* USER CODE BEGIN Includes */ +#include "usbd_audio.h" +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef hUsbDeviceFS; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/App/usb_device.h b/Xibeca/USB_DEVICE/App/usb_device.h new file mode 100644 index 00000000..7c91b657 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/App/usbd_desc.c b/Xibeca/USB_DEVICE/App/usbd_desc.c new file mode 100644 index 00000000..6ea9c473 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usbd_desc.c @@ -0,0 +1,394 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : App/usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_FS 0xDADA +#define USBD_PRODUCT_STRING_FS "OWL-XIBECA" +#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" +#define USBD_INTERFACE_STRING_FS "AUDIO Interface" + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for FS. + * @{ + */ + +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef FS_Desc = +{ + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/* USB_DeviceDescriptor */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang indentifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ + + /* USER CODE END USBD_FS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/App/usbd_desc.h b/Xibeca/USB_DEVICE/App/usbd_desc.h new file mode 100644 index 00000000..51de9706 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef FS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.c b/Xibeca/USB_DEVICE/Target/usbd_conf.c new file mode 100644 index 00000000..073b6145 --- /dev/null +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.c @@ -0,0 +1,680 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : Target/usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +/* USER CODE BEGIN Includes */ +#include "device.h" +uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_FS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 9; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +/* void *USBD_static_malloc(uint32_t size) */ +/* { */ +/* static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/\* On 32-bit boundary *\/ */ +/* return mem; */ +/* } */ + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + +/** + * @brief Delays routine for the USB device library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.h b/Xibeca/USB_DEVICE/Target/usbd_conf.h new file mode 100644 index 00000000..7fb0f34a --- /dev/null +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.h @@ -0,0 +1,176 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 5U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 1U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL 0U +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U +/*---------- -----------*/ +#define USBD_AUDIO_FREQ 22100U + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros make sure to use static memory allocation */ +/** Alias for memory allocation. */ +#define USBD_malloc (void *)USBD_static_malloc + +/** Alias for memory release. */ +#define USBD_free USBD_static_free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc new file mode 100644 index 00000000..931f00d6 --- /dev/null +++ b/Xibeca/Xibeca.ioc @@ -0,0 +1,906 @@ +#MicroXplorer Configuration settings - do not modify +Dma.SPI3_TX.2.MemInc=DMA_MINC_ENABLE +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A0.ConfNb=1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_A0.0=FMC_A0,13b-sda1 +PG8.Signal=FMC_SDCLK +SH.GPXTI14.0=GPIO_EXTI14 +PG0.Signal=FMC_A10 +RCC.PLLFRACN=0 +PC3_C.Mode=Full_Duplex_Master +SAI1.Instance-SAI_A_MasterWithClock=SAI$Index_Block_A +RCC.RTCFreq_Value=32000 +PA15\ (JTDI).Signal=S_TIM2_CH1 +RCC.CpuClockFreq_Value=480000000 +PD2.GPIOParameters=GPIO_Label +SH.FMC_SDNWE.ConfNb=1 +PG14.GPIOParameters=GPIO_Speed,GPIO_Label +SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended +SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 +PA2.GPIOParameters=GPIO_Label +SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 +RCC.LPTIM1Freq_Value=120000000 +USB_DEVICE.PID_AUDIO_FS=0xDADA +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +SH.FMC_D25.0=FMC_D25,sd-32b-d1 +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SH.FMC_NBL2.ConfNb=1 +SH.S_TIM3_CH2.ConfNb=1 +PF7.Signal=UART7_TX +SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 +PH9.Signal=FMC_D17 +SH.FMC_D11_DA11.0=FMC_D11,sd-32b-d1 +RCC.I2C4Freq_Value=120000000 +Dma.SPI3_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +PB6.Signal=UART5_TX +PC7.Signal=S_TIM3_CH2 +PD0.Signal=FMC_D2_DA2 +SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX +PD8.Signal=FMC_D13_DA13 +PE1.Signal=FMC_NBL1 +QUADSPI.FlashSize=22 +NVIC.EXTI15_10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +ProjectManager.ProjectBuild=false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +PA0.Locked=true +Dma.ADC1.3.RequestNumber=1 +ADC1.OffsetSignedSaturation-3\#ChannelRegularConversion=DISABLE +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +PC2_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +ProjectManager.BackupPrevious=false +RCC.FMCFreq_Value=240000000 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL3 +PE9.Signal=FMC_D6_DA6 +Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.ADC1.3.Mode=DMA_CIRCULAR +SH.FMC_A2.0=FMC_A2,13b-sda1 +PB1.GPIO_Label=ADC3 +RCC.USART16Freq_Value=120000000 +PA8.Signal=UART7_RX +SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 +Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +ProjectManager.HalAssertFull=true +RCC.DIVP2Freq_Value=25000000 +PA0.Signal=GPIO_Input +Mcu.Package=UFBGA176 +SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K +PB1.Signal=ADCx_INP5 +PC10.Stacked=true +SAI1.SlotActive-SAI_B_SyncSlave=0x0000FFFF +SPI2.Mode=SPI_MODE_MASTER +ADC1.OversamplingMode=DISABLE +RCC.PLL3FRACN=0 +SPI3.Mode=SPI_MODE_MASTER +PD12.Signal=S_TIM4_CH1 +SH.FMC_SDNCAS.ConfNb=1 +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +SAI1.FSPolarity-SAI_B_SyncSlave=SAI_FS_ACTIVE_HIGH +PC3_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PC3_C.GPIO_Label=ADC_SPI_MOSI +SH.FMC_A11.ConfNb=1 +SH.FMC_D27.0=FMC_D27,sd-32b-d1 +FREERTOS.FootprintOK=true +Dma.SAI1_A.0.SyncSignalID=NONE +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface +RCC.LPUART1Freq_Value=120000000 +PF10.Mode=Single Bank 1 +USB_OTG_FS.IPParameters=VirtualMode +PA4.GPIO_Label=OLED_RST +ADC1.EOCSelection=ADC_EOC_SEQ_CONV +PD15.Signal=FMC_D1_DA1 +SH.ADCx_INP10.ConfNb=1 +RCC.VCO3OutputFreq_Value=196571428.5714286 +SH.FMC_D3_DA3.ConfNb=1 +PG12.Signal=LPTIM1_IN1 +SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +USB_DEVICE.VID-AUDIO_FS=0x1209 +Mcu.Pin80=PC2_C +Mcu.Pin81=PC3_C +SH.S_TIM4_CH1.ConfNb=1 +SH.FMC_A4.0=FMC_A4,13b-sda1 +ProjectManager.ProjectFileName=Xibeca.ioc +SH.FMC_A5.ConfNb=1 +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +PH13.Signal=FMC_D21 +Mcu.Pin79=PC1 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +Mcu.PinsNb=121 +PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label +PC11.Locked=true +Mcu.Pin73=PF8 +Mcu.Pin74=PH11 +Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE +Mcu.Pin71=PF10 +Mcu.Pin72=PF9 +Mcu.Pin77=PG2 +PC13.Locked=true +SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE +PG5.Signal=FMC_A15_BA1 +Mcu.Pin78=PC0 +ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE +Mcu.Pin75=PH10 +PC13.Signal=GPXTI13 +PG3.Locked=true +Mcu.Pin76=PD15 +SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 +FREERTOS.INCLUDE_vTaskDelayUntil=1 +Dma.ADC1.3.Priority=DMA_PRIORITY_LOW +Mcu.Pin70=PG3 +SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=-0.01 % +SH.FMC_D16.0=FMC_D16,sd-32b-d1 +Mcu.Pin68=PG5 +Mcu.Pin69=PG4 +SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended +PG14.Locked=true +Mcu.Pin62=PG7 +Mcu.Pin63=PG6 +Mcu.Pin60=PF4 +Mcu.Pin61=PH5 +Mcu.Pin66=PF5 +RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 +Mcu.Pin67=PH12 +Mcu.Pin64=PF7 +Mcu.Pin65=PF6 +PF8.GPIO_Label=FLASH_DQ0 +PD10.Signal=FMC_D15_DA15 +RCC.D1CPREFreq_Value=480000000 +RCC.Tim1OutputFreq_Value=240000000 +SH.FMC_D29.0=FMC_D29,sd-32b-d1 +Mcu.Pin59=PF3 +Mcu.Pin57=PG8 +PC15-OSC32_OUT\ (OSC32_OUT).Locked=true +Mcu.Pin58=PC6 +PH4.Locked=true +Mcu.Pin51=PC8 +Mcu.Pin52=PC7 +Mcu.Pin50=PH3 +Mcu.Pin55=PF1 +Mcu.Pin56=PH4 +Mcu.Pin53=PH1-OSC_OUT (PH1) +Mcu.Pin54=PF2 +PB11.GPIOParameters=GPIO_Label +Mcu.Pin48=PA8 +Mcu.Pin49=PH0-OSC_IN (PH0) +Mcu.Pin46=PH2 +Mcu.Pin47=PC9 +SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER +PG6.GPIOParameters=GPIO_Speed,GPIO_Label +Mcu.Pin40=PI11 +Mcu.Pin41=PH13 +Mcu.Pin44=PA9 +Mcu.Pin45=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin42=PH14 +Mcu.Pin43=PI0 +PI7.Signal=FMC_D29 +PC2_C.GPIO_Label=ADC_SPI_MISO +SH.FMC_A6.0=FMC_A6,13b-sda1 +RCC.AHB12Freq_Value=240000000 +PE14.Signal=FMC_D11_DA11 +PE6.Mode=SAI_A_MasterWithClock +Mcu.Pin37=PC14-OSC32_IN (OSC32_IN) +Mcu.Pin38=PF0 +SAI1.SlotNumber-SAI_B_SyncSlave=8 +Mcu.Pin35=PH15 +Mcu.Pin36=PI1 +SH.FMC_D14_DA14.ConfNb=1 +Mcu.Pin39=PI10 +Dma.ADC1.3.SyncSignalID=NONE +PI2.Signal=FMC_D26 +Mcu.Pin30=PA11 +Mcu.Pin33=PI4 +Mcu.Pin34=PD2 +Mcu.Pin31=PC13 +Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Mcu.Pin32=PI9 +Dma.SAI1_A.0.SyncRequestNumber=1 +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +FREERTOS.configUSE_MUTEXES=0 +QUADSPI.FifoThreshold=4 +PF13.Signal=FMC_A7 +PC10.GPIOParameters=GPIO_Speed +SH.SharedStack_PC8.0=SDMMC1_D0 +SH.SharedStack_PC8.1=GPIO_EXTI8 +SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 +PC9.GPIOParameters=GPIO_Label +PF9.GPIOParameters=GPIO_Speed,GPIO_Label +Mcu.Pin26=PI5 +SH.FMC_D18.0=FMC_D18,sd-32b-d1 +Mcu.Pin27=PD1 +Mcu.Pin24=PI7 +SH.FMC_D21.ConfNb=1 +Mcu.Pin25=PI6 +Dma.SPI3_TX.2.SyncEnable=DISABLE +Mcu.Pin28=PI3 +Mcu.Pin29=PI2 +Mcu.Pin22=PC10 +Mcu.Pin23=PA12 +Mcu.Pin20=PD0 +ADC1.master=1 +Mcu.Pin21=PC11 +PA3.Locked=true +PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 +NVIC.ForceEnableDMAVector=true +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +SH.FMC_SDNRAS.ConfNb=1 +ProjectManager.HeapSize=0x200 +Mcu.Pin15=PB6 +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +Mcu.Pin16=PG15 +Mcu.Pin13=PE6 +Mcu.Pin14=PB7 +PF10.GPIOParameters=GPIO_Speed,GPIO_Label +Mcu.Pin19=PG10 +Mcu.Pin17=PG12 +Mcu.Pin18=PG11 +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +Mcu.Pin11=PE4 +Mcu.Pin12=PE5 +Mcu.Pin10=PA13 (JTMS/SWDIO) +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR +PE3.Signal=SAI1_SD_B +PF4.Signal=FMC_A4 +SH.FMC_D26.ConfNb=1 +PD2.Signal=SharedStack_PD2 +Mcu.Family=STM32H7 +SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master +ProjectManager.MainLocation=Core/Src +SH.SharedStack_PC12.0=SDMMC1_CK +SH.FMC_A6.ConfNb=1 +USB_DEVICE.CLASS_NAME_FS=AUDIO +ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE +SH.FMC_A8.0=FMC_A8,13b-sda1 +ProjectManager.KeepUserCode=true +PH14.Signal=FMC_D22 +PH10.Signal=FMC_D18 +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN +ADC1.ContinuousConvMode=ENABLE +SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PG2.Signal=FMC_A12 +SAI1.FrameLength-SAI_B_SyncSlave=256 +TIM4.EncoderMode=TIM_ENCODERMODE_TI12 +SAI1.FSDefinition-SAI_A_MasterWithClock=SAI_FS_CHANNEL_IDENTIFICATION +PE2.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA11.Mode=Device_Only +PF9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +RCC.PLL2FRACN=6144 +SAI1.OutputDrive-SAI_B_SyncSlave=SAI_OUTPUTDRIVE_ENABLE +PD2.Locked=true +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +RCC.VCO2OutputFreq_Value=150000000 +SH.FMC_A11.0=FMC_A11,13b-sda1 +SH.ADCx_INP11.ConfNb=1 +Dma.SPI3_TX.2.Mode=DMA_NORMAL +PG15.Signal=FMC_SDNCAS +PG11.Signal=LPTIM1_IN2 +PD13.Signal=S_TIM4_CH2 +Mcu.IP4=FMC +Mcu.IP5=FREERTOS +Dma.SPI3_TX.2.SignalID=NONE +Mcu.IP2=DEBUG +Mcu.IP3=DMA +Mcu.IP0=ADC1 +Mcu.IP1=CORTEX_M7 +PE4.GPIOParameters=GPIO_Speed +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +RCC.DIVP3Freq_Value=98285714.2857143 +RCC.SDMMCFreq_Value=192000000 +ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_8 +SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 +Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +ADC1.Resolution=ADC_RESOLUTION_12B +ProjectManager.PreviousToolchain= +SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK +Dma.SAI1_B.1.Instance=DMA1_Stream1 +Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +FREERTOS.configUSE_PREEMPTION=0 +RCC.HRTIMFreq_Value=240000000 +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10 +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +RCC.DIVR3Freq_Value=98285714.2857143 +RCC.HSE_VALUE=8000000 +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +SH.FMC_A14_BA0.ConfNb=1 +Mcu.IP10=SAI1 +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true +Mcu.IP12=SPI3 +Mcu.IP11=SPI2 +SH.SharedStack_PC10.1=SPI3_SCK,TX_Only_Simplex_Unidirect_Master +PA4.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +SH.SharedStack_PC10.0=SDMMC1_D2 +Mcu.IP18=UART7 +Mcu.IP17=UART5 +Mcu.IP19=USB_DEVICE +RCC.DIVP1Freq_Value=480000000 +Mcu.IP14=TIM2 +PF9.Mode=Single Bank 1 +Mcu.IP13=SYS +Mcu.IP16=TIM4 +Mcu.IP15=TIM3 +PF11.Signal=FMC_SDNRAS +PC11.GPIO_Label=OLED_DC +PB5.Mode=Asynchronous +PE3.GPIOParameters=GPIO_Speed +PB7.Signal=I2C1_SDA +Mcu.IP20=USB_OTG_FS +SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface +SH.FMC_D27.ConfNb=1 +SH.FMC_D16.ConfNb=1 +SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-XIBECA +PA6.Signal=GPIO_Input +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +SH.FMC_D4_DA4.ConfNb=1 +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +ProjectManager.ToolChainLocation= +SAI1.FSOffset-SAI_A_MasterWithClock=SAI_FS_BEFOREFIRSTBIT +PF8.Signal=QUADSPI_BK1_IO0 +SH.FMC_D30.ConfNb=1 +RCC.DIVR1Freq_Value=480000000 +NVIC.SPI3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +Mcu.Pin95=PA2 +Mcu.Pin96=PA6 +Mcu.Pin93=PD12 +Mcu.Pin94=PD10 +Mcu.Pin99=PF15 +Mcu.Pin97=PC5 +Mcu.Pin98=PF12 +Dma.Request2=SPI3_TX +Dma.Request1=SAI1_B +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.Request3=ADC1 +FREERTOS.configUSE_TICK_HOOK=0 +Mcu.Pin91=PG0 +Mcu.Pin92=PE13 +NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +Mcu.Pin90=PF13 +PC5.Signal=ADCx_INP8 +PH2.Mode=SdramChipSelect1_1 +PE7.Signal=FMC_D4_DA4 +Dma.Request0=SAI1_A +SH.FMC_D22.ConfNb=1 +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +PE2.GPIO_Label=FLASH_DQ2 +Mcu.Pin84=PH9 +Mcu.Pin85=PD14 +Mcu.Pin82=PG1 +Mcu.Pin83=PH8 +Mcu.Pin88=PA0 +PA3.Signal=GPIO_Output +Mcu.Pin89=PA4 +Mcu.Pin86=PD13 +Mcu.Pin87=PA1 +SH.FMC_A3.ConfNb=1 +SAI1.VirtualSlotActive-SAI_A_MasterWithClock=SAI_SLOTACTIVE_ALL +SH.FMC_D20.0=FMC_D20,sd-32b-d1 +SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +PG7.Signal=SAI1_MCLK_A +PC9.GPIO_Label=EXTI9 +Dma.SAI1_B.1.RequestNumber=1 +Dma.SPI3_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +NVIC.SavedSvcallIrqHandlerGenerated=true +Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY +PC11.Signal=GPIO_Output +Dma.SAI1_A.0.SignalID=NONE +SPI2.NSSPMode=SPI_NSS_PULSE_DISABLE +PC8.Signal=SharedStack_PC8 +PF10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended +SH.FMC_D31.0=FMC_D31,sd-32b-d1 +ProjectManager.DefaultFWLocation=true +PD9.Signal=FMC_D14_DA14 +PC12.Stacked=true +ProjectManager.DeletePrevious=true +PB10.Locked=true +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS +PinOutPanel.CurrentBGAView=Top +RCC.FamilyName=M +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +FREERTOS.configUSE_IDLE_HOOK=0 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz +PA9.Mode=Activate_VBUS +SH.FMC_A15_BA1.ConfNb=1 +SH.SharedStack_PD2.0=SDMMC1_CMD +PF6.Signal=QUADSPI_BK1_IO3 +SH.SharedStack_PD2.1=GPIO_EXTI2 +PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPIO_Input +PB10.GPIO_Label=ADC_SPI_CLK +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +RCC.VCO1OutputFreq_Value=960000000 +SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 +PH8.Signal=FMC_D16 +Dma.ADC1.3.SyncRequestNumber=1 +PC5.GPIOParameters=GPIO_Label +RCC.AXIClockFreq_Value=240000000 +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase +PE2.GPIOParameters=GPIO_Speed,GPIO_Label +RCC.USBFreq_Value=48000000 +PF9.GPIO_Label=FLASH_DQ1 +SH.FMC_D24.ConfNb=1 +Dma.SAI1_B.1.SyncEnable=DISABLE +PA1.Signal=S_TIM2_CH2 +RCC.CKPERFreq_Value=64000000 +Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY +board=custom +PG12.Mode=Encoder_mode_occur1 +PI9.Signal=FMC_D30 +SH.FMC_D22.0=FMC_D22,sd-32b-d1 +MxCube.Version=6.2.1 +RCC.FDCANFreq_Value=192000000 +PI4.Signal=FMC_NBL2 +PE5.Mode=SAI_A_MasterWithClock +RCC.ADCFreq_Value=25000000 +PC1.GPIO_Label=ADC5 +VP_SYS_VS_Systick.Mode=SysTick +SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 +SAI1.SlotNumber-SAI_A_MasterWithClock=8 +SH.FMC_D29.ConfNb=1 +SH.FMC_D18.ConfNb=1 +PF1.Signal=FMC_A1 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +SH.FMC_D11_DA11.ConfNb=1 +ADC1.NbrOfConversion=4 +ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVM3,DIVN1,DIVN2,DIVN3,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +ProjectManager.AskForMigrate=true +PE0.Signal=FMC_NBL0 +Dma.SAI1_B.1.SyncSignalID=NONE +PE12.Signal=FMC_D9_DA9 +NVIC.SavedPendsvIrqHandlerGenerated=true +Mcu.IP8=QUADSPI +SH.ADCx_INP8.ConfNb=1 +Mcu.IP9=RCC +Mcu.IP6=LPTIM1 +Mcu.IP7=NVIC +ProjectManager.CoupleFile=false +RCC.SYSCLKFreq_VALUE=480000000 +RCC.I2C123Freq_Value=120000000 +SH.SharedStack_PC8.ConfNb=2 +ADC1.Rank-3\#ChannelRegularConversion=4 +ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +KeepUserPlacement=false +SH.ADCx_INP14.ConfNb=1 +NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +PH3.Signal=FMC_SDNE0 +PC3_C.Signal=SPI2_MOSI +PB7.Locked=true +PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +PC8.Locked=true +SH.FMC_D8_DA8.ConfNb=1 +PG14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +Dma.SAI1_A.0.SyncEnable=DISABLE +PA6.Locked=true +SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF +SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 +SH.FMC_D24.0=FMC_D24,sd-32b-d1 +SH.FMC_A4.ConfNb=1 +SPI3.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI3.VirtualType=VM_MASTER +PH12.Signal=FMC_D20 +QUADSPI.ClockPrescaler=9 +SPI2.VirtualType=VM_MASTER +PB10.Mode=Full_Duplex_Master +PC12.Locked=true +SH.ADCx_INP10.0=ADC1_INP10,IN10-Single-Ended +PG4.Signal=FMC_A14_BA0 +NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +PC12.Signal=SharedStack_PC12 +PG6.GPIO_Label=FLASH_NCS +PG3.GPIOParameters=GPIO_Label +PI11.Locked=true +PG6.Mode=Single Bank 1 +PinOutPanel.RotationAngle=0 +PF6.GPIO_Label=FLASH_DQ3 +RCC.MCO1PinFreq_Value=64000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.AHB4Freq_Value=240000000 +SH.GPXTI13.0=GPIO_EXTI13 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +RCC.SPI123CLockSelection=RCC_SPI123CLKSOURCE_PLL2 +Dma.ADC1.3.MemInc=DMA_MINC_ENABLE +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +SH.FMC_A12.ConfNb=1 +PH5.Signal=FMC_SDNWE +Dma.SPI3_TX.2.SyncRequestNumber=1 +PE2.Mode=Single Bank 1 +ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 +SH.FMC_D10_DA10.ConfNb=1 +PB6.Mode=Asynchronous +RCC.DIVQ3Freq_Value=98285714.2857143 +SH.FMC_D17.ConfNb=1 +PE5.Signal=SAI1_SCK_A +PF10.GPIO_Label=FLASH_CLK +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +PA4.Locked=true +RCC.DIVM3=7 +RCC.DIVM2=1 +RCC.DIVM1=1 +Dma.ADC1.3.Instance=DMA1_Stream3 +MxDb.Version=DB.6.0.21 +PB0.GPIOParameters=GPIO_Label +SH.FMC_D26.0=FMC_D26,sd-32b-d1 +PI6.Signal=FMC_D28 +PI3.Signal=FMC_D27 +SH.FMC_D15_DA15.ConfNb=1 +SPI2.CalculateBaudRate=97.656 KBits/s +PC11.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface +SH.SharedStack_PC12.ConfNb=2 +PE2.Signal=QUADSPI_BK1_IO2 +PF8.Mode=Single Bank 1 +PA14\ (JTCK/SWCLK).Mode=Trace_Asynchronous_SW +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false +PF3.Signal=FMC_A3 +SH.FMC_D25.ConfNb=1 +NVIC.SAI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +RCC.DIVR2Freq_Value=75000000 +PE10.Signal=FMC_D7_DA7 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +RCC.MCO2PinFreq_Value=480000000 +PC8.GPIOParameters=GPIO_Label +PF8.GPIOParameters=GPIO_Speed,GPIO_Label +RCC.DFSDMFreq_Value=120000000 +SH.FMC_A1.0=FMC_A1,13b-sda1 +SH.GPXTI14.ConfNb=1 +PH2.Signal=FMC_SDCKE0 +SH.FMC_SDCLK.0=FMC_SDCLK,13b-sda1 +RCC.TraceFreq_Value=480000000 +RCC.APB4Freq_Value=120000000 +RCC.CECFreq_Value=32000 +RCC.SAI23Freq_Value=192000000 +PF14.Signal=FMC_A8 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +SAI1.FrameLength-SAI_A_MasterWithClock=256 +PB10.GPIOParameters=GPIO_Speed,GPIO_Label +PI11.Signal=GPIO_Output +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 +ProjectManager.CustomerFirmwarePackage= +SH.SharedStack_PD2.ConfNb=2 +PG6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +SH.SharedStack_PC9.ConfNb=2 +Dma.SAI1_B.1.EventEnable=DISABLE +SH.FMC_A7.ConfNb=1 +NVIC.QUADSPI_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +PH15.Signal=FMC_D23 +SH.FMC_A1.ConfNb=1 +SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 +RCC.DIVQ1=5 +ADC1.Rank-0\#ChannelRegularConversion=1 +SH.FMC_D28.0=FMC_D28,sd-32b-d1 +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,master,ConversionDataManagement,Overrun +RCC.SWPMI1Freq_Value=120000000 +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +Dma.SPI3_TX.2.EventEnable=DISABLE +PC6.Signal=S_TIM3_CH1 +PB11.GPIO_Label=ADC_SPI_NCS +PD13.GPIOParameters=GPIO_PuPd +PD1.Signal=FMC_D3_DA3 +RCC.DIVP2=6 +TIM4.IC2Filter=4 +PC0.Signal=ADCx_INP10 +PC11.GPIOParameters=GPIO_Speed,GPIO_Label +RCC.QSPIFreq_Value=240000000 +QUADSPI.IPParameters=ClockPrescaler,FifoThreshold,FlashSize +PC9.Stacked=true +PG10.Signal=GPIO_Input +PG10.Locked=true +SH.FMC_A3.0=FMC_A3,13b-sda1 +RCC.USART234578Freq_Value=120000000 +SH.FMC_D31.ConfNb=1 +RCC.SPI123Freq_Value=25000000 +TIM4.IPParameters=EncoderMode,IC1Filter,IC2Filter +Dma.SAI1_A.0.RequestNumber=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 +PC3_C.GPIOParameters=GPIO_Speed,GPIO_Label +PA9.Signal=USB_OTG_FS_VBUS +RCC.DIVN3=172 +SH.S_TIM2_CH2.ConfNb=1 +RCC.DIVN2=18 +RCC.DIVN1=120 +PC2_C.Mode=Full_Duplex_Master +SH.SharedStack_PC9.0=SDMMC1_D1 +SH.SharedStack_PC9.1=GPIO_EXTI9 +SH.FMC_D17.0=FMC_D17,sd-32b-d1 +ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE +SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended +PB10.Signal=SPI2_SCK +SH.ADCx_INP5.ConfNb=1 +RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 +ProjectManager.LastFirmware=true +Mcu.Pin116=PB10 +Mcu.Pin117=PB11 +Mcu.Pin118=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin119=VP_SYS_VS_Systick +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +SH.FMC_D20.ConfNb=1 +PE15.Signal=FMC_D12_DA12 +PE8.Signal=FMC_D5_DA5 +PI1.Signal=FMC_D25 +RCC.RNGFreq_Value=48000000 +Mcu.Pin112=PE7 +Mcu.Pin113=PE10 +Mcu.Pin114=PE12 +Mcu.Pin115=PE15 +Mcu.Pin110=PF11 +Mcu.Pin111=PF14 +SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 +PG14.GPIO_Label=OLED_CS +ProjectManager.FreePins=true +RCC.LPTIM2Freq_Value=120000000 +SH.FMC_NBL1.ConfNb=1 +ProjectManager.UnderRoot=false +SH.FMC_D7_DA7.ConfNb=1 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD +PA4.Signal=GPIO_Output +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +PB5.Signal=UART5_RX +Mcu.Pin120=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +SH.FMC_A10.ConfNb=1 +Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +ProjectManager.CompilerOptimize=6 +ADC1.Rank-1\#ChannelRegularConversion=2 +SH.FMC_A5.0=FMC_A5,13b-sda1 +PG11.Mode=Encoder_mode_occur1 +PA11.Signal=USB_OTG_FS_DM +Dma.SPI3_TX.2.PeriphInc=DMA_PINC_DISABLE +Dma.ADC1.3.SignalID=NONE +SH.S_TIM3_CH1.ConfNb=1 +PF6.Mode=Single Bank 1 +RCC.LPTIM345Freq_Value=120000000 +ProjectManager.ComputerToolchain=false +PF9.Signal=QUADSPI_BK1_IO1 +RCC.LTDCFreq_Value=98285714.2857143 +PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW +Mcu.Pin109=PB0 +Dma.ADC1.3.EventEnable=DISABLE +Mcu.Pin105=PD8 +PA8.Mode=Asynchronous +Mcu.Pin106=PA3 +SPI2.DataSize=SPI_DATASIZE_8BIT +Mcu.Pin107=PA7 +Mcu.Pin108=PB1 +SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 +PG3.GPIO_Label=ADC_RST +SH.FMC_D12_DA12.ConfNb=1 +RCC.HCLK3ClockFreq_Value=240000000 +PB0.Signal=ADCx_INP9 +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SH.FMC_D19.0=FMC_D19,sd-32b-d1 +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +PC1.Signal=ADCx_INP11 +Dma.SAI1_A.0.Instance=DMA1_Stream0 +PD2.GPIO_Label=EXTI2 +PG7.GPIOParameters=GPIO_Speed +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Mcu.Pin101=PE9 +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +Mcu.Pin102=PE11 +Mcu.Pin103=PE14 +Mcu.Pin104=PD9 +PF6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +Mcu.Pin100=PE8 +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +RCC.DIVQ2Freq_Value=75000000 +SH.S_TIM4_CH2.ConfNb=1 +RCC.SAI1Freq_Value=98285714.2857143 +RCC.CortexFreq_Value=480000000 +SH.FMC_A2.ConfNb=1 +PG6.Signal=QUADSPI_BK1_NCS +Mcu.UserName=STM32H743IIKx +PB10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +Dma.SPI3_TX.2.Instance=DMA1_Stream2 +RCC.HPRE=RCC_HCLK_DIV2 +PC10.Locked=true +SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE +PC10.Signal=SharedStack_PC10 +SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=ADC1 +SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 +PC9.Locked=true +PB0.GPIO_Label=ADC7 +PC10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PC13.GPIO_Label=EXTI13 +Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +PB11.Signal=GPIO_Output +SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 +Dma.SPI3_TX.2.SyncSignalID=NONE +PE5.GPIOParameters=GPIO_Speed +ProjectManager.StackSize=0x400 +RCC.VCOInput3Freq_Value=1142857.142857143 +PH3.Mode=SdramChipSelect1_1 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +SH.FMC_A7.0=FMC_A7,13b-sda1 +PA12.Signal=USB_OTG_FS_DP +SPI2.CLKPolarity=SPI_POLARITY_HIGH +Mcu.UserConstants= +PC1.GPIOParameters=GPIO_Label +SH.GPXTI13.ConfNb=1 +Mcu.ThirdPartyNb=0 +RCC.HCLKFreq_Value=240000000 +Mcu.IPNb=21 +RCC.SPDIFRXFreq_Value=192000000 +Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE +PF12.Signal=FMC_A6 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +Mcu.Pin6=PB3 (JTDO/TRACESWO) +Mcu.Pin7=PC12 +Mcu.Pin8=PA15 (JTDI) +Mcu.Pin9=PA14 (JTCK/SWCLK) +Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +PC2_C.Signal=SPI2_MISO +SH.FMC_A10.0=FMC_A10,13b-sda1 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256 +Mcu.Pin0=PE3 +SPI3.DataSize=SPI_DATASIZE_8BIT +Mcu.Pin1=PE2 +GPIO.groupedBy=Group By Peripherals +Mcu.Pin2=PE1 +Mcu.Pin3=PE0 +Mcu.Pin4=PB5 +Mcu.Pin5=PG14 +SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 +PC8.Stacked=true +SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 +ADC1.Rank-2\#ChannelRegularConversion=3 +PE13.Signal=FMC_D10_DA10 +PI5.Signal=FMC_NBL3 +PE4.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PI0.Signal=FMC_D24 +File.Version=6 +Dma.SAI1_A.0.EventEnable=DISABLE +SH.FMC_D5_DA5.ConfNb=1 +SH.SharedStack_PC10.ConfNb=2 +SH.S_TIM2_CH1.ConfNb=1 +SH.FMC_D2_DA2.ConfNb=1 +PE4.Mode=SAI_A_MasterWithClock +Dma.SPI3_TX.2.Priority=DMA_PRIORITY_LOW +SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 +PE4.Signal=SAI1_FS_A +PE6.GPIOParameters=GPIO_Speed +Dma.RequestsNb=4 +ProjectManager.ProjectName=Xibeca +RCC.APB3Freq_Value=120000000 +SAI1.VirtualSlotActive-SAI_B_SyncSlave=SAI_SLOTACTIVE_ALL +Dma.SPI3_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE +PA7.Locked=true +SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 +RCC.D1PPRE=RCC_APB3_DIV2 +PA2.GPIO_Label=ADC2 +USB_OTG_FS.VirtualMode=Device_Only +SH.FMC_A9.0=FMC_A9,13b-sda1 +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE +SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 +SPI2.CLKPhase=SPI_PHASE_2EDGE +TIM4.IC1Filter=4 +PF5.Signal=FMC_A5 +Dma.SAI1_B.1.SignalID=NONE +SH.FMC_D19.ConfNb=1 +Dma.SPI3_TX.2.RequestNumber=1 +SH.FMC_D30.0=FMC_D30,sd-32b-d1 +SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,NSSPMode +SPI2.Direction=SPI_DIRECTION_2LINES +PF0.Signal=FMC_A0 +SH.FMC_NBL0.ConfNb=1 +PE3.Mode=SAI_B_SyncSlave +RCC.Tim2OutputFreq_Value=240000000 +RCC.DFSDMACLkFreq_Value=98285714.2857143 +SH.FMC_A12.0=FMC_A12,13b-sda1 +RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE +SH.FMC_A9.ConfNb=1 +PA13\ (JTMS/SWDIO).Mode=Trace_Asynchronous_SW +Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +PH11.Signal=FMC_D19 +ProjectManager.NoMain=false +USB_DEVICE.VirtualModeFS=Audio_FS +PG3.Signal=GPIO_Output +PG1.Signal=FMC_A11 +SAI1.FSPolarity-SAI_A_MasterWithClock=SAI_FS_ACTIVE_HIGH +ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE +RCC.SAI4BFreq_Value=192000000 +SH.FMC_SDCLK.ConfNb=1 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +PI10.Signal=FMC_D31 +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE +ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +PD2.Stacked=true +Dma.ADC1.3.SyncEnable=DISABLE +PC14-OSC32_IN\ (OSC32_IN).Locked=true +RCC.SPI6Freq_Value=120000000 +PC12.GPIOParameters=GPIO_Speed +PC8.GPIO_Label=EXTI8 +SH.FMC_D21.0=FMC_D21,sd-32b-d1 +PF7.Mode=Asynchronous +SH.ADCx_INP9.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface +SH.FMC_NBL3.ConfNb=1 +RCC.SPI45Freq_Value=120000000 +PH4.Signal=GPIO_Output +PD12.GPIOParameters=GPIO_PuPd +PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +SAI1.SlotSize-SAI_A_MasterWithClock=SAI_SLOTSIZE_32B +ADC1.OffsetSignedSaturation-2\#ChannelRegularConversion=DISABLE +SH.FMC_D1_DA1.ConfNb=1 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_14 +SAI1.DataSize-SAI_A_MasterWithClock=SAI_DATASIZE_24 +PF2.Signal=FMC_A2 +ProjectManager.RegisterCallBack= +SH.FMC_D28.ConfNb=1 +PG7.Mode=SAI_A_MasterWithClock +PE11.Signal=FMC_D8_DA8 +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +PG14.Signal=GPIO_Output +SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface +Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave,FSDefinition-SAI_A_MasterWithClock,FSDefinition-SAI_B_SyncSlave,ActiveFrameLength-SAI_A_MasterWithClock,ActiveFrameLength-SAI_B_SyncSlave +RCC.VCOInput1Freq_Value=8000000 +PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +NVIC.SavedSystickIrqHandlerGenerated=true +RCC.APB2Freq_Value=120000000 +SPI3.CalculateBaudRate=1.5625 MBits/s +SH.FMC_D13_DA13.ConfNb=1 +PC13.GPIOParameters=GPIO_Label +PF10.Signal=QUADSPI_CLK +Dma.SPI3_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE +SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +PD13.GPIO_PuPd=GPIO_PULLUP +PF15.Signal=FMC_A9 +PA4.GPIOParameters=GPIO_Speed,GPIO_Label +PE6.Signal=SAI1_SD_A +Mcu.Name=STM32H743IIKx +SH.FMC_D23.ConfNb=1 +PA2.Signal=ADCx_INP14 +PD14.Signal=FMC_D0_DA0 +PA12.Mode=Device_Only +Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH +PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 +PC5.GPIO_Label=ADC4 +SH.FMC_D23.0=FMC_D23,sd-32b-d1 +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +PF6.GPIOParameters=GPIO_Speed,GPIO_Label +RCC.SAI4AFreq_Value=192000000 +SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended +ADC1.NbrOfConversionFlag=1 +SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT +PF8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +RCC.DIVQ1Freq_Value=192000000 +PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label +Dma.SAI1_B.1.SyncRequestNumber=1 +RCC.D3PPRE=RCC_APB4_DIV2 +PC9.Signal=SharedStack_PC9 +NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +RCC.VCOInput2Freq_Value=8000000 +RCC.APB1Freq_Value=120000000 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 +PB11.Locked=true +ProjectManager.DeviceId=STM32H743IIKx +ProjectManager.LibraryCopy=1 +SAI1.ClockStrobing-SAI_A_MasterWithClock=SAI_CLOCKSTROBING_RISINGEDGE +PD12.GPIO_PuPd=GPIO_PULLUP +PB1.GPIOParameters=GPIO_Label +PA7.Signal=GPIO_Output diff --git a/dist.sh b/dist.sh deleted file mode 100755 index 576e4d25..00000000 --- a/dist.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -mkdir -p dist -# make syx files -for nm in Lich Wizard Alchemist Magus Witch -do - make -C $nm clean all sysex && cp $nm/Build/$nm.syx dist -done -# make OWL Pedal and OWL Modular bin and syx files -make -C OwlPedal PLATFORM=Pedal clean all sysex && cp OwlPedal/Build/OwlPedal.{syx,bin} dist -make -C OwlPedal PLATFORM=Modular clean all sysex && cp OwlPedal/Build/OwlModular.{syx,bin} dist diff --git a/openware-notes.txt b/openware-notes.txt index 112fcb1d..8f17ccd0 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -234,6 +234,11 @@ OWLPORT=`amidi -l|grep OWL|sed 's/.*\(hw:.*\),.*/\1/g'` Record 2 seconds 48k 16bit stereo arecord -D hw:1 -c 2 -r 48000 -f S16_LE out.wav +AUDIODEV=hw:1 rec out.wav + +Playback +aplay -D hw:1 out.wav +AUDIODEV=hw:1 play out.wav ----------------------------------------------------------------- @@ -360,6 +365,9 @@ DC Offset removed with 48dB 10Hz hpf todo: - bootloader verify +- send and receive error messages +- send error messages without polling +- bootloader message with reason for bootloader mode (watchdog, magic, no/invalid firmware) - disable all: sysex rule - IWDG->KR = 0xaaaa only if watchog is enabled, otherwise it hangs - fix Noctua bootloader @@ -381,3 +389,39 @@ play -c 1 -r 48k -t f32 sample.raw FirmwareSender -in sample.raw -out "OWL*" -name "sample.wav" ----------------------------------------------------------------- + +H7 ADC: +set Scan enable, Continuous enable, Conversion End of sequence, and ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR + +----------------------------------------------------------------- + +ABFSR 0x04: AHBP busfault + +----------------------------------------------------------------- + +Dynamic module / code loading with Position Independent Code / Executables PIC / PIE +https://github.com/rgujju/STM32-projects/tree/master/got_plt +https://community.arm.com/support-forums/f/architectures-and-processors-forum/45919/gcc-does-not-generate-correct-code-while-building-pic +https://systemoverlord.com/2017/03/19/got-and-plt-for-pwning.html +https://reverseengineering.stackexchange.com/questions/1992/what-is-plt-got + +----------------------------------------------------------------- + +CPPFLAGS += -fdata-sections -ffunction-sections +Required to compile without missing (unused) symbols + +----------------------------------------------------------------- + +USB audio: +- pre fx +- post fx +- interlace + +[usb] -| |- [usb] + +- fx -+ +[adc] -| |- [dac] + +e.g. 4ch adc/dac, 4ch usb tx/rx, 8 ch fx + +----------------------------------------------------------------- +