├── .cproject ├── .gitattributes ├── .gitignore ├── .project ├── .settings ├── de.loskutov.anyedit.AnyEditTools.prefs ├── language.settings.xml ├── org.eclipse.cdt.codan.core.prefs └── org.eclipse.cdt.managedbuilder.core.prefs ├── Lib ├── STM32F4xx_StdPeriph_Driver │ ├── inc │ │ ├── misc.h │ │ ├── stm32f4xx_adc.h │ │ ├── stm32f4xx_can.h │ │ ├── stm32f4xx_crc.h │ │ ├── stm32f4xx_cryp.h │ │ ├── stm32f4xx_dac.h │ │ ├── stm32f4xx_dbgmcu.h │ │ ├── stm32f4xx_dcmi.h │ │ ├── stm32f4xx_dma.h │ │ ├── stm32f4xx_dma2d.h │ │ ├── stm32f4xx_exti.h │ │ ├── stm32f4xx_flash.h │ │ ├── stm32f4xx_fmc.h │ │ ├── stm32f4xx_fsmc.h │ │ ├── stm32f4xx_gpio.h │ │ ├── stm32f4xx_hash.h │ │ ├── stm32f4xx_i2c.h │ │ ├── stm32f4xx_iwdg.h │ │ ├── stm32f4xx_ltdc.h │ │ ├── stm32f4xx_pwr.h │ │ ├── stm32f4xx_rcc.h │ │ ├── stm32f4xx_rng.h │ │ ├── stm32f4xx_rtc.h │ │ ├── stm32f4xx_sai.h │ │ ├── stm32f4xx_sdio.h │ │ ├── stm32f4xx_spi.h │ │ ├── stm32f4xx_syscfg.h │ │ ├── stm32f4xx_tim.h │ │ ├── stm32f4xx_usart.h │ │ └── stm32f4xx_wwdg.h │ └── src │ │ ├── misc.c │ │ ├── stm32f4xx_dac.c │ │ ├── stm32f4xx_dma.c │ │ ├── stm32f4xx_exti.c │ │ ├── stm32f4xx_gpio.c │ │ ├── stm32f4xx_i2c.c │ │ ├── stm32f4xx_rcc.c │ │ ├── stm32f4xx_rng.c │ │ ├── stm32f4xx_spi.c │ │ ├── stm32f4xx_syscfg.c │ │ └── stm32f4xx_tim.c ├── STM32_USB_HOST_Library │ └── Core │ │ ├── inc │ │ ├── usbh_conf_template.h │ │ ├── usbh_core.h │ │ ├── usbh_def.h │ │ ├── usbh_hcs.h │ │ ├── usbh_ioreq.h │ │ └── usbh_stdreq.h │ │ └── src │ │ ├── usbh_core.c │ │ ├── usbh_hcs.c │ │ ├── usbh_ioreq.c │ │ └── usbh_stdreq.c └── STM32_USB_OTG_Driver │ ├── inc │ ├── usb_bsp.h │ ├── usb_conf_template.h │ ├── usb_core.h │ ├── usb_dcd.h │ ├── usb_dcd_int.h │ ├── usb_defines.h │ ├── usb_hcd.h │ ├── usb_hcd_int.h │ └── usb_regs.h │ └── src │ ├── usb_core.c │ ├── usb_hcd.c │ └── usb_hcd_int.c ├── README.md ├── Release ├── Dekrispator.elf ├── Dekrispator.hex ├── Dekrispator.lst ├── Dekrispator.map ├── Lib │ ├── STM32F4xx_StdPeriph_Driver │ │ └── src │ │ │ └── subdir.mk │ ├── STM32_USB_HOST_Library │ │ └── Core │ │ │ └── src │ │ │ └── subdir.mk │ └── STM32_USB_OTG_Driver │ │ └── src │ │ └── subdir.mk ├── Synth │ └── subdir.mk ├── System │ └── subdir.mk ├── USB │ ├── MIDIstream_class │ │ └── subdir.mk │ └── subdir.mk ├── makefile ├── objects.mk └── sources.mk ├── Ressources ├── MIDI_mapping.ods └── dekrispator_nanoKv1.nktrl_set ├── Synth ├── CONSTANTS.h ├── adsr.c ├── adsr.h ├── audio.c ├── audio.h ├── blepvco.c ├── blepvco.h ├── chorusFD.c ├── chorusFD.h ├── delay.c ├── delay.h ├── drifter.c ├── drifter.h ├── main.c ├── main.h ├── math_tools.c ├── math_tools.h ├── midi_interface.c ├── midi_interface.h ├── minblep_tables.c ├── minblep_tables.h ├── notesTables.c ├── notesTables.h ├── oscillators.c ├── oscillators.h ├── phaser.c ├── phaser.h ├── random.c ├── random.h ├── resonantFilter.c ├── resonantFilter.h ├── sequencer.c ├── sequencer.h ├── sinetable.c ├── sinetable.h ├── soundGen.c ├── soundGen.h ├── timers.c └── timers.h ├── System ├── core_cm4.h ├── core_cm4_simd.h ├── core_cmFunc.h ├── core_cmInstr.h ├── my_stm32f4_discovery.c ├── my_stm32f4_discovery.h ├── my_stm32f4_discovery_audio_codec.c ├── my_stm32f4_discovery_audio_codec.h ├── startup_stm32f4xx.c ├── stm32f407xav.ld ├── stm32f4xx.h ├── stm32f4xx_conf.h ├── stm32fxxx_it.c ├── stm32fxxx_it.h ├── system_stm32f4xx.c └── system_stm32f4xx.h └── USB ├── MIDIstream_class ├── usbh_midi_core.c └── usbh_midi_core.h ├── usb_bsp.c ├── usb_bsp.h ├── usb_conf.h ├── usbh_conf.h ├── usbh_usr.c └── usbh_usr.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.d 6 | *.o 7 | 8 | 9 | *.pydevproject 10 | #.project 11 | .metadata 12 | bin/ 13 | tmp/ 14 | *.tmp 15 | *.bak 16 | *.swp 17 | *~.nib 18 | local.properties 19 | .classpath 20 | #.settings/ 21 | .loadpath 22 | 23 | # External tool builders 24 | .externalToolBuilders/ 25 | 26 | # Locally stored "Eclipse launch configurations" 27 | *.launch 28 | 29 | # CDT-specific 30 | #.cproject 31 | 32 | # PDT-specific 33 | .buildpath 34 | 35 | 36 | ################# 37 | ## Visual Studio 38 | ################# 39 | 40 | ## Ignore Visual Studio temporary files, build results, and 41 | ## files generated by popular Visual Studio add-ons. 42 | 43 | # User-specific files 44 | *.suo 45 | *.user 46 | *.sln.docstates 47 | 48 | # Build results 49 | 50 | #[Dd]ebug/ 51 | #[Rr]elease/ 52 | x64/ 53 | build/ 54 | [Bb]in/ 55 | [Oo]bj/ 56 | 57 | # MSTest test Results 58 | [Tt]est[Rr]esult*/ 59 | [Bb]uild[Ll]og.* 60 | 61 | *_i.c 62 | *_p.c 63 | *.ilk 64 | *.meta 65 | *.obj 66 | *.pch 67 | *.pdb 68 | *.pgc 69 | *.pgd 70 | *.rsp 71 | *.sbr 72 | *.tlb 73 | *.tli 74 | *.tlh 75 | *.tmp 76 | *.tmp_proj 77 | *.log 78 | *.vspscc 79 | *.vssscc 80 | .builds 81 | *.pidb 82 | *.log 83 | *.scc 84 | 85 | # Visual C++ cache files 86 | ipch/ 87 | *.aps 88 | *.ncb 89 | *.opensdf 90 | *.sdf 91 | *.cachefile 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | 98 | # Guidance Automation Toolkit 99 | *.gpState 100 | 101 | # ReSharper is a .NET coding add-in 102 | _ReSharper*/ 103 | *.[Rr]e[Ss]harper 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | *.ncrunch* 113 | .*crunch*.local.xml 114 | 115 | # Installshield output folder 116 | [Ee]xpress/ 117 | 118 | # DocProject is a documentation generator add-in 119 | DocProject/buildhelp/ 120 | DocProject/Help/*.HxT 121 | DocProject/Help/*.HxC 122 | DocProject/Help/*.hhc 123 | DocProject/Help/*.hhk 124 | DocProject/Help/*.hhp 125 | DocProject/Help/Html2 126 | DocProject/Help/html 127 | 128 | # Click-Once directory 129 | publish/ 130 | 131 | # Publish Web Output 132 | *.Publish.xml 133 | *.pubxml 134 | 135 | # NuGet Packages Directory 136 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 137 | #packages/ 138 | 139 | # Windows Azure Build Output 140 | csx 141 | *.build.csdef 142 | 143 | # Windows Store app package directory 144 | AppPackages/ 145 | 146 | # Others 147 | sql/ 148 | *.Cache 149 | ClientBin/ 150 | [Ss]tyle[Cc]op.* 151 | ~$* 152 | *~ 153 | *.dbmdl 154 | *.[Pp]ublish.xml 155 | *.pfx 156 | *.publishsettings 157 | 158 | # RIA/Silverlight projects 159 | Generated_Code/ 160 | 161 | # Backup & report files from converting an old project file to a newer 162 | # Visual Studio version. Backup files are not needed, because we have git ;-) 163 | _UpgradeReport_Files/ 164 | Backup*/ 165 | UpgradeLog*.XML 166 | UpgradeLog*.htm 167 | 168 | # SQL Server files 169 | App_Data/*.mdf 170 | App_Data/*.ldf 171 | 172 | ############# 173 | ## Windows detritus 174 | ############# 175 | 176 | # Windows image file caches 177 | Thumbs.db 178 | ehthumbs.db 179 | 180 | # Folder config file 181 | Desktop.ini 182 | 183 | # Recycle Bin used on file shares 184 | $RECYCLE.BIN/ 185 | 186 | # Mac crap 187 | .DS_Store 188 | 189 | 190 | ############# 191 | ## Python 192 | ############# 193 | 194 | *.py[co] 195 | 196 | # Packages 197 | *.egg 198 | *.egg-info 199 | dist/ 200 | build/ 201 | eggs/ 202 | parts/ 203 | var/ 204 | sdist/ 205 | develop-eggs/ 206 | .installed.cfg 207 | 208 | # Installer logs 209 | pip-log.txt 210 | 211 | # Unit test / coverage reports 212 | .coverage 213 | .tox 214 | 215 | #Translations 216 | *.mo 217 | 218 | #Mr Developer 219 | .mr.developer.cfg 220 | #/Release 221 | /Release 222 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dekrispator 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /.settings/de.loskutov.anyedit.AnyEditTools.prefs: -------------------------------------------------------------------------------- 1 | activeContentFilterList=*.makefile,makefile,*.Makefile,Makefile,Makefile.*,*.mk,MANIFEST.MF 2 | addNewLine=true 3 | convertActionOnSaave=AnyEdit.CnvrtTabToSpaces 4 | eclipse.preferences.version=1 5 | ignoreBlankLinesWhenTrimming=false 6 | inActiveContentFilterList= 7 | javaTabWidthForJava=true 8 | org.eclipse.jdt.ui.editor.tab.width=2 9 | projectPropsEnabled=false 10 | removeTrailingSpaces=true 11 | replaceAllSpaces=false 12 | replaceAllTabs=false 13 | saveAndAddLine=false 14 | saveAndConvert=false 15 | saveAndTrim=true 16 | useModulo4Tabs=false 17 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/CPATH/delimiter=; 3 | environment/buildEnvironmentInclude/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/C_INCLUDE_PATH/delimiter=; 5 | environment/buildEnvironmentInclude/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/C_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/append=true 7 | environment/buildEnvironmentInclude/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/appendContributed=true 8 | environment/buildEnvironmentLibrary/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/LIBRARY_PATH/delimiter=; 9 | environment/buildEnvironmentLibrary/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/LIBRARY_PATH/operation=remove 10 | environment/buildEnvironmentLibrary/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/append=true 11 | environment/buildEnvironmentLibrary/ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.2044054199/appendContributed=true 12 | -------------------------------------------------------------------------------- /Lib/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_CRC_H 31 | #define __STM32F4xx_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* Exported functions --------------------------------------------------------*/ 61 | 62 | void CRC_ResetDR(void); 63 | uint32_t CRC_CalcCRC(uint32_t Data); 64 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 65 | uint32_t CRC_GetCRC(void); 66 | void CRC_SetIDRegister(uint8_t IDValue); 67 | uint8_t CRC_GetIDRegister(void); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __STM32F4xx_CRC_H */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 84 | -------------------------------------------------------------------------------- /Lib/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F4xx_DBGMCU_H 30 | #define __STM32F4xx_DBGMCU_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "stm32f4xx.h" 38 | 39 | /** @addtogroup STM32F4xx_StdPeriph_Driver 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup DBGMCU 44 | * @{ 45 | */ 46 | 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 54 | #define DBGMCU_STOP ((uint32_t)0x00000002) 55 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 56 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00)) 57 | 58 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001) 59 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002) 60 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004) 61 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00000008) 62 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010) 63 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020) 64 | #define DBGMCU_TIM12_STOP ((uint32_t)0x00000040) 65 | #define DBGMCU_TIM13_STOP ((uint32_t)0x00000080) 66 | #define DBGMCU_TIM14_STOP ((uint32_t)0x00000100) 67 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400) 68 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800) 69 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000) 70 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000) 71 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000) 72 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x00800000) 73 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000) 74 | #define DBGMCU_CAN2_STOP ((uint32_t)0x04000000) 75 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xF91FE200) == 0x00) && ((PERIPH) != 0x00)) 76 | 77 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001) 78 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002) 79 | #define DBGMCU_TIM9_STOP ((uint32_t)0x00010000) 80 | #define DBGMCU_TIM10_STOP ((uint32_t)0x00020000) 81 | #define DBGMCU_TIM11_STOP ((uint32_t)0x00040000) 82 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8FFFC) == 0x00) && ((PERIPH) != 0x00)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /* Exported macro ------------------------------------------------------------*/ 88 | /* Exported functions --------------------------------------------------------*/ 89 | uint32_t DBGMCU_GetREVID(void); 90 | uint32_t DBGMCU_GetDEVID(void); 91 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 92 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 93 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __STM32F4xx_DBGMCU_H */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /Lib/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_IWDG_H 31 | #define __STM32F4xx_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup IWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup IWDG_WriteAccess 56 | * @{ 57 | */ 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 70 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 71 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 72 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 73 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 74 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 75 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 76 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 77 | ((PRESCALER) == IWDG_Prescaler_8) || \ 78 | ((PRESCALER) == IWDG_Prescaler_16) || \ 79 | ((PRESCALER) == IWDG_Prescaler_32) || \ 80 | ((PRESCALER) == IWDG_Prescaler_64) || \ 81 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 82 | ((PRESCALER) == IWDG_Prescaler_256)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup IWDG_Flag 88 | * @{ 89 | */ 90 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 91 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 92 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 93 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /* Exported macro ------------------------------------------------------------*/ 103 | /* Exported functions --------------------------------------------------------*/ 104 | 105 | /* Prescaler and Counter configuration functions ******************************/ 106 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 107 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 108 | void IWDG_SetReload(uint16_t Reload); 109 | void IWDG_ReloadCounter(void); 110 | 111 | /* IWDG activation function ***************************************************/ 112 | void IWDG_Enable(void); 113 | 114 | /* Flag management function ***************************************************/ 115 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* __STM32F4xx_IWDG_H */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 132 | -------------------------------------------------------------------------------- /Lib/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rng.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_rng.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the Random 8 | * Number Generator(RNG) firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_RNG_H 31 | #define __STM32F4xx_RNG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup RNG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup RNG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup RNG_flags_definition 56 | * @{ 57 | */ 58 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */ 59 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */ 60 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */ 61 | 62 | #define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \ 63 | ((RNG_FLAG) == RNG_FLAG_CECS) || \ 64 | ((RNG_FLAG) == RNG_FLAG_SECS)) 65 | #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \ 66 | ((RNG_FLAG) == RNG_FLAG_SECS)) 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup RNG_interrupts_definition 72 | * @{ 73 | */ 74 | #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */ 75 | #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */ 76 | 77 | #define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00)) 78 | #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI)) 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /* Exported macro ------------------------------------------------------------*/ 88 | /* Exported functions --------------------------------------------------------*/ 89 | 90 | /* Function used to set the RNG configuration to the default reset state *****/ 91 | void RNG_DeInit(void); 92 | 93 | /* Configuration function *****************************************************/ 94 | void RNG_Cmd(FunctionalState NewState); 95 | 96 | /* Get 32 bit Random number function ******************************************/ 97 | uint32_t RNG_GetRandomNumber(void); 98 | 99 | /* Interrupts and flags management functions **********************************/ 100 | void RNG_ITConfig(FunctionalState NewState); 101 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG); 102 | void RNG_ClearFlag(uint8_t RNG_FLAG); 103 | ITStatus RNG_GetITStatus(uint8_t RNG_IT); 104 | void RNG_ClearITPendingBit(uint8_t RNG_IT); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /*__STM32F4xx_RNG_H */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 121 | -------------------------------------------------------------------------------- /Lib/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_WWDG_H 31 | #define __STM32F4xx_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup WWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup WWDG_Prescaler 56 | * @{ 57 | */ 58 | 59 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 60 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 61 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 62 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 63 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 64 | ((PRESCALER) == WWDG_Prescaler_2) || \ 65 | ((PRESCALER) == WWDG_Prescaler_4) || \ 66 | ((PRESCALER) == WWDG_Prescaler_8)) 67 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 68 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /* Exported macro ------------------------------------------------------------*/ 79 | /* Exported functions --------------------------------------------------------*/ 80 | 81 | /* Function used to set the WWDG configuration to the default reset state ****/ 82 | void WWDG_DeInit(void); 83 | 84 | /* Prescaler, Refresh window and Counter configuration functions **************/ 85 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 86 | void WWDG_SetWindowValue(uint8_t WindowValue); 87 | void WWDG_EnableIT(void); 88 | void WWDG_SetCounter(uint8_t Counter); 89 | 90 | /* WWDG activation function ***************************************************/ 91 | void WWDG_Enable(uint8_t Counter); 92 | 93 | /* Interrupts and flags management functions **********************************/ 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F4xx_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 112 | -------------------------------------------------------------------------------- /Lib/STM32_USB_HOST_Library/Core/inc/usbh_conf_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_conf_template 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief General USB Host library configuration 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBH_CONF__H__ 30 | #define __USBH_CONF__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | 34 | /** @addtogroup USBH_OTG_DRIVER 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBH_CONF 39 | * @brief usb otg low level driver configuration file 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBH_CONF_Exported_Defines 44 | * @{ 45 | */ 46 | 47 | #define USBH_MAX_NUM_ENDPOINTS 2 48 | #define USBH_MAX_NUM_INTERFACES 2 49 | #ifdef USE_USB_OTG_FS 50 | #define USBH_MSC_MPS_SIZE 0x40 51 | #else 52 | #define USBH_MSC_MPS_SIZE 0x200 53 | #endif 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | 60 | /** @defgroup USBH_CONF_Exported_Types 61 | * @{ 62 | */ 63 | /** 64 | * @} 65 | */ 66 | 67 | 68 | /** @defgroup USBH_CONF_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBH_CONF_Exported_Variables 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBH_CONF_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | 90 | #endif //__USBH_CONF__H__ 91 | 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 101 | 102 | -------------------------------------------------------------------------------- /Lib/STM32_USB_HOST_Library/Core/inc/usbh_def.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrBlueXav/Dekrispator/f23665ba689f0a6d6cd88037d5676ee4c92910c3/Lib/STM32_USB_HOST_Library/Core/inc/usbh_def.h -------------------------------------------------------------------------------- /Lib/STM32_USB_HOST_Library/Core/inc/usbh_hcs.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hcs.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Header file for usbh_hcs.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_HCS_H 30 | #define __USBH_HCS_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usbh_core.h" 34 | 35 | /** @addtogroup USBH_LIB 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup USBH_LIB_CORE 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBH_HCS 44 | * @brief This file is the header file for usbh_hcs.c 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBH_HCS_Exported_Defines 49 | * @{ 50 | */ 51 | #define HC_MAX 8 52 | 53 | #define HC_OK 0x0000 54 | #define HC_USED 0x8000 55 | #define HC_ERROR 0xFFFF 56 | #define HC_USED_MASK 0x7FFF 57 | /** 58 | * @} 59 | */ 60 | 61 | /** @defgroup USBH_HCS_Exported_Types 62 | * @{ 63 | */ 64 | /** 65 | * @} 66 | */ 67 | 68 | 69 | /** @defgroup USBH_HCS_Exported_Macros 70 | * @{ 71 | */ 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBH_HCS_Exported_Variables 77 | * @{ 78 | */ 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup USBH_HCS_Exported_FunctionsPrototype 84 | * @{ 85 | */ 86 | 87 | uint8_t USBH_Alloc_Channel(USB_OTG_CORE_HANDLE *pdev, uint8_t ep_addr); 88 | 89 | uint8_t USBH_Free_Channel (USB_OTG_CORE_HANDLE *pdev, uint8_t idx); 90 | 91 | uint8_t USBH_DeAllocate_AllChannel (USB_OTG_CORE_HANDLE *pdev); 92 | 93 | uint8_t USBH_Open_Channel (USB_OTG_CORE_HANDLE *pdev, 94 | uint8_t ch_num, 95 | uint8_t dev_address, 96 | uint8_t speed, 97 | uint8_t ep_type, 98 | uint16_t mps); 99 | 100 | uint8_t USBH_Modify_Channel (USB_OTG_CORE_HANDLE *pdev, 101 | uint8_t hc_num, 102 | uint8_t dev_address, 103 | uint8_t speed, 104 | uint8_t ep_type, 105 | uint16_t mps); 106 | /** 107 | * @} 108 | */ 109 | 110 | 111 | 112 | #endif /* __USBH_HCS_H */ 113 | 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 128 | 129 | 130 | -------------------------------------------------------------------------------- /Lib/STM32_USB_HOST_Library/Core/inc/usbh_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Header file for usbh_ioreq.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_IOREQ_H 30 | #define __USBH_IOREQ_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_conf.h" 34 | #include "usbh_core.h" 35 | #include "usbh_def.h" 36 | 37 | /** @addtogroup USBH_LIB 38 | * @{ 39 | */ 40 | 41 | /** @addtogroup USBH_LIB_CORE 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBH_IOREQ 46 | * @brief This file is the header file for usbh_ioreq.c 47 | * @{ 48 | */ 49 | 50 | 51 | /** @defgroup USBH_IOREQ_Exported_Defines 52 | * @{ 53 | */ 54 | #define USBH_SETUP_PKT_SIZE 8 55 | #define USBH_EP0_EP_NUM 0 56 | #define USBH_MAX_PACKET_SIZE 0x40 57 | /** 58 | * @} 59 | */ 60 | 61 | 62 | /** @defgroup USBH_IOREQ_Exported_Types 63 | * @{ 64 | */ 65 | /** 66 | * @} 67 | */ 68 | 69 | 70 | /** @defgroup USBH_IOREQ_Exported_Macros 71 | * @{ 72 | */ 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup USBH_IOREQ_Exported_Variables 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBH_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | USBH_Status USBH_CtlSendSetup ( USB_OTG_CORE_HANDLE *pdev, 88 | uint8_t *buff, 89 | uint8_t hc_num); 90 | 91 | USBH_Status USBH_CtlSendData ( USB_OTG_CORE_HANDLE *pdev, 92 | uint8_t *buff, 93 | uint16_t length, 94 | uint8_t hc_num); 95 | 96 | USBH_Status USBH_CtlReceiveData( USB_OTG_CORE_HANDLE *pdev, 97 | uint8_t *buff, 98 | uint16_t length, 99 | uint8_t hc_num); 100 | 101 | USBH_Status USBH_BulkReceiveData( USB_OTG_CORE_HANDLE *pdev, 102 | uint8_t *buff, 103 | uint16_t length, 104 | uint8_t hc_num); 105 | 106 | USBH_Status USBH_BulkSendData ( USB_OTG_CORE_HANDLE *pdev, 107 | uint8_t *buff, 108 | uint16_t length, 109 | uint8_t hc_num); 110 | 111 | USBH_Status USBH_InterruptReceiveData( USB_OTG_CORE_HANDLE *pdev, 112 | uint8_t *buff, 113 | uint8_t length, 114 | uint8_t hc_num); 115 | 116 | USBH_Status USBH_InterruptSendData( USB_OTG_CORE_HANDLE *pdev, 117 | uint8_t *buff, 118 | uint8_t length, 119 | uint8_t hc_num); 120 | 121 | USBH_Status USBH_CtlReq (USB_OTG_CORE_HANDLE *pdev, 122 | USBH_HOST *phost, 123 | uint8_t *buff, 124 | uint16_t length); 125 | 126 | USBH_Status USBH_IsocReceiveData( USB_OTG_CORE_HANDLE *pdev, 127 | uint8_t *buff, 128 | uint32_t length, 129 | uint8_t hc_num); 130 | 131 | 132 | USBH_Status USBH_IsocSendData( USB_OTG_CORE_HANDLE *pdev, 133 | uint8_t *buff, 134 | uint32_t length, 135 | uint8_t hc_num); 136 | /** 137 | * @} 138 | */ 139 | 140 | #endif /* __USBH_IOREQ_H */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 155 | 156 | 157 | -------------------------------------------------------------------------------- /Lib/STM32_USB_HOST_Library/Core/inc/usbh_stdreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_stdreq.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Header file for usbh_stdreq.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive ----------------------------------------------*/ 29 | #ifndef __USBH_STDREQ_H 30 | #define __USBH_STDREQ_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_conf.h" 34 | #include "usb_hcd.h" 35 | #include "usbh_core.h" 36 | #include "usbh_def.h" 37 | 38 | /** @addtogroup USBH_LIB 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup USBH_LIB_CORE 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBH_STDREQ 47 | * @brief This file is the 48 | * @{ 49 | */ 50 | 51 | 52 | /** @defgroup USBH_STDREQ_Exported_Defines 53 | * @{ 54 | */ 55 | /*Standard Feature Selector for clear feature command*/ 56 | #define FEATURE_SELECTOR_ENDPOINT 0X00 57 | #define FEATURE_SELECTOR_DEVICE 0X01 58 | 59 | 60 | #define INTERFACE_DESC_TYPE 0x04 61 | #define ENDPOINT_DESC_TYPE 0x05 62 | #define INTERFACE_DESC_SIZE 0x09 63 | 64 | 65 | #define USBH_HID_CLASS 0x03 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | 72 | /** @defgroup USBH_STDREQ_Exported_Types 73 | * @{ 74 | */ 75 | /** 76 | * @} 77 | */ 78 | 79 | 80 | /** @defgroup USBH_STDREQ_Exported_Macros 81 | * @{ 82 | */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USBH_STDREQ_Exported_Variables 88 | * @{ 89 | */ 90 | extern uint8_t USBH_CfgDesc[512]; 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @defgroup USBH_STDREQ_Exported_FunctionsPrototype 96 | * @{ 97 | */ 98 | USBH_Status USBH_GetDescriptor(USB_OTG_CORE_HANDLE *pdev, 99 | USBH_HOST *phost, 100 | uint8_t req_type, 101 | uint16_t value_idx, 102 | uint8_t* buff, 103 | uint16_t length ); 104 | 105 | USBH_Status USBH_Get_DevDesc(USB_OTG_CORE_HANDLE *pdev, 106 | USBH_HOST *phost, 107 | uint8_t length); 108 | 109 | USBH_Status USBH_Get_StringDesc(USB_OTG_CORE_HANDLE *pdev, 110 | USBH_HOST *phost, 111 | uint8_t string_index, 112 | uint8_t *buff, 113 | uint16_t length); 114 | 115 | USBH_Status USBH_SetCfg(USB_OTG_CORE_HANDLE *pdev, 116 | USBH_HOST *phost, 117 | uint16_t configuration_value); 118 | 119 | USBH_Status USBH_Get_CfgDesc(USB_OTG_CORE_HANDLE *pdev, 120 | USBH_HOST *phost, 121 | uint16_t length); 122 | 123 | USBH_Status USBH_SetAddress(USB_OTG_CORE_HANDLE *pdev, 124 | USBH_HOST *phost, 125 | uint8_t DeviceAddress); 126 | 127 | USBH_Status USBH_ClrFeature(USB_OTG_CORE_HANDLE *pdev, 128 | USBH_HOST *phost, 129 | uint8_t ep_num, uint8_t hc_num); 130 | 131 | USBH_Status USBH_SetInterface(USB_OTG_CORE_HANDLE *pdev, 132 | USBH_HOST *phost, 133 | uint8_t ep_num, uint8_t altSetting); 134 | 135 | USBH_Status USBH_Issue_ClrFeature(USB_OTG_CORE_HANDLE *pdev, 136 | USBH_HOST *phost, 137 | uint8_t ep_num); 138 | 139 | USBH_DescHeader_t *USBH_GetNextDesc (uint8_t *pbuf, 140 | uint16_t *ptr); 141 | /** 142 | * @} 143 | */ 144 | 145 | #endif /* __USBH_STDREQ_H */ 146 | 147 | /** 148 | * @} 149 | */ 150 | 151 | /** 152 | * @} 153 | */ 154 | 155 | /** 156 | * @} 157 | */ 158 | 159 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 160 | 161 | 162 | -------------------------------------------------------------------------------- /Lib/STM32_USB_HOST_Library/Core/src/usbh_hcs.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_hcs.c 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief This file implements functions for opening and closing host channels 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbh_hcs.h" 30 | 31 | /** @addtogroup USBH_LIB 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup USBH_LIB_CORE 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBH_HCS 40 | * @brief This file includes opening and closing host channels 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBH_HCS_Private_Defines 45 | * @{ 46 | */ 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup USBH_HCS_Private_TypesDefinitions 52 | * @{ 53 | */ 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | /** @defgroup USBH_HCS_Private_Macros 60 | * @{ 61 | */ 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBH_HCS_Private_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | 76 | /** @defgroup USBH_HCS_Private_FunctionPrototypes 77 | * @{ 78 | */ 79 | static uint16_t USBH_GetFreeChannel (USB_OTG_CORE_HANDLE *pdev); 80 | /** 81 | * @} 82 | */ 83 | 84 | 85 | /** @defgroup USBH_HCS_Private_Functions 86 | * @{ 87 | */ 88 | 89 | 90 | 91 | /** 92 | * @brief USBH_Open_Channel 93 | * Open a pipe 94 | * @param pdev : Selected device 95 | * @param hc_num: Host channel Number 96 | * @param dev_address: USB Device address allocated to attached device 97 | * @param speed : USB device speed (Full/Low) 98 | * @param ep_type: end point type (Bulk/int/ctl) 99 | * @param mps: max pkt size 100 | * @retval Status 101 | */ 102 | uint8_t USBH_Open_Channel (USB_OTG_CORE_HANDLE *pdev, 103 | uint8_t hc_num, 104 | uint8_t dev_address, 105 | uint8_t speed, 106 | uint8_t ep_type, 107 | uint16_t mps) 108 | { 109 | 110 | pdev->host.hc[hc_num].ep_num = pdev->host.channel[hc_num]& 0x7F; 111 | pdev->host.hc[hc_num].ep_is_in = (pdev->host.channel[hc_num] & 0x80 ) == 0x80; 112 | pdev->host.hc[hc_num].dev_addr = dev_address; 113 | pdev->host.hc[hc_num].ep_type = ep_type; 114 | pdev->host.hc[hc_num].max_packet = mps; 115 | pdev->host.hc[hc_num].speed = speed; 116 | pdev->host.hc[hc_num].toggle_in = 0; 117 | pdev->host.hc[hc_num].toggle_out = 0; 118 | if(speed == HPRT0_PRTSPD_HIGH_SPEED) 119 | { 120 | pdev->host.hc[hc_num].do_ping = 1; 121 | } 122 | 123 | USB_OTG_HC_Init(pdev, hc_num) ; 124 | 125 | return HC_OK; 126 | 127 | } 128 | 129 | /** 130 | * @brief USBH_Modify_Channel 131 | * Modify a pipe 132 | * @param pdev : Selected device 133 | * @param hc_num: Host channel Number 134 | * @param dev_address: USB Device address allocated to attached device 135 | * @param speed : USB device speed (Full/Low) 136 | * @param ep_type: end point type (Bulk/int/ctl) 137 | * @param mps: max pkt size 138 | * @retval Status 139 | */ 140 | uint8_t USBH_Modify_Channel (USB_OTG_CORE_HANDLE *pdev, 141 | uint8_t hc_num, 142 | uint8_t dev_address, 143 | uint8_t speed, 144 | uint8_t ep_type, 145 | uint16_t mps) 146 | { 147 | 148 | if(dev_address != 0) 149 | { 150 | pdev->host.hc[hc_num].dev_addr = dev_address; 151 | } 152 | 153 | if((pdev->host.hc[hc_num].max_packet != mps) && (mps != 0)) 154 | { 155 | pdev->host.hc[hc_num].max_packet = mps; 156 | } 157 | 158 | if((pdev->host.hc[hc_num].speed != speed ) && (speed != 0 )) 159 | { 160 | pdev->host.hc[hc_num].speed = speed; 161 | } 162 | 163 | USB_OTG_HC_Init(pdev, hc_num); 164 | return HC_OK; 165 | 166 | } 167 | 168 | /** 169 | * @brief USBH_Alloc_Channel 170 | * Allocate a new channel for the pipe 171 | * @param ep_addr: End point for which the channel to be allocated 172 | * @retval hc_num: Host channel number 173 | */ 174 | uint8_t USBH_Alloc_Channel (USB_OTG_CORE_HANDLE *pdev, uint8_t ep_addr) 175 | { 176 | uint16_t hc_num; 177 | 178 | hc_num = USBH_GetFreeChannel(pdev); 179 | 180 | if (hc_num != HC_ERROR) 181 | { 182 | pdev->host.channel[hc_num] = HC_USED | ep_addr; 183 | } 184 | return hc_num; 185 | } 186 | 187 | /** 188 | * @brief USBH_Free_Pipe 189 | * Free the USB host channel 190 | * @param idx: Channel number to be freed 191 | * @retval Status 192 | */ 193 | uint8_t USBH_Free_Channel (USB_OTG_CORE_HANDLE *pdev, uint8_t idx) 194 | { 195 | if(idx < HC_MAX) 196 | { 197 | pdev->host.channel[idx] &= HC_USED_MASK; 198 | } 199 | return USBH_OK; 200 | } 201 | 202 | 203 | /** 204 | * @brief USBH_DeAllocate_AllChannel 205 | * Free all USB host channel 206 | * @param pdev : core instance 207 | * @retval Status 208 | */ 209 | uint8_t USBH_DeAllocate_AllChannel (USB_OTG_CORE_HANDLE *pdev) 210 | { 211 | uint8_t idx; 212 | 213 | for (idx = 2; idx < HC_MAX ; idx ++) 214 | { 215 | pdev->host.channel[idx] = 0; 216 | } 217 | return USBH_OK; 218 | } 219 | 220 | /** 221 | * @brief USBH_GetFreeChannel 222 | * Get a free channel number for allocation to a device endpoint 223 | * @param None 224 | * @retval idx: Free Channel number 225 | */ 226 | static uint16_t USBH_GetFreeChannel (USB_OTG_CORE_HANDLE *pdev) 227 | { 228 | uint8_t idx = 0; 229 | 230 | for (idx = 0 ; idx < HC_MAX ; idx++) 231 | { 232 | if ((pdev->host.channel[idx] & HC_USED) == 0) 233 | { 234 | return idx; 235 | } 236 | } 237 | return HC_ERROR; 238 | } 239 | 240 | 241 | /** 242 | * @} 243 | */ 244 | 245 | /** 246 | * @} 247 | */ 248 | 249 | /** 250 | * @} 251 | */ 252 | 253 | /** 254 | * @} 255 | */ 256 | 257 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 258 | 259 | 260 | -------------------------------------------------------------------------------- /Lib/STM32_USB_OTG_Driver/inc/usb_bsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_bsp.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Specific api's relative to the used hardware platform 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_BSP__H__ 30 | #define __USB_BSP__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_core.h" 34 | #include "usb_conf.h" 35 | 36 | /** @addtogroup USB_OTG_DRIVER 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USB_BSP 41 | * @brief This file is the 42 | * @{ 43 | */ 44 | 45 | 46 | /** @defgroup USB_BSP_Exported_Defines 47 | * @{ 48 | */ 49 | /** 50 | * @} 51 | */ 52 | 53 | 54 | /** @defgroup USB_BSP_Exported_Types 55 | * @{ 56 | */ 57 | /** 58 | * @} 59 | */ 60 | 61 | 62 | /** @defgroup USB_BSP_Exported_Macros 63 | * @{ 64 | */ 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup USB_BSP_Exported_Variables 70 | * @{ 71 | */ 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USB_BSP_Exported_FunctionsPrototype 77 | * @{ 78 | */ 79 | void BSP_Init(void); 80 | 81 | void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev); 82 | void USB_OTG_BSP_uDelay (const uint32_t usec); 83 | void USB_OTG_BSP_mDelay (const uint32_t msec); 84 | void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev); 85 | #ifdef USE_HOST_MODE 86 | void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev); 87 | void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state); 88 | #endif 89 | /** 90 | * @} 91 | */ 92 | 93 | #endif //__USB_BSP__H__ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 103 | 104 | -------------------------------------------------------------------------------- /Lib/STM32_USB_OTG_Driver/inc/usb_dcd.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_dcd.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Peripheral Driver Header file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __DCD_H__ 30 | #define __DCD_H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_core.h" 34 | 35 | 36 | /** @addtogroup USB_OTG_DRIVER 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USB_DCD 41 | * @brief This file is the 42 | * @{ 43 | */ 44 | 45 | 46 | /** @defgroup USB_DCD_Exported_Defines 47 | * @{ 48 | */ 49 | #define USB_OTG_EP_CONTROL 0 50 | #define USB_OTG_EP_ISOC 1 51 | #define USB_OTG_EP_BULK 2 52 | #define USB_OTG_EP_INT 3 53 | #define USB_OTG_EP_MASK 3 54 | 55 | /* Device Status */ 56 | #define USB_OTG_DEFAULT 1 57 | #define USB_OTG_ADDRESSED 2 58 | #define USB_OTG_CONFIGURED 3 59 | #define USB_OTG_SUSPENDED 4 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USB_DCD_Exported_Types 67 | * @{ 68 | */ 69 | /******************************************************************************** 70 | Data structure type 71 | ********************************************************************************/ 72 | typedef struct 73 | { 74 | uint8_t bLength; 75 | uint8_t bDescriptorType; 76 | uint8_t bEndpointAddress; 77 | uint8_t bmAttributes; 78 | uint16_t wMaxPacketSize; 79 | uint8_t bInterval; 80 | } 81 | EP_DESCRIPTOR , *PEP_DESCRIPTOR; 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | 88 | /** @defgroup USB_DCD_Exported_Macros 89 | * @{ 90 | */ 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @defgroup USB_DCD_Exported_Variables 96 | * @{ 97 | */ 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup USB_DCD_Exported_FunctionsPrototype 103 | * @{ 104 | */ 105 | /******************************************************************************** 106 | EXPORTED FUNCTION FROM THE USB-OTG LAYER 107 | ********************************************************************************/ 108 | void DCD_Init(USB_OTG_CORE_HANDLE *pdev , 109 | USB_OTG_CORE_ID_TypeDef coreID); 110 | 111 | void DCD_DevConnect (USB_OTG_CORE_HANDLE *pdev); 112 | void DCD_DevDisconnect (USB_OTG_CORE_HANDLE *pdev); 113 | void DCD_EP_SetAddress (USB_OTG_CORE_HANDLE *pdev, 114 | uint8_t address); 115 | uint32_t DCD_EP_Open(USB_OTG_CORE_HANDLE *pdev , 116 | uint8_t ep_addr, 117 | uint16_t ep_mps, 118 | uint8_t ep_type); 119 | 120 | uint32_t DCD_EP_Close (USB_OTG_CORE_HANDLE *pdev, 121 | uint8_t ep_addr); 122 | 123 | 124 | uint32_t DCD_EP_PrepareRx ( USB_OTG_CORE_HANDLE *pdev, 125 | uint8_t ep_addr, 126 | uint8_t *pbuf, 127 | uint16_t buf_len); 128 | 129 | uint32_t DCD_EP_Tx (USB_OTG_CORE_HANDLE *pdev, 130 | uint8_t ep_addr, 131 | uint8_t *pbuf, 132 | uint32_t buf_len); 133 | uint32_t DCD_EP_Stall (USB_OTG_CORE_HANDLE *pdev, 134 | uint8_t epnum); 135 | uint32_t DCD_EP_ClrStall (USB_OTG_CORE_HANDLE *pdev, 136 | uint8_t epnum); 137 | uint32_t DCD_EP_Flush (USB_OTG_CORE_HANDLE *pdev, 138 | uint8_t epnum); 139 | uint32_t DCD_Handle_ISR(USB_OTG_CORE_HANDLE *pdev); 140 | 141 | uint32_t DCD_GetEPStatus(USB_OTG_CORE_HANDLE *pdev , 142 | uint8_t epnum); 143 | 144 | void DCD_SetEPStatus (USB_OTG_CORE_HANDLE *pdev , 145 | uint8_t epnum , 146 | uint32_t Status); 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | 153 | #endif //__DCD_H__ 154 | 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 164 | 165 | -------------------------------------------------------------------------------- /Lib/STM32_USB_OTG_Driver/inc/usb_dcd_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_dcd_int.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Peripheral Device Interface Layer 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef USB_DCD_INT_H__ 30 | #define USB_DCD_INT_H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_dcd.h" 34 | 35 | 36 | 37 | /** @addtogroup USB_OTG_DRIVER 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USB_DCD_INT 42 | * @brief This file is the 43 | * @{ 44 | */ 45 | 46 | 47 | /** @defgroup USB_DCD_INT_Exported_Defines 48 | * @{ 49 | */ 50 | 51 | typedef struct _USBD_DCD_INT 52 | { 53 | uint8_t (* DataOutStage) (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum); 54 | uint8_t (* DataInStage) (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum); 55 | uint8_t (* SetupStage) (USB_OTG_CORE_HANDLE *pdev); 56 | uint8_t (* SOF) (USB_OTG_CORE_HANDLE *pdev); 57 | uint8_t (* Reset) (USB_OTG_CORE_HANDLE *pdev); 58 | uint8_t (* Suspend) (USB_OTG_CORE_HANDLE *pdev); 59 | uint8_t (* Resume) (USB_OTG_CORE_HANDLE *pdev); 60 | uint8_t (* IsoINIncomplete) (USB_OTG_CORE_HANDLE *pdev); 61 | uint8_t (* IsoOUTIncomplete) (USB_OTG_CORE_HANDLE *pdev); 62 | 63 | uint8_t (* DevConnected) (USB_OTG_CORE_HANDLE *pdev); 64 | uint8_t (* DevDisconnected) (USB_OTG_CORE_HANDLE *pdev); 65 | 66 | }USBD_DCD_INT_cb_TypeDef; 67 | 68 | extern USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops; 69 | /** 70 | * @} 71 | */ 72 | 73 | 74 | /** @defgroup USB_DCD_INT_Exported_Types 75 | * @{ 76 | */ 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup USB_DCD_INT_Exported_Macros 82 | * @{ 83 | */ 84 | 85 | #define CLEAR_IN_EP_INTR(epnum,intr) \ 86 | diepint.d32=0; \ 87 | diepint.b.intr = 1; \ 88 | USB_OTG_WRITE_REG32(&pdev->regs.INEP_REGS[epnum]->DIEPINT,diepint.d32); 89 | 90 | #define CLEAR_OUT_EP_INTR(epnum,intr) \ 91 | doepint.d32=0; \ 92 | doepint.b.intr = 1; \ 93 | USB_OTG_WRITE_REG32(&pdev->regs.OUTEP_REGS[epnum]->DOEPINT,doepint.d32); 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup USB_DCD_INT_Exported_Variables 100 | * @{ 101 | */ 102 | /** 103 | * @} 104 | */ 105 | 106 | /** @defgroup USB_DCD_INT_Exported_FunctionsPrototype 107 | * @{ 108 | */ 109 | 110 | uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev); 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | 117 | #endif // USB_DCD_INT_H__ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 127 | 128 | -------------------------------------------------------------------------------- /Lib/STM32_USB_OTG_Driver/inc/usb_hcd.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_hcd.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Host layer Header file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_HCD_H__ 30 | #define __USB_HCD_H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_regs.h" 34 | #include "usb_core.h" 35 | 36 | 37 | /** @addtogroup USB_OTG_DRIVER 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USB_HCD 42 | * @brief This file is the 43 | * @{ 44 | */ 45 | 46 | 47 | /** @defgroup USB_HCD_Exported_Defines 48 | * @{ 49 | */ 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @defgroup USB_HCD_Exported_Types 56 | * @{ 57 | */ 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @defgroup USB_HCD_Exported_Macros 64 | * @{ 65 | */ 66 | /** 67 | * @} 68 | */ 69 | 70 | /** @defgroup USB_HCD_Exported_Variables 71 | * @{ 72 | */ 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup USB_HCD_Exported_FunctionsPrototype 78 | * @{ 79 | */ 80 | uint32_t HCD_Init (USB_OTG_CORE_HANDLE *pdev , 81 | USB_OTG_CORE_ID_TypeDef coreID); 82 | uint32_t HCD_HC_Init (USB_OTG_CORE_HANDLE *pdev , 83 | uint8_t hc_num); 84 | uint32_t HCD_SubmitRequest (USB_OTG_CORE_HANDLE *pdev , 85 | uint8_t hc_num) ; 86 | uint32_t HCD_GetCurrentSpeed (USB_OTG_CORE_HANDLE *pdev); 87 | uint32_t HCD_ResetPort (USB_OTG_CORE_HANDLE *pdev); 88 | uint32_t HCD_IsDeviceConnected (USB_OTG_CORE_HANDLE *pdev); 89 | uint32_t HCD_GetCurrentFrame (USB_OTG_CORE_HANDLE *pdev) ; 90 | URB_STATE HCD_GetURB_State (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num); 91 | uint32_t HCD_GetXferCnt (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num); 92 | HC_STATUS HCD_GetHCState (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num) ; 93 | /** 94 | * @} 95 | */ 96 | 97 | #endif //__USB_HCD_H__ 98 | 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** 105 | * @} 106 | */ 107 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 108 | 109 | -------------------------------------------------------------------------------- /Lib/STM32_USB_OTG_Driver/inc/usb_hcd_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_hcd_int.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Peripheral Device Interface Layer 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __HCD_INT_H__ 30 | #define __HCD_INT_H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "usb_hcd.h" 34 | 35 | 36 | /** @addtogroup USB_OTG_DRIVER 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USB_HCD_INT 41 | * @brief This file is the 42 | * @{ 43 | */ 44 | 45 | 46 | /** @defgroup USB_HCD_INT_Exported_Defines 47 | * @{ 48 | */ 49 | /** 50 | * @} 51 | */ 52 | 53 | 54 | /** @defgroup USB_HCD_INT_Exported_Types 55 | * @{ 56 | */ 57 | 58 | typedef struct _USBH_HCD_INT 59 | { 60 | uint8_t (* SOF) (USB_OTG_CORE_HANDLE *pdev); 61 | uint8_t (* DevConnected) (USB_OTG_CORE_HANDLE *pdev); 62 | uint8_t (* DevDisconnected) (USB_OTG_CORE_HANDLE *pdev); 63 | 64 | }USBH_HCD_INT_cb_TypeDef; 65 | 66 | extern USBH_HCD_INT_cb_TypeDef *USBH_HCD_INT_fops; 67 | /** 68 | * @} 69 | */ 70 | 71 | 72 | /** @defgroup USB_HCD_INT_Exported_Macros 73 | * @{ 74 | */ 75 | 76 | #define CLEAR_HC_INT(HC_REGS, intr) \ 77 | {\ 78 | USB_OTG_HCINTn_TypeDef hcint_clear; \ 79 | hcint_clear.d32 = 0; \ 80 | hcint_clear.b.intr = 1; \ 81 | USB_OTG_WRITE_REG32(&((HC_REGS)->HCINT), hcint_clear.d32);\ 82 | }\ 83 | 84 | #define MASK_HOST_INT_CHH(hc_num) { USB_OTG_HCINTMSK_TypeDef INTMSK; \ 85 | INTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK); \ 86 | INTMSK.b.chhltd = 0; \ 87 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK, INTMSK.d32);} 88 | 89 | #define UNMASK_HOST_INT_CHH(hc_num) { USB_OTG_HCINTMSK_TypeDef INTMSK; \ 90 | INTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK); \ 91 | INTMSK.b.chhltd = 1; \ 92 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK, INTMSK.d32);} 93 | 94 | #define MASK_HOST_INT_ACK(hc_num) { USB_OTG_HCINTMSK_TypeDef INTMSK; \ 95 | INTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK); \ 96 | INTMSK.b.ack = 0; \ 97 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK, GINTMSK.d32);} 98 | 99 | #define UNMASK_HOST_INT_ACK(hc_num) { USB_OTG_HCGINTMSK_TypeDef INTMSK; \ 100 | INTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK); \ 101 | INTMSK.b.ack = 1; \ 102 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCINTMSK, INTMSK.d32);} 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** @defgroup USB_HCD_INT_Exported_Variables 109 | * @{ 110 | */ 111 | /** 112 | * @} 113 | */ 114 | 115 | /** @defgroup USB_HCD_INT_Exported_FunctionsPrototype 116 | * @{ 117 | */ 118 | /* Callbacks handler */ 119 | void ConnectCallback_Handler(USB_OTG_CORE_HANDLE *pdev); 120 | void Disconnect_Callback_Handler(USB_OTG_CORE_HANDLE *pdev); 121 | void Overcurrent_Callback_Handler(USB_OTG_CORE_HANDLE *pdev); 122 | uint32_t USBH_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev); 123 | 124 | /** 125 | * @} 126 | */ 127 | 128 | 129 | 130 | #endif //__HCD_INT_H__ 131 | 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 141 | 142 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Dekrispator 2 | =========== 3 | 4 | ////// Please check now Dekrispator_v2 repository for new STM32F4Cube HAL based version. ////// 5 | 6 | Transform your STM32F4 Discovery board into an experimental music synthesizer or autonomous noise box with USB MIDI Host function for interaction ! 7 | 8 | The sound demos are here : https://soundcloud.com/bluexav 9 | 10 | A video is here : http://youtu.be/fcLrcDCaI7w 11 | 12 | - - - - 13 | 14 | **Usage** 15 | 16 | Flash your board with "dekrispator.hex" (in Release folder) and enjoy hours and hours of sweet music coming of it ! Sounds can be loud so beware ! 17 | 18 | When powering up the board, the synth starts in "demo mode" unless you press and maintain a little the user button before power. In that case the synth enters "user mode". 19 | 20 | *Demo mode* : The synth works on its own, sounds are perpetually changing. If you press the user button, sounds and effects stop always changing and the red LED lights on : the synth parameters are frozen. Press once again the user button and the red LED lights off : unfreeze. 21 | 22 | *User mode* : Connect an USB MIDI controller (like Korg NanoKontrol...) to the board's micro USB connector and control the synth. 23 | The MIDI mapping of the synth controls are in MIDI_mapping.ods file. I nearly used the factory settings of Korg NanoKontrol V1 (some momentary/toggle buttons modified). 24 | 25 | The MIDI USB Host driver is rudimentary and has still some issues ! 26 | 27 | The orange LED reflects the CPU usage : when it's dim CPU gets overloaded. 28 | 29 | Ready to use files are in Ressources folder. 30 | 31 | - - - - 32 | 33 | **Dekrispator features** : 34 | 35 | * monophonic 36 | * all digital ! 37 | * oscillators with : 38 | * very low aliased analog waveforms with minBLEP oscillators (thanks Sean Bolton) 39 | * 4 OP FM generator 40 | * multisaw (several saws with individual "drifters") 41 | * 10 sine additive generator 42 | * noise 43 | * vibrato 44 | * tremolo 45 | * drive/distortion 46 | * 16 step random sequencer 47 | * several scales to choose from 48 | * 2 parallel filters LP/BP/HP with LFOs 49 | * Effects : 50 | * Echo 51 | * Chorus/Flanger 52 | * Phaser 53 | * random sound/FX patch generator 54 | 55 | - - - - 56 | 57 | **Building from source :** 58 | 59 | I've used (Windows): 60 | 61 | * Eclipse Kepler 62 | * GNU ARM plugin for Eclipse 63 | * Yagarto tools for make, rm, ... 64 | * GNU Tools for ARM Embedded Processors (gcc 4.8 2013 q4) 65 | * STM32 ST-LINK Utility for flashing the microcontroller 66 | 67 | Simple command line : 68 | Go into Release folder and type make (with Cygwin terminal). 69 | 70 | Compiles also on Linux (Ubuntu 12.04 LTS) ! 71 | - - - 72 | **See also the port to Windows, Linux, Mac and Raspberry Pi by erwincoumans :** 73 | 74 | https://github.com/erwincoumans/StkDekrispatorSynthesizer 75 | -------------------------------------------------------------------------------- /Release/Dekrispator.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrBlueXav/Dekrispator/f23665ba689f0a6d6cd88037d5676ee4c92910c3/Release/Dekrispator.elf -------------------------------------------------------------------------------- /Release/Lib/STM32F4xx_StdPeriph_Driver/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../Lib/STM32F4xx_StdPeriph_Driver/src/misc.c \ 8 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c \ 9 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c \ 10 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c \ 11 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c \ 12 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c \ 13 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c \ 14 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c \ 15 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c \ 16 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c \ 17 | ../Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c 18 | 19 | OBJS += \ 20 | ./Lib/STM32F4xx_StdPeriph_Driver/src/misc.o \ 21 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.o \ 22 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.o \ 23 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.o \ 24 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.o \ 25 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.o \ 26 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.o \ 27 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.o \ 28 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.o \ 29 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.o \ 30 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.o 31 | 32 | C_DEPS += \ 33 | ./Lib/STM32F4xx_StdPeriph_Driver/src/misc.d \ 34 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.d \ 35 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.d \ 36 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.d \ 37 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.d \ 38 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.d \ 39 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.d \ 40 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.d \ 41 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.d \ 42 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.d \ 43 | ./Lib/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.d 44 | 45 | 46 | # Each subdirectory must supply rules for building sources it contributes 47 | Lib/STM32F4xx_StdPeriph_Driver/src/%.o: ../Lib/STM32F4xx_StdPeriph_Driver/src/%.c 48 | @echo 'Building file: $<' 49 | @echo 'Invoking: Cross ARM C Compiler' 50 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 51 | @echo 'Finished building: $<' 52 | @echo ' ' 53 | 54 | 55 | -------------------------------------------------------------------------------- /Release/Lib/STM32_USB_HOST_Library/Core/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../Lib/STM32_USB_HOST_Library/Core/src/usbh_core.c \ 8 | ../Lib/STM32_USB_HOST_Library/Core/src/usbh_hcs.c \ 9 | ../Lib/STM32_USB_HOST_Library/Core/src/usbh_ioreq.c \ 10 | ../Lib/STM32_USB_HOST_Library/Core/src/usbh_stdreq.c 11 | 12 | OBJS += \ 13 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_core.o \ 14 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_hcs.o \ 15 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_ioreq.o \ 16 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_stdreq.o 17 | 18 | C_DEPS += \ 19 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_core.d \ 20 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_hcs.d \ 21 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_ioreq.d \ 22 | ./Lib/STM32_USB_HOST_Library/Core/src/usbh_stdreq.d 23 | 24 | 25 | # Each subdirectory must supply rules for building sources it contributes 26 | Lib/STM32_USB_HOST_Library/Core/src/%.o: ../Lib/STM32_USB_HOST_Library/Core/src/%.c 27 | @echo 'Building file: $<' 28 | @echo 'Invoking: Cross ARM C Compiler' 29 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 30 | @echo 'Finished building: $<' 31 | @echo ' ' 32 | 33 | 34 | -------------------------------------------------------------------------------- /Release/Lib/STM32_USB_OTG_Driver/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../Lib/STM32_USB_OTG_Driver/src/usb_core.c \ 8 | ../Lib/STM32_USB_OTG_Driver/src/usb_hcd.c \ 9 | ../Lib/STM32_USB_OTG_Driver/src/usb_hcd_int.c 10 | 11 | OBJS += \ 12 | ./Lib/STM32_USB_OTG_Driver/src/usb_core.o \ 13 | ./Lib/STM32_USB_OTG_Driver/src/usb_hcd.o \ 14 | ./Lib/STM32_USB_OTG_Driver/src/usb_hcd_int.o 15 | 16 | C_DEPS += \ 17 | ./Lib/STM32_USB_OTG_Driver/src/usb_core.d \ 18 | ./Lib/STM32_USB_OTG_Driver/src/usb_hcd.d \ 19 | ./Lib/STM32_USB_OTG_Driver/src/usb_hcd_int.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | Lib/STM32_USB_OTG_Driver/src/%.o: ../Lib/STM32_USB_OTG_Driver/src/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: Cross ARM C Compiler' 26 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Release/Synth/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../Synth/adsr.c \ 8 | ../Synth/audio.c \ 9 | ../Synth/blepvco.c \ 10 | ../Synth/chorusFD.c \ 11 | ../Synth/delay.c \ 12 | ../Synth/drifter.c \ 13 | ../Synth/main.c \ 14 | ../Synth/math_tools.c \ 15 | ../Synth/midi_interface.c \ 16 | ../Synth/minblep_tables.c \ 17 | ../Synth/notesTables.c \ 18 | ../Synth/oscillators.c \ 19 | ../Synth/phaser.c \ 20 | ../Synth/random.c \ 21 | ../Synth/resonantFilter.c \ 22 | ../Synth/sequencer.c \ 23 | ../Synth/sinetable.c \ 24 | ../Synth/soundGen.c \ 25 | ../Synth/timers.c 26 | 27 | OBJS += \ 28 | ./Synth/adsr.o \ 29 | ./Synth/audio.o \ 30 | ./Synth/blepvco.o \ 31 | ./Synth/chorusFD.o \ 32 | ./Synth/delay.o \ 33 | ./Synth/drifter.o \ 34 | ./Synth/main.o \ 35 | ./Synth/math_tools.o \ 36 | ./Synth/midi_interface.o \ 37 | ./Synth/minblep_tables.o \ 38 | ./Synth/notesTables.o \ 39 | ./Synth/oscillators.o \ 40 | ./Synth/phaser.o \ 41 | ./Synth/random.o \ 42 | ./Synth/resonantFilter.o \ 43 | ./Synth/sequencer.o \ 44 | ./Synth/sinetable.o \ 45 | ./Synth/soundGen.o \ 46 | ./Synth/timers.o 47 | 48 | C_DEPS += \ 49 | ./Synth/adsr.d \ 50 | ./Synth/audio.d \ 51 | ./Synth/blepvco.d \ 52 | ./Synth/chorusFD.d \ 53 | ./Synth/delay.d \ 54 | ./Synth/drifter.d \ 55 | ./Synth/main.d \ 56 | ./Synth/math_tools.d \ 57 | ./Synth/midi_interface.d \ 58 | ./Synth/minblep_tables.d \ 59 | ./Synth/notesTables.d \ 60 | ./Synth/oscillators.d \ 61 | ./Synth/phaser.d \ 62 | ./Synth/random.d \ 63 | ./Synth/resonantFilter.d \ 64 | ./Synth/sequencer.d \ 65 | ./Synth/sinetable.d \ 66 | ./Synth/soundGen.d \ 67 | ./Synth/timers.d 68 | 69 | 70 | # Each subdirectory must supply rules for building sources it contributes 71 | Synth/%.o: ../Synth/%.c 72 | @echo 'Building file: $<' 73 | @echo 'Invoking: Cross ARM C Compiler' 74 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 75 | @echo 'Finished building: $<' 76 | @echo ' ' 77 | 78 | 79 | -------------------------------------------------------------------------------- /Release/System/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../System/my_stm32f4_discovery.c \ 8 | ../System/my_stm32f4_discovery_audio_codec.c \ 9 | ../System/startup_stm32f4xx.c \ 10 | ../System/stm32fxxx_it.c \ 11 | ../System/system_stm32f4xx.c 12 | 13 | OBJS += \ 14 | ./System/my_stm32f4_discovery.o \ 15 | ./System/my_stm32f4_discovery_audio_codec.o \ 16 | ./System/startup_stm32f4xx.o \ 17 | ./System/stm32fxxx_it.o \ 18 | ./System/system_stm32f4xx.o 19 | 20 | C_DEPS += \ 21 | ./System/my_stm32f4_discovery.d \ 22 | ./System/my_stm32f4_discovery_audio_codec.d \ 23 | ./System/startup_stm32f4xx.d \ 24 | ./System/stm32fxxx_it.d \ 25 | ./System/system_stm32f4xx.d 26 | 27 | 28 | # Each subdirectory must supply rules for building sources it contributes 29 | System/%.o: ../System/%.c 30 | @echo 'Building file: $<' 31 | @echo 'Invoking: Cross ARM C Compiler' 32 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 33 | @echo 'Finished building: $<' 34 | @echo ' ' 35 | 36 | 37 | -------------------------------------------------------------------------------- /Release/USB/MIDIstream_class/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../USB/MIDIstream_class/usbh_midi_core.c 8 | 9 | OBJS += \ 10 | ./USB/MIDIstream_class/usbh_midi_core.o 11 | 12 | C_DEPS += \ 13 | ./USB/MIDIstream_class/usbh_midi_core.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | USB/MIDIstream_class/%.o: ../USB/MIDIstream_class/%.c 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: Cross ARM C Compiler' 20 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /Release/USB/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../USB/usb_bsp.c \ 8 | ../USB/usbh_usr.c 9 | 10 | OBJS += \ 11 | ./USB/usb_bsp.o \ 12 | ./USB/usbh_usr.o 13 | 14 | C_DEPS += \ 15 | ./USB/usb_bsp.d \ 16 | ./USB/usbh_usr.d 17 | 18 | 19 | # Each subdirectory must supply rules for building sources it contributes 20 | USB/%.o: ../USB/%.c 21 | @echo 'Building file: $<' 22 | @echo 'Invoking: Cross ARM C Compiler' 23 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -DSTM32F40_41xxx -D__FPU_USED=1 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DSTM32F407VG -I../Synth -I../USB -I../USB/MIDIstream_class -I../Lib/STM32F4xx_StdPeriph_Driver/inc -I../Lib/STM32_USB_OTG_Driver/inc -I../Lib/STM32_USB_HOST_Library/Core/inc -I../System -std=gnu99 -flto -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<" 24 | @echo 'Finished building: $<' 25 | @echo ' ' 26 | 27 | 28 | -------------------------------------------------------------------------------- /Release/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include USB/MIDIstream_class/subdir.mk 12 | -include USB/subdir.mk 13 | -include System/subdir.mk 14 | -include Synth/subdir.mk 15 | -include Lib/STM32_USB_OTG_Driver/src/subdir.mk 16 | -include Lib/STM32_USB_HOST_Library/Core/src/subdir.mk 17 | -include Lib/STM32F4xx_StdPeriph_Driver/src/subdir.mk 18 | -include subdir.mk 19 | -include objects.mk 20 | 21 | ifneq ($(MAKECMDGOALS),clean) 22 | ifneq ($(strip $(C_DEPS)),) 23 | -include $(C_DEPS) 24 | endif 25 | ifneq ($(strip $(ASM_DEPS)),) 26 | -include $(ASM_DEPS) 27 | endif 28 | ifneq ($(strip $(S_UPPER_DEPS)),) 29 | -include $(S_UPPER_DEPS) 30 | endif 31 | endif 32 | 33 | -include ../makefile.defs 34 | 35 | # Add inputs and outputs from these tool invocations to the build variables 36 | SECONDARY_FLASH += \ 37 | Dekrispator.hex \ 38 | 39 | SECONDARY_LIST += \ 40 | Dekrispator.lst \ 41 | 42 | SECONDARY_SIZE += \ 43 | Dekrispator.siz \ 44 | 45 | 46 | # All Target 47 | all: Dekrispator.elf secondary-outputs 48 | 49 | # Tool invocations 50 | Dekrispator.elf: $(OBJS) $(USER_OBJS) 51 | @echo 'Building target: $@' 52 | @echo 'Invoking: Cross ARM C Linker' 53 | arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O3 -ffunction-sections -fdata-sections -fno-builtin -fsingle-precision-constant -flto -Wall -T ../System/stm32f407xav.ld -nostartfiles -Xlinker --gc-sections -Wl,-Map,"Dekrispator.map" -flto --entry=main -o "Dekrispator.elf" $(OBJS) $(USER_OBJS) $(LIBS) 54 | @echo 'Finished building target: $@' 55 | @echo ' ' 56 | 57 | Dekrispator.hex: Dekrispator.elf 58 | @echo 'Invoking: Cross ARM GNU Create Flash Image' 59 | arm-none-eabi-objcopy -O ihex "Dekrispator.elf" "Dekrispator.hex" 60 | @echo 'Finished building: $@' 61 | @echo ' ' 62 | 63 | Dekrispator.lst: Dekrispator.elf 64 | @echo 'Invoking: Cross ARM GNU Create Listing' 65 | arm-none-eabi-objdump --source --all-headers --demangle --line-numbers --wide "Dekrispator.elf" > "Dekrispator.lst" 66 | @echo 'Finished building: $@' 67 | @echo ' ' 68 | 69 | Dekrispator.siz: Dekrispator.elf 70 | @echo 'Invoking: Cross ARM GNU Print Size' 71 | arm-none-eabi-size --format=berkeley --totals "Dekrispator.elf" 72 | @echo 'Finished building: $@' 73 | @echo ' ' 74 | 75 | # Other Targets 76 | clean: 77 | -$(RM) $(SECONDARY_SIZE)$(OBJS)$(C_DEPS)$(ASM_DEPS)$(SECONDARY_FLASH)$(SECONDARY_LIST)$(S_UPPER_DEPS) Dekrispator.elf 78 | -@echo ' ' 79 | 80 | secondary-outputs: $(SECONDARY_FLASH) $(SECONDARY_LIST) $(SECONDARY_SIZE) 81 | 82 | .PHONY: all clean dependents 83 | .SECONDARY: 84 | 85 | -include ../makefile.targets 86 | -------------------------------------------------------------------------------- /Release/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := -lm 8 | 9 | -------------------------------------------------------------------------------- /Release/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | ELF_SRCS := 6 | O_SRCS := 7 | C_SRCS := 8 | S_UPPER_SRCS := 9 | OBJ_SRCS := 10 | ASM_SRCS := 11 | SECONDARY_SIZE := 12 | OBJS := 13 | C_DEPS := 14 | ASM_DEPS := 15 | SECONDARY_FLASH := 16 | SECONDARY_LIST := 17 | S_UPPER_DEPS := 18 | 19 | # Every subdirectory with source files must be described here 20 | SUBDIRS := \ 21 | USB \ 22 | USB/MIDIstream_class \ 23 | System \ 24 | Synth \ 25 | Lib/STM32_USB_OTG_Driver/src \ 26 | Lib/STM32_USB_HOST_Library/Core/src \ 27 | Lib/STM32F4xx_StdPeriph_Driver/src \ 28 | 29 | -------------------------------------------------------------------------------- /Ressources/MIDI_mapping.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrBlueXav/Dekrispator/f23665ba689f0a6d6cd88037d5676ee4c92910c3/Ressources/MIDI_mapping.ods -------------------------------------------------------------------------------- /Ressources/dekrispator_nanoKv1.nktrl_set: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrBlueXav/Dekrispator/f23665ba689f0a6d6cd88037d5676ee4c92910c3/Ressources/dekrispator_nanoKv1.nktrl_set -------------------------------------------------------------------------------- /Synth/CONSTANTS.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : CONSTANTS.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | #ifndef __CONSTANTS_H__ 10 | #define __CONSTANTS_H__ 11 | 12 | /*--------------------------------------------------------------------------------------*/ 13 | 14 | #define SAMPLERATE 48000 15 | #define Fs ((float)(SAMPLERATE)) // samplerate 16 | #define Ts (1.f/Fs) // sample period 17 | #define _2PI 6.283185307f 18 | #define _PI 3.14159265f 19 | 20 | #define BUFF_LEN_DIV4 400 // number of samples in the audiobuffer for each channel <==> XX ms latency at 48kHz 21 | #define BUFF_LEN_DIV2 (2*BUFF_LEN_DIV4) 22 | #define BUFF_LEN (4*BUFF_LEN_DIV4) // Audio buffer length : count in 16bits half-words 23 | #define VOL 70 // initial output DAC volume 24 | #define MAXVOL 100 // maximal output DAC volume 25 | 26 | #define SYSTICK_FREQ 500 // system tick interruption frequency in Hz 27 | #define DEBOUNCE_TIME 500 28 | #define PARAM_MAX 21 // maximal parameter index, starting at 0 29 | 30 | #define MIDI_MAX 127.f // floating max value 31 | #define MIDI_MAXi 127 // integer max value 32 | 33 | #define _CCM_ __attribute__((section(".ccm"))) // 34 | 35 | #if defined (__GNUC__) /* GNU Compiler */ 36 | #define __ALIGN __attribute__ ((aligned (4))) 37 | #endif /* __GNUC__ */ 38 | 39 | /************************************************************************************/ 40 | #endif /*__CONSTANTS_H__ */ 41 | -------------------------------------------------------------------------------- /Synth/adsr.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : adsr.c 4 | * Author : modified by Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | /***************************************************/ 11 | /* 12 | This Envelope subclass implements a 13 | traditional ADSR (Attack, Decay, 14 | Sustain, Release) envelope. It 15 | responds to simple keyOn and keyOff 16 | messages, keeping track of its state. 17 | The \e state = ADSR::DONE after the 18 | envelope value reaches 0.0 in the 19 | ADSR::RELEASE state. 20 | 21 | by Perry R. Cook and Gary P. Scavone, 1995 - 2005. 22 | */ 23 | /* 24 | * This program is free software; you can redistribute it and/or modify 25 | * it under the terms of the GNU General Public License as published by 26 | * the Free Software Foundation; either version 2 of the License, or 27 | * (at your option) any later version. 28 | * 29 | * This program is distributed in the hope that it will be useful, 30 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32 | * GNU General Public License for more details. 33 | * 34 | * You should have received a copy of the GNU General Public License 35 | * along with this program; if not, write to the Free Software 36 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 37 | * 38 | */ 39 | /***************************************************/ 40 | 41 | #include "adsr.h" 42 | 43 | /*---------------------------------------------------------------------------*/ 44 | 45 | ADSR_t adsr _CCM_; 46 | 47 | /*---------------------------------------------------------------------------*/ 48 | 49 | void ADSR_init(ADSR_t *env) 50 | { 51 | env->target_ = 0.0; 52 | env->value_ = 0.0; 53 | env->attackRate_ = 0.001; 54 | env->decayRate_ = 0.001; 55 | env->sustainLevel_ = 0.5; 56 | env->releaseRate_ = 0.01; 57 | env->state_ = ATTACK; 58 | env->cnt_ = 0; 59 | //env->gateTime_ = 10000; 60 | } 61 | 62 | void ADSR_keyOn(ADSR_t *env) 63 | { 64 | env->cnt_ = 0; 65 | env->target_ = 1.0f; 66 | env->rate_ = env->attackRate_; 67 | env->state_ = ATTACK; 68 | } 69 | 70 | void ADSR_keyOff(ADSR_t *env) 71 | { 72 | env->cnt_ = 0; 73 | env->target_ = 0.0; 74 | env->rate_ = env->releaseRate_; 75 | env->state_ = RELEASE; 76 | } 77 | 78 | void ADSR_setAttackRate(ADSR_t *env, float rate) 79 | { 80 | env->attackRate_ = rate; 81 | } 82 | 83 | void ADSR_setDecayRate(ADSR_t *env, float rate) 84 | { 85 | env->decayRate_ = rate; 86 | } 87 | 88 | void ADSR_setSustainLevel(ADSR_t *env, float level) 89 | { 90 | env->sustainLevel_ = level; 91 | } 92 | 93 | void ADSR_setReleaseRate(ADSR_t *env, float rate) 94 | { 95 | env->releaseRate_ = rate; 96 | } 97 | 98 | void ADSR_setAttackTime(ADSR_t *env, float time) 99 | { 100 | env->attackRate_ = 1.0 / ( time * Fs ); 101 | } 102 | 103 | void ADSR_setDecayTime(ADSR_t *env, float time) 104 | { 105 | env->decayRate_ = 1.0 / ( time * Fs ); 106 | } 107 | 108 | void ADSR_setReleaseTime(ADSR_t *env, float time) 109 | { 110 | env->releaseRate_ = env->sustainLevel_ / ( time * Fs ); 111 | } 112 | 113 | void ADSR_setAllTimes(ADSR_t *env, float aTime, float dTime, float sLevel, float rTime) 114 | { 115 | ADSR_setAttackTime(env, aTime); 116 | ADSR_setDecayTime(env, dTime); 117 | ADSR_setSustainLevel(env, sLevel); 118 | ADSR_setReleaseTime(env, rTime); 119 | } 120 | 121 | void ADSR_setTarget(ADSR_t *env, float target) 122 | { 123 | env->target_ = target; 124 | if (env->value_ < env->target_) { 125 | env->state_ = ATTACK; 126 | ADSR_setSustainLevel(env, env->target_); 127 | env->rate_ = env->attackRate_; 128 | } 129 | if (env->value_ > env->target_) { 130 | ADSR_setSustainLevel(env, env->target_); 131 | env->state_ = DECAY; 132 | env->rate_ = env->decayRate_; 133 | } 134 | } 135 | 136 | void ADSR_setValue(ADSR_t *env, float value) 137 | { 138 | env->state_ = SUSTAIN; 139 | env->target_ = value; 140 | env->value_ = value; 141 | ADSR_setSustainLevel(env, value); 142 | env->rate_ = 0.0f; 143 | } 144 | 145 | int ADSR_getState(ADSR_t *env) 146 | { 147 | return env->state_; 148 | } 149 | 150 | void AttTime_set(uint8_t val) 151 | { 152 | ADSR_setAttackTime(&adsr, val/MIDI_MAX + 0.0001f); 153 | } 154 | void DecTime_set(uint8_t val) 155 | { 156 | ADSR_setDecayTime(&adsr, .2*val/MIDI_MAX + 0.0001f); 157 | } 158 | void SustLevel_set(uint8_t val) 159 | { 160 | ADSR_setSustainLevel(&adsr, val/MIDI_MAX); 161 | } 162 | void RelTime_set(uint8_t val) 163 | { 164 | ADSR_setReleaseTime(&adsr, .5f * val/MIDI_MAX + 0.0001f); 165 | } 166 | /*--------------------------------------------------------------------------------------*/ 167 | float ADSR_computeSample(ADSR_t *env) 168 | { 169 | (env->cnt_)++; 170 | 171 | switch (env->state_) { 172 | 173 | case ATTACK: 174 | env->value_ += env->rate_; 175 | if (env->value_ >= env->target_) 176 | { 177 | env->value_ = env->target_; 178 | env->rate_ = env->decayRate_; 179 | env->target_ = env->sustainLevel_; 180 | env->state_ = DECAY; 181 | } 182 | break; 183 | 184 | case DECAY: 185 | env->value_ -= env->decayRate_; 186 | if (env->value_ <= env->sustainLevel_) 187 | { 188 | env->value_ = env->sustainLevel_; 189 | env->rate_ = 0.0f; 190 | env->state_ = SUSTAIN; 191 | } 192 | break; 193 | 194 | case RELEASE: 195 | env->value_ -= env->releaseRate_; 196 | if (env->value_ <= 0.0f) 197 | { 198 | env->value_ = 0.0f; 199 | env->state_ = DONE; 200 | } 201 | } 202 | 203 | env->lastOutput_ = env->value_; 204 | return env->value_; 205 | } 206 | 207 | /******************************************************* EOF ***********************************************************/ 208 | -------------------------------------------------------------------------------- /Synth/adsr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : adsr.h 4 | * Author : modified by Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /***************************************************/ 10 | /*! \class ADSR 11 | \brief STK ADSR envelope class. 12 | 13 | This Envelope subclass implements a 14 | traditional ADSR (Attack, Decay, 15 | Sustain, Release) envelope. It 16 | responds to simple keyOn and keyOff 17 | messages, keeping track of its state. 18 | The \e state = ADSR::DONE after the 19 | envelope value reaches 0.0 in the 20 | ADSR::RELEASE state. 21 | 22 | by Perry R. Cook and Gary P. Scavone, 1995 - 2005. 23 | */ 24 | /***************************************************/ 25 | 26 | #ifndef STK_ADSR_H 27 | #define STK_ADSR_H 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | 31 | #include 32 | #include 33 | #include 34 | #include "CONSTANTS.h" 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | 38 | //! Envelope states. 39 | enum { ATTACK, DECAY, SUSTAIN, RELEASE, DONE }; 40 | 41 | typedef struct 42 | { 43 | float attackRate_; 44 | float decayRate_; 45 | float sustainLevel_; 46 | float releaseRate_; 47 | float value_; 48 | float lastOutput_; 49 | float target_; 50 | float rate_; 51 | int state_; 52 | uint32_t cnt_; // sample counter for on state 53 | 54 | 55 | } ADSR_t ; 56 | 57 | 58 | /* Exported functions --------------------------------------------------------*/ 59 | 60 | //! Default constructor. 61 | void ADSR_init(ADSR_t *env); 62 | 63 | //! Set target = 1, state = \e ADSR::ATTACK. 64 | void ADSR_keyOn(ADSR_t *env); 65 | 66 | //! Set target = 0, state = \e ADSR::RELEASE. 67 | void ADSR_keyOff(ADSR_t *env); 68 | 69 | //! Set the attack rate. 70 | void ADSR_setAttackRate(ADSR_t *env, float rate); 71 | 72 | //! Set the decay rate. 73 | void ADSR_setDecayRate(ADSR_t *env, float rate); 74 | 75 | //! Set the sustain level. 76 | void ADSR_setSustainLevel(ADSR_t *env, float level); 77 | 78 | //! Set the release rate. 79 | void ADSR_setReleaseRate(ADSR_t *env, float rate); 80 | 81 | //! Set the attack rate based on a time duration. 82 | void ADSR_setAttackTime(ADSR_t *env, float time); 83 | 84 | //! Set the decay rate based on a time duration. 85 | void ADSR_setDecayTime(ADSR_t *env, float time); 86 | 87 | //! Set the release rate based on a time duration. 88 | void ADSR_setReleaseTime(ADSR_t *env, float time); 89 | 90 | //! Set sustain level and attack, decay, and release time durations. 91 | void ADSR_setAllTimes(ADSR_t *env, float aTime, float dTime, float sLevel, float rTime); 92 | 93 | //! Set the target value. 94 | void ADSR_setTarget(ADSR_t *env, float target); 95 | 96 | //! Return the current envelope \e state (ATTACK, DECAY, SUSTAIN, RELEASE, DONE). 97 | int ADSR_getState(ADSR_t *env) ; 98 | 99 | //! Set to state = ADSR::SUSTAIN with current and target values of \e aValue. 100 | void ADSR_setValue(ADSR_t *env, float value); 101 | 102 | float ADSR_computeSample( ADSR_t *env ); 103 | 104 | void setGateTime(uint8_t val); 105 | void AttTime_set(uint8_t val); 106 | void DecTime_set(uint8_t val); 107 | void SustLevel_set(uint8_t val); 108 | void RelTime_set(uint8_t val); 109 | 110 | /*********************************************************************************************************/ 111 | #endif 112 | -------------------------------------------------------------------------------- /Synth/audio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : audio.c 4 | * Date : 5 | * Author : Xavier Halgand 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | */ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | 28 | #include "audio.h" 29 | 30 | /*----------------------------------------------------------------------------*/ 31 | 32 | uint16_t audiobuff[BUFF_LEN]; // THE audio buffer 33 | static uint8_t volume = VOL; 34 | static bool sound = true; 35 | 36 | /*------------------------------------------------------------------------------*/ 37 | void audio_init(void) 38 | { 39 | EVAL_AUDIO_Init(OUTPUT_DEVICE_AUTO, VOL, SAMPLERATE); 40 | EVAL_AUDIO_Play((uint16_t*) audiobuff, BUFF_LEN); // start sound 41 | } 42 | 43 | //--------------------------------------------------------------------------- 44 | /** 45 | * @brief Basic management of the timeout situation. 46 | * @param None 47 | * @retval None 48 | */ 49 | uint32_t 50 | Codec_TIMEOUT_UserCallback(void) 51 | { 52 | //STM_EVAL_LEDOn(LED5); /* alert : red LED ! */ 53 | return (0); 54 | } 55 | //--------------------------------------------------------------------------- 56 | /** 57 | * @brief Manages the DMA Half Transfer complete interrupt. 58 | * @param None 59 | * @retval None 60 | */ 61 | void 62 | EVAL_AUDIO_HalfTransfer_CallBack(uint32_t pBuffer, uint32_t Size) 63 | { 64 | /* Generally this interrupt routine is used to load the buffer when 65 | a streaming scheme is used: When first Half buffer is already transferred load 66 | the new data to the first half of buffer while DMA is transferring data from 67 | the second half. And when Transfer complete occurs, load the second half of 68 | the buffer while the DMA is transferring from the first half ... */ 69 | 70 | STM_EVAL_LEDOff(LED_Orange); 71 | make_sound((uint16_t *)audiobuff, BUFF_LEN_DIV4); 72 | STM_EVAL_LEDOn(LED_Orange); 73 | } 74 | //--------------------------------------------------------------------------- 75 | /** 76 | * @brief Manages the DMA Complete Transfer complete interrupt. 77 | * @param None 78 | * @retval None 79 | */ 80 | void 81 | EVAL_AUDIO_TransferComplete_CallBack(uint32_t pBuffer, uint32_t Size) 82 | { 83 | STM_EVAL_LEDOff(LED_Orange); 84 | make_sound((uint16_t *)(audiobuff + BUFF_LEN_DIV2), BUFF_LEN_DIV4); 85 | STM_EVAL_LEDOn(LED_Orange); 86 | } 87 | 88 | //--------------------------------------------------------------------------- 89 | /** NOT USED ! 90 | * @brief Get next data sample callback 91 | * @param None 92 | * @retval Next data sample to be sent 93 | */ 94 | uint16_t 95 | EVAL_AUDIO_GetSampleCallBack(void) 96 | { 97 | return 0; 98 | } 99 | 100 | 101 | //--------------------------------- toggle ON/OFF volume ------------------------------------------ 102 | void toggleSound(void) 103 | { 104 | if ( ! sound ) 105 | { 106 | //pitchGenResetPhase(); 107 | EVAL_AUDIO_VolumeCtl(volume); 108 | sound = true; 109 | } 110 | else 111 | { 112 | EVAL_AUDIO_VolumeCtl(0); 113 | sound = false; 114 | } 115 | } 116 | //------------------------------- increase output DAC volume -------------------------------------------- 117 | void incVol(void) 118 | { 119 | if (volume < MAXVOL) 120 | { 121 | volume++; 122 | EVAL_AUDIO_VolumeCtl(volume); 123 | } 124 | } 125 | //-------------------------------- decrease output DAC volume ------------------------------------------ 126 | void decVol(void) 127 | { 128 | if (volume > 0) 129 | { 130 | volume--; 131 | EVAL_AUDIO_VolumeCtl(volume); 132 | } 133 | } 134 | //------------------------------------------------------------------------------------------------------ 135 | void Volume_set(uint8_t val) 136 | { 137 | volume = (uint8_t)(MAXVOL/MIDI_MAX * val); 138 | EVAL_AUDIO_VolumeCtl(volume); 139 | } 140 | 141 | /**********************************************************************************************************/ 142 | -------------------------------------------------------------------------------- /Synth/audio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : audio.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | /* Define to prevent recursive inclusion -------------------------------------*/ 11 | #ifndef __AUDIO_H 12 | #define __AUDIO_H 13 | 14 | 15 | /* Includes ------------------------------------------------------------------*/ 16 | 17 | #include 18 | #include 19 | #include "CONSTANTS.h" 20 | #include "my_stm32f4_discovery_audio_codec.h" 21 | #include "my_stm32f4_discovery.h" 22 | #include "soundGen.h" 23 | 24 | /* Exported functions ------------------------------------------------------- */ 25 | void audio_init(void); 26 | void toggleSound(void); 27 | void incVol(void); 28 | void decVol(void); 29 | void Volume_set(uint8_t val); 30 | 31 | 32 | 33 | #endif /* __AUDIO_H */ 34 | -------------------------------------------------------------------------------- /Synth/blepvco.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : blepvco.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | 11 | /* blepvco - minBLEP-based, hard-sync-capable LADSPA VCOs. 12 | * 13 | * Copyright (C) 2004-2005 Sean Bolton. 14 | * 15 | * Much of the LADSPA framework used here comes from VCO-plugins 16 | * 0.3.0, copyright (c) 2003-2004 Fons Adriaensen. 17 | * 18 | * This program is free software; you can redistribute it and/or 19 | * modify it under the terms of the GNU General Public License as 20 | * published by the Free Software Foundation; either version 2 of 21 | * the License, or (at your option) any later version. 22 | * 23 | * This program is distributed in the hope that it will be 24 | * useful, but WITHOUT ANY WARRANTY; without even the implied 25 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 26 | * PURPOSE. See the GNU General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public 29 | * License along with this program; if not, write to the Free 30 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 31 | * MA 02111-1307, USA. 32 | */ 33 | 34 | #ifndef _BLEPVCO_H 35 | #define _BLEPVCO_H 36 | 37 | #include 38 | #include "minblep_tables.h" 39 | #include "CONSTANTS.h" 40 | 41 | //---------------------------------------------------------------------------------------------------------- 42 | 43 | enum { FILLEN = 256 }; 44 | 45 | //---------------------------------------------------------------------------------------------------------- 46 | 47 | void place_step_dd(float *buffer, int index, float phase, float w, float scale); 48 | void place_slope_dd(float *buffer, int index, float phase, float w, float slope_delta); 49 | 50 | //---------------------------------------------------------------------------------------------------------- 51 | 52 | //class VCO_blepsaw 53 | 54 | typedef struct 55 | { 56 | float out; 57 | float amp; 58 | float last_amp; 59 | float freq; 60 | float syncin; 61 | float syncout; 62 | float _p, _w, _z; 63 | float _f [FILLEN + STEP_DD_PULSE_LENGTH]; 64 | int _j; 65 | bool _init; 66 | 67 | } VCO_blepsaw_t; 68 | 69 | void VCO_blepsaw_Init(VCO_blepsaw_t *vco); 70 | float VCO_blepsaw_SampleCompute(VCO_blepsaw_t *vco); 71 | 72 | //---------------------------------------------------------------------------------------------------------- 73 | 74 | // class VCO_bleprect 75 | 76 | typedef struct 77 | { 78 | float out; 79 | float amp; 80 | float last_amp; 81 | float freq; 82 | float waveform; // duty cycle, must be in [-1, 1] 83 | float syncin; 84 | float syncout; 85 | float _p, _w, _b, _x, _z; 86 | float _f [FILLEN + STEP_DD_PULSE_LENGTH]; 87 | int _j, _k; 88 | bool _init; 89 | 90 | } VCO_bleprect_t ; 91 | 92 | void VCO_bleprect_Init(VCO_bleprect_t *vco); 93 | float VCO_bleprect_SampleCompute(VCO_bleprect_t *vco); 94 | 95 | //---------------------------------------------------------------------------------------------------------- 96 | 97 | // class VCO_bleptri 98 | 99 | typedef struct 100 | { 101 | float out; 102 | float amp; 103 | float last_amp; 104 | float freq; 105 | float waveform; // duty cycle, must be in [-1, 1] 106 | float syncin; 107 | float syncout; 108 | float _p, _w, _b, _z; 109 | float _f [FILLEN + LONGEST_DD_PULSE_LENGTH]; 110 | int _j, _k; 111 | bool _init; 112 | 113 | } VCO_bleptri_t ; 114 | 115 | void VCO_bleptri_Init(VCO_bleptri_t *vco); 116 | float VCO_bleptri_SampleCompute(VCO_bleptri_t *vco); 117 | 118 | #endif /* _BLEPVCO_H */ 119 | -------------------------------------------------------------------------------- /Synth/chorusFD.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : chorusFD.h 4 | * Author : Xavier Halgand (thanks to Gabriel Rivas) 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | 11 | /************************************************************************************************************ 12 | * chorus/flanger diagram (one channel) : 13 | * 14 | * ---------[mix >---------------------------- 15 | * | | 16 | * | | 17 | * |x1 v 18 | * xin ------>[+]----->[z^-M]--[interp.]----[fw >--------->[+]-----> yout 19 | * ^ delay line | 20 | * | | 21 | * --< fb]<------------------- 22 | * 23 | ************************************************************************************************************/ 24 | 25 | 26 | #ifndef __CHORUSFD_H__ 27 | #define __CHORUSFD_H__ 28 | 29 | /*--------------------------------------------------------------------------------------*/ 30 | 31 | #include 32 | #include 33 | #include "sinetable.h" 34 | #include 35 | #include "CONSTANTS.h" 36 | 37 | /*--------------------------------------------------------------------------------------*/ 38 | 39 | #define DEPTH 1400 // Size of delay buffer, in samples : 29.17 ms 40 | #define LEFT_DELAY 240 /* initial left delay */ 41 | #define RIGHT_DELAY 240 /* initial right delay */ 42 | #define LEFT_SWEEP 50 43 | #define RIGHT_SWEEP 50 44 | #define MAX_RATE 7.f // in Hz 45 | #define MIN_RATE 0.02f // in Hz 46 | #define LEFT_RATE 0.11f // in Hz 47 | #define RIGHT_RATE 0.12f // in Hz 48 | #define FEEDBACK -0.2f // look at the diagram 49 | #define FORWARD 0.5f 50 | #define MIX 0.5f 51 | 52 | 53 | /*---------------------------------------------------------------------------------------*/ 54 | typedef struct 55 | { 56 | float amp; 57 | float freq; 58 | float phase; 59 | float out; 60 | 61 | } Lfo_t; 62 | 63 | /*---------------------------------------------------------------------------------------*/ 64 | 65 | typedef struct 66 | { 67 | float mix; /* delay blend parameter */ 68 | float fb; /* feedback volume */ 69 | float fw; /* delay tap mix volume */ 70 | int32_t in_idx; /* delay write index */ 71 | float dline[DEPTH] ; /* delay buffer */ 72 | float baseDelay; /* tap position */ 73 | int8_t mode; /* constant or variable delayed feedback ? */ 74 | 75 | } monochorus_t ; 76 | 77 | /*---------------------------------------------------------------------------------------------*/ 78 | void Chorus_reset(uint8_t val); 79 | void Chorus_init(void); 80 | void ChorusDelay_init(monochorus_t *del, float delay_samples,float dfb,float dfw, float dmix); 81 | void stereoChorus_compute (float * left_out, float * right_out, float in); 82 | 83 | void inc_chorusFeedback(void); 84 | void dec_chorusFeedback(void); 85 | void ChorusFeedback_set(uint8_t val); 86 | 87 | void inc_chorusRate(void); 88 | void dec_chorusRate(void); 89 | void ChorusRate_set(uint8_t val); 90 | void ChorusSecondRate_set(uint8_t val); 91 | 92 | void inc_chorusDelay(void); 93 | void dec_chorusDelay(void); 94 | void ChorusDelay_set(uint8_t val); 95 | 96 | void inc_chorusSweep(void); 97 | void dec_chorusSweep(void); 98 | void ChorusSweep_set(uint8_t val); 99 | 100 | void ChorusMode_toggle(void); 101 | void ChorusMode_switch(uint8_t val); 102 | 103 | void ChorusFDBsign_change(void); 104 | void ChorusFDBsign_switch(uint8_t val); 105 | 106 | void Delay_set_fb(monochorus_t *del, float val); 107 | void Delay_set_fw(monochorus_t *del, float val); 108 | void Delay_set_mix(monochorus_t *del, float val); 109 | void Delay_set_delay(monochorus_t *del, float n_delay); 110 | float Delay_get_fb(monochorus_t *del); 111 | float Delay_get_fw(monochorus_t *del); 112 | float Delay_get_mix(monochorus_t *del); 113 | 114 | float mono_chorus_compute(monochorus_t *del, Lfo_t *lfo, float xin); 115 | 116 | /*****************************************************************************************************/ 117 | #endif 118 | -------------------------------------------------------------------------------- /Synth/delay.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : delay.c 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : simple delay/echo effect with low pass filter in the feedback loop 7 | ****************************************************************************** 8 | */ 9 | /* 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | */ 25 | #include "delay.h" 26 | 27 | /*-------------------------------------------------------------------------------------------*/ 28 | /* Delay effect variables */ 29 | static float delayline[DELAYLINE_LEN + 2 ]; 30 | static float *readpos; // output pointer of delay line 31 | static float *writepos; // input pointer of delay line 32 | static uint32_t shift; 33 | static float coeff_a1 = 0.6f; // coeff for the one pole low-pass filter in the feedback loop 34 | // coeff_a1 is between 0 and 1 35 | // 0 : no filtering ; 1 : heavy filtering 36 | static float old_dy; //previous delayed sample 37 | static float fdb = INIT_FEEDB; 38 | static float wet = INIT_WET; 39 | 40 | /*-------------------------------------------------------------------------------------------*/ 41 | void Delay_init(void) 42 | { 43 | /* initialize pointers positions for delay effect */ 44 | shift = DELAY; 45 | readpos = delayline; 46 | writepos = delayline + DELAY; 47 | } 48 | /*-------------------------------------------------------------------------------------------*/ 49 | void Delay_clean(void) 50 | { 51 | for (int i = 0 ; i < DELAYLINE_LEN + 2; i++) 52 | delayline[i] = 0; 53 | } 54 | /*-------------------------------------------------------------------------------------------*/ 55 | void Delay_time_inc(uint8_t val) 56 | { 57 | if (val == MIDI_MAX) { 58 | 59 | float *pos; 60 | if(shift < (DELAYLINE_LEN - DELTA_DELAY)) 61 | shift += DELTA_DELAY; // 62 | pos = writepos - shift; 63 | if (pos >= delayline) 64 | readpos = pos; 65 | else 66 | readpos = pos + DELAYLINE_LEN - 1; 67 | } 68 | } 69 | /*-------------------------------------------------------------------------------------------*/ 70 | void Delay_time_dec(uint8_t val) 71 | { 72 | if (val == MIDI_MAX) { 73 | 74 | float *pos; 75 | if(shift > (MIN_DELAY + DELTA_DELAY)) shift -= DELTA_DELAY; // 76 | pos = writepos - shift; 77 | if (pos >= delayline) 78 | readpos = pos; 79 | else 80 | readpos = pos + DELAYLINE_LEN - 1; 81 | } 82 | } 83 | /*-------------------------------------------------------------------------------------------*/ 84 | void Delay_time_set(uint8_t val) 85 | { 86 | float *pos; 87 | shift = (uint32_t) lrintf((DELAYLINE_LEN - 1 - MIN_DELAY)/MIDI_MAX * val + MIN_DELAY); 88 | pos = writepos - shift; 89 | if (pos >= delayline) 90 | readpos = pos; 91 | else 92 | readpos = pos + DELAYLINE_LEN - 1; 93 | 94 | } 95 | /*-------------------------------------------------------------------------------------------*/ 96 | void Delay_feedback_inc(void) 97 | { 98 | /* increment feedback delay */ 99 | 100 | fdb *= 1.05f ;// 101 | } 102 | /*-------------------------------------------------------------------------------------------*/ 103 | void Delay_feedback_dec(void) 104 | { 105 | /* decrement feedback delay */ 106 | 107 | fdb *= 0.95f ;// 108 | } 109 | /*-------------------------------------------------------------------------------------------*/ 110 | void DelayFeedback_set(uint8_t val) 111 | { 112 | fdb = val / MIDI_MAX; 113 | } 114 | /*-------------------------------------------------------------------------------------------*/ 115 | void DelayWet_set(uint8_t val) 116 | { 117 | wet = val / MIDI_MAX; 118 | } 119 | /*-------------------------------------------------------------------------------------------*/ 120 | float Delay_compute (float x) 121 | { 122 | float y, dy; 123 | 124 | // (*readpos) : delayed sample read at the output of the delay line 125 | dy = (1.f - coeff_a1)*(*readpos) + coeff_a1 * old_dy; // apply lowpass filter in the loop 126 | old_dy = dy; 127 | y = x + fdb*dy; 128 | 129 | y = (y > 1.0f) ? 1.0f : y ; //clip too loud samples 130 | y = (y < -1.0f) ? -1.0f : y ; 131 | *writepos = y; // write new computed sample at the input of the delay line 132 | 133 | /* update the delay line pointers : */ 134 | writepos++; 135 | readpos++; 136 | 137 | if ((writepos - delayline) >= DELAYLINE_LEN) 138 | writepos = delayline; // wrap pointer 139 | 140 | if ((readpos - delayline) >= DELAYLINE_LEN) 141 | readpos = delayline; // wrap pointer 142 | 143 | return (wet * y + (1 - wet) * x); 144 | 145 | } 146 | /************************************************** EOF ****************************************************/ 147 | 148 | -------------------------------------------------------------------------------- /Synth/delay.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : delay.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __DELAY_H 11 | #define __DELAY_H 12 | 13 | //************************************************************************************************* 14 | 15 | /*--------------------- Global Defines ------------------------ */ 16 | #define DELAYLINE_LEN 30000 // max delay in samples (30000 is 0.625 seconds) 17 | #define DELAY 13000 // init delay (in samples) 18 | #define MIN_DELAY 250 // min delay, in samples 19 | #define DELTA_DELAY 20 // variation step of delay time 20 | #define INIT_FEEDB 0.4f 21 | #define INIT_WET 0.5f 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include 25 | #include 26 | #include "CONSTANTS.h" 27 | 28 | /* Exported functions --------------------------------------------------------*/ 29 | 30 | void Delay_init(void); 31 | void Delay_clean(void); 32 | float Delay_compute (float x); 33 | void Delay_feedback_inc(void); 34 | void Delay_feedback_dec(void); 35 | void DelayFeedback_set(uint8_t val); 36 | void DelayWet_set(uint8_t val); 37 | void Delay_time_inc(uint8_t val); 38 | void Delay_time_dec(uint8_t val); 39 | void Delay_time_set(uint8_t val); 40 | 41 | //************************************************************************************************* 42 | #endif 43 | -------------------------------------------------------------------------------- /Synth/drifter.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : drifter.c 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : random segment waveform generator 7 | ****************************************************************************** 8 | */ 9 | /* 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | */ 25 | #include "drifter.h" 26 | 27 | /*-------------------------------------------------------------------------------------------*/ 28 | 29 | Drifter_t d1 _CCM_ ; 30 | Drifter_t d2 _CCM_ ; 31 | Drifter_t d3 _CCM_ ; 32 | 33 | /*-------------------------------------------------------------------------------------------*/ 34 | void Drifter_amp_set(uint8_t val) 35 | { 36 | d1.gain = d2.gain = d3.gain = (val / MIDI_MAX)*(val / MIDI_MAX); 37 | 38 | } 39 | void Drifter_minFreq_set(uint8_t val) 40 | { 41 | d1.fmin = d2.fmin = d3.fmin = .1f + 50 * val / MIDI_MAX; 42 | 43 | } 44 | void Drifter_maxFreq_set(uint8_t val) 45 | { 46 | float x; 47 | 48 | x = (1 + 19 * val / MIDI_MAX )* d1.fmin ; 49 | if (x > 10000) 50 | d1.fmax = d2.fmax = d3.fmax = 10000; 51 | else { 52 | d1.fmax = d2.fmax = d3.fmax = x; 53 | } 54 | } 55 | 56 | /*-------------------------------------------------------------------------------------------*/ 57 | void drifter_newSegment(Drifter_t *d) // 58 | { 59 | d->n = 0; 60 | d->initial = d->final; 61 | d->minLength = 0.5f * Fs / d->fmax ; 62 | d->maxLength = 0.5f * Fs / d->fmin ; 63 | d->length = frand_a_b(d->minLength,d->maxLength); 64 | d->final = frand_a_b(-1, 1); 65 | d->slope = (d->final - d->initial) / d->length ; 66 | } 67 | /*-------------------------------------------------------------------------------------------*/ 68 | float drifter_nextSample(Drifter_t *d) // 69 | { 70 | d->out = d->gain * (d->slope * d->n + d->initial); 71 | (d->n)++; 72 | if (d->n >= d->length) 73 | { 74 | drifter_newSegment(d); 75 | } 76 | return d->out; 77 | } 78 | /*-------------------------------------------------------------------------------------------*/ 79 | float d1_drifter_nextSample(void) // 80 | { 81 | return drifter_nextSample(&d1); 82 | } 83 | /*-------------------------------------------------------------------------------------------*/ 84 | float d2_drifter_nextSample(void) // 85 | { 86 | return drifter_nextSample(&d2); 87 | } 88 | /*---------------------------------------------------------------------------------------------*/ 89 | void drifter_prepare(Drifter_t *d) 90 | { 91 | d->final = 0; 92 | d->fmax = 4; 93 | d->fmin = 2; 94 | d->gain = .01f; 95 | 96 | drifter_newSegment(d); 97 | } 98 | /*---------------------------------------------------------------------------------------------*/ 99 | void drifter_init(void) 100 | { 101 | drifter_prepare(&d1); 102 | drifter_prepare(&d2); 103 | drifter_prepare(&d3); 104 | } 105 | /*------------------------------------------END--------------------------------------------*/ 106 | 107 | -------------------------------------------------------------------------------- /Synth/drifter.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : drifter.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | #ifndef __DRIFTER_H__ 10 | #define __DRIFTER_H__ 11 | /************************************************************************************/ 12 | #include 13 | #include "random.h" 14 | #include "CONSTANTS.h" 15 | 16 | /*---------------------------------------------------------------------------------*/ 17 | typedef struct 18 | { 19 | /*--- parameters ----*/ 20 | float fmax; // sort of max frequency 21 | float fmin; // sort of min frequency 22 | float gain; // drifter output is bound in [-gain, +gain] 23 | 24 | /*---- internals -----*/ 25 | float minLength; 26 | float maxLength; 27 | uint32_t length; 28 | uint32_t n; //sample counter 29 | float initial; 30 | float final; 31 | float slope; 32 | 33 | /*--- output ---*/ 34 | float out; 35 | 36 | } Drifter_t; 37 | 38 | /*----------------------------------------------------------------------------------*/ 39 | void drifter_init (void) ; 40 | float drifter_nextSample(Drifter_t *d); 41 | float d1_drifter_nextSample(void) ; 42 | float d2_drifter_nextSample(void) ; 43 | void Drifter_amp_set(uint8_t val); 44 | void Drifter_minFreq_set(uint8_t val); 45 | void Drifter_maxFreq_set(uint8_t val); 46 | 47 | 48 | /************************************************************************************/ 49 | #endif 50 | -------------------------------------------------------------------------------- /Synth/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file main.c 4 | * @author Xavier Halgand 5 | * @version 6 | * @date 7 | * @brief Dekrispator main file 8 | ****************************************************************************** 9 | * 10 | * 11 | ****************************************************************************** 12 | */ 13 | 14 | /* 15 | * This program is free software; you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation; either version 2 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 | * 29 | */ 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | 33 | #include "main.h" 34 | 35 | /*---------------------------------------------------------------------------*/ 36 | 37 | __ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_Core_dev __ALIGN_END ; 38 | 39 | __ALIGN_BEGIN USBH_HOST USB_Host __ALIGN_END ; 40 | 41 | bool demoMode = true; 42 | bool freeze = false; 43 | 44 | /*----------------------------------------------------------------------------*/ 45 | 46 | void ButtonPressed_action(void) 47 | { 48 | if (freeze == false) 49 | { 50 | freeze = true; 51 | STM_EVAL_LEDOn(LED_Red); 52 | } 53 | else 54 | { 55 | freeze = false; 56 | STM_EVAL_LEDOff(LED_Red); 57 | } 58 | } 59 | /*----------------------------------------------------------------------------*/ 60 | void ButtonReleased_action(void) 61 | { 62 | // nothing to do 63 | } 64 | 65 | /*====================================================================================================*/ 66 | 67 | int main(void) 68 | { 69 | 70 | /* Initialize Discovery board LEDS */ 71 | STM_EVAL_LEDInit(LED_Green); 72 | STM_EVAL_LEDInit(LED_Orange); 73 | STM_EVAL_LEDInit(LED_Red); 74 | STM_EVAL_LEDInit(LED_Blue); 75 | 76 | /* Initialize User Button */ 77 | STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); 78 | 79 | /* Setup SysTick Timer for x msec interrupts.----------------------------*/ 80 | setSysTick(); 81 | 82 | randomGen_init();/* Initialize the on-board random number generator ! */ 83 | Synth_Init(); 84 | audio_init(); 85 | 86 | /* Choose demo or user mode --------------------------*/ 87 | if(STM_EVAL_PBGetState(BUTTON_USER)) // press or not user button before and during startup to choose user or demo mode 88 | { // normal user mode, with USB (button pressed) 89 | demoMode = false; 90 | /* Init Host Library */ 91 | USBH_Init(&USB_OTG_Core_dev, 92 | USB_OTG_FS_CORE_ID, 93 | &USB_Host, 94 | &MIDI_cb, 95 | &USR_Callbacks); 96 | 97 | while (1) 98 | { 99 | /* Host Task handler */ 100 | USBH_Process(&USB_OTG_Core_dev , &USB_Host); 101 | 102 | USB_OTG_BSP_mDelay(1);// how many ms ????? 103 | 104 | } 105 | } 106 | else 107 | { // demo mode, no USB, no interaction, automatic working 108 | demoMode = true; 109 | while (1); 110 | } 111 | } 112 | 113 | 114 | /*****************************END OF FILE****************************************************************/ 115 | -------------------------------------------------------------------------------- /Synth/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file main.h 4 | * Author: Xavier Halgand 5 | * @author 6 | * @version 7 | * @date 8 | * @brief Header for main.c module 9 | ****************************************************************************** 10 | */ 11 | 12 | /* Define to prevent recursive inclusion -------------------------------------*/ 13 | #ifndef __MAIN_H 14 | #define __MAIN_H 15 | 16 | /* Includes ------------------------------------------------------------------*/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* Local includes ------------------------------------------------------------------*/ 23 | #include "usb_bsp.h" 24 | #include "usbh_core.h" 25 | #include "usbh_usr.h" 26 | #include "usbh_midi_core.h" 27 | 28 | #include "audio.h" 29 | #include "timers.h" 30 | #include "soundGen.h" 31 | #include "my_stm32f4_discovery.h" 32 | #include "stm32f4xx.h" 33 | #include "stm32f4xx_conf.h" 34 | #include "my_stm32f4_discovery_audio_codec.h" 35 | #include "stm32fxxx_it.h" 36 | #include "delay.h" 37 | #include "chorusFD.h" 38 | #include "random.h" 39 | #include "CONSTANTS.h" 40 | #include "drifter.h" 41 | #include "resonantFilter.h" 42 | #include "adsr.h" 43 | #include "sequencer.h" 44 | 45 | /*-------------------------------------------------------*/ 46 | #endif /* __MAIN_H */ 47 | 48 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 49 | -------------------------------------------------------------------------------- /Synth/math_tools.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : math_tools.c 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | */ 25 | 26 | #include "math_tools.h" 27 | 28 | /*-----------------------------------------------------------------------------------*/ 29 | float approx_exp(float x) 30 | { 31 | float y; // exp(x) = lim n->inf (1 + x/n)^n, here we've choosen n = 16 32 | y = 1.f + x/16.f ; 33 | y *= y; 34 | y *= y; 35 | y *= y; 36 | y *= y; 37 | return y ; 38 | } 39 | //------------------------------------------------------------------------------------ 40 | // input val in 0 ... 127 41 | // output is an exponential between min and max 42 | float Lin2Exp(uint8_t val, float min, float max) 43 | { 44 | return min * powf(max / min, val / MIDI_MAX); 45 | } 46 | //------------------------------------------------------------------------------------ 47 | 48 | float tanhXdX(float x) 49 | { 50 | float a = x*x; 51 | // IIRC I got this as Pade-approx for tanh(sqrt(x))/sqrt(x) 52 | x = ((a + 105)*a + 945) / ((15*a + 420)*a + 945); 53 | return x; 54 | } 55 | 56 | //------------------------------------------------------------------------------------ 57 | float fastTanh(float var) 58 | { 59 | if(var < -1.95f) return -1.0f; 60 | else if(var > 1.95f) return 1.0f; 61 | else return 4.15f*var/(4.29f+var*var); 62 | } 63 | //------------------------------------------------------------------------------------ 64 | float softClipTwo(float in) 65 | { 66 | return in * tanhXdX(0.5*in); 67 | } 68 | //------------------------------------------------------------------------------------ 69 | float fastTan(float x) 70 | { 71 | float A = -15*x+x*x*x; 72 | float B = 3*(-5+2*x*x); 73 | return A/B; 74 | } 75 | -------------------------------------------------------------------------------- /Synth/math_tools.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : math_tools.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __MATH_TOOLS_H 11 | #define __MATH_TOOLS_H 12 | 13 | /*-------------------------------------------------------*/ 14 | 15 | #include 16 | #include 17 | #include "CONSTANTS.h" 18 | 19 | /*-------------------------------------------------------*/ 20 | float approx_exp(float x); 21 | float Lin2Exp(uint8_t val, float min, float max); // input val in 0 ... 127 22 | float tanhXdX(float x); 23 | float fastTanh(float var); 24 | float softClipTwo(float in); 25 | float fastTan(float x); 26 | 27 | /*-------------------------------------------------------*/ 28 | #endif /* __MATH_TOOLS_H */ 29 | -------------------------------------------------------------------------------- /Synth/midi_interface.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : midi_interface.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __MIDI_INTERFACE_H 11 | #define __MIDI_INTERFACE_H 12 | 13 | /* Includes ------------------------------------------------------------------*/ 14 | #include 15 | #include 16 | #include 17 | #include "CONSTANTS.h" 18 | #include "random.h" 19 | #include "drifter.h" 20 | #include "sinetable.h" 21 | #include "notesTables.h" 22 | #include "drifter.h" 23 | #include "soundGen.h" 24 | #include "audio.h" 25 | 26 | /* Exported functions ------------------------------------------------------- */ 27 | void MIDI_Decode(uint8_t * outBuf); 28 | void MagicFX(uint8_t val); 29 | void MagicPatch(uint8_t val); 30 | 31 | /****************************************************************************************************************************/ 32 | #endif /* __MIDI_INTERFACE_H */ 33 | -------------------------------------------------------------------------------- /Synth/minblep_tables.h: -------------------------------------------------------------------------------- 1 | /* blepvco - minBLEP-based, hard-sync-capable LADSPA VCOs. 2 | * 3 | * Copyright (C) 2004-2005 Sean Bolton. 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied 12 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 13 | * PURPOSE. See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public 16 | * License along with this program; if not, write to the Free 17 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 | * MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _MINBLEP_TABLES_H 22 | #define _MINBLEP_TABLES_H 23 | 24 | /* minBLEP constants */ 25 | /* minBLEP table oversampling factor (must be a power of two): */ 26 | #define MINBLEP_PHASES 64 27 | /* MINBLEP_PHASES minus one: */ 28 | #define MINBLEP_PHASE_MASK 63 29 | /* length in samples of (truncated) step discontinuity delta: */ 30 | #define STEP_DD_PULSE_LENGTH 72 31 | /* length in samples of (truncated) slope discontinuity delta: */ 32 | #define SLOPE_DD_PULSE_LENGTH 71 33 | /* the longer of the two above: */ 34 | #define LONGEST_DD_PULSE_LENGTH STEP_DD_PULSE_LENGTH 35 | /* delay between start of DD pulse and the discontinuity, in samples: */ 36 | #define DD_SAMPLE_DELAY 4 37 | 38 | typedef struct { float value, delta; } float_value_delta; 39 | 40 | /* in minblep_tables.c: */ 41 | extern const float_value_delta step_dd_table[]; 42 | extern const float slope_dd_table[]; 43 | 44 | #endif /* _MINBLEP_TABLES_H */ 45 | -------------------------------------------------------------------------------- /Synth/notesTables.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : notesTables.c 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | /* 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | */ 26 | 27 | #include "notesTables.h" 28 | 29 | /* ******************************************************************************** 30 | * Table of notes frequencies 31 | * 107 notes, first one is MIDI note #21 (A0), last one is #127 (G9) 32 | * 33 | * ********************************************************************************/ 34 | 35 | const float_t notesFreq[] = 36 | { 37 | /* A0 --> */ 27.50000000, 29.13523509, 30.86770633, 38 | 32.70319566, // <-- C1 (#24) 39 | 34.64782887, 36.70809599, 38.89087297, 41.20344461, 40 | 43.65352893, 46.24930284, 48.99942950, 51.91308720, 41 | 55.00000000, 58.27047019, 61.73541266, 42 | 65.40639133, // <-- C2 43 | 69.29565774, 73.41619198, 77.78174593, 82.40688923, 44 | 87.30705786, 92.49860568, 97.99885900, 103.82617439, 45 | 110.00000000, 116.54094038, 123.47082531, 46 | 130.81278265, //<-- C3 47 | 138.59131549, 146.83238396, 155.56349186, 164.81377846, 48 | 174.61411572, 184.99721136, 195.99771799, 207.65234879, 49 | 220.00000000, 233.08188076, 246.94165063, 50 | 261.62556530, // <-- C4 51 | 277.18263098,293.66476792, 311.12698372, 329.62755691, 52 | 349.22823143, 369.99442271, 391.99543598, 415.30469758, 53 | 440.00000000, 466.16376152, 493.88330126, 54 | 523.25113060, // <-- C5 55 | 554.36526195, 587.32953583, 622.25396744, 659.25511383, 56 | 698.45646287, 739.98884542, 783.99087196, 830.60939516, 57 | 880.00000000, 932.32752304, 987.76660251, 58 | 1046.50226120, // <-- C6 59 | 1108.73052391, 1174.65907167, 1244.50793489, 1318.51022765, 60 | 1396.91292573, 1479.97769085, 1567.98174393, 1661.21879032, 61 | 1760.00000000, 1864.65504607, 1975.53320502, 62 | 2093.00452240, // <-- C7 63 | 2217.46104781, 2349.31814334, 2489.01586978, 2637.02045530, 64 | 2793.82585146, 2959.95538169, 3135.96348785, 3322.43758064, 65 | 3520.00000000, 3729.31009214, 3951.06641005, 66 | 4186.00904481, // <-- C8 67 | 4434.92209563, 4698.63628668, 4978.03173955, 5274.04091061, 68 | 5587.65170293, 5919.91076339, 6271.92697571, 6644.87516128, 69 | 7040.00000000, 7458.62018429, 7902.13282010, 70 | 8372.01808962, // <-- C9 71 | 8869.84419126, 9397.27257336, 9956.06347911, 10548.08182121, 72 | 11175.30340586, 11839.82152677, 12543.85395142 73 | }; 74 | 75 | /******************************************************************************/ 76 | /* 77 | * SCALES 78 | * 79 | *****************************************************************************/ 80 | 81 | 82 | /* do ré mi sol la */ 83 | const uint8_t MIDIscale01[] = 84 | { 85 | 5,// number of notes in this scale 86 | 0,2,4,7,9 87 | }; 88 | 89 | /* do ré mib solb sol la */ 90 | const uint8_t MIDIscale02[] = 91 | { 92 | 6,// number of notes in this scale 93 | 0,2,3,6,7,9 94 | }; 95 | /* do ré mi fa sol la */ 96 | const uint8_t MIDIscale03[] = 97 | { 98 | 6,// number of notes in this scale 99 | 0,2,4,5,7,9 100 | }; 101 | 102 | /* do ré fa la */ 103 | const uint8_t MIDIscale04[] = 104 | { 105 | 4,// number of notes in this scale 106 | 0,2,5,9 107 | }; 108 | 109 | /* Gamme par ton : do# ré# fa sol la si */ 110 | const uint8_t MIDIscale05[] = 111 | { 112 | 6,// number of notes in this scale 113 | 1,3,5,7,9,11 114 | }; 115 | 116 | /* la mineur mélodique */ 117 | const uint8_t MIDIscale06[] = 118 | { 119 | /* C D E F G# A B */ 120 | 7,// number of notes in this scale 121 | 0,2,4,5,8,9,11 122 | }; 123 | 124 | 125 | /* do et sol */ 126 | const uint8_t MIDIscale07[] = 127 | { 128 | 2,// number of notes in this scale 129 | 0,7 130 | }; 131 | 132 | /* do et la */ 133 | const uint8_t MIDIscale08[] = 134 | { 135 | 2,// number of notes in this scale 136 | 0,9 137 | }; 138 | 139 | /* C chord */ 140 | const uint8_t MIDIscale09[] = 141 | { 142 | 3,// number of notes in this scale 143 | 0,4,7 144 | }; 145 | 146 | /* Dmin7 chord */ 147 | const uint8_t MIDIscale10[] = 148 | { 149 | 4,// number of notes in this scale 150 | 0,2,5,9 151 | }; 152 | 153 | /* do ré mi fa sol la si */ 154 | const uint8_t MIDIscale11[] = 155 | { 156 | 7, // number of notes in this scale 157 | 0,2,4,5,7,9,11 158 | }; 159 | 160 | /* the 12 notes */ 161 | const uint8_t MIDIscale12[] = 162 | { 163 | 12, // number of notes in this scale 164 | 0,1,2,3,4,5,6,7,8,9,10,11 165 | }; 166 | 167 | 168 | /* do */ 169 | const uint8_t MIDIscale13[] = 170 | { 171 | 1,// number of notes in this scale 172 | 0 173 | }; 174 | 175 | /* do ré */ 176 | const uint8_t MIDIscale14[] = 177 | { 178 | 2, // number of notes in this scale 179 | 0,2 180 | }; 181 | -------------------------------------------------------------------------------- /Synth/notesTables.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : notesTables.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __NOTESTABLES_H 11 | #define __NOTESTABLES_H 12 | 13 | /* Includes ------------------------------------------------------------------*/ 14 | 15 | #include 16 | #include 17 | 18 | /*--------------------- Global Defines ------------------------ */ 19 | 20 | #define MAX_SCALE_INDEX 14 /* starting at 0 ! */ 21 | #define FIRST_NOTE 21 /* MIDI number */ 22 | #define MAX_NOTE_INDEX 106 /* starting at 0 ! */ 23 | 24 | 25 | /*---------------------------------------------------------------------------*/ 26 | extern const float_t notesFreq[]; 27 | extern const uint8_t MIDIscale01[]; 28 | extern const uint8_t MIDIscale02[]; 29 | extern const uint8_t MIDIscale03[]; 30 | extern const uint8_t MIDIscale04[]; 31 | extern const uint8_t MIDIscale05[]; 32 | extern const uint8_t MIDIscale06[]; 33 | extern const uint8_t MIDIscale07[]; 34 | extern const uint8_t MIDIscale08[]; 35 | extern const uint8_t MIDIscale09[]; 36 | extern const uint8_t MIDIscale10[]; 37 | extern const uint8_t MIDIscale11[]; 38 | extern const uint8_t MIDIscale12[]; 39 | extern const uint8_t MIDIscale13[]; 40 | extern const uint8_t MIDIscale14[]; 41 | 42 | /*---------------------------------------------------------------------------*/ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Synth/oscillators.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : oscillators.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __OSCILLATORS_H 11 | #define __OSCILLATORS_H 12 | 13 | /*--------------------- Global Defines ------------------------ */ 14 | #define PARTIALS_NUMBER 10 // number of computed harmonics in the additive generator 15 | 16 | /* Includes ------------------------------------------------------------------*/ 17 | #include 18 | #include 19 | #include 20 | #include "CONSTANTS.h" 21 | #include "math_tools.h" 22 | #include "random.h" 23 | #include "drifter.h" 24 | #include "sinetable.h" 25 | #include "notesTables.h" 26 | #include "drifter.h" 27 | #include "blepvco.h" 28 | /*----------------------------------------------------------------------------*/ 29 | 30 | enum timbre { MORPH_SAW = 0, SPLIT, ACC_SINE, WT_SINE, ADDITIVE, POWER_SINE, BLEPTRIANGLE, BLEPSQUARE, 31 | NOISE, CHORD15, CHORD135, CHORD13min5, VOICES3, DRIFTERS, FM2, BLEPSAW, LAST_SOUND }; 32 | 33 | /*----------------------------------------------------------------------------*/ 34 | typedef struct 35 | { 36 | float_t amp; // should be <= 1 for normal sound output 37 | float_t last_amp; 38 | float_t freq; // Hertz 39 | float_t phase; // radians 40 | float_t phi0; // radians 41 | float_t modInd; // Modulation Index for FM 42 | float_t mul; // pitch frequency multiplier 43 | float_t out; // output sample 44 | 45 | } Oscillator_t; 46 | 47 | /* Exported functions ------------------------------------------------------- */ 48 | 49 | float_t OpSampleCompute0(Oscillator_t * op); // accurate sine 50 | /*-------------------------------------------------------*/ 51 | float_t OpSampleCompute1(Oscillator_t * op); // basic sawtooth^2 52 | /*-------------------------------------------------------*/ 53 | float_t OpSampleCompute2(Oscillator_t * op); // basic sawtooth 54 | /*-------------------------------------------------------*/ 55 | float_t OpSampleCompute3(Oscillator_t * op); // sin(phi)^5 56 | /*-------------------------------------------------------*/ 57 | float_t OpSampleCompute4(Oscillator_t * op); // Complex waveform : +/- |sin(phi)|^alpha(freq), tends to a sine at high freqs 58 | /*-------------------------------------------------------*/ 59 | float_t OpSampleCompute5(Oscillator_t * op); // Basic Triangle 60 | /*-------------------------------------------------------*/ 61 | float_t OpSampleCompute6(Oscillator_t * op); // Morphing sawtooth, tends to a triangle at high freqs 62 | /*-------------------------------------------------------*/ 63 | float_t Osc_WT_SINE_SampleCompute(Oscillator_t * op) ;// basic wave table sine 64 | float_t Osc_FM_sine_SampleCompute(Oscillator_t * op, float FMinput); // basic wave table sine with FM 65 | /*-------------------------------------------------------*/ 66 | float_t OpSampleCompute7bis(Oscillator_t * op); // basic wave table positive sine : 0 < output < op.amp 67 | /*-------------------------------------------------------*/ 68 | float_t OpSampleCompute8(Oscillator_t * op); // basic square 69 | /*-------------------------------------------------------*/ 70 | void AdditiveGen_newWaveform(void); // 71 | /*-------------------------------------------------------*/ 72 | float_t AdditiveGen_SampleCompute(Oscillator_t * op); // additive sine generator 73 | /*-------------------------------------------------------*/ 74 | float_t FM1_sampleCompute(void); // op4 -> op3 -> op2 -> op1 => sound 75 | float_t FM2_sampleCompute(float frq); // (op2 -> op1) + (op4 -> op3) => sound 76 | void FM_op_freq_set(Oscillator_t *op, uint8_t val); 77 | void FM_op_modInd_set(Oscillator_t *op, uint8_t val); 78 | /*-------------------------------------------------------*/ 79 | void osc_init(Oscillator_t * op, float_t amp, float_t freq); 80 | /*-------------------------------------------------------*/ 81 | void OpSetFreq(Oscillator_t * op, float_t f); 82 | /*-------------------------------------------------------*/ 83 | void Drifter_centralFreq_set(uint8_t val); 84 | float Lin2Exp(uint8_t val, float min, float max); // input val in 0 ... 127 85 | /*-------------------------------------------------------*/ 86 | float waveCompute(uint8_t sound, float f0); 87 | 88 | /****************************************************************************************************************************/ 89 | #endif /* __OSCILLATORS_H */ 90 | -------------------------------------------------------------------------------- /Synth/phaser.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file phaser.c 4 | * @author Xavier Halgand, thanks to Ross Bencina and music-dsp.org guys ! 5 | * @version 6 | * @date december 2012 7 | * @brief 8 | 9 | ****************************************************************************** 10 | * This program is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License as 12 | * published by the Free Software Foundation; either version 2 of 13 | * the License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be 16 | * useful, but WITHOUT ANY WARRANTY; without even the implied 17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 18 | * PURPOSE. See the GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public 21 | * License along with this program; if not, write to the Free 22 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | #include "phaser.h" 27 | 28 | /*---------------------------------------------------------------------*/ 29 | #define MAX_RATE 7.f // in Hz 30 | #define MIN_RATE 0.02f // in Hz 31 | 32 | /*This defines the phaser stages 33 | that is the number of allpass filters 34 | */ 35 | #define PH_STAGES 6 36 | 37 | /*---------------------------------------------------------------------*/ 38 | 39 | static float old[PH_STAGES]; 40 | static float f_min, f_max; 41 | static float swrate; 42 | static float wet ; 43 | static float dmin, dmax; //range 44 | static float fb; //feedback 45 | static float lfoPhase; 46 | static float lfoInc; 47 | static float a1; 48 | static float zm1; 49 | 50 | /*---------------------------------------------------------------------*/ 51 | void PhaserInit(void) 52 | { 53 | f_min = 200.f; 54 | f_max = 1700.f; 55 | swrate = 0.1f; 56 | fb = 0.7f; 57 | wet = 0.3f; 58 | 59 | dmin = 2 * f_min / SAMPLERATE; 60 | dmax = 2 * f_max / SAMPLERATE; 61 | lfoInc = _2PI * swrate / SAMPLERATE; 62 | } 63 | /*---------------------------------------------------------------------*/ 64 | void Phaser_Rate_set(uint8_t val) 65 | { 66 | swrate = (MAX_RATE - MIN_RATE) / MIDI_MAX * val + MIN_RATE; 67 | lfoInc = _2PI * swrate / SAMPLERATE; 68 | } 69 | /*---------------------------------------------------------------------*/ 70 | void Phaser_Feedback_set(uint8_t val) 71 | { 72 | fb = 0.999f * val / MIDI_MAX; 73 | } 74 | /*---------------------------------------------------------------------*/ 75 | void Phaser_Wet_set(uint8_t val) 76 | { 77 | wet = val / MIDI_MAX; 78 | } 79 | /*---------------------------------------------------------------------*/ 80 | void PhaserRate(float rate) 81 | { 82 | swrate = rate; 83 | lfoInc = _2PI * swrate / SAMPLERATE; 84 | } 85 | /*---------------------------------------------------------------------*/ 86 | void PhaserFeedback(float fdb) 87 | { 88 | fb = fdb; 89 | } 90 | /*---------------------------------------------------------------------*/ 91 | static float allpass(float yin, int ind) 92 | { 93 | float yout; 94 | 95 | yout = - yin * a1 + old[ind]; 96 | old[ind] = yout * a1 + yin; 97 | return yout; 98 | } 99 | 100 | /*---------------------------------------------------------------------*/ 101 | float Phaser_compute(float xin) 102 | { 103 | float yout; 104 | int i; 105 | float d; 106 | 107 | //calculate and update phaser sweep lfo... 108 | 109 | d = dmin + (dmax - dmin) * ((sinetable[lrintf(ALPHA * lfoPhase)] + 1.f)*0.5f); 110 | 111 | lfoPhase += lfoInc; 112 | if( lfoPhase >= _2PI ) lfoPhase -= _2PI; 113 | 114 | //update filter coeffs 115 | a1 = (1.f - d) / (1.f + d); 116 | 117 | //calculate output 118 | 119 | yout = allpass(xin + zm1 * fb, 0); 120 | 121 | for(i = 1; i < PH_STAGES; i++) 122 | { 123 | yout = allpass(yout, i); 124 | } 125 | zm1 = yout; 126 | 127 | yout = (1 - wet) * xin + wet * yout; 128 | 129 | return yout; 130 | } 131 | 132 | -------------------------------------------------------------------------------- /Synth/phaser.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file phaser.h 4 | * @author Xavier Halgand, thanks to Ross Bencina and music-dsp.org guys ! 5 | * @version 6 | * @date december 2012 7 | * @brief 8 | 9 | ****************************************************************************** 10 | * This program is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License as 12 | * published by the Free Software Foundation; either version 2 of 13 | * the License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be 16 | * useful, but WITHOUT ANY WARRANTY; without even the implied 17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 18 | * PURPOSE. See the GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public 21 | * License along with this program; if not, write to the Free 22 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | 27 | #ifndef __PHASER_H__ 28 | #define __PHASER_H__ 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include 32 | #include "CONSTANTS.h" 33 | #include "sinetable.h" 34 | 35 | /* Exported functions ------------------------------------------------------- */ 36 | void PhaserInit(void); 37 | void Phaser_Rate_set(uint8_t val); 38 | void Phaser_Feedback_set(uint8_t val); 39 | void Phaser_Wet_set(uint8_t val); 40 | float Phaser_compute(float xin); 41 | void PhaserRate(float rate); 42 | void PhaserFeedback(float fdb); 43 | 44 | 45 | /*---------------------------------------------------------------------------*/ 46 | #endif 47 | -------------------------------------------------------------------------------- /Synth/random.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : random.c 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | #include "random.h" 11 | 12 | 13 | //--------------------------------------------------------------------------- 14 | void randomGen_init(void) 15 | { 16 | RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE); 17 | RNG_Cmd(ENABLE); 18 | while (RNG_GetFlagStatus(RNG_FLAG_DRDY) == RESET) 19 | ; 20 | srand(RNG_GetRandomNumber()); 21 | } 22 | //--------------------------------------------------------------------------- 23 | /************** 24 | * returns a random float between a and b 25 | *****************/ 26 | float_t frand_a_b(float_t a, float_t b) 27 | { 28 | return ( rand()/(float_t)RAND_MAX ) * (b-a) + a ; 29 | } 30 | 31 | 32 | //--------------------------------------------------------------------------- 33 | /************** 34 | * returns a random float between 0 and 1 35 | *****************/ 36 | float_t randomNum(void) 37 | { 38 | float_t random = 1.0f; 39 | while (RNG_GetFlagStatus(RNG_FLAG_DRDY) == RESET) 40 | ; 41 | random = (float_t) (RNG_GetRandomNumber() / 4294967294.0f); 42 | return random; 43 | } 44 | 45 | /*-----------------------------------------------------------------------------*/ 46 | /************** 47 | * returns a random integer between 0 and MIDI_MAX 48 | *****************/ 49 | uint8_t MIDIrandVal(void) 50 | { 51 | return (uint8_t)lrintf(frand_a_b(0 , MIDI_MAX)); 52 | } 53 | -------------------------------------------------------------------------------- /Synth/random.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : random.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | #ifndef __RANDOM_H__ 10 | #define __RANDOM_H__ 11 | 12 | /* Includes ------------------------------------------------------------------*/ 13 | #include 14 | #include 15 | #include 16 | #include "stm32f4xx_rng.h" 17 | #include "stm32f4xx_rcc.h" 18 | #include "CONSTANTS.h" 19 | 20 | 21 | /*-Exported functions---------------------------------------------------------*/ 22 | void randomGen_init (void); 23 | float_t frand_a_b (float_t a, float_t b); 24 | float_t randomNum (void); 25 | uint8_t MIDIrandVal(void); 26 | 27 | 28 | /************************************************************************************/ 29 | #endif 30 | -------------------------------------------------------------------------------- /Synth/resonantFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * resonantFilter.h 3 | * 4 | * Created on: 05.04.2012 5 | * ------------------------------------------------------------------------------------------------------------------------ 6 | * Copyright 2013 Julian Schmidt 7 | * Julian@sonic-potions.com 8 | * ------------------------------------------------------------------------------------------------------------------------ 9 | * This file is part of the Sonic Potions LXR drumsynth firmware. 10 | * ------------------------------------------------------------------------------------------------------------------------ 11 | * Redistribution and use of the LXR code or any derivative works are permitted 12 | * provided that the following conditions are met: 13 | * 14 | * - The code may not be sold, nor may it be used in a commercial product or activity. 15 | * 16 | * - Redistributions that are modified from the original source must include the complete 17 | * source code, including the source code for all components used by a binary built 18 | * from the modified sources. However, as a special exception, the source code distributed 19 | * need not include anything that is normally distributed (in either source or binary form) 20 | * with the major components (compiler, kernel, and so on) of the operating system on which 21 | * the executable runs, unless that component itself accompanies the executable. 22 | * 23 | * - Redistributions must reproduce the above copyright notice, this list of conditions and the 24 | * following disclaimer in the documentation and/or other materials provided with the distribution. 25 | * ------------------------------------------------------------------------------------------------------------------------ 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 27 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 32 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * ------------------------------------------------------------------------------------------------------------------------ 34 | */ 35 | 36 | 37 | #ifndef RESONANTFILTER_H_ 38 | #define RESONANTFILTER_H_ 39 | 40 | /* 41 | * ResonantFilter.c 42 | * 43 | * Created on: 05.04.2012 44 | * Author: Julian 45 | */ 46 | //---------------------------------------------------- 47 | 48 | #include 49 | #include 50 | #include "CONSTANTS.h" 51 | #include "math_tools.h" 52 | 53 | //---------------------------------------------------- 54 | //removed to free some cpu cycles 55 | #define ENABLE_NONLINEAR_INTEGRATORS 1 56 | #define FILTER_GAIN_F 0.88f 57 | #define USE_SHAPER_NONLINEARITY 0 58 | #define MAX_FREQ 8000.f 59 | #define MIN_FREQ 80.f 60 | 61 | //---------------------------------------------------- 62 | enum filterTypeEnum 63 | { 64 | FILTER_LP=1, 65 | FILTER_HP, 66 | FILTER_BP, 67 | FILTER_NOTCH, 68 | FILTER_PEAK 69 | }; 70 | 71 | 72 | //---------------------------------------------------- 73 | typedef struct ResoFilterStruct 74 | { 75 | uint8_t type; // filter type : LP, HP, BP... 76 | float f; /**< cutoff */ 77 | float g; /**< embedded integrator gain (Fig 3.11), wc == wa*/ 78 | float q; /**< q value calculated from setReso()*/ 79 | float s1; 80 | float s2; 81 | float drive; 82 | #if ENABLE_NONLINEAR_INTEGRATORS 83 | float zi; //input z^(-1) 84 | #endif 85 | 86 | #if USE_SHAPER_NONLINEARITY 87 | Distortion shaper; 88 | #endif 89 | 90 | } ResonantFilter; 91 | 92 | 93 | //float translateLinExp(uint8_t val); 94 | //------------------------------------------------------------------------------------ 95 | void SVF_setReso(ResonantFilter* filter, float feedback); 96 | //------------------------------------------------------------------------------------ 97 | void SVF_setDrive(ResonantFilter* filter, uint8_t drive); 98 | //------------------------------------------------------------------------------------ 99 | void SVF_directSetFilterValue(ResonantFilter* filter, float val); 100 | //------------------------------------------------------------------------------------ 101 | //void SVF_calcBlockZDF(ResonantFilter* filter, const uint8_t type, int16_t* buf, const uint8_t size); 102 | //------------------------------------------------------------------------------------ 103 | void SVF_recalcFreq(ResonantFilter* filter); 104 | 105 | float SVF_calcSample(ResonantFilter* filter, float in); 106 | //------------------------------------------------------------------------------------ 107 | void SVF_init(void); 108 | 109 | void Filter1Freq_set(uint8_t val); 110 | 111 | void Filter1Res_set(uint8_t val); 112 | 113 | void Filter1Drive_set(uint8_t val); 114 | 115 | void Filter1Type_set(uint8_t val); 116 | /*-----------------------------------------------------------------------------------*/ 117 | void Filter2Freq_set(uint8_t val); 118 | 119 | void Filter2Res_set(uint8_t val); 120 | 121 | void Filter2Drive_set(uint8_t val); 122 | 123 | void Filter2Type_set(uint8_t val); 124 | 125 | #endif /* RESONANTFILTER_H_ */ 126 | -------------------------------------------------------------------------------- /Synth/sequencer.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : sequencer.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __SEQUENCER_H 11 | #define __SEQUENCER_H 12 | 13 | /*----------------------------------------------------------------------------*/ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include "CONSTANTS.h" 20 | #include "random.h" 21 | #include "notesTables.h" 22 | 23 | /*-----------------------------------------------------------------------------*/ 24 | 25 | #define NUMBER_STEPS 16 26 | #define INIT_TEMPO (4*80) 27 | 28 | /*------------------------------------------------------------------------------*/ 29 | typedef struct 30 | { 31 | uint8_t note[NUMBER_STEPS]; // 32 | uint8_t veloc[NUMBER_STEPS]; // 33 | 34 | } Track_t; 35 | /*------------------------------------------------------------------------------*/ 36 | typedef struct 37 | { 38 | Track_t track1; 39 | float_t tempo; // unit : bpm 40 | int32_t steptime; // unit : # of samples 41 | int32_t smp_count; // sample counter 42 | uint8_t step_idx; // current step index 43 | uint32_t gateTime; // desired gate on time (in samples) 44 | 45 | } Sequencer_t; 46 | /*------------------------------------------------------------------------------*/ 47 | typedef struct 48 | { 49 | uint8_t scaleIndex ; 50 | uint8_t *currentScale ; 51 | uint8_t octaveSpread; 52 | uint8_t rootNote; 53 | int8_t transpose; 54 | bool automaticON; // random notes ? 55 | bool glideON; // glissando between notes ? 56 | bool chRequested; 57 | bool someNotesMuted; 58 | 59 | } NoteGenerator_t; 60 | 61 | /*-------------- Exported Functions Prototype ---------------------------*/ 62 | 63 | void seq_tempo_set(uint8_t val); 64 | void sequencer_init(void); 65 | void sequencer_process(void); 66 | void seq_sequence_new(void); 67 | void seq_transpose(void); 68 | void seq_transpUp(void); // one tone up 69 | void seq_transpDown(void); // one tone down 70 | void seq_transp(int8_t s, uint8_t val); 71 | void seq_gateTime_set(uint8_t val); 72 | void seq_chooseScale(uint8_t idx); 73 | void seq_scale_set(uint8_t val); 74 | void seq_switchMovingSeq(uint8_t val); 75 | void seq_switchMute(uint8_t val); 76 | void seq_switchGlide(uint8_t val); 77 | void seq_doubleTempo(void); 78 | void seq_halfTempo(void); 79 | void seq_incTempo(void); 80 | void seq_decTempo(void); 81 | void seq_freqMax_set(uint8_t val); 82 | 83 | 84 | /* User Callbacks: user has to implement these functions in his code if 85 | they are needed. -----------------------------------------------------------*/ 86 | void sequencer_newSequence_action(void); 87 | void sequencer_newStep_action(void); 88 | 89 | /******************************************************************************/ 90 | #endif 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /Synth/sinetable.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : sinetable.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | 11 | /* Define to prevent recursive inclusion -------------------------------------*/ 12 | #ifndef __sinetable_h_ 13 | #define __sinetable_h_ 14 | 15 | #include 16 | 17 | #define SINETABLE_SIZE 1024 18 | #define _2PI 6.283185307f 19 | #define ALPHA (SINETABLE_SIZE/_2PI) 20 | 21 | extern const float_t sinetable[1025]; 22 | 23 | #endif // __sinetable_h_ 24 | 25 | -------------------------------------------------------------------------------- /Synth/soundGen.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : soundGen.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | /* Define to prevent recursive inclusion -------------------------------------*/ 10 | #ifndef __SOUNDGEN_H 11 | #define __SOUNDGEN_H 12 | 13 | /*--------------------- Global Defines ------------------------ */ 14 | 15 | #define MAX_FILTER_LFO_AMP 32.f 16 | #define DECAY_FACTOR 0.99975f // initial multiplying factor for the envelope decay 17 | #define MIN_DECAY_FACTOR 0.999f 18 | #define VIBRATO_AMP 0.01f 19 | #define VIBRATO_FREQ 5.5f 20 | #define MAX_VIBRATO_AMP 0.5f 21 | #define MAX_VIBRATO_FREQ 12.f 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include 25 | #include 26 | #include 27 | #include "CONSTANTS.h" 28 | #include "math_tools.h" 29 | #include "random.h" 30 | //#include "pitchGenerator.h" 31 | #include "sequencer.h" 32 | #include "oscillators.h" 33 | #include "delay.h" 34 | #include "chorusFD.h" 35 | #include "phaser.h" 36 | #include "sinetable.h" 37 | #include "notesTables.h" 38 | #include "timers.h" 39 | #include "resonantFilter.h" 40 | #include "adsr.h" 41 | #include "midi_interface.h" 42 | #include "blepvco.h" 43 | 44 | /* Exported functions ------------------------------------------------------- */ 45 | uint8_t soundNumber_get(void); 46 | void autoSound_set(int8_t val); 47 | void RandSound1(uint8_t val); 48 | void RandSound2(uint8_t val); 49 | 50 | void DemoMode_toggle(uint8_t val); 51 | //void DemoMode_freeze(uint8_t val); // is it useful ? 52 | /*-------------------------------------------------------*/ 53 | void FM_OP1_freq_set(uint8_t val); 54 | void FM_OP1_modInd_set(uint8_t val); 55 | 56 | /*-------------------------------------------------------*/ 57 | void FM_OP2_freq_set(uint8_t val); 58 | void FM_OP2_freqMul_inc(uint8_t val); 59 | void FM_OP2_freqMul_dec(uint8_t val); 60 | void FM_OP2_modInd_set(uint8_t val); 61 | 62 | /*-------------------------------------------------------*/ 63 | void FM_OP3_freq_set(uint8_t val); 64 | void FM_OP3_freqMul_inc(uint8_t val); 65 | void FM_OP3_freqMul_dec(uint8_t val); 66 | void FM_OP3_modInd_set(uint8_t val); 67 | 68 | /*-------------------------------------------------------*/ 69 | void FM_OP4_freq_set(uint8_t val); 70 | void FM_OP4_freqMul_inc(uint8_t val); 71 | void FM_OP4_freqMul_dec(uint8_t val); 72 | void FM_OP4_modInd_set(uint8_t val); 73 | 74 | /*-------------------------------------------------------*/ 75 | void AmpLFO_amp_set(uint8_t val); 76 | void AmpLFO_freq_set(uint8_t val); 77 | 78 | void Filt1LFO_amp_set(uint8_t val); 79 | void Filt1LFO_freq_set(uint8_t val); 80 | 81 | void Filt2LFO_amp_set(uint8_t val); 82 | void Filt2LFO_freq_set(uint8_t val); 83 | 84 | void toggleVibrato(void); 85 | void VibratoAmp_set(uint8_t val); 86 | void VibratoFreq_set(uint8_t val); 87 | 88 | void toggleSynthOut(void); 89 | void SynthOut_switch(uint8_t val); 90 | 91 | void AdditiveGen_newWaveform(void); 92 | 93 | void incSynthOut(void); 94 | void decSynthOut(void); 95 | void SynthOut_amp_set(uint8_t val); 96 | 97 | void Delay_toggle(void); 98 | void Delay_switch(uint8_t val); 99 | 100 | void toggleFilter(void); 101 | void Filter_Random_switch(uint8_t val); 102 | 103 | void Phaser_switch(uint8_t val); 104 | 105 | void Chorus_toggle(void); 106 | void Chorus_switch(uint8_t val); 107 | 108 | void incDecay(void); 109 | void decDecay(void); 110 | void setDecayFactor(uint8_t val); 111 | 112 | void nextSound(void); 113 | void prevSound(void); 114 | void Sound_set(uint8_t val); 115 | 116 | void soundGenInit(void); 117 | void soundGenNewWave(void); 118 | void Synth_Init(void); 119 | 120 | void make_sound(uint16_t *buf , uint16_t len); 121 | void OpsRandFreq(void); 122 | 123 | #endif /* __SOUNDGEN_H */ 124 | -------------------------------------------------------------------------------- /Synth/timers.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : timers.c 4 | * Date : 5 | * Author : Xavier Halgand 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | /* Includes ------------------------------------------------------------------*/ 11 | 12 | #include "timers.h" 13 | 14 | static uint32_t TimingDelay = 0; 15 | static uint32_t TimingDelay1 = 0; 16 | //--------------------------------------------------------------------------- 17 | void setSysTick(void) 18 | { 19 | if (SysTick_Config(SystemCoreClock / SYSTICK_FREQ)) 20 | { 21 | /* Capture error */ 22 | while (1) 23 | ; 24 | } 25 | //NVIC_SetPriority(SysTick_IRQn,0); 26 | } 27 | //--------------------------------------------------------------------------- 28 | /** 29 | * @brief Inserts a delay time. 30 | * @param nTime: specifies the delay time length, in milliseconds. 31 | * @retval None 32 | */ 33 | void wait(uint32_t nTime) 34 | { 35 | TimingDelay = nTime; 36 | 37 | while (TimingDelay != 0) 38 | ; 39 | } 40 | //--------------------------------------------------------------------------- 41 | /** 42 | * @brief Decrements the TimingDelays variables. 43 | * Called by SysTick_Handler() in stm32f4xx_it.c 44 | * @param None 45 | * @retval None 46 | */ 47 | void TimingDelay_Decrement(void) 48 | { 49 | if (TimingDelay != 0) 50 | { 51 | TimingDelay--; 52 | } 53 | if (TimingDelay1 != 0) 54 | { 55 | TimingDelay1--; 56 | } 57 | } 58 | 59 | //--------------------------------------------------------------------------- 60 | 61 | uint32_t getTime(void) 62 | { 63 | return TimingDelay1; 64 | } 65 | 66 | void setTime(uint32_t val) 67 | { 68 | TimingDelay1 = val; 69 | } 70 | -------------------------------------------------------------------------------- /Synth/timers.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : timers.h 4 | * Author : Xavier Halgand 5 | * Date : 6 | * Description : 7 | ****************************************************************************** 8 | */ 9 | 10 | /* Define to prevent recursive inclusion -------------------------------------*/ 11 | #ifndef __TIMERS_H 12 | #define __TIMERS_H 13 | 14 | 15 | /* Includes ------------------------------------------------------------------*/ 16 | #include 17 | #include 18 | #include "CONSTANTS.h" 19 | #include "audio.h" 20 | #include "my_stm32f4_discovery_audio_codec.h" 21 | #include "my_stm32f4_discovery.h" 22 | #include "soundGen.h" 23 | 24 | 25 | /* Exported functions ------------------------------------------------------- */ 26 | void TimingDelay_Decrement(void); 27 | void wait(uint32_t nTime); 28 | void setSysTick(void); 29 | uint32_t getTime(void); 30 | void setTime(uint32_t val); 31 | 32 | /*************************************************************************************/ 33 | #endif /* __TIMERS_H */ 34 | -------------------------------------------------------------------------------- /System/my_stm32f4_discovery.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file my_stm32f4_discovery.h 4 | * 5 | * @brief This file contains definitions for STM32F4-Discovery Kit's Leds and 6 | * push-button hardware resources + ....more.... 7 | ****************************************************************************** 8 | 9 | ****************************************************************************** 10 | */ 11 | 12 | /* Define to prevent recursive inclusion -------------------------------------*/ 13 | #ifndef __STM32F4_DISCOVERY_H 14 | #define __STM32F4_DISCOVERY_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include 24 | #include "stm32f4xx.h" 25 | #include "CONSTANTS.h" 26 | /** @addtogroup Utilities 27 | * @{ 28 | */ 29 | 30 | /** @addtogroup STM32F4_DISCOVERY 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL 35 | * @{ 36 | */ 37 | 38 | /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Types 39 | * @{ 40 | */ 41 | typedef enum 42 | { 43 | LED4 = 0, 44 | LED3 = 1, 45 | LED5 = 2, 46 | LED6 = 3 47 | } Led_TypeDef; 48 | 49 | #define LED_Green LED4 50 | #define LED_Orange LED3 51 | #define LED_Red LED5 52 | #define LED_Blue LED6 53 | 54 | typedef enum 55 | { 56 | BUTTON_USER = 0, 57 | } Button_TypeDef; 58 | 59 | typedef enum 60 | { 61 | BUTTON_MODE_GPIO = 0, 62 | BUTTON_MODE_EXTI = 1 63 | } ButtonMode_TypeDef; 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Constants 69 | * @{ 70 | */ 71 | 72 | /** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL_LED 73 | * @{ 74 | */ 75 | #define LEDn 4 76 | 77 | #define LED4_PIN GPIO_Pin_12 78 | #define LED4_GPIO_PORT GPIOD 79 | #define LED4_GPIO_CLK RCC_AHB1Periph_GPIOD 80 | 81 | #define LED3_PIN GPIO_Pin_13 82 | #define LED3_GPIO_PORT GPIOD 83 | #define LED3_GPIO_CLK RCC_AHB1Periph_GPIOD 84 | 85 | #define LED5_PIN GPIO_Pin_14 86 | #define LED5_GPIO_PORT GPIOD 87 | #define LED5_GPIO_CLK RCC_AHB1Periph_GPIOD 88 | 89 | #define LED6_PIN GPIO_Pin_15 90 | #define LED6_GPIO_PORT GPIOD 91 | #define LED6_GPIO_CLK RCC_AHB1Periph_GPIOD 92 | /** 93 | * @} 94 | */ 95 | 96 | /** @addtogroup STM32F4_DISCOVERY_LOW_LEVEL_BUTTON 97 | * @{ 98 | */ 99 | #define BUTTONn 1 100 | 101 | /** 102 | * @brief Wakeup push-button 103 | */ 104 | #define USER_BUTTON_PIN GPIO_Pin_0 105 | #define USER_BUTTON_GPIO_PORT GPIOA 106 | #define USER_BUTTON_GPIO_CLK RCC_AHB1Periph_GPIOA 107 | #define USER_BUTTON_EXTI_LINE EXTI_Line0 108 | #define USER_BUTTON_EXTI_PORT_SOURCE EXTI_PortSourceGPIOA 109 | #define USER_BUTTON_EXTI_PIN_SOURCE EXTI_PinSource0 110 | #define USER_BUTTON_EXTI_IRQn EXTI0_IRQn 111 | /** 112 | * @} 113 | */ 114 | 115 | /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Macros 116 | * @{ 117 | */ 118 | /** 119 | * @} 120 | */ 121 | 122 | 123 | /** @defgroup STM32F4_DISCOVERY_LOW_LEVEL_Exported_Functions 124 | * @{ 125 | */ 126 | void STM_EVAL_LEDInit(Led_TypeDef Led); 127 | void STM_EVAL_LEDOn(Led_TypeDef Led); 128 | void STM_EVAL_LEDOff(Led_TypeDef Led); 129 | void STM_EVAL_LEDToggle(Led_TypeDef Led); 130 | void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); 131 | uint32_t STM_EVAL_PBGetState(Button_TypeDef Button); 132 | 133 | /*----------------------------------------------------------------------------------*/ 134 | 135 | void start_LED_On(Led_TypeDef Led, uint32_t duration); 136 | void update_temporized_LED(Led_TypeDef Led); 137 | void DebounceUserButton(void); 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | #ifdef __cplusplus 144 | } 145 | #endif 146 | 147 | #endif /* __STM32F4_DISCOVERY_H */ 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | 161 | 162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 163 | -------------------------------------------------------------------------------- /System/stm32f407xav.ld: -------------------------------------------------------------------------------- 1 | /*============= this is a link file for : =========================== 2 | STM32F407VG 3 | GNU ARM GCC with Coocox CoIDE 4 | ====================================================================*/ 5 | 6 | OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") 7 | /* Internal Memory Map*/ 8 | MEMORY 9 | { 10 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x00100000 11 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000 12 | ccm (rwx) : ORIGIN = 0x10000000, LENGTH = 0x00010000 13 | } 14 | 15 | _eram = 0x20000000 + 0x00020000; 16 | 17 | /* Section Definitions */ 18 | SECTIONS 19 | { 20 | /* collect all uninitialized .ccm sections */ 21 | /* A directed static allocation would look like this : 22 | volatile uint8_t buff0[16384] __attribute__((section(".ccm"))); */ 23 | .ccm (NOLOAD) : 24 | { 25 | . = ALIGN(4); 26 | *(.ccm) 27 | *(.ccm.*) 28 | . = ALIGN(4); 29 | } > ccm 30 | 31 | .text : 32 | { 33 | KEEP(*(.isr_vector .isr_vector.*)) 34 | *(.text .text.* .gnu.linkonce.t.*) 35 | *(.glue_7t) *(.glue_7) 36 | *(.rodata .rodata* .gnu.linkonce.r.*) 37 | } > rom 38 | 39 | .ARM.extab : 40 | { 41 | *(.ARM.extab* .gnu.linkonce.armextab.*) 42 | } > rom 43 | 44 | __exidx_start = .; 45 | .ARM.exidx : 46 | { 47 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 48 | } > rom 49 | __exidx_end = .; 50 | 51 | . = ALIGN(4); 52 | _etext = .; 53 | _sidata = .; 54 | 55 | .data : AT (_etext) 56 | { 57 | _sdata = .; 58 | *(.data .data.*) 59 | . = ALIGN(4); 60 | _edata = . ; 61 | } > ram 62 | 63 | /* .bss section which is used for uninitialized data */ 64 | .bss (NOLOAD) : 65 | { 66 | _sbss = . ; 67 | *(.bss .bss.*) 68 | *(COMMON) 69 | . = ALIGN(4); 70 | _ebss = . ; 71 | } > ram 72 | 73 | /* stack section */ 74 | .co_stack (NOLOAD): 75 | { 76 | . = ALIGN(8); 77 | *(.co_stack .co_stack.*) 78 | } > ram 79 | 80 | . = ALIGN(4); 81 | _end = . ; 82 | } 83 | -------------------------------------------------------------------------------- /System/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrBlueXav/Dekrispator/f23665ba689f0a6d6cd88037d5676ee4c92910c3/System/stm32f4xx.h -------------------------------------------------------------------------------- /System/stm32f4xx_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_conf.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F4xx_CONF_H 30 | #define __STM32F4xx_CONF_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | /* Uncomment the line below to enable peripheral header file inclusion */ 34 | #include "stm32f4xx_adc.h" 35 | #include "stm32f4xx_can.h" 36 | #include "stm32f4xx_crc.h" 37 | #include "stm32f4xx_cryp.h" 38 | #include "stm32f4xx_dac.h" 39 | #include "stm32f4xx_dbgmcu.h" 40 | #include "stm32f4xx_dcmi.h" 41 | #include "stm32f4xx_dma.h" 42 | #include "stm32f4xx_exti.h" 43 | #include "stm32f4xx_flash.h" 44 | #include "stm32f4xx_fsmc.h" 45 | #include "stm32f4xx_hash.h" 46 | #include "stm32f4xx_gpio.h" 47 | #include "stm32f4xx_i2c.h" 48 | #include "stm32f4xx_iwdg.h" 49 | #include "stm32f4xx_pwr.h" 50 | #include "stm32f4xx_rcc.h" 51 | #include "stm32f4xx_rng.h" 52 | #include "stm32f4xx_rtc.h" 53 | #include "stm32f4xx_sdio.h" 54 | #include "stm32f4xx_spi.h" 55 | #include "stm32f4xx_syscfg.h" 56 | #include "stm32f4xx_tim.h" 57 | #include "stm32f4xx_usart.h" 58 | #include "stm32f4xx_wwdg.h" 59 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 60 | 61 | /* Exported types ------------------------------------------------------------*/ 62 | /* Exported constants --------------------------------------------------------*/ 63 | 64 | /* If an external clock source is used, then the value of the following define 65 | should be set to the value of the external clock source, else, if no external 66 | clock is used, keep this define commented */ 67 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */ 68 | 69 | 70 | /* Uncomment the line below to expanse the "assert_param" macro in the 71 | Standard Peripheral Library drivers code */ 72 | /* #define USE_FULL_ASSERT 1 */ 73 | 74 | /* Exported macro ------------------------------------------------------------*/ 75 | #ifdef USE_FULL_ASSERT 76 | 77 | /** 78 | * @brief The assert_param macro is used for function's parameters check. 79 | * @param expr: If expr is false, it calls assert_failed function 80 | * which reports the name of the source file and the source 81 | * line number of the call that failed. 82 | * If expr is true, it returns no value. 83 | * @retval None 84 | */ 85 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 86 | /* Exported functions ------------------------------------------------------- */ 87 | void assert_failed(uint8_t* file, uint32_t line); 88 | #else 89 | #define assert_param(expr) ((void)0) 90 | #endif /* USE_FULL_ASSERT */ 91 | 92 | #endif /* __STM32F4xx_CONF_H */ 93 | 94 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /System/stm32fxxx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32fxxx_it.c 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief This file includes the interrupt handlers for the application 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usb_bsp.h" 30 | #include "usb_hcd_int.h" 31 | #include "usbh_core.h" 32 | #include "stm32f4xx_conf.h" 33 | #include "stm32fxxx_it.h" 34 | /* Private typedef -----------------------------------------------------------*/ 35 | 36 | /* Private define ------------------------------------------------------------*/ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | 40 | /* Private variables ---------------------------------------------------------*/ 41 | 42 | /*-----------------------------------------------------------------------------*/ 43 | extern USB_OTG_CORE_HANDLE USB_OTG_Core_dev; 44 | extern USBH_HOST USB_Host; 45 | extern bool demoMode; 46 | 47 | extern void USB_OTG_BSP_TimerIRQ (void); 48 | 49 | /* Private functions ---------------------------------------------------------*/ 50 | 51 | /******************************************************************************/ 52 | /* Cortex-M Processor Exceptions Handlers */ 53 | /******************************************************************************/ 54 | /** 55 | * @brief NMI_Handler 56 | * This function handles NMI exception. 57 | * @param None 58 | * @retval None 59 | */ 60 | void NMI_Handler(void) 61 | { 62 | } 63 | 64 | /** 65 | * @brief EXTI1_IRQHandler 66 | * This function handles External line 1 interrupt request. 67 | * It's used by USB host function to report over current detection 68 | * @param None 69 | * @retval None 70 | */ 71 | void EXTI1_IRQHandler(void) 72 | { 73 | if(EXTI_GetITStatus(EXTI_Line1) != RESET) 74 | { 75 | USB_Host.usr_cb->OverCurrentDetected(); 76 | EXTI_ClearITPendingBit(EXTI_Line1); 77 | } 78 | } 79 | 80 | /** 81 | * @brief HardFault_Handler 82 | * This function handles Hard Fault exception. 83 | * @param None 84 | * @retval None 85 | */ 86 | void HardFault_Handler(void) 87 | { 88 | /* Go to infinite loop when Hard Fault exception occurs */ 89 | while (1) 90 | { 91 | } 92 | } 93 | 94 | /** 95 | * @brief MemManage_Handler 96 | * This function handles Memory Manage exception. 97 | * @param None 98 | * @retval None 99 | */ 100 | void MemManage_Handler(void) 101 | { 102 | /* Go to infinite loop when Memory Manage exception occurs */ 103 | while (1) 104 | { 105 | } 106 | } 107 | 108 | /** 109 | * @brief BusFault_Handler 110 | * This function handles Bus Fault exception. 111 | * @param None 112 | * @retval None 113 | */ 114 | void BusFault_Handler(void) 115 | { 116 | /* Go to infinite loop when Bus Fault exception occurs */ 117 | while (1) 118 | { 119 | } 120 | } 121 | 122 | /** 123 | * @brief UsageFault_Handler 124 | * This function handles Usage Fault exception. 125 | * @param None 126 | * @retval None 127 | */ 128 | void UsageFault_Handler(void) 129 | { 130 | /* Go to infinite loop when Usage Fault exception occurs */ 131 | while (1) 132 | { 133 | } 134 | } 135 | 136 | /** 137 | * @brief SVC_Handler 138 | * This function handles SVCall exception. 139 | * @param None 140 | * @retval None 141 | */ 142 | void SVC_Handler(void) 143 | { 144 | } 145 | 146 | /** 147 | * @brief DebugMon_Handler 148 | * This function handles Debug Monitor exception. 149 | * @param None 150 | * @retval None 151 | */ 152 | void DebugMon_Handler(void) 153 | { 154 | } 155 | 156 | 157 | /** 158 | * @brief PendSV_Handler 159 | * This function handles PendSVC exception. 160 | * @param None 161 | * @retval None 162 | */ 163 | void PendSV_Handler(void) 164 | { 165 | } 166 | 167 | /** 168 | * @brief TIM2_IRQHandler 169 | * This function handles Timer2 Handler. 170 | * @param None 171 | * @retval None 172 | */ 173 | void TIM2_IRQHandler(void) 174 | { 175 | USB_OTG_BSP_TimerIRQ(); 176 | } 177 | 178 | 179 | /** 180 | * @brief OTG_FS_IRQHandler 181 | * This function handles USB-On-The-Go FS global interrupt request. 182 | * requests. 183 | * @param None 184 | * @retval None 185 | */ 186 | #ifdef USE_USB_OTG_FS 187 | void OTG_FS_IRQHandler(void) 188 | #else 189 | void OTG_HS_IRQHandler(void) 190 | #endif 191 | { 192 | USBH_OTG_ISR_Handler(&USB_OTG_Core_dev); 193 | } 194 | 195 | /** 196 | * @brief This function handles SysTick Handler. 197 | * It's used for delays and button debounce functions 198 | * @param None 199 | * @retval None 200 | */ 201 | void SysTick_Handler(void) 202 | { 203 | TimingDelay_Decrement(); 204 | update_temporized_LED(LED_Blue); 205 | if (demoMode == true) DebounceUserButton(); 206 | } 207 | 208 | 209 | /******************************************************************************/ 210 | /* STM32Fxxx Peripherals Interrupt Handlers */ 211 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 212 | /* available peripheral interrupt handler's name please refer to the startup */ 213 | /* file (startup_stm32fxxx.s). */ 214 | /******************************************************************************/ 215 | 216 | 217 | /*****************************************************************************************END OF FILE****/ 218 | -------------------------------------------------------------------------------- /System/stm32fxxx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32fxxx_it.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32Fxxx_IT_H 30 | #define __STM32Fxxx_IT_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usb_conf.h" 38 | #include "my_stm32f4_discovery.h" 39 | //#include "bargraph.h" 40 | //#include "debounce.h" 41 | #include "timers.h" 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* Exported functions ------------------------------------------------------- */ 46 | 47 | void NMI_Handler(void); 48 | void HardFault_Handler(void); 49 | void MemManage_Handler(void); 50 | void BusFault_Handler(void); 51 | void UsageFault_Handler(void); 52 | void SVC_Handler(void); 53 | void DebugMon_Handler(void); 54 | void PendSV_Handler(void); 55 | void SysTick_Handler(void); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* __STM32Fxxx_IT_H */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /System/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f4xx_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F4XX_H 40 | #define __SYSTEM_STM32F4XX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @addtogroup STM32F4xx_System_Includes 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @addtogroup STM32F4xx_System_Exported_types 56 | * @{ 57 | */ 58 | 59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*__SYSTEM_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /USB/MIDIstream_class/usbh_midi_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_midi_core.h 4 | * @author Xavier Halgand 5 | * @version 6 | * @date 7 | * @brief This file contains all the prototypes for the usbh_midi_core.c 8 | ****************************************************************************** 9 | * 10 | * 11 | ****************************************************************************** 12 | */ 13 | 14 | /* Define to prevent recursive ----------------------------------------------*/ 15 | #ifndef __USBH_MIDI_CORE_H 16 | #define __USBH_MIDI_CORE_H 17 | 18 | /* Includes ------------------------------------------------------------------*/ 19 | #include "usbh_core.h" 20 | #include "usbh_stdreq.h" 21 | #include "usb_bsp.h" 22 | #include "usbh_ioreq.h" 23 | #include "usbh_hcs.h" 24 | #include "usbh_usr.h" 25 | #include "midi_interface.h" 26 | 27 | /******************************************************************************/ 28 | /* States for MIDI State Machine */ 29 | typedef enum 30 | { 31 | MIDI_IDLE= 0, 32 | MIDI_SEND_DATA, 33 | MIDI_BUSY, 34 | MIDI_GET_DATA, 35 | MIDI_POLL, 36 | MIDI_ERROR 37 | } 38 | MIDI_State_t; 39 | 40 | /******************************************************************************/ 41 | typedef struct MIDI_cb 42 | { 43 | void (*Init) (void); 44 | void (*Decode) (uint8_t *data); 45 | } 46 | MIDI_cb_t; 47 | 48 | /******************************************************************************/ 49 | /* Structure for MIDI process */ 50 | typedef struct _MIDI_Process 51 | { 52 | MIDI_State_t state; 53 | uint8_t buff[USBH_MIDI_MPS_SIZE]; 54 | uint8_t hc_num_in; 55 | uint8_t hc_num_out; 56 | uint8_t MIDIBulkOutEp; 57 | uint8_t MIDIBulkInEp; 58 | uint16_t MIDIBulkInEpSize; 59 | uint16_t MIDIBulkOutEpSize; 60 | MIDI_cb_t *cb; 61 | } 62 | MIDI_Machine_t; 63 | 64 | 65 | /**************************************************************************/ 66 | 67 | typedef struct _MIDIDescriptor 68 | { 69 | uint8_t bLength; 70 | uint8_t bDescriptorType; 71 | uint16_t bcdHID; /* indicates what endpoint this descriptor is describing */ 72 | uint8_t bCountryCode; /* specifies the transfer type. */ 73 | uint8_t bNumDescriptors; /* specifies the transfer type. */ 74 | uint8_t bReportDescriptorType; /* Maximum Packet Size this endpoint is capable of sending or receiving */ 75 | uint16_t wItemLength; /* is used to specify the polling interval of certain transfers. */ 76 | } 77 | USBH_MIDIDesc_t; 78 | 79 | /******************************************************************************/ 80 | /** \brief MIDI Class Driver Event Packet. 81 | * 82 | * Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface. 83 | * 84 | * \note Regardless of CPU architecture, these values should be stored as little endian. 85 | */ 86 | typedef struct 87 | { 88 | uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */ 89 | 90 | uint8_t Data1; /**< First byte of data in the MIDI event. */ 91 | uint8_t Data2; /**< Second byte of data in the MIDI event. */ 92 | uint8_t Data3; /**< Third byte of data in the MIDI event. */ 93 | } 94 | MIDI_EventPacket_t; 95 | 96 | /******************************************************************************/ 97 | extern USBH_Class_cb_TypeDef MIDI_cb; 98 | 99 | uint8_t MIDI_RcvData(uint8_t *outBuf); 100 | 101 | 102 | 103 | #endif /* __USBH_MIDI_CORE_H */ 104 | 105 | 106 | /************************ ****************** *****END OF FILE****/ 107 | 108 | -------------------------------------------------------------------------------- /USB/usb_bsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_bsp.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief Specific api's relative to the used hardware platform 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_BSP__H__ 30 | #define __USB_BSP__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm32f4xx_tim.h" 34 | #include "usb_core.h" 35 | #include "usb_conf.h" 36 | 37 | /** @addtogroup USB_OTG_DRIVER 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USB_BSP 42 | * @brief This file is the 43 | * @{ 44 | */ 45 | 46 | 47 | /** @defgroup USB_BSP_Exported_Defines 48 | * @{ 49 | */ 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @defgroup USB_BSP_Exported_Types 56 | * @{ 57 | */ 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @defgroup USB_BSP_Exported_Macros 64 | * @{ 65 | */ 66 | /** 67 | * @} 68 | */ 69 | 70 | /** @defgroup USB_BSP_Exported_Variables 71 | * @{ 72 | */ 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup USB_BSP_Exported_FunctionsPrototype 78 | * @{ 79 | */ 80 | void BSP_Init(void); 81 | void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev); 82 | void USB_OTG_BSP_uDelay (const uint32_t usec); 83 | void USB_OTG_BSP_mDelay (const uint32_t msec); 84 | void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev); 85 | 86 | #ifdef USE_HOST_MODE 87 | void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev); 88 | void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state); 89 | #endif 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | #endif //__USB_BSP__H__ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | 106 | -------------------------------------------------------------------------------- /USB/usbh_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USBH_conf.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief General low level driver configuration 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBH_CONF__H__ 30 | #define __USBH_CONF__H__ 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | 34 | 35 | /** @defgroup USBH_CONF_Exported_Defines 36 | * @{ 37 | */ 38 | 39 | #define USBH_MAX_NUM_ENDPOINTS 2 40 | #define USBH_MAX_NUM_INTERFACES 10 41 | #define USBH_MIDI_MPS_SIZE 64 42 | 43 | 44 | 45 | #endif //__USBH_CONF__H__ 46 | 47 | 48 | 49 | /*****************************END OF FILE****/ 50 | 51 | -------------------------------------------------------------------------------- /USB/usbh_usr.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_usr.c 4 | * @author Xavier Halgand 5 | * @version 6 | * @date 7 | * @brief This file includes the user application layer 8 | ****************************************************************************** 9 | * 10 | * 11 | ****************************************************************************** 12 | */ 13 | 14 | /* Includes ------------------------------------------------------------------*/ 15 | 16 | #include "usbh_usr.h" 17 | 18 | 19 | /*----------------------------------------------------------------------------------*/ 20 | 21 | /* Points to the DEVICE_PROP structure of current device */ 22 | /* The purpose of this register is to speed up the execution */ 23 | 24 | USBH_Usr_cb_TypeDef USR_Callbacks = 25 | { 26 | USBH_USR_Init, 27 | USBH_USR_DeInit, 28 | USBH_USR_DeviceAttached, 29 | USBH_USR_ResetDevice, 30 | USBH_USR_DeviceDisconnected, 31 | USBH_USR_OverCurrentDetected, 32 | USBH_USR_DeviceSpeedDetected, 33 | USBH_USR_Device_DescAvailable, 34 | USBH_USR_DeviceAddressAssigned, 35 | USBH_USR_Configuration_DescAvailable, 36 | USBH_USR_Manufacturer_String, 37 | USBH_USR_Product_String, 38 | USBH_USR_SerialNum_String, 39 | USBH_USR_EnumerationDone, 40 | USBH_USR_UserInput, 41 | USBH_USR_MIDI_Application, 42 | USBH_USR_DeviceNotSupported, 43 | USBH_USR_UnrecoveredError 44 | }; 45 | 46 | /** 47 | * @brief USBH_USR_Init 48 | * Displays the message on LCD for host lib initialization 49 | * @param None 50 | * @retval None 51 | */ 52 | void USBH_USR_Init(void) 53 | { 54 | 55 | } 56 | 57 | /** 58 | * @brief USBH_USR_DeviceAttached 59 | * Displays the message on LCD on device attached 60 | * @param None 61 | * @retval None 62 | */ 63 | void USBH_USR_DeviceAttached(void) 64 | { 65 | //LCD_UsrLog ((void*)MSG_DEV_ATTACHED); 66 | } 67 | 68 | /** 69 | * @brief USBH_USR_UnrecoveredError 70 | * @param None 71 | * @retval None 72 | */ 73 | void USBH_USR_UnrecoveredError (void) 74 | { 75 | STM_EVAL_LEDOff(LED_Green); 76 | //LCD_ErrLog((void*)MSG_UNREC_ERROR); 77 | } 78 | 79 | /** 80 | * @brief USBH_DisconnectEvent 81 | * Device disconnect event 82 | * @param None 83 | * @retval None 84 | */ 85 | void USBH_USR_DeviceDisconnected (void) 86 | { 87 | STM_EVAL_LEDOff(LED_Green); 88 | } 89 | 90 | /** 91 | * @brief USBH_USR_ResetUSBDevice 92 | * Reset USB Device 93 | * @param None 94 | * @retval None 95 | */ 96 | void USBH_USR_ResetDevice(void) 97 | { 98 | /* Users can do their application actions here for the USB-Reset */ 99 | } 100 | 101 | 102 | /** 103 | * @brief USBH_USR_DeviceSpeedDetected 104 | * Displays the message on LCD for device speed 105 | * @param Devicespeed : Device Speed 106 | * @retval None 107 | */ 108 | void USBH_USR_DeviceSpeedDetected(uint8_t DeviceSpeed) 109 | { 110 | 111 | } 112 | 113 | /** 114 | * @brief USBH_USR_Device_DescAvailable 115 | * Displays the message on LCD for device descriptor 116 | * @param DeviceDesc : device descriptor 117 | * @retval None 118 | */ 119 | void USBH_USR_Device_DescAvailable(void *DeviceDesc) 120 | { 121 | 122 | } 123 | 124 | /** 125 | * @brief USBH_USR_DeviceAddressAssigned 126 | * USB device is successfully assigned the Address 127 | * @param None 128 | * @retval None 129 | */ 130 | void USBH_USR_DeviceAddressAssigned(void) 131 | { 132 | 133 | } 134 | 135 | 136 | /** 137 | * @brief USBH_USR_Conf_Desc 138 | * Displays the message on LCD for configuration descriptor 139 | * @param ConfDesc : Configuration descriptor 140 | * @retval None 141 | */ 142 | void USBH_USR_Configuration_DescAvailable(USBH_CfgDesc_TypeDef * cfgDesc, 143 | USBH_InterfaceDesc_TypeDef *itfDesc, 144 | USBH_EpDesc_TypeDef *epDesc) 145 | { 146 | 147 | } 148 | 149 | /** 150 | * @brief USBH_USR_Manufacturer_String 151 | * Displays the message on LCD for Manufacturer String 152 | * @param ManufacturerString : Manufacturer String of Device 153 | * @retval None 154 | */ 155 | void USBH_USR_Manufacturer_String(void *ManufacturerString) 156 | { 157 | 158 | } 159 | 160 | /** 161 | * @brief USBH_USR_Product_String 162 | * Displays the message on LCD for Product String 163 | * @param ProductString : Product String of Device 164 | * @retval None 165 | */ 166 | void USBH_USR_Product_String(void *ProductString) 167 | { 168 | 169 | } 170 | 171 | /** 172 | * @brief USBH_USR_SerialNum_String 173 | * Displays the message on LCD for SerialNum_String 174 | * @param SerialNumString : SerialNum_String of device 175 | * @retval None 176 | */ 177 | void USBH_USR_SerialNum_String(void *SerialNumString) 178 | { 179 | 180 | } 181 | 182 | /** 183 | * @brief EnumerationDone 184 | * User response request is displayed to ask for 185 | * application jump to class 186 | * @param None 187 | * @retval None 188 | */ 189 | void USBH_USR_EnumerationDone(void) 190 | { 191 | /* Enumeration complete */ 192 | STM_EVAL_LEDOn(LED_Green); 193 | } 194 | 195 | /** 196 | * @brief USBH_USR_DeviceNotSupported 197 | * Device is not supported 198 | * @param None 199 | * @retval None 200 | */ 201 | void USBH_USR_DeviceNotSupported(void) 202 | { 203 | STM_EVAL_LEDOff(LED_Green); 204 | } 205 | 206 | 207 | /** 208 | * @brief USBH_USR_UserInput 209 | * User Action for application state entry 210 | * @param None 211 | * @retval USBH_USR_Status : User response for key button 212 | */ 213 | USBH_USR_Status USBH_USR_UserInput(void) 214 | { 215 | return USBH_USR_RESP_OK; 216 | } 217 | 218 | /*-----------------------------------------------------------------------------*/ 219 | /** 220 | * @brief USBH_USR_OverCurrentDetected 221 | * Device Overcurrent detection event 222 | * @param None 223 | * @retval None 224 | */ 225 | void USBH_USR_OverCurrentDetected (void) 226 | { 227 | STM_EVAL_LEDOn(LED_Red); 228 | } 229 | /*-----------------------------------------------------------------------------*/ 230 | 231 | /*-----------------------------------------------------------------------------*/ 232 | /** 233 | * @brief USBH_USR_DeInit 234 | * Deinit User state and associated variables 235 | * @param None 236 | * @retval None 237 | */ 238 | void USBH_USR_DeInit(void) 239 | { 240 | } 241 | 242 | 243 | /*-----------------------------------------------------------------------------*/ 244 | 245 | int USBH_USR_MIDI_Application(void) 246 | { 247 | return (0); 248 | } 249 | 250 | 251 | 252 | 253 | /************************ *****END OF FILE****/ 254 | 255 | -------------------------------------------------------------------------------- /USB/usbh_usr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbh_usr.h 4 | * @author MCD Application Team 5 | * @version V2.1.0 6 | * @date 19-March-2012 7 | * @brief This file is the header file for usb usr file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __USH_USR_H__ 31 | #define __USH_USR_H__ 32 | 33 | 34 | /* Includes ------------------------------------------------------------------*/ 35 | #include "usbh_core.h" 36 | #include "usb_conf.h" 37 | #include 38 | //#include "soundGen.h" 39 | //#include "audio.h" 40 | //#include "CONSTANTS.h" 41 | 42 | /** @addtogroup USBH_USER 43 | * @{ 44 | */ 45 | 46 | /** @addtogroup USBH_HID_DEMO_USER_CALLBACKS 47 | * @{ 48 | */ 49 | 50 | /** @defgroup USBH_USR 51 | * @brief This file is the header file for user action 52 | * @{ 53 | */ 54 | 55 | 56 | /** @defgroup USBH_CORE_Exported_Variables 57 | * @{ 58 | */ 59 | 60 | 61 | extern USBH_Usr_cb_TypeDef USR_Callbacks; 62 | 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | 69 | /** @defgroup USBH_CORE_Exported_FunctionsPrototype 70 | * @{ 71 | */ 72 | 73 | void USBH_USR_ApplicationSelected(void); 74 | void USBH_USR_Init(void); 75 | void USBH_USR_DeInit(void); 76 | void USBH_USR_DeviceAttached(void); 77 | void USBH_USR_ResetDevice(void); 78 | void USBH_USR_DeviceDisconnected (void); 79 | void USBH_USR_OverCurrentDetected (void); 80 | void USBH_USR_DeviceSpeedDetected(uint8_t DeviceSpeed); 81 | void USBH_USR_Device_DescAvailable(void *); 82 | void USBH_USR_DeviceAddressAssigned(void); 83 | void USBH_USR_Configuration_DescAvailable(USBH_CfgDesc_TypeDef * cfgDesc, 84 | USBH_InterfaceDesc_TypeDef *itfDesc, 85 | USBH_EpDesc_TypeDef *epDesc); 86 | void USBH_USR_Manufacturer_String(void *); 87 | void USBH_USR_Product_String(void *); 88 | void USBH_USR_SerialNum_String(void *); 89 | void USBH_USR_EnumerationDone(void); 90 | USBH_USR_Status USBH_USR_UserInput(void); 91 | int USBH_USR_MIDI_Application(void); 92 | void USBH_USR_DeInit(void); 93 | void USBH_USR_DeviceNotSupported(void); 94 | void USBH_USR_UnrecoveredError(void); 95 | /*-----------------------------------------------------------------------------*/ 96 | //void MIDI_poll(void); 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | #endif /* __USBH_USR_H */ 114 | 115 | /*************************END OF FILE****/ 116 | --------------------------------------------------------------------------------