├── README.md └── usb_synth ├── Include ├── mxconstants.h ├── stm32f1xx_hal_conf.h └── sysConfig.h ├── LibMIDI ├── Include │ ├── midiEventQueue.h │ ├── midiInput.h │ ├── midiOutput.h │ ├── midiTypes.h │ └── midiUSB.h └── Source │ ├── midiEventQueue.c │ ├── midiInput.c │ ├── midiOutput.c │ └── midiUSB.c ├── LibOS ├── Include │ ├── sysHelpers.h │ ├── sysMain.h │ ├── sysTimer.h │ └── sysTypes.h ├── STM32F103MIDIUSBBoard │ ├── Include │ │ ├── halHelpers.h │ │ ├── halMIDIPort.h │ │ ├── mxconstants.h │ │ ├── stm32f1xx_hal_conf.h │ │ └── stm32f1xx_it.h │ └── Source │ │ ├── halMIDIPort.c │ │ ├── halMain.c │ │ ├── halSystem.c │ │ ├── halSystemTimer.c │ │ └── system_stm32f1xx.c ├── STM32F1xxCMSIS │ ├── Include │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ ├── core_sc300.h │ │ ├── stm32f100xb.h │ │ ├── stm32f100xe.h │ │ ├── stm32f101x6.h │ │ ├── stm32f101xb.h │ │ ├── stm32f101xe.h │ │ ├── stm32f101xg.h │ │ ├── stm32f102x6.h │ │ ├── stm32f102xb.h │ │ ├── stm32f103x6.h │ │ ├── stm32f103xb.h │ │ ├── stm32f103xe.h │ │ ├── stm32f103xg.h │ │ ├── stm32f105xc.h │ │ ├── stm32f107xc.h │ │ ├── stm32f1xx.h │ │ ├── stm32f1xx_hal.h │ │ ├── stm32f1xx_hal_adc.h │ │ ├── stm32f1xx_hal_adc_ex.h │ │ ├── stm32f1xx_hal_can.h │ │ ├── stm32f1xx_hal_can_ex.h │ │ ├── stm32f1xx_hal_cec.h │ │ ├── stm32f1xx_hal_conf_template.h │ │ ├── stm32f1xx_hal_cortex.h │ │ ├── stm32f1xx_hal_crc.h │ │ ├── stm32f1xx_hal_dac.h │ │ ├── stm32f1xx_hal_dac_ex.h │ │ ├── stm32f1xx_hal_def.h │ │ ├── stm32f1xx_hal_dma.h │ │ ├── stm32f1xx_hal_dma_ex.h │ │ ├── stm32f1xx_hal_eth.h │ │ ├── stm32f1xx_hal_flash.h │ │ ├── stm32f1xx_hal_flash_ex.h │ │ ├── stm32f1xx_hal_gpio.h │ │ ├── stm32f1xx_hal_gpio_ex.h │ │ ├── stm32f1xx_hal_hcd.h │ │ ├── stm32f1xx_hal_i2c.h │ │ ├── stm32f1xx_hal_i2s.h │ │ ├── stm32f1xx_hal_irda.h │ │ ├── stm32f1xx_hal_iwdg.h │ │ ├── stm32f1xx_hal_nand.h │ │ ├── stm32f1xx_hal_nor.h │ │ ├── stm32f1xx_hal_pccard.h │ │ ├── stm32f1xx_hal_pcd.h │ │ ├── stm32f1xx_hal_pcd_ex.h │ │ ├── stm32f1xx_hal_pwr.h │ │ ├── stm32f1xx_hal_rcc.h │ │ ├── stm32f1xx_hal_rcc_ex.h │ │ ├── stm32f1xx_hal_rtc.h │ │ ├── stm32f1xx_hal_rtc_ex.h │ │ ├── stm32f1xx_hal_sd.h │ │ ├── stm32f1xx_hal_smartcard.h │ │ ├── stm32f1xx_hal_spi.h │ │ ├── stm32f1xx_hal_sram.h │ │ ├── stm32f1xx_hal_tim.h │ │ ├── stm32f1xx_hal_tim_ex.h │ │ ├── stm32f1xx_hal_uart.h │ │ ├── stm32f1xx_hal_usart.h │ │ ├── stm32f1xx_hal_wwdg.h │ │ ├── stm32f1xx_ll_fsmc.h │ │ ├── stm32f1xx_ll_sdmmc.h │ │ ├── stm32f1xx_ll_usb.h │ │ └── system_stm32f1xx.h │ ├── Source │ │ ├── stm32f1xx_hal.c │ │ ├── stm32f1xx_hal_adc.c │ │ ├── stm32f1xx_hal_adc_ex.c │ │ ├── stm32f1xx_hal_can.c │ │ ├── stm32f1xx_hal_cec.c │ │ ├── stm32f1xx_hal_cortex.c │ │ ├── stm32f1xx_hal_crc.c │ │ ├── stm32f1xx_hal_dac.c │ │ ├── stm32f1xx_hal_dac_ex.c │ │ ├── stm32f1xx_hal_dma.c │ │ ├── stm32f1xx_hal_eth.c │ │ ├── stm32f1xx_hal_flash.c │ │ ├── stm32f1xx_hal_flash_ex.c │ │ ├── stm32f1xx_hal_gpio.c │ │ ├── stm32f1xx_hal_gpio_ex.c │ │ ├── stm32f1xx_hal_hcd.c │ │ ├── stm32f1xx_hal_i2c.c │ │ ├── stm32f1xx_hal_i2s.c │ │ ├── stm32f1xx_hal_irda.c │ │ ├── stm32f1xx_hal_iwdg.c │ │ ├── stm32f1xx_hal_nand.c │ │ ├── stm32f1xx_hal_nor.c │ │ ├── stm32f1xx_hal_pccard.c │ │ ├── stm32f1xx_hal_pcd.c │ │ ├── stm32f1xx_hal_pcd_ex.c │ │ ├── stm32f1xx_hal_pwr.c │ │ ├── stm32f1xx_hal_rcc.c │ │ ├── stm32f1xx_hal_rcc_ex.c │ │ ├── stm32f1xx_hal_rtc.c │ │ ├── stm32f1xx_hal_rtc_ex.c │ │ ├── stm32f1xx_hal_sd.c │ │ ├── stm32f1xx_hal_smartcard.c │ │ ├── stm32f1xx_hal_spi.c │ │ ├── stm32f1xx_hal_spi_ex.c │ │ ├── stm32f1xx_hal_sram.c │ │ ├── stm32f1xx_hal_tim.c │ │ ├── stm32f1xx_hal_tim_ex.c │ │ ├── stm32f1xx_hal_uart.c │ │ ├── stm32f1xx_hal_usart.c │ │ ├── stm32f1xx_hal_wwdg.c │ │ ├── stm32f1xx_ll_fsmc.c │ │ ├── stm32f1xx_ll_sdmmc.c │ │ └── stm32f1xx_ll_usb.c │ └── Startup │ │ ├── startup_stm32f100xb.s │ │ ├── startup_stm32f100xe.s │ │ ├── startup_stm32f101x6.s │ │ ├── startup_stm32f101xb.s │ │ ├── startup_stm32f101xe.s │ │ ├── startup_stm32f101xg.s │ │ ├── startup_stm32f102x6.s │ │ ├── startup_stm32f102xb.s │ │ ├── startup_stm32f103x6.s │ │ ├── startup_stm32f103xb.s │ │ ├── startup_stm32f103xe.s │ │ ├── startup_stm32f103xg.s │ │ ├── startup_stm32f105xc.s │ │ └── startup_stm32f107xc.s ├── STM32F1xxCommon │ └── syscalls.c ├── STM32f1xxUSB │ ├── Include │ │ ├── usb_device.h │ │ ├── usbd_conf.h │ │ ├── usbd_core.h │ │ ├── usbd_ctlreq.h │ │ ├── usbd_def.h │ │ ├── usbd_desc.h │ │ ├── usbd_ioreq.h │ │ ├── usbd_midi.h │ │ └── usbd_midi_if.h │ └── Source │ │ ├── usbd_core.c │ │ ├── usbd_ctlreq.c │ │ ├── usbd_ioreq.c │ │ ├── usbd_midi.c │ │ ├── usbd_midi_conf.c │ │ └── usbd_midi_desc.c └── Source │ ├── sysHelpers.c │ └── sysTimer.c ├── MIDIUSB.map ├── MIDI_USB_Synth.cogui ├── MIDI_USB_Synth.comarker ├── MIDI_USB_Synth.coproj ├── MIDI_USB_Synth ├── Debug │ └── bin │ │ ├── MIDIUSB.bin │ │ ├── MIDIUSB.elf │ │ ├── MIDIUSB.map │ │ └── history.xml └── MIDIUSB.elf.xcodeproj │ └── project.pbxproj ├── README.md ├── Source ├── appMain.c ├── drum.h └── sample.h └── link.ld /README.md: -------------------------------------------------------------------------------- 1 | # stm32-Synth 2 | A powerful midi synth based on the stm32f103cb 3 | IMPORTANT:This project uses the stm32f103cb NOT the stm32f103c8, the code requires 110k of flash. 4 | The coocox website is down so you need to get it from somewhere else:(that "somewhere else" https://www.softpedia.com/get/Programming/Coding-languages-Compilers/CooCox-CoIDE.shtml) 5 | 6 | Precompiled bin file in usb_synth/MIDI_USB_Synth/Debug/bin/ 7 | 8 | Video of it:https://youtu.be/Z8oxVrtKEWA 9 | 10 | Schematic:https://easyeda.com/elpro/stm32f103cb-synth 11 | 12 | More info on:https://mitxela.com/forum/topic/stm32f103cb-synth-a-powerful-synth 13 | -------------------------------------------------------------------------------- /usb_synth/Include/mxconstants.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : mxconstants.h 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2017 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | 35 | /* USER CODE BEGIN Includes */ 36 | 37 | /* USER CODE END Includes */ 38 | 39 | /* Private define ------------------------------------------------------------*/ 40 | 41 | //#define LED_Pin GPIO_PIN_13 42 | //#define LED_GPIO_Port GPIOC 43 | #define CONNECT_LED_Pin GPIO_PIN_1 44 | #define CONNECT_LED_GPIO_Port GPIOA 45 | #define TX_LED_Pin GPIO_PIN_13 46 | #define TX_LED_GPIO_Port GPIOC 47 | #define RX_LED_Pin GPIO_PIN_14 48 | #define RX_LED_GPIO_Port GPIOC 49 | /* USER CODE BEGIN Private defines */ 50 | 51 | /* USER CODE END Private defines */ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 62 | -------------------------------------------------------------------------------- /usb_synth/Include/sysConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef __sysConfig_h 2 | #define __sysConfig_h 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | /////////////////////////////////////////////////////////////////////////////// 10 | // MIDI config 11 | #define midiOUT_BUFFER_MAX_EVENT_COUNT 2048 12 | #define midiIN_BUFFER_MAX_EVENT_COUNT 256 13 | #define midiTRANSMIT_BUFFER_SIZE 256 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Include/midiEventQueue.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI Event queue */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __midiEventQueue_h 12 | #define __midiEventQueue_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* Types */ 21 | /*****************************************************************************/ 22 | 23 | /// MIDI event queue state description data 24 | typedef struct 25 | { 26 | USBMIDIEventPacket* EventQueue; 27 | uint16_t EventQueueSize; 28 | volatile uint16_t PushIndex; 29 | volatile uint16_t PopIndex; 30 | } midiEventQueueInfo; 31 | 32 | /*****************************************************************************/ 33 | /* Function prototypes */ 34 | /*****************************************************************************/ 35 | 36 | void midiEventQueueInitialize(midiEventQueueInfo* in_event_queue, USBMIDIEventPacket* in_buffer, uint16_t in_buffer_size); 37 | bool midiEventQueueIsEmpty(midiEventQueueInfo* in_event_queue); 38 | bool midiEventQueuePush(midiEventQueueInfo* in_event_queue, USBMIDIEventPacket in_event); 39 | USBMIDIEventPacket midiEventQueuePop(midiEventQueueInfo* in_event_queue); 40 | void midiEventQueueClear(midiEventQueueInfo* in_event_queue); 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Include/midiInput.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI input handler */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __midiInput_h 12 | #define __midiInput_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | 20 | /*****************************************************************************/ 21 | /* Function prototypes */ 22 | /*****************************************************************************/ 23 | void midiInputInitialize(void); 24 | bool midiInputIsEmpty(void); 25 | void midiInputDataReceived(uint8_t in_data); 26 | uint16_t midiInputEventPopAndStore(uint8_t* in_buffer, uint16_t in_buffer_length); 27 | bool midiInputIsReceiving(void); 28 | void midiInputClear(void); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Include/midiOutput.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI output message translating and buffering */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __midiOutBuffer_h 12 | #define __midiOutBuffer_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* Function prototypes */ 21 | /*****************************************************************************/ 22 | void midiOutputInitialize(void); 23 | bool midiOutputEventPush(USBMIDIEventPacket in_event); 24 | bool midiOutputEventPopAndStore(uint8_t* in_midi_buffer, uint16_t in_midi_buffer_size, uint16_t* in_buffer_pos); 25 | bool midiOutput(uint8_t* data,uint8_t* data1,uint8_t* data2,uint8_t* data3); 26 | bool midiOutputIsEmpty(void); 27 | bool midiOutputIsTransmitting(void); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Include/midiTypes.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI related type definitions */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef _midiTypes_h 12 | #define _midiTypes_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* Macros */ 21 | /*****************************************************************************/ 22 | #define midiGET_MIDI_EVENT_CABLE_NUMBER(x) (x & 0x0f) 23 | #define midiGET_MIDI_EVENT_CODE_INDEX_NUMBER(x) ((x >> 4) & 0x0f) 24 | #define midiIS_STATUS_CODE(x) ((x & 0x80) != 0) 25 | #define midiGET_STATUS_CODE(x) (x & 0xf0) 26 | #define midiGET_CHANNEL(x) ((x & 0x0f)+1) 27 | #define midiIS_CHANNEL_MESSAGE(x) (x >= MIDI_NOTE_OFF && x < MIDI_SYSTEM_EXCLUSIVE) 28 | #define midiIS_REAL_TIME_MESSAGE(x) (x >= MIDI_CLOCK) 29 | #define midiIS_SYSTEM_COMMON_MESSAGE(x) (x >= MIDI_SYSTEM_EXCLUSIVE && x < MIDI_CLOCK) 30 | 31 | /*****************************************************************************/ 32 | /* Types */ 33 | /*****************************************************************************/ 34 | 35 | /// MIDI Message types 36 | typedef enum 37 | { 38 | MIDI_INVALID_TYPE = 0x00, ///< For notifying errors 39 | MIDI_NOTE_OFF = 0x80, ///< Note Off 40 | MIDI_NOTE_ON = 0x90, ///< Note On 41 | MIDI_AFTERTOUCH_POLY = 0xA0, ///< Polyphonic AfterTouch 42 | MIDI_CONTROL_CHANGE = 0xB0, ///< Control Change / Channel Mode 43 | MIDI_PROGRAM_CHANGE = 0xC0, ///< Program Change 44 | MIDI_AFTERTOUCH_CHANNEL = 0xD0, ///< Channel (monophonic) AfterTouch 45 | MIDI_PITCH_BEND = 0xE0, ///< Pitch Bend 46 | MIDI_SYSTEM_EXCLUSIVE = 0xF0, ///< System Exclusive 47 | MIDI_TIME_CODE_QUARTER_FRAME = 0xF1, ///< System Common - MIDI Time Code Quarter Frame 48 | MIDI_SONG_POSITION = 0xF2, ///< System Common - Song Position Pointer 49 | MIDI_SONG_SELECT = 0xF3, ///< System Common - Song Select 50 | MIDI_TUNE_REQUEST = 0xF6, ///< System Common - Tune Request 51 | MIDI_SYSTEM_EXLUSIVE_END = 0xf7, ///< System exlusive end 52 | MIDI_CLOCK = 0xF8, ///< System Real Time - Timing Clock 53 | MIDI_START = 0xFA, ///< System Real Time - Start 54 | MIDI_CONTINUE = 0xFB, ///< System Real Time - Continue 55 | MIDI_STOP = 0xFC, ///< System Real Time - Stop 56 | MIDI_ACTIVE_SENSING = 0xFE, ///< System Real Time - Active Sensing 57 | MIDI_SYSTEM_RESET = 0xFF, ///< System Real Time - System Reset 58 | } MidiMessageType; 59 | 60 | /// USB MIDI code index 61 | typedef enum 62 | { 63 | CIN_MISC = 0x0, ///< 1, 2 or 3 Miscellaneous function codes.Reserved for future extensions. 64 | CIN_CABLE_EVENT = 0x1, ///> 1, 2 or 3 Cable events.Reserved for future expansion. 65 | CIN_TWO_BYTE_SYSTEM_COMMON_MESSAGE = 0x2, ///< 2 Two byte System Common messages like MTC, SongSelect, etc. 66 | CIN_THREE_BYTE_SYSTEM_COMMON_MESSAGE = 0x03, ///< 3 Three byte System Common messages like SPP, etc. 67 | CIN_SYSEX = 0x4, ///< 3 SysEx starts or continues 68 | CIN_SYSEX_END_1 = 0x5, ///< 1 Single byte System Common Message or SysEx ends with following single byte. 69 | CIN_SYSEX_END_2 = 0x6, ///< 2 SysEx ends with following two bytes. 70 | CIN_SYSEX_END_3 = 0x7, ///< 3 SysEx ends with following three bytes. 71 | CIN_NOTE_OFF = 0x8, ///< 3 Note - off 72 | CIN_NOTE_ON = 0x9, ///< 3 Note - on 73 | CIN_POLY_KEYPRESS = 0xA, ///< 3 Poly - KeyPress 74 | CIN_CONTROL_CHANGE = 0xB, ///< 3 Control Change 75 | CIN_PROGRAM_CHANGE = 0xC, ///< 2 Program Change 76 | CIN_CHANNEL_PRESSURE = 0xD, ///< 2 Channel Pressure 77 | CIN_PITCH_BEND = 0xE, ///< 3 PitchBend Change 78 | CIN_SINGLE_BYTE = 0xF, ///< 1 Single Byte 79 | } USBMIDICodeIndexNumber; 80 | 81 | #pragma pack(1) 82 | 83 | /// MIDI event struct 84 | typedef union 85 | { 86 | uint32_t EventData; 87 | 88 | struct 89 | { 90 | uint8_t PacketHeader; 91 | 92 | union 93 | { 94 | uint8_t Data[3]; 95 | struct 96 | { 97 | uint8_t Status; 98 | uint8_t Param1; 99 | uint8_t Param2; 100 | }; 101 | 102 | struct 103 | { 104 | uint8_t Data0; 105 | uint8_t Data1; 106 | uint8_t Data2; 107 | }; 108 | }; 109 | }; 110 | } USBMIDIEventPacket; 111 | 112 | #pragma pack() 113 | 114 | 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Include/midiUSB.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI Output buffer handling functions */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __midiUSB_h 12 | #define __midiUSB_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* Function prototypes */ 21 | /*****************************************************************************/ 22 | void midiUSBDeviceInitialize(void); 23 | void midiUSBTask(void); 24 | uint8_t midiUSBTransmit(uint8_t* Buf, uint16_t Len); 25 | bool midiIsConnected(void); 26 | 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Source/midiEventQueue.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI Event queue */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | /*****************************************************************************/ 12 | /* Include files */ 13 | /*****************************************************************************/ 14 | #include 15 | #include 16 | 17 | /*****************************************************************************/ 18 | /* Function implementation */ 19 | /*****************************************************************************/ 20 | 21 | /////////////////////////////////////////////////////////////////////////////// 22 | /// @brief Initializes MIDI event queue 23 | /// @param in_event_queue Event queue state descriptor 24 | /// @param in_buffer Queue storage for events 25 | /// @param in_buffer_size Queue buffer size in number of events 26 | void midiEventQueueInitialize(midiEventQueueInfo* in_event_queue, USBMIDIEventPacket* in_buffer, uint16_t in_buffer_size) 27 | { 28 | sysMemZero(in_event_queue, sizeof(midiEventQueueInfo)); 29 | 30 | in_event_queue->EventQueue = in_buffer; 31 | in_event_queue->EventQueueSize = in_buffer_size; 32 | } 33 | 34 | /////////////////////////////////////////////////////////////////////////////// 35 | /// @brief Returns the state (empty/non empty) of the MIDI buffer 36 | /// @param in_event_queue Event queue state descriptor 37 | bool midiEventQueueIsEmpty(midiEventQueueInfo* in_event_queue) 38 | { 39 | return (in_event_queue->PushIndex == in_event_queue->PopIndex); 40 | } 41 | 42 | /////////////////////////////////////////////////////////////////////////////// 43 | /// @brief Clears MIDI event queue 44 | /// @param in_event_queue Event queue state descriptor 45 | void midiEventQueueClear(midiEventQueueInfo* in_event_queue) 46 | { 47 | in_event_queue->PushIndex = 0; 48 | in_event_queue->PopIndex = 0; 49 | } 50 | 51 | /////////////////////////////////////////////////////////////////////////////// 52 | /// @brief Pushes MIDI event into the MIDI output queue 53 | /// @param in_event_queue Event queue state descriptor 54 | /// @param in_event MIDI event to push 55 | /// @return true if event was pushed or false is there is no space in the buffer 56 | bool midiEventQueuePush(midiEventQueueInfo* in_event_queue, USBMIDIEventPacket in_event) 57 | { 58 | uint16_t new_push_index; 59 | 60 | // generate new push pointer 61 | new_push_index = in_event_queue->PushIndex + 1; 62 | if (new_push_index >= in_event_queue->EventQueueSize) 63 | new_push_index = 0; 64 | 65 | // check for free space in the buffer 66 | if (new_push_index == in_event_queue->PopIndex) 67 | return false; 68 | 69 | // store event in the buffer 70 | in_event_queue->EventQueue[new_push_index].EventData = in_event.EventData; 71 | 72 | in_event_queue->PushIndex = new_push_index; 73 | 74 | return true; 75 | } 76 | 77 | /////////////////////////////////////////////////////////////////////////////// 78 | /// @brief Pops MIDI event from the queue. 79 | /// @param in_event_queue Event queue state descriptor 80 | /// @return MIDI event, invalidated of there is no event in the queue 81 | USBMIDIEventPacket midiEventQueuePop(midiEventQueueInfo* in_event_queue) 82 | { 83 | USBMIDIEventPacket retval; 84 | uint16_t new_pop_pointer; 85 | 86 | retval.EventData = 0; 87 | 88 | // check if buffer contains event 89 | if (in_event_queue->PopIndex != in_event_queue->PushIndex) 90 | { 91 | // increment pop pointer 92 | new_pop_pointer = in_event_queue->PopIndex + 1; 93 | if (new_pop_pointer >= in_event_queue->EventQueueSize) 94 | new_pop_pointer = 0; 95 | 96 | retval.EventData = in_event_queue->EventQueue[new_pop_pointer].EventData; 97 | 98 | in_event_queue->PopIndex = new_pop_pointer; 99 | } 100 | 101 | return retval; 102 | } 103 | 104 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Source/midiOutput.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI output message translating and buffering */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | /*****************************************************************************/ 12 | /* Include files */ 13 | /*****************************************************************************/ 14 | #include 15 | #include 16 | #include 17 | 18 | /*****************************************************************************/ 19 | /* Module local variables */ 20 | /*****************************************************************************/ 21 | 22 | // MIDI out event buffer 23 | static USBMIDIEventPacket l_midi_output_queue_buffer[midiOUT_BUFFER_MAX_EVENT_COUNT]; 24 | /*static*/ midiEventQueueInfo l_midi_output_queue; 25 | static volatile bool l_is_transmitting; 26 | 27 | static MidiMessageType l_running_status; 28 | 29 | /*****************************************************************************/ 30 | /* Function implementation */ 31 | /*****************************************************************************/ 32 | 33 | /////////////////////////////////////////////////////////////////////////////// 34 | /// @brief Initialize MIDI output 35 | void midiOutputInitialize(void) 36 | { 37 | midiEventQueueInitialize(&l_midi_output_queue, l_midi_output_queue_buffer, midiOUT_BUFFER_MAX_EVENT_COUNT); 38 | l_running_status = MIDI_INVALID_TYPE; 39 | l_is_transmitting = false; 40 | } 41 | 42 | /////////////////////////////////////////////////////////////////////////////// 43 | /// @brief Returns the state of the MIDI Out buffer 44 | bool midiOutputIsEmpty(void) 45 | { 46 | return midiEventQueueIsEmpty(&l_midi_output_queue); 47 | } 48 | 49 | /////////////////////////////////////////////////////////////////////////////// 50 | /// @brief Returns true when MIDI data is transmitted since the last call of the function 51 | /// @return True is MIDI message was transmitted 52 | bool midiOutputIsTransmitting(void) 53 | { 54 | bool retval = l_is_transmitting; 55 | 56 | l_is_transmitting = false; 57 | 58 | return retval; 59 | } 60 | 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | /// @brief Pushes MIDI event into the MIDI output queue 64 | /// @param in_event MIDI event to push 65 | /// @return true if event was pushed or false is there is no space in the buffer 66 | bool midiOutputEventPush(USBMIDIEventPacket in_event) 67 | { 68 | return midiEventQueuePush(&l_midi_output_queue, in_event); 69 | } 70 | 71 | /////////////////////////////////////////////////////////////////////////////// 72 | /// @brief Pops MIDI event from the queue and converts it to a regular midi message and stores it in the given midi message buffer. 73 | /// @param in_midi_buffer MIDI message buffer to store the popped and converted event 74 | /// @param in_midi_buffer_size Size of the MIDI message buffer in bytes 75 | /// @param in_buffer_pos Address of the index of the first free byte in the MIDI buffer. The pointer will be updated to point again to the first free byte. 76 | bool midiOutputEventPopAndStore(uint8_t* in_midi_buffer, uint16_t in_midi_buffer_size, uint16_t* in_buffer_pos) 77 | { 78 | uint16_t buffer_pos = *in_buffer_pos; 79 | USBMIDIEventPacket event; 80 | 81 | // check free space in the target buffer (MIDI event is not longer than 3 bytes) 82 | if (buffer_pos + 3 >= in_midi_buffer_size) 83 | return false; 84 | 85 | // check if buffer contains event 86 | if (midiEventQueueIsEmpty(&l_midi_output_queue)) 87 | return false; 88 | 89 | // pop event 90 | event = midiEventQueuePop(&l_midi_output_queue); 91 | 92 | // convert data from USB event format to MIDI message and store it in the buffer 93 | switch (event.PacketHeader) 94 | { 95 | // Miscellaneous function codes.Reserved for future extensions. 96 | case CIN_MISC: 97 | l_running_status = MIDI_INVALID_TYPE; 98 | break; 99 | 100 | // Cable events.Reserved for future expansion. 101 | case CIN_CABLE_EVENT: 102 | l_running_status = MIDI_INVALID_TYPE; 103 | break; 104 | 105 | // Two - byte System Common messages like MTC, SongSelect, etc. 106 | case CIN_TWO_BYTE_SYSTEM_COMMON_MESSAGE: 107 | in_midi_buffer[buffer_pos++] = event.Data0; 108 | in_midi_buffer[buffer_pos++] = event.Data1; 109 | l_running_status = MIDI_INVALID_TYPE; 110 | break; 111 | 112 | // Three - byte System Common messages like SPP, etc. 113 | case CIN_THREE_BYTE_SYSTEM_COMMON_MESSAGE: 114 | in_midi_buffer[buffer_pos++] = event.Data0; 115 | in_midi_buffer[buffer_pos++] = event.Data1; 116 | in_midi_buffer[buffer_pos++] = event.Data2; 117 | l_running_status = MIDI_INVALID_TYPE; 118 | break; 119 | 120 | // SysEx starts or continues 121 | case CIN_SYSEX: 122 | in_midi_buffer[buffer_pos++] = event.Data0; 123 | in_midi_buffer[buffer_pos++] = event.Data1; 124 | in_midi_buffer[buffer_pos++] = event.Data2; 125 | l_running_status = MIDI_INVALID_TYPE; 126 | break; 127 | 128 | // Single byte System Common Message or SysEx ends with following single byte. 129 | case CIN_SYSEX_END_1: 130 | in_midi_buffer[buffer_pos++] = event.Data0; 131 | l_running_status = MIDI_INVALID_TYPE; 132 | break; 133 | 134 | // SysEx ends with following two bytes. 135 | case CIN_SYSEX_END_2: 136 | in_midi_buffer[buffer_pos++] = event.Data0; 137 | in_midi_buffer[buffer_pos++] = event.Data1; 138 | l_running_status = MIDI_INVALID_TYPE; 139 | break; 140 | 141 | // SysEx ends with following three bytes. 142 | case CIN_SYSEX_END_3: 143 | in_midi_buffer[buffer_pos++] = event.Data0; 144 | in_midi_buffer[buffer_pos++] = event.Data1; 145 | in_midi_buffer[buffer_pos++] = event.Data2; 146 | l_running_status = MIDI_INVALID_TYPE; 147 | break; 148 | 149 | // Note - off 150 | case CIN_NOTE_OFF: 151 | if (l_running_status != event.Data0) // send status if needed 152 | in_midi_buffer[buffer_pos++] = event.Data0; 153 | in_midi_buffer[buffer_pos++] = event.Data1; 154 | in_midi_buffer[buffer_pos++] = event.Data2; 155 | l_running_status = event.Data0; 156 | break; 157 | 158 | // Note - on 159 | case CIN_NOTE_ON: 160 | if (l_running_status != event.Data0) // send status if needed 161 | in_midi_buffer[buffer_pos++] = event.Data0; 162 | in_midi_buffer[buffer_pos++] = event.Data1; 163 | in_midi_buffer[buffer_pos++] = event.Data2; 164 | l_running_status = event.Data0; 165 | break; 166 | 167 | // Poly - KeyPress 168 | case CIN_POLY_KEYPRESS: 169 | if (l_running_status != event.Data0) // send status if needed 170 | in_midi_buffer[buffer_pos++] = event.Data0; 171 | in_midi_buffer[buffer_pos++] = event.Data1; 172 | in_midi_buffer[buffer_pos++] = event.Data2; 173 | l_running_status = event.Data0; 174 | break; 175 | 176 | // Control Change 177 | case CIN_CONTROL_CHANGE: 178 | if (l_running_status != event.Data0) // send status if needed 179 | in_midi_buffer[buffer_pos++] = event.Data0; 180 | in_midi_buffer[buffer_pos++] = event.Data1; 181 | in_midi_buffer[buffer_pos++] = event.Data2; 182 | l_running_status = event.Data0; 183 | break; 184 | 185 | // Program Change 186 | case CIN_PROGRAM_CHANGE: 187 | if (l_running_status != event.Data0) // send status if needed 188 | in_midi_buffer[buffer_pos++] = event.Data0; 189 | in_midi_buffer[buffer_pos++] = event.Data1; 190 | l_running_status = event.Data0; 191 | break; 192 | 193 | // Channel Pressure 194 | case CIN_CHANNEL_PRESSURE: 195 | if (l_running_status != event.Data0) // send status if needed 196 | in_midi_buffer[buffer_pos++] = event.Data0; 197 | in_midi_buffer[buffer_pos++] = event.Data1; 198 | l_running_status = event.Data0; 199 | break; 200 | 201 | // PitchBend Change 202 | case CIN_PITCH_BEND: 203 | if (l_running_status != event.Data0) // send status if needed 204 | in_midi_buffer[buffer_pos++] = event.Data0; 205 | in_midi_buffer[buffer_pos++] = event.Data1; 206 | in_midi_buffer[buffer_pos++] = event.Data2; 207 | l_running_status = event.Data0; 208 | break; 209 | 210 | // Single Byte 211 | case CIN_SINGLE_BYTE: 212 | in_midi_buffer[buffer_pos++] = event.Data0; 213 | break; 214 | } 215 | 216 | // update pointer 217 | *in_buffer_pos = buffer_pos; 218 | 219 | // update TX state 220 | l_is_transmitting = true; 221 | 222 | return true; 223 | } 224 | bool midiOutput(uint8_t* data,uint8_t* data1,uint8_t* data2,uint8_t* data3) 225 | { 226 | uint16_t buffer_pos = 0; 227 | USBMIDIEventPacket event; 228 | 229 | 230 | // check if buffer contains event 231 | if (midiEventQueueIsEmpty(&l_midi_output_queue)) 232 | return false; 233 | 234 | // pop event 235 | event = midiEventQueuePop(&l_midi_output_queue); 236 | 237 | // convert data from USB event format to MIDI message and store it in the buffer 238 | 239 | 240 | // GPIOC ->ODR |=GPIO_ODR_ODR13; 241 | *data=event.PacketHeader; 242 | *data1= event.Data0; 243 | *data2= event.Data1; 244 | *data3= event.Data2; 245 | /*if(data==CIN_NOTE_OFF)GPIOC ->ODR |=GPIO_ODR_ODR13; 246 | if(data==CIN_NOTE_ON)GPIOC ->ODR &= ~ GPIO_ODR_ODR13;*/ 247 | l_running_status = event.Data0; 248 | 249 | l_is_transmitting = true; 250 | 251 | return true; 252 | } 253 | -------------------------------------------------------------------------------- /usb_synth/LibMIDI/Source/midiUSB.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* USB MIDI interface */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | /*****************************************************************************/ 12 | /* Includes */ 13 | /*****************************************************************************/ 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | /*****************************************************************************/ 22 | /* Module local functions */ 23 | /*****************************************************************************/ 24 | static int8_t midiUSBInitialize(void); 25 | static int8_t midiUSBDeinitialize(void); 26 | static int8_t midiUSBReceive(uint8_t* pbuf, uint32_t *Len); 27 | static void midiUSBProcessUSBReceivedEvent(void); 28 | static void midiUSBProcessUSBTransmitEvent(void); 29 | 30 | /*****************************************************************************/ 31 | /* Module local variables */ 32 | /*****************************************************************************/ 33 | 34 | // Buffers and variables for MIDI->USB transmission 35 | static uint8_t l_usb_transmit_buffer[USB_MIDI_DATA_HS_IN_SIZE]; 36 | 37 | // Buffers and variables for USB->MIDI transmission 38 | static uint8_t l_usb_receive_buffer[USB_MIDI_DATA_HS_OUT_SIZE]; 39 | static USBMIDIEventPacket* l_pending_receive_event_buffer = NULL; 40 | static uint16_t l_pending_receiver_event_buffer_count; 41 | static uint16_t l_pending_receiver_event_buffer_index; 42 | 43 | static USBD_MIDI_ItfTypeDef USBD_Interface_fops_FS = 44 | { 45 | midiUSBInitialize, 46 | midiUSBDeinitialize, 47 | midiUSBReceive 48 | }; 49 | 50 | /*****************************************************************************/ 51 | /* Global variables */ 52 | /*****************************************************************************/ 53 | 54 | // USB Device Core handle declaration 55 | USBD_HandleTypeDef hUsbDeviceFS; 56 | 57 | /*****************************************************************************/ 58 | /* Function implementation */ 59 | /*****************************************************************************/ 60 | 61 | 62 | ////////////////////////////////////////////////////////////////////////////// 63 | /// @brief Initializes USB MIDI device 64 | void midiUSBDeviceInitialize(void) 65 | { 66 | /* Init Device Library,Add Supported Class and Start the library*/ 67 | USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); 68 | 69 | USBD_RegisterClass(&hUsbDeviceFS, &USBD_MIDI); 70 | 71 | USBD_MIDI_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS); 72 | 73 | USBD_Start(&hUsbDeviceFS); 74 | } 75 | 76 | /////////////////////////////////////////////////////////////////////////////// 77 | /// @brief Check MIDI USB connection status 78 | /// @return True if device is connected to the USB host and enumerated 79 | bool midiIsConnected(void) 80 | { 81 | return (hUsbDeviceFS.pClassData != NULL); 82 | } 83 | 84 | /////////////////////////////////////////////////////////////////////////////// 85 | /// @brief Initializes the MIDI USB low layer over the FS USB IP 86 | /// @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 87 | static int8_t midiUSBInitialize(void) 88 | { 89 | // Set Application Buffers 90 | USBD_MIDI_SetTxBuffer(&hUsbDeviceFS, l_usb_transmit_buffer, 0); 91 | USBD_MIDI_SetRxBuffer(&hUsbDeviceFS, l_usb_receive_buffer); 92 | 93 | return (USBD_OK); 94 | } 95 | 96 | /////////////////////////////////////////////////////////////////////////////// 97 | /// @brief DeInitializes the MIDI USB media low layer 98 | /// @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 99 | static int8_t midiUSBDeinitialize(void) 100 | { 101 | return (USBD_OK); 102 | } 103 | 104 | /////////////////////////////////////////////////////////////////////////////// 105 | /// @brief Process data received over USB MIDI data OUT endpoint 106 | /// @param Buf: Buffer of data to be received 107 | /// @param Len: Number of data received (in bytes) 108 | /// @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL 109 | static int8_t midiUSBReceive(uint8_t* Buf, uint32_t *Len) 110 | { 111 | // prepare processing new received packet 112 | l_pending_receive_event_buffer = (USBMIDIEventPacket*)Buf; 113 | l_pending_receiver_event_buffer_count = (uint16_t)(*Len / sizeof(USBMIDIEventPacket)); 114 | l_pending_receiver_event_buffer_index = 0; 115 | 116 | // process received packet 117 | midiUSBProcessUSBReceivedEvent(); 118 | 119 | return (USBD_OK); 120 | } 121 | 122 | /////////////////////////////////////////////////////////////////////////////// 123 | /// @brief Handles task related to MIDI USB communication 124 | void midiUSBTask(void) 125 | { 126 | // process events received over USB 127 | midiUSBProcessUSBReceivedEvent(); 128 | midiUSBProcessUSBTransmitEvent(); 129 | } 130 | 131 | /////////////////////////////////////////////////////////////////////////////// 132 | /// @brief Transmits data over USB 133 | static void midiUSBProcessUSBTransmitEvent(void) 134 | { 135 | int16_t packet_length; 136 | 137 | // check for connection 138 | if(midiIsConnected()) 139 | { 140 | // if connected transfer received MIDI event over the USB 141 | if (!USBD_MIDI_IsTransmitterBusy(&hUsbDeviceFS) && !midiInputIsEmpty()) 142 | { 143 | packet_length = midiInputEventPopAndStore(l_usb_transmit_buffer, USB_MIDI_DATA_HS_IN_SIZE); 144 | 145 | if (packet_length > 0) 146 | { 147 | USBD_MIDI_SetTxBuffer(&hUsbDeviceFS, l_usb_transmit_buffer, packet_length); 148 | USBD_MIDI_TransmitPacket(&hUsbDeviceFS); 149 | } 150 | } 151 | } 152 | else 153 | { 154 | // if not connected clear MIDI input buffer 155 | midiInputClear(); 156 | } 157 | } 158 | 159 | 160 | /////////////////////////////////////////////////////////////////////////////// 161 | /// @brief Processes received data from MIDI USB 162 | static void midiUSBProcessUSBReceivedEvent(void) 163 | { 164 | // do nothing if it is not connected 165 | if(!midiIsConnected()) 166 | return; 167 | 168 | // if buffer is not empty -> process buffer 169 | if (l_pending_receive_event_buffer != NULL) 170 | { 171 | // copy events to the event buffer 172 | while (l_pending_receiver_event_buffer_index < l_pending_receiver_event_buffer_count) 173 | { 174 | if (!midiOutputEventPush(l_pending_receive_event_buffer[l_pending_receiver_event_buffer_index])) 175 | break; 176 | 177 | l_pending_receiver_event_buffer_index++; 178 | } 179 | 180 | // if all events could be copied into event buffer then reset buffer 181 | if (l_pending_receiver_event_buffer_index >= l_pending_receiver_event_buffer_count) 182 | { 183 | l_pending_receive_event_buffer = NULL; 184 | l_pending_receiver_event_buffer_count = 0; 185 | l_pending_receiver_event_buffer_index = 0; 186 | } 187 | } 188 | 189 | // if buffer is empty and receiver is not started -> start it 190 | if(!USBD_MIDI_IsReceiverBusy(&hUsbDeviceFS)) 191 | { 192 | if(l_pending_receive_event_buffer == NULL) 193 | { 194 | // restart receiver 195 | USBD_MIDI_SetRxBuffer(&hUsbDeviceFS, l_usb_receive_buffer); 196 | USBD_MIDI_ReceivePacket(&hUsbDeviceFS); 197 | } 198 | } 199 | } 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /usb_synth/LibOS/Include/sysHelpers.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* Collection of various system helper functions */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __sysHelpers_h 12 | #define __sysHelpers_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* Function prototypes */ 21 | /*****************************************************************************/ 22 | void sysMemZero(void* in_destination, size_t in_size); 23 | void sysMemCopy(void* in_destination, void* in_source, size_t in_size); 24 | 25 | #endif -------------------------------------------------------------------------------- /usb_synth/LibOS/Include/sysMain.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* Main Entry Function */ 3 | /* */ 4 | /* Copyright (C) 2016 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | #ifndef __sysMain_h 11 | #define __sysMain_h 12 | 13 | /*****************************************************************************/ 14 | /* Includes */ 15 | /*****************************************************************************/ 16 | #include 17 | 18 | /*****************************************************************************/ 19 | /* Function prototypes */ 20 | /*****************************************************************************/ 21 | void sysInitialization(void); 22 | void appMainTask(void); 23 | void appInitialization(void); 24 | #endif 25 | -------------------------------------------------------------------------------- /usb_synth/LibOS/Include/sysTimer.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* System timer (1ms) routines */ 3 | /* */ 4 | /* Copyright (C) 2014-2015 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __sysTimer_h 12 | #define __sysTimer_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* Constants */ 21 | /*****************************************************************************/ 22 | #define sysTIMER_TICKS_PER_SECOND 1000 // number of tick in one second 23 | 24 | /*****************************************************************************/ 25 | /* Types */ 26 | /*****************************************************************************/ 27 | #ifndef drvSYSTEMTIMER_USE16BIT 28 | typedef uint32_t sysTick; 29 | #else 30 | typedef uint16_t sysTick; 31 | #endif 32 | 33 | /*****************************************************************************/ 34 | /* Function prototypes */ 35 | /*****************************************************************************/ 36 | void sysTimerInitialize(void); 37 | void halSystemTimerInitialize(void); 38 | sysTick sysTimerGetTimestamp(void); 39 | void sysTimerDelay(sysTick in_delay_ms); 40 | sysTick sysTimerGetTimeSince(sysTick in_start_time_ms); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /usb_synth/LibOS/Include/sysTypes.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* System Type Definitions */ 3 | /* */ 4 | /* Copyright (C) 2014 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __sysTypes_h 12 | #define __sysTypes_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | /*****************************************************************************/ 23 | /* Constants */ 24 | /*****************************************************************************/ 25 | #define sysSTRING_MAX_LENGTH 0xfffe 26 | #define sysSTRING_INVALID_POS 0xffff 27 | 28 | /*****************************************************************************/ 29 | /* Common types */ 30 | /*****************************************************************************/ 31 | typedef uint16_t sysStringLength; 32 | 33 | typedef char sysChar; 34 | typedef char sysASCIIChar; 35 | typedef uint16_t sysUnicodeChar; 36 | typedef sysChar* sysString; 37 | typedef const sysChar* sysConstString; 38 | 39 | /*****************************************************************************/ 40 | /* Macros */ 41 | /*****************************************************************************/ 42 | #ifndef LOW 43 | #define LOW(x) ((x)&0xff) 44 | #endif 45 | 46 | #ifndef HIGH 47 | #define HIGH(x) ((x)>>8) 48 | #endif 49 | 50 | #ifndef BV 51 | #define BV(x) (1<<(x)) 52 | #endif 53 | 54 | #define STRINGIZE(x) ___STRINGIZE(x) 55 | #define ___STRINGIZE(x) #x 56 | 57 | #define sysNULL 0 58 | 59 | #define sysUNUSED(x) (void)(x) 60 | 61 | #define sysASSERT(x) assert_param(x) 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Include/halHelpers.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* Hardware Abstraction Layer Functions (general, system wide functions) */ 3 | /* */ 4 | /* Copyright (C) 2016 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __halHelpers_h 12 | #define __halHelpers_h 13 | 14 | /*****************************************************************************/ 15 | /* Includes */ 16 | /*****************************************************************************/ 17 | #include 18 | 19 | /*****************************************************************************/ 20 | /* PIN Settings helper macros */ 21 | /*****************************************************************************/ 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | /// @brief Sets pin(s) low 25 | /// @note Defined as macro to get maximum speed using register access 26 | /// @param GPIOx: GPIOx PORT where you want to set pin low 27 | /// @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them low 28 | /// @retval None 29 | #define drvHAL_SetPinLow(GPIOx, GPIO_Pin) ((GPIOx)->BSRR = ((GPIO_Pin)<<16)) 30 | 31 | /////////////////////////////////////////////////////////////////////////////// 32 | /// @brief Sets pin(s) high 33 | /// @note Defined as macro to get maximum speed using register access 34 | /// @param GPIOx: GPIOx PORT where you want to set pin high 35 | /// @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them high 36 | /// @retval None 37 | #define drvHAL_SetPinHigh(GPIOx, GPIO_Pin) ((GPIOx)->BSRR = (GPIO_Pin)) 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | /// @brief Sets pin(s) value 41 | /// @note Defined as macro to get maximum speed using register access 42 | /// @param GPIOx: GPIOx PORT where you want to set pin value 43 | /// @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them value 44 | /// @param val: If parameter is 0 then pin will be low, otherwise high 45 | /// @retval None 46 | #define drvHAL_SetPinValue(GPIOx, GPIO_Pin, val) ((val) ? drvHAL_SetPinHigh(GPIOx, GPIO_Pin) : drvHAL_SetPinLow(GPIOx, GPIO_Pin)) 47 | 48 | #endif -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Include/halMIDIPort.h: -------------------------------------------------------------------------------- 1 | #ifndef __halMIDIPort_h 2 | #define __halMIDIPort_h 3 | 4 | #include 5 | 6 | void halMIDIPortInitialize(void); 7 | void halMIDIPortSendBuffer(uint8_t* in_buffer, uint16_t in_buffer_length); 8 | bool halMIDIIsTransmitterEmpty(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Include/mxconstants.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : mxconstants.h 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | 35 | /* USER CODE BEGIN Includes */ 36 | 37 | /* USER CODE END Includes */ 38 | 39 | /* Private define ------------------------------------------------------------*/ 40 | 41 | #define LED_Pin GPIO_PIN_13 42 | #define LED_GPIO_Port GPIOC 43 | #define WIFI_TX_Pin GPIO_PIN_9 44 | #define WIFI_TX_GPIO_Port GPIOA 45 | #define WIFI_RX_Pin GPIO_PIN_10 46 | #define WIFI_RX_GPIO_Port GPIOA 47 | #define SSD1306_SCL_Pin GPIO_PIN_6 48 | #define SSD1306_SCL_GPIO_Port GPIOB 49 | #define SSD1306_SDA_Pin GPIO_PIN_7 50 | #define SSD1306_SDA_GPIO_Port GPIOB 51 | /* USER CODE BEGIN Private defines */ 52 | 53 | /* USER CODE END Private defines */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Include/stm32f1xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __STM32F1xx_IT_H 36 | #define __STM32F1xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | /* Exported types ------------------------------------------------------------*/ 44 | /* Exported constants --------------------------------------------------------*/ 45 | /* Exported macro ------------------------------------------------------------*/ 46 | /* Exported functions ------------------------------------------------------- */ 47 | 48 | void SysTick_Handler(void); 49 | void USB_LP_CAN1_RX0_IRQHandler(void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* __STM32F1xx_IT_H */ 56 | 57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 58 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Source/halMIDIPort.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* MIDI port handling on STM32F103 */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | /*****************************************************************************/ 12 | /* Includes */ 13 | /*****************************************************************************/ 14 | #include "stm32f1xx_hal.h" 15 | #include 16 | #include 17 | 18 | /*****************************************************************************/ 19 | /* Module global variables */ 20 | /*****************************************************************************/ 21 | static UART_HandleTypeDef l_uart_handle; 22 | static DMA_HandleTypeDef l_uart_tx_dma_handle; 23 | 24 | /*****************************************************************************/ 25 | /* Function implementation */ 26 | /*****************************************************************************/ 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | /// @brief Initializes MIDI Port 30 | void halMIDIPortInitialize(void) 31 | { 32 | GPIO_InitTypeDef GPIO_InitStruct; 33 | 34 | // USART Initialize 35 | __USART2_CLK_ENABLE(); 36 | 37 | /**USART2 GPIO Configuration 38 | PA2 ------> USART2_TX 39 | PA3 ------> USART2_RX 40 | */ 41 | GPIO_InitStruct.Pin = GPIO_PIN_2; 42 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 43 | GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; 44 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 45 | 46 | GPIO_InitStruct.Pin = GPIO_PIN_3; 47 | GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT; 48 | GPIO_InitStruct.Pull = GPIO_PULLUP; 49 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 50 | 51 | l_uart_handle.Instance = USART2; 52 | l_uart_handle.Init.BaudRate = 31250; 53 | l_uart_handle.Init.WordLength = UART_WORDLENGTH_8B; 54 | l_uart_handle.Init.StopBits = UART_STOPBITS_1; 55 | l_uart_handle.Init.Parity = UART_PARITY_NONE; 56 | l_uart_handle.Init.Mode = UART_MODE_TX_RX; 57 | HAL_UART_Init(&l_uart_handle); 58 | 59 | /* DMA controller clock enable */ 60 | __HAL_RCC_DMA1_CLK_ENABLE(); 61 | 62 | // Peripheral DMA initiaize 63 | l_uart_tx_dma_handle.Instance = DMA1_Channel7; 64 | l_uart_tx_dma_handle.Init.Direction = DMA_MEMORY_TO_PERIPH; 65 | l_uart_tx_dma_handle.Init.PeriphInc = DMA_PINC_DISABLE; 66 | l_uart_tx_dma_handle.Init.MemInc = DMA_MINC_ENABLE; 67 | l_uart_tx_dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 68 | l_uart_tx_dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 69 | l_uart_tx_dma_handle.Init.Mode = DMA_NORMAL; 70 | l_uart_tx_dma_handle.Init.Priority = DMA_PRIORITY_MEDIUM; 71 | HAL_DMA_Init(&l_uart_tx_dma_handle); 72 | 73 | __HAL_LINKDMA(&l_uart_handle, hdmatx, l_uart_tx_dma_handle); 74 | 75 | // Peripheral interrupt initialize 76 | HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); 77 | HAL_NVIC_EnableIRQ(USART2_IRQn); 78 | 79 | // DMA interrupt initialize 80 | HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0); 81 | HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn); 82 | 83 | // enable receiver input 84 | // __HAL_USART_ENABLE_IT(&l_uart_handle, UART_IT_RXNE); 85 | } 86 | 87 | /////////////////////////////////////////////////////////////////////////////// 88 | /// @brief Send buffer content over MIDI interface 89 | /// @param in_buffer Buffer containing data to send 90 | /// @param in_buffer_length Number of bytes to send 91 | void halMIDIPortSendBuffer(uint8_t* in_buffer, uint16_t in_buffer_length) 92 | { 93 | // check if transmitter is idle 94 | if (!halMIDIIsTransmitterEmpty()) 95 | return; 96 | 97 | // Start transmission 98 | HAL_UART_Transmit_DMA(&l_uart_handle, in_buffer, in_buffer_length); 99 | } 100 | 101 | /////////////////////////////////////////////////////////////////////////////// 102 | /// @brief Returns transmitter state 103 | /// @retval Returns true when transmitter is ready to send new block of data 104 | bool halMIDIIsTransmitterEmpty(void) 105 | { 106 | return (l_uart_handle.State == HAL_UART_STATE_READY || l_uart_handle.State == HAL_UART_STATE_BUSY_RX); 107 | } 108 | 109 | /////////////////////////////////////////////////////////////////////////////// 110 | /// @param UART transmit DMA IRQ handler 111 | void DMA1_Channel7_IRQHandler(void) 112 | { 113 | HAL_DMA_IRQHandler(&l_uart_tx_dma_handle); 114 | } 115 | 116 | /////////////////////////////////////////////////////////////////////////////// 117 | /// @param UART IRQ handler 118 | void USART2_IRQHandler(void) 119 | { 120 | uint32_t tmp1 = 0; 121 | uint32_t tmp2 = 0; 122 | uint8_t received_data; 123 | 124 | // Override HAL original interrupt handler and handle incoming characters individually 125 | // All other interrupt sources will be handled by the HAL interrupt handler function 126 | // Check for received character interrupt 127 | tmp1 = __HAL_UART_GET_FLAG(&l_uart_handle, UART_FLAG_RXNE); 128 | tmp2 = __HAL_UART_GET_IT_SOURCE(&l_uart_handle, UART_IT_RXNE); 129 | if ((tmp1 != RESET) && (tmp2 != RESET)) 130 | { 131 | // get received byte 132 | received_data = (uint8_t)(l_uart_handle.Instance->DR & (uint8_t)0x00FF); 133 | 134 | // process received byte 135 | midiInputDataReceived(received_data); 136 | } 137 | 138 | // HAL interrupt handler 139 | HAL_UART_IRQHandler(&l_uart_handle); 140 | } 141 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Source/halMain.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : main.c 4 | * Description : Main program body 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include 35 | 36 | int main(void) 37 | { 38 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 39 | sysInitialization(); 40 | /* 41 | while (1) 42 | {*/ 43 | appMainTask(); 44 | //} 45 | } 46 | 47 | 48 | #ifdef USE_FULL_ASSERT 49 | 50 | /** 51 | * @brief Reports the name of the source file and the source line number 52 | * where the assert_param error has occurred. 53 | * @param file: pointer to the source file name 54 | * @param line: assert_param error line source number 55 | * @retval None 56 | */ 57 | void assert_failed(uint8_t* file, uint32_t line) 58 | { 59 | /* USER CODE BEGIN 6 */ 60 | /* User can add his own implementation to report the file name and line number, 61 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 62 | /* USER CODE END 6 */ 63 | 64 | } 65 | 66 | #endif 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Source/halSystem.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* Includes */ 3 | /*****************************************************************************/ 4 | #include "stm32f1xx_hal.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /*****************************************************************************/ 14 | /* Local function prototypes */ 15 | /*****************************************************************************/ 16 | static void halSystemClockConfig(void); 17 | static void halGPIOInitialize(void); 18 | 19 | extern PCD_HandleTypeDef hpcd_USB_FS; 20 | 21 | /////////////////////////////////////////////////////////////////////////////// 22 | /// @brief Initializes HW subsystem 23 | void sysInitialization(void) 24 | { 25 | // Init HAL 26 | HAL_Init(); 27 | 28 | halSystemTimerInitialize(); 29 | 30 | // Configures GPIO pins 31 | halGPIOInitialize(); 32 | 33 | // Configure the system clock 34 | halSystemClockConfig(); 35 | 36 | // Start USB device stack 37 | midiUSBDeviceInitialize(); 38 | //MX_USB_DEVICE_Init(); 39 | 40 | // initializes hw MIDI serial port 41 | halMIDIPortInitialize(); 42 | midiInputInitialize(); 43 | midiOutputInitialize(); 44 | } 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | /// @brief Configures system clock 48 | static void halSystemClockConfig(void) 49 | { 50 | RCC_OscInitTypeDef RCC_OscInitStruct; 51 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 52 | RCC_PeriphCLKInitTypeDef PeriphClkInit; 53 | 54 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 55 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 56 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 57 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 58 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 59 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; 60 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 61 | 62 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1; 63 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 64 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 65 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 66 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 67 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); 68 | 69 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 70 | PeriphClkInit.UsbClockSelection = RCC_USBPLLCLK_DIV1_5; 71 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); 72 | 73 | } 74 | 75 | /////////////////////////////////////////////////////////////////////////////// 76 | /// @briegf Configures GPIO pins 77 | static void halGPIOInitialize(void) 78 | { 79 | GPIO_InitTypeDef GPIO_InitStruct; 80 | 81 | /* GPIO Ports Clock Enable */ 82 | __GPIOA_CLK_ENABLE(); 83 | __GPIOB_CLK_ENABLE(); 84 | __GPIOC_CLK_ENABLE(); 85 | __GPIOD_CLK_ENABLE(); 86 | 87 | /*Configure GPIO pin : LED_Pin */ 88 | GPIO_InitStruct.Pin = 0x2; 89 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 90 | GPIO_InitStruct.Speed = GPIO_SPEED_LOW; 91 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 92 | 93 | GPIO_InitStruct.Pin = 0x2000; 94 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 95 | GPIO_InitStruct.Speed = GPIO_SPEED_LOW; 96 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 97 | 98 | GPIO_InitStruct.Pin = 0x4000; 99 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 100 | GPIO_InitStruct.Speed = GPIO_SPEED_LOW; 101 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 102 | } 103 | 104 | 105 | /////////////////////////////////////////////////////////////////////////////// 106 | /// @brief Initializes the Global MSP. 107 | void HAL_MspInit(void) 108 | { 109 | __HAL_RCC_AFIO_CLK_ENABLE(); 110 | 111 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 112 | 113 | // NOJTAG: JTAG-DP Disabled and SW-DP Enabled 114 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); 115 | } 116 | 117 | 118 | /** 119 | * @brief This function handles USB low priority or CAN RX0 interrupts. 120 | */ 121 | void USB_LP_CAN1_RX0_IRQHandler(void) 122 | { 123 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */ 124 | 125 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */ 126 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 127 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */ 128 | 129 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */ 130 | } 131 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F103MIDIUSBBoard/Source/halSystemTimer.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* System timer (1ms) driver */ 3 | /* (emulated on Win32) */ 4 | /* */ 5 | /* Copyright (C) 2014-2015 Laszlo Arvai */ 6 | /* All rights reserved. */ 7 | /* */ 8 | /* This software may be modified and distributed under the terms */ 9 | /* of the GNU General Public License. See the LICENSE file for details. */ 10 | /*****************************************************************************/ 11 | 12 | /*****************************************************************************/ 13 | /* Includes */ 14 | /*****************************************************************************/ 15 | #include 16 | #include 17 | 18 | /*****************************************************************************/ 19 | /* Function implementation */ 20 | /*****************************************************************************/ 21 | 22 | /////////////////////////////////////////////////////////////////////////////// 23 | /// @brief Initializes system timer 24 | void halSystemTimerInitialize(void) 25 | { 26 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); 27 | 28 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 29 | 30 | /* SysTick_IRQn interrupt configuration */ 31 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 32 | } 33 | 34 | /////////////////////////////////////////////////////////////////////////////// 35 | /// @brief Gets system timer current value (current timestamp) 36 | /// @return System timer value 37 | sysTick sysTimerGetTimestamp(void) 38 | { 39 | return HAL_GetTick(); 40 | } 41 | 42 | /////////////////////////////////////////////////////////////////////////////// 43 | /// @ brief This function handles System tick timer. 44 | void SysTick_Handler(void) 45 | { 46 | HAL_IncTick(); 47 | HAL_SYSTICK_IRQHandler(); 48 | } -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | //extern const q31_t realCoefAQ31[1024]; 50 | //extern const q31_t realCoefBQ31[1024]; 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f100xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f100xb.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f100xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f100xe.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101x6.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101xb.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101xe.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101xg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f101xg.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f102x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f102x6.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f102xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f102xb.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103x6.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103xb.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103xe.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103xg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f103xg.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f105xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f105xc.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f107xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f107xc.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx.h -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx_hal_can_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_can_ex.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of CAN HAL Extension module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_CAN_EX_H 40 | #define __STM32F1xx_HAL_CAN_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || \ 47 | defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC) 48 | 49 | /* Includes ------------------------------------------------------------------*/ 50 | #include "stm32f1xx_hal_def.h" 51 | 52 | /** @addtogroup STM32F1xx_HAL_Driver 53 | * @{ 54 | */ 55 | 56 | /** @defgroup CANEx CANEx 57 | * @{ 58 | */ 59 | 60 | /* Exported types ------------------------------------------------------------*/ 61 | 62 | /** 63 | * @brief CAN filter configuration structure definition 64 | */ 65 | /* CAN filter banks differences over STM32F1 devices: */ 66 | /* - STM32F1 Connectivity line: 28 filter banks shared between CAN1 and CAN2 */ 67 | /* - Other STM32F10x devices: 14 filter banks */ 68 | 69 | typedef struct 70 | { 71 | uint32_t FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit 72 | configuration, first one for a 16-bit configuration). 73 | This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ 74 | 75 | uint32_t FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit 76 | configuration, second one for a 16-bit configuration). 77 | This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ 78 | 79 | uint32_t FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number, 80 | according to the mode (MSBs for a 32-bit configuration, 81 | first one for a 16-bit configuration). 82 | This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ 83 | 84 | uint32_t FilterMaskIdLow; /*!< Specifies the filter mask number or identification number, 85 | according to the mode (LSBs for a 32-bit configuration, 86 | second one for a 16-bit configuration). 87 | This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ 88 | 89 | uint32_t FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter. 90 | This parameter can be a value of @ref CAN_filter_FIFO */ 91 | #if defined(STM32F105xC) || defined(STM32F107xC) 92 | uint32_t FilterNumber; /*!< Specifies the filter which will be initialized. 93 | This parameter must be a number between Min_Data = 0 and Max_Data = 27. */ 94 | #else 95 | uint32_t FilterNumber; /*!< Specifies the filter which will be initialized. 96 | This parameter must be a number between Min_Data = 0 and Max_Data = 13. */ 97 | #endif /* STM32F105xC || STM32F107xC */ 98 | uint32_t FilterMode; /*!< Specifies the filter mode to be initialized. 99 | This parameter can be a value of @ref CAN_filter_mode */ 100 | 101 | uint32_t FilterScale; /*!< Specifies the filter scale. 102 | This parameter can be a value of @ref CAN_filter_scale */ 103 | 104 | uint32_t FilterActivation; /*!< Enable or disable the filter. 105 | This parameter can be set to ENABLE or DISABLE. */ 106 | 107 | uint32_t BankNumber; /*!< Select the start slave bank filter 108 | This parameter must be a number between Min_Data = 0 and Max_Data = 28. */ 109 | 110 | }CAN_FilterConfTypeDef; 111 | 112 | /* Exported constants --------------------------------------------------------*/ 113 | /* Exported macro ------------------------------------------------------------*/ 114 | /* Private macro -------------------------------------------------------------*/ 115 | 116 | /** @defgroup CANEx_Private_Macros CAN Extended Private Macros 117 | * @{ 118 | */ 119 | #if defined(STM32F105xC) || defined(STM32F107xC) 120 | #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27) 121 | #else 122 | #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 13) 123 | #endif /* STM32F105xC || STM32F107xC */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | #endif /* STM32F103x6) || STM32F103xB || STM32F103xE || */ 139 | /* STM32F103xG) || STM32F105xC || STM32F107xC */ 140 | 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | 145 | #endif /* __STM32F1xx_HAL_CAN_EX_H */ 146 | 147 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 148 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx_hal_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_crc.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of CRC HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_CRC_H 40 | #define __STM32F1xx_HAL_CRC_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f1xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F1xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup CRC 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | 59 | /** @defgroup CRC_Exported_Types CRC Exported Types 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @brief CRC HAL State Structure definition 65 | */ 66 | typedef enum 67 | { 68 | HAL_CRC_STATE_RESET = 0x00, /*!< CRC not yet initialized or disabled */ 69 | HAL_CRC_STATE_READY = 0x01, /*!< CRC initialized and ready for use */ 70 | HAL_CRC_STATE_BUSY = 0x02, /*!< CRC internal process is ongoing */ 71 | HAL_CRC_STATE_TIMEOUT = 0x03, /*!< CRC timeout state */ 72 | HAL_CRC_STATE_ERROR = 0x04 /*!< CRC error state */ 73 | 74 | }HAL_CRC_StateTypeDef; 75 | 76 | /** 77 | * @brief CRC handle Structure definition 78 | */ 79 | typedef struct 80 | { 81 | CRC_TypeDef *Instance; /*!< Register base address */ 82 | 83 | HAL_LockTypeDef Lock; /*!< CRC locking object */ 84 | 85 | __IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */ 86 | 87 | }CRC_HandleTypeDef; 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /* Exported constants --------------------------------------------------------*/ 94 | /* Exported macro ------------------------------------------------------------*/ 95 | 96 | /** @defgroup CRC_Exported_Macros CRC Exported Macros 97 | * @{ 98 | */ 99 | 100 | /** @brief Reset CRC handle state 101 | * @param __HANDLE__: CRC handle 102 | * @retval None 103 | */ 104 | #define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) 105 | 106 | /** 107 | * @brief Resets CRC Data Register. 108 | * @param __HANDLE__: CRC handle 109 | * @retval None 110 | */ 111 | #define __HAL_CRC_DR_RESET(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR,CRC_CR_RESET)) 112 | 113 | /** 114 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 115 | * @param __HANDLE__: CRC handle 116 | * @param __VALUE__: 8-bit value to be stored in the ID register 117 | * @retval None 118 | */ 119 | #define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__))) 120 | 121 | /** 122 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register. 123 | * @param __HANDLE__: CRC handle 124 | * @retval 8-bit value of the ID register 125 | */ 126 | #define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR) 127 | 128 | /** 129 | * @} 130 | */ 131 | 132 | /* Exported functions --------------------------------------------------------*/ 133 | 134 | /** @addtogroup CRC_Exported_Functions 135 | * @{ 136 | */ 137 | 138 | /** @addtogroup CRC_Exported_Functions_Group1 139 | * @{ 140 | */ 141 | 142 | /* Initialization/de-initialization functions **********************************/ 143 | HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); 144 | HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef *hcrc); 145 | void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); 146 | void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** @addtogroup CRC_Exported_Functions_Group2 153 | * @{ 154 | */ 155 | 156 | /* Peripheral Control functions ************************************************/ 157 | uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 158 | uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 159 | 160 | 161 | /** 162 | * @} 163 | */ 164 | 165 | /** @addtogroup CRC_Exported_Functions_Group3 166 | ** @{ 167 | */ 168 | 169 | /* Peripheral State functions **************************************************/ 170 | HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc); 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | /** 186 | * @} 187 | */ 188 | 189 | #ifdef __cplusplus 190 | } 191 | #endif 192 | 193 | #endif /* __STM32F1xx_HAL_CRC_H */ 194 | 195 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 196 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_def.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief This file contains HAL common defines, enumeration, macros and 8 | * structures definitions. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2015 STMicroelectronics

13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ 40 | #ifndef __STM32F1xx_HAL_DEF 41 | #define __STM32F1xx_HAL_DEF 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f1xx.h" 49 | #include "Legacy/stm32_hal_legacy.h" 50 | #include 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | 54 | /** 55 | * @brief HAL Status structures definition 56 | */ 57 | typedef enum 58 | { 59 | HAL_OK = 0x00, 60 | HAL_ERROR = 0x01, 61 | HAL_BUSY = 0x02, 62 | HAL_TIMEOUT = 0x03 63 | } HAL_StatusTypeDef; 64 | 65 | /** 66 | * @brief HAL Lock structures definition 67 | */ 68 | typedef enum 69 | { 70 | HAL_UNLOCKED = 0x00, 71 | HAL_LOCKED = 0x01 72 | } HAL_LockTypeDef; 73 | 74 | /* Exported macro ------------------------------------------------------------*/ 75 | 76 | #define HAL_MAX_DELAY 0xFFFFFFFF 77 | 78 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) 79 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 80 | 81 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ 82 | do{ \ 83 | (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ 84 | (__DMA_HANDLE_).Parent = (__HANDLE__); \ 85 | } while(0) 86 | 87 | #define UNUSED(x) ((void)(x)) 88 | 89 | /** @brief Reset the Handle's State field. 90 | * @param __HANDLE__: specifies the Peripheral Handle. 91 | * @note This macro can be used for the following purpose: 92 | * - When the Handle is declared as local variable; before passing it as parameter 93 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 94 | * to set to 0 the Handle's "State" field. 95 | * Otherwise, "State" field may have any random value and the first time the function 96 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 97 | * (i.e. HAL_PPP_MspInit() will not be executed). 98 | * - When there is a need to reconfigure the low level hardware: instead of calling 99 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 100 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 101 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 102 | * @retval None 103 | */ 104 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 105 | 106 | #if (USE_RTOS == 1) 107 | #error " USE_RTOS should be 0 in the current HAL release " 108 | #else 109 | #define __HAL_LOCK(__HANDLE__) \ 110 | do{ \ 111 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 112 | { \ 113 | return HAL_BUSY; \ 114 | } \ 115 | else \ 116 | { \ 117 | (__HANDLE__)->Lock = HAL_LOCKED; \ 118 | } \ 119 | }while (0) 120 | 121 | #define __HAL_UNLOCK(__HANDLE__) \ 122 | do{ \ 123 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 124 | }while (0) 125 | #endif /* USE_RTOS */ 126 | 127 | #if defined ( __GNUC__ ) 128 | #ifndef __weak 129 | #define __weak __attribute__((weak)) 130 | #endif /* __weak */ 131 | #ifndef __packed 132 | #define __packed __attribute__((__packed__)) 133 | #endif /* __packed */ 134 | #endif /* __GNUC__ */ 135 | 136 | 137 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 138 | #if defined (__GNUC__) /* GNU Compiler */ 139 | #ifndef __ALIGN_END 140 | #define __ALIGN_END __attribute__ ((aligned (4))) 141 | #endif /* __ALIGN_END */ 142 | #ifndef __ALIGN_BEGIN 143 | #define __ALIGN_BEGIN 144 | #endif /* __ALIGN_BEGIN */ 145 | #else 146 | #ifndef __ALIGN_END 147 | #define __ALIGN_END 148 | #endif /* __ALIGN_END */ 149 | #ifndef __ALIGN_BEGIN 150 | #if defined (__CC_ARM) /* ARM Compiler */ 151 | #define __ALIGN_BEGIN __align(4) 152 | #elif defined (__ICCARM__) /* IAR Compiler */ 153 | #define __ALIGN_BEGIN 154 | #endif /* __CC_ARM */ 155 | #endif /* __ALIGN_BEGIN */ 156 | #endif /* __GNUC__ */ 157 | 158 | /** 159 | * @brief __RAM_FUNC definition 160 | */ 161 | #if defined ( __CC_ARM ) 162 | /* ARM Compiler 163 | ------------ 164 | RAM functions are defined using the toolchain options. 165 | Functions that are executed in RAM should reside in a separate source module. 166 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 167 | area of a module to a memory space in physical RAM. 168 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 169 | dialog. 170 | */ 171 | #define __RAM_FUNC HAL_StatusTypeDef 172 | 173 | #elif defined ( __ICCARM__ ) 174 | /* ICCARM Compiler 175 | --------------- 176 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 177 | */ 178 | #define __RAM_FUNC __ramfunc HAL_StatusTypeDef 179 | 180 | #elif defined ( __GNUC__ ) 181 | /* GNU Compiler 182 | ------------ 183 | RAM functions are defined using a specific toolchain attribute 184 | "__attribute__((section(".RamFunc")))". 185 | */ 186 | #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) 187 | 188 | #endif 189 | 190 | /** 191 | * @brief __NOINLINE definition 192 | */ 193 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 194 | /* ARM & GNUCompiler 195 | ---------------- 196 | */ 197 | #define __NOINLINE __attribute__ ( (noinline) ) 198 | 199 | #elif defined ( __ICCARM__ ) 200 | /* ICCARM Compiler 201 | --------------- 202 | */ 203 | #define __NOINLINE _Pragma("optimize = no_inline") 204 | 205 | #endif 206 | 207 | 208 | #ifdef __cplusplus 209 | } 210 | #endif 211 | 212 | #endif /* ___STM32F1xx_HAL_DEF */ 213 | 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 215 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx_hal_hcd.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_hcd.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of HCD HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_HCD_H 40 | #define __STM32F1xx_HAL_HCD_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32F105xC) || defined(STM32F107xC) 47 | 48 | 49 | /* Includes ------------------------------------------------------------------*/ 50 | #include "stm32f1xx_ll_usb.h" 51 | 52 | /** @addtogroup STM32F1xx_HAL_Driver 53 | * @{ 54 | */ 55 | 56 | /** @addtogroup HCD 57 | * @{ 58 | */ 59 | 60 | /* Exported types ------------------------------------------------------------*/ 61 | /** @defgroup HCD_Exported_Types HCD Exported Types 62 | * @{ 63 | */ 64 | 65 | /** 66 | * @brief HCD Status structure definition 67 | */ 68 | typedef enum 69 | { 70 | HAL_HCD_STATE_RESET = 0x00, 71 | HAL_HCD_STATE_READY = 0x01, 72 | HAL_HCD_STATE_ERROR = 0x02, 73 | HAL_HCD_STATE_BUSY = 0x03, 74 | HAL_HCD_STATE_TIMEOUT = 0x04 75 | } HCD_StateTypeDef; 76 | 77 | typedef USB_OTG_GlobalTypeDef HCD_TypeDef; 78 | typedef USB_OTG_CfgTypeDef HCD_InitTypeDef; 79 | typedef USB_OTG_HCTypeDef HCD_HCTypeDef; 80 | typedef USB_OTG_URBStateTypeDef HCD_URBStateTypeDef; 81 | typedef USB_OTG_HCStateTypeDef HCD_HCStateTypeDef; 82 | 83 | /** 84 | * @brief HCD Handle Structure definition 85 | */ 86 | typedef struct 87 | { 88 | HCD_TypeDef *Instance; /*!< Register base address */ 89 | HCD_InitTypeDef Init; /*!< HCD required parameters */ 90 | HCD_HCTypeDef hc[15]; /*!< Host channels parameters */ 91 | HAL_LockTypeDef Lock; /*!< HCD peripheral status */ 92 | __IO HCD_StateTypeDef State; /*!< HCD communication state */ 93 | void *pData; /*!< Pointer Stack Handler */ 94 | } HCD_HandleTypeDef; 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /* Exported constants --------------------------------------------------------*/ 101 | /** @defgroup HCD_Exported_Constants HCD Exported Constants 102 | * @{ 103 | */ 104 | /** @defgroup HCD_Speed HCD Speed 105 | * @{ 106 | */ 107 | #define HCD_SPEED_LOW 2 108 | #define HCD_SPEED_FULL 3 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /* Exported macro ------------------------------------------------------------*/ 119 | /** @defgroup HCD_Exported_Macros HCD Exported Macros 120 | * @brief macros to handle interrupts and specific clock configurations 121 | * @{ 122 | */ 123 | #define __HAL_HCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance) 124 | #define __HAL_HCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance) 125 | 126 | 127 | #define __HAL_HCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__)) 128 | #define __HAL_HCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__)) 129 | #define __HAL_HCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0) 130 | 131 | 132 | #define __HAL_HCD_CLEAR_HC_INT(chnum, __INTERRUPT__) (USBx_HC(chnum)->HCINT = (__INTERRUPT__)) 133 | #define __HAL_HCD_MASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM) 134 | #define __HAL_HCD_UNMASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM) 135 | #define __HAL_HCD_MASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM) 136 | #define __HAL_HCD_UNMASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_ACKM) 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /* Exported functions --------------------------------------------------------*/ 143 | /** @addtogroup HCD_Exported_Functions HCD Exported Functions 144 | * @{ 145 | */ 146 | 147 | /* Initialization/de-initialization functions ********************************/ 148 | /** @addtogroup HCD_Exported_Functions_Group1 Initialization and de-initialization functions 149 | * @{ 150 | */ 151 | HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd); 152 | HAL_StatusTypeDef HAL_HCD_DeInit (HCD_HandleTypeDef *hhcd); 153 | HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, 154 | uint8_t ch_num, 155 | uint8_t epnum, 156 | uint8_t dev_address, 157 | uint8_t speed, 158 | uint8_t ep_type, 159 | uint16_t mps); 160 | 161 | HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, 162 | uint8_t ch_num); 163 | 164 | void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd); 165 | void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd); 166 | /** 167 | * @} 168 | */ 169 | 170 | /* I/O operation functions ***************************************************/ 171 | /** @addtogroup HCD_Exported_Functions_Group2 IO operation functions 172 | * @{ 173 | */ 174 | HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, 175 | uint8_t pipe, 176 | uint8_t direction, 177 | uint8_t ep_type, 178 | uint8_t token, 179 | uint8_t* pbuff, 180 | uint16_t length, 181 | uint8_t do_ping); 182 | 183 | /* Non-Blocking mode: Interrupt */ 184 | void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd); 185 | void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd); 186 | void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd); 187 | void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd); 188 | void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, 189 | uint8_t chnum, 190 | HCD_URBStateTypeDef urb_state); 191 | /** 192 | * @} 193 | */ 194 | /* Peripheral Control functions **********************************************/ 195 | /** @addtogroup HCD_Exported_Functions_Group3 Peripheral Control functions 196 | * @{ 197 | */ 198 | HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd); 199 | HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd); 200 | HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd); 201 | /** 202 | * @} 203 | */ 204 | /* Peripheral State functions ************************************************/ 205 | /** @addtogroup HCD_Exported_Functions_Group4 Peripheral State functions 206 | * @{ 207 | */ 208 | HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd); 209 | HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum); 210 | uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum); 211 | HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum); 212 | uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd); 213 | uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd); 214 | /** 215 | * @} 216 | */ 217 | 218 | /** 219 | * @} 220 | */ 221 | 222 | /* Private macros ------------------------------------------------------------*/ 223 | /** @defgroup HCD_Private_Macros HCD Private Macros 224 | * @{ 225 | */ 226 | /** @defgroup HCD_Instance_definition HCD Instance definition 227 | * @{ 228 | */ 229 | #define IS_HCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS)) 230 | /** 231 | * @} 232 | */ 233 | /** 234 | * @} 235 | */ 236 | 237 | /** 238 | * @} 239 | */ 240 | 241 | /** 242 | * @} 243 | */ 244 | 245 | #endif /* STM32F105xC || STM32F107xC */ 246 | 247 | 248 | #ifdef __cplusplus 249 | } 250 | #endif 251 | 252 | #endif /* __STM32F1xx_HAL_HCD_H */ 253 | 254 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 255 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of Extended PCD HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_PCD_EX_H 40 | #define __STM32F1xx_HAL_PCD_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32F102x6) || defined(STM32F102xB) || \ 47 | defined(STM32F103x6) || defined(STM32F103xB) || \ 48 | defined(STM32F103xE) || defined(STM32F103xG) || \ 49 | defined(STM32F105xC) || defined(STM32F107xC) 50 | 51 | /* Includes ------------------------------------------------------------------*/ 52 | #include "stm32f1xx_hal_def.h" 53 | 54 | /** @addtogroup STM32F1xx_HAL_Driver 55 | * @{ 56 | */ 57 | 58 | /** @addtogroup PCDEx 59 | * @{ 60 | */ 61 | 62 | /* Exported types ------------------------------------------------------------*/ 63 | /* Exported constants --------------------------------------------------------*/ 64 | /* Exported macros -----------------------------------------------------------*/ 65 | /* Exported functions --------------------------------------------------------*/ 66 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 67 | * @{ 68 | */ 69 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 70 | * @{ 71 | */ 72 | #if defined (USB_OTG_FS) 73 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 74 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 75 | #endif /* USB_OTG_FS */ 76 | 77 | #if defined (USB) 78 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 79 | uint16_t ep_addr, 80 | uint16_t ep_kind, 81 | uint32_t pmaadress); 82 | #endif /* USB */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @addtogroup PCDEx_Exported_Functions_Group2 Peripheral State functions 88 | * @{ 89 | */ 90 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state); 91 | /** 92 | * @} 93 | */ 94 | /** 95 | * @} 96 | */ 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | #endif /* STM32F102x6 || STM32F102xB || */ 105 | /* STM32F103x6 || STM32F103xB || */ 106 | /* STM32F103xE || STM32F103xG || */ 107 | /* STM32F105xC || STM32F107xC */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | 114 | #endif /* __STM32F1xx_HAL_PCD_EX_H */ 115 | 116 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 117 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/stm32f1xx_hal_sram.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_sram.h 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Header file of SRAM HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F1xx_HAL_SRAM_H 40 | #define __STM32F1xx_HAL_SRAM_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f1xx_ll_fsmc.h" 48 | 49 | /** @addtogroup STM32F1xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | #if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) || defined(STM32F100xE) 54 | 55 | /** @addtogroup SRAM 56 | * @{ 57 | */ 58 | 59 | /* Exported typedef ----------------------------------------------------------*/ 60 | 61 | /** @defgroup SRAM_Exported_Types SRAM Exported Types 62 | * @{ 63 | */ 64 | /** 65 | * @brief HAL SRAM State structures definition 66 | */ 67 | typedef enum 68 | { 69 | HAL_SRAM_STATE_RESET = 0x00, /*!< SRAM not yet initialized or disabled */ 70 | HAL_SRAM_STATE_READY = 0x01, /*!< SRAM initialized and ready for use */ 71 | HAL_SRAM_STATE_BUSY = 0x02, /*!< SRAM internal process is ongoing */ 72 | HAL_SRAM_STATE_ERROR = 0x03, /*!< SRAM error state */ 73 | HAL_SRAM_STATE_PROTECTED = 0x04 /*!< SRAM peripheral NORSRAM device write protected */ 74 | 75 | }HAL_SRAM_StateTypeDef; 76 | 77 | /** 78 | * @brief SRAM handle Structure definition 79 | */ 80 | typedef struct 81 | { 82 | FSMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ 83 | 84 | FSMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */ 85 | 86 | FSMC_NORSRAM_InitTypeDef Init; /*!< SRAM device control configuration parameters */ 87 | 88 | HAL_LockTypeDef Lock; /*!< SRAM locking object */ 89 | 90 | __IO HAL_SRAM_StateTypeDef State; /*!< SRAM device access state */ 91 | 92 | DMA_HandleTypeDef *hdma; /*!< Pointer DMA handler */ 93 | 94 | }SRAM_HandleTypeDef; 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /* Exported constants --------------------------------------------------------*/ 101 | /* Exported macro ------------------------------------------------------------*/ 102 | 103 | /** @defgroup SRAM_Exported_Macros SRAM Exported Macros 104 | * @{ 105 | */ 106 | 107 | /** @brief Reset SRAM handle state 108 | * @param __HANDLE__: SRAM handle 109 | * @retval None 110 | */ 111 | #define __HAL_SRAM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SRAM_STATE_RESET) 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /* Exported functions --------------------------------------------------------*/ 118 | 119 | /** @addtogroup SRAM_Exported_Functions 120 | * @{ 121 | */ 122 | 123 | /** @addtogroup SRAM_Exported_Functions_Group1 124 | * @{ 125 | */ 126 | 127 | /* Initialization/de-initialization functions **********************************/ 128 | HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FSMC_NORSRAM_TimingTypeDef *Timing, FSMC_NORSRAM_TimingTypeDef *ExtTiming); 129 | HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram); 130 | void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram); 131 | void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram); 132 | 133 | void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); 134 | void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /** @addtogroup SRAM_Exported_Functions_Group2 141 | * @{ 142 | */ 143 | 144 | /* I/O operation functions *****************************************************/ 145 | HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize); 146 | HAL_StatusTypeDef HAL_SRAM_Write_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pSrcBuffer, uint32_t BufferSize); 147 | HAL_StatusTypeDef HAL_SRAM_Read_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pDstBuffer, uint32_t BufferSize); 148 | HAL_StatusTypeDef HAL_SRAM_Write_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pSrcBuffer, uint32_t BufferSize); 149 | HAL_StatusTypeDef HAL_SRAM_Read_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); 150 | HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); 151 | HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); 152 | HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** @addtogroup SRAM_Exported_Functions_Group3 159 | * @{ 160 | */ 161 | 162 | /* SRAM Control functions ******************************************************/ 163 | HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram); 164 | HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram); 165 | 166 | /** 167 | * @} 168 | */ 169 | 170 | /** @addtogroup SRAM_Exported_Functions_Group4 171 | * @{ 172 | */ 173 | 174 | /* SRAM State functions *********************************************************/ 175 | HAL_SRAM_StateTypeDef HAL_SRAM_GetState(SRAM_HandleTypeDef *hsram); 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | /** 186 | * @} 187 | */ 188 | 189 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG || STM32F100xE */ 190 | 191 | /** 192 | * @} 193 | */ 194 | 195 | #ifdef __cplusplus 196 | } 197 | #endif 198 | 199 | #endif /* __STM32F1xx_HAL_SRAM_H */ 200 | 201 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 202 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Include/system_stm32f1xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V4.0.1 6 | * @date 31-July-2015 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /** @addtogroup CMSIS 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup stm32f10x_system 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Define to prevent recursive inclusion 48 | */ 49 | #ifndef __SYSTEM_STM32F10X_H 50 | #define __SYSTEM_STM32F10X_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** @addtogroup STM32F10x_System_Includes 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | /** @addtogroup STM32F10x_System_Exported_types 66 | * @{ 67 | */ 68 | 69 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Constants 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F10x_System_Exported_Macros 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32F10x_System_Exported_Functions 92 | * @{ 93 | */ 94 | 95 | extern void SystemInit(void); 96 | extern void SystemCoreClockUpdate(void); 97 | /** 98 | * @} 99 | */ 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /*__SYSTEM_STM32F10X_H */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 115 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Source/stm32f1xx_hal_gpio_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_gpio_ex.c 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief GPIO Extension HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the General Purpose Input/Output (GPIO) extension peripheral. 10 | * + Extended features functions 11 | * 12 | @verbatim 13 | ============================================================================== 14 | ##### GPIO Peripheral extension features ##### 15 | ============================================================================== 16 | [..] GPIO module on STM32F1 family, manage also the AFIO register: 17 | (+) Possibility to use the EVENTOUT Cortex feature 18 | 19 | ##### How to use this driver ##### 20 | ============================================================================== 21 | [..] This driver provides functions to use EVENTOUT Cortex feature 22 | (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 23 | (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 24 | (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 25 | 26 | @endverbatim 27 | ****************************************************************************** 28 | * @attention 29 | * 30 | *

© COPYRIGHT(c) 2015 STMicroelectronics

31 | * 32 | * Redistribution and use in source and binary forms, with or without modification, 33 | * are permitted provided that the following conditions are met: 34 | * 1. Redistributions of source code must retain the above copyright notice, 35 | * this list of conditions and the following disclaimer. 36 | * 2. Redistributions in binary form must reproduce the above copyright notice, 37 | * this list of conditions and the following disclaimer in the documentation 38 | * and/or other materials provided with the distribution. 39 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 40 | * may be used to endorse or promote products derived from this software 41 | * without specific prior written permission. 42 | * 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 44 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 49 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 50 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 51 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 | * 54 | ****************************************************************************** 55 | */ 56 | 57 | /* Includes ------------------------------------------------------------------*/ 58 | #include "stm32f1xx_hal.h" 59 | 60 | /** @addtogroup STM32F1xx_HAL_Driver 61 | * @{ 62 | */ 63 | 64 | /** @defgroup GPIOEx GPIOEx 65 | * @brief GPIO HAL module driver 66 | * @{ 67 | */ 68 | 69 | #ifdef HAL_GPIO_MODULE_ENABLED 70 | 71 | /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions 72 | * @{ 73 | */ 74 | 75 | /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions 76 | * @brief Extended features functions 77 | * 78 | @verbatim 79 | ============================================================================== 80 | ##### Extended features functions ##### 81 | ============================================================================== 82 | [..] This section provides functions allowing to: 83 | (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 84 | (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 85 | (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 86 | 87 | @endverbatim 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected. 93 | * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal. 94 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT. 95 | * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal. 96 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN. 97 | * @retval None 98 | */ 99 | void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource) 100 | { 101 | /* Verify the parameters */ 102 | assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource)); 103 | assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource)); 104 | 105 | /* Apply the new configuration */ 106 | MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT)|(AFIO_EVCR_PIN), (GPIO_PortSource)|(GPIO_PinSource)); 107 | } 108 | 109 | /** 110 | * @brief Enables the Event Output. 111 | * @retval None 112 | */ 113 | void HAL_GPIOEx_EnableEventout(void) 114 | { 115 | SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 116 | } 117 | 118 | /** 119 | * @brief Disables the Event Output. 120 | * @retval None 121 | */ 122 | void HAL_GPIOEx_DisableEventout(void) 123 | { 124 | CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 125 | } 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | #endif /* HAL_GPIO_MODULE_ENABLED */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** 142 | * @} 143 | */ 144 | 145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 146 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Source/stm32f1xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Extended PCD HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the USB Peripheral Controller: 10 | * + Extended features functions: Update FIFO configuration, 11 | * PMA configuration for EPs 12 | * 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© COPYRIGHT(c) 2015 STMicroelectronics

17 | * 18 | * Redistribution and use in source and binary forms, with or without modification, 19 | * are permitted provided that the following conditions are met: 20 | * 1. Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * 2. Redistributions in binary form must reproduce the above copyright notice, 23 | * this list of conditions and the following disclaimer in the documentation 24 | * and/or other materials provided with the distribution. 25 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************** 41 | */ 42 | 43 | /* Includes ------------------------------------------------------------------*/ 44 | #include "stm32f1xx_hal.h" 45 | 46 | /** @addtogroup STM32F1xx_HAL_Driver 47 | * @{ 48 | */ 49 | 50 | #ifdef HAL_PCD_MODULE_ENABLED 51 | 52 | #if defined(STM32F102x6) || defined(STM32F102xB) || \ 53 | defined(STM32F103x6) || defined(STM32F103xB) || \ 54 | defined(STM32F103xE) || defined(STM32F103xG) || \ 55 | defined(STM32F105xC) || defined(STM32F107xC) 56 | 57 | 58 | /** @defgroup PCDEx PCDEx 59 | * @brief PCD Extended HAL module driver 60 | * @{ 61 | */ 62 | 63 | 64 | /* Private types -------------------------------------------------------------*/ 65 | /* Private variables ---------------------------------------------------------*/ 66 | /* Private constants ---------------------------------------------------------*/ 67 | /* Private macros ------------------------------------------------------------*/ 68 | /* Private functions ---------------------------------------------------------*/ 69 | /* Exported functions --------------------------------------------------------*/ 70 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 71 | * @{ 72 | */ 73 | 74 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 75 | * @brief PCDEx control functions 76 | * 77 | @verbatim 78 | =============================================================================== 79 | ##### Extended Peripheral Control functions ##### 80 | =============================================================================== 81 | [..] This section provides functions allowing to: 82 | (+) Update FIFO (USB_OTG_FS) 83 | (+) Update PMA configuration (USB) 84 | 85 | @endverbatim 86 | * @{ 87 | */ 88 | 89 | #if defined (USB_OTG_FS) 90 | /** 91 | * @brief Set Tx FIFO 92 | * @param hpcd: PCD handle 93 | * @param fifo: The number of Tx fifo 94 | * @param size: Fifo size 95 | * @retval HAL status 96 | */ 97 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) 98 | { 99 | uint8_t index = 0; 100 | uint32_t Tx_Offset = 0; 101 | 102 | /* TXn min size = 16 words. (n : Transmit FIFO index) 103 | When a TxFIFO is not used, the Configuration should be as follows: 104 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) 105 | --> Txm can use the space allocated for Txn. 106 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) 107 | --> Txn should be configured with the minimum space of 16 words 108 | The FIFO is used optimally when used TxFIFOs are allocated in the top 109 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. 110 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */ 111 | 112 | Tx_Offset = hpcd->Instance->GRXFSIZ; 113 | 114 | if(fifo == 0) 115 | { 116 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = (size << 16) | Tx_Offset; 117 | } 118 | else 119 | { 120 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; 121 | for (index = 0; index < (fifo - 1); index++) 122 | { 123 | Tx_Offset += (hpcd->Instance->DIEPTXF[index] >> 16); 124 | } 125 | 126 | /* Multiply Tx_Size by 2 to get higher performance */ 127 | hpcd->Instance->DIEPTXF[fifo - 1] = (size << 16) | Tx_Offset; 128 | 129 | } 130 | 131 | return HAL_OK; 132 | } 133 | 134 | /** 135 | * @brief Set Rx FIFO 136 | * @param hpcd: PCD handle 137 | * @param size: Size of Rx fifo 138 | * @retval HAL status 139 | */ 140 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) 141 | { 142 | hpcd->Instance->GRXFSIZ = size; 143 | return HAL_OK; 144 | } 145 | #endif /* USB_OTG_FS */ 146 | 147 | #if defined (USB) 148 | /** 149 | * @brief Configure PMA for EP 150 | * @param hpcd : Device instance 151 | * @param ep_addr: endpoint address 152 | * @param ep_kind: endpoint Kind 153 | * USB_SNG_BUF: Single Buffer used 154 | * USB_DBL_BUF: Double Buffer used 155 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint 156 | * this parameter is 16-bit value providing the address 157 | * in PMA allocated to endpoint. 158 | * In case of double buffer endpoint this parameter 159 | * is a 32-bit value providing the endpoint buffer 0 address 160 | * in the LSB part of 32-bit value and endpoint buffer 1 address 161 | * in the MSB part of 32-bit value. 162 | * @retval HAL status 163 | */ 164 | 165 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 166 | uint16_t ep_addr, 167 | uint16_t ep_kind, 168 | uint32_t pmaadress) 169 | 170 | { 171 | PCD_EPTypeDef *ep = NULL; 172 | 173 | /* initialize ep structure*/ 174 | if ((0x80 & ep_addr) == 0x80) 175 | { 176 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; 177 | } 178 | else 179 | { 180 | ep = &hpcd->OUT_ep[ep_addr]; 181 | } 182 | 183 | /* Here we check if the endpoint is single or double Buffer*/ 184 | if (ep_kind == PCD_SNG_BUF) 185 | { 186 | /*Single Buffer*/ 187 | ep->doublebuffer = 0; 188 | /*Configure te PMA*/ 189 | ep->pmaadress = (uint16_t)pmaadress; 190 | } 191 | else /*USB_DBL_BUF*/ 192 | { 193 | /*Double Buffer Endpoint*/ 194 | ep->doublebuffer = 1; 195 | /*Configure the PMA*/ 196 | ep->pmaaddr0 = pmaadress & 0xFFFF; 197 | ep->pmaaddr1 = (pmaadress & 0xFFFF0000) >> 16; 198 | } 199 | 200 | return HAL_OK; 201 | } 202 | #endif /* USB */ 203 | /** 204 | * @} 205 | */ 206 | 207 | /** @defgroup PCDEx_Exported_Functions_Group2 Peripheral State functions 208 | * @brief Manage device connection state 209 | * @{ 210 | */ 211 | /** 212 | * @brief Software Device Connection, 213 | * this function is not required by USB OTG FS peripheral, it is used 214 | * only by USB Device FS peripheral. 215 | * @param hpcd: PCD handle 216 | * @param state: connection state (0 : disconnected / 1: connected) 217 | * @retval None 218 | */ 219 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) 220 | { 221 | /* NOTE : This function Should not be modified, when the callback is needed, 222 | the HAL_PCDEx_SetConnectionState could be implemented in the user file 223 | */ 224 | } 225 | /** 226 | * @} 227 | */ 228 | 229 | /** 230 | * @} 231 | */ 232 | 233 | /** 234 | * @} 235 | */ 236 | 237 | #endif /* STM32F102x6 || STM32F102xB || */ 238 | /* STM32F103x6 || STM32F103xB || */ 239 | /* STM32F103xE || STM32F103xG || */ 240 | /* STM32F105xC || STM32F107xC */ 241 | 242 | #endif /* HAL_PCD_MODULE_ENABLED */ 243 | 244 | 245 | /** 246 | * @} 247 | */ 248 | 249 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 250 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCMSIS/Source/stm32f1xx_hal_spi_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_spi_ex.c 4 | * @author MCD Application Team 5 | * @version V1.0.1 6 | * @date 31-July-2015 7 | * @brief Extended SPI HAL module driver. 8 | * 9 | * This file provides firmware functions to manage the following 10 | * functionalities SPI extension peripheral: 11 | * + Extended Peripheral Control functions 12 | * 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© COPYRIGHT(c) 2015 STMicroelectronics

17 | * 18 | * Redistribution and use in source and binary forms, with or without modification, 19 | * are permitted provided that the following conditions are met: 20 | * 1. Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * 2. Redistributions in binary form must reproduce the above copyright notice, 23 | * this list of conditions and the following disclaimer in the documentation 24 | * and/or other materials provided with the distribution. 25 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************** 41 | */ 42 | 43 | /* Includes ------------------------------------------------------------------*/ 44 | #include "stm32f1xx_hal.h" 45 | 46 | /** @addtogroup STM32F1xx_HAL_Driver 47 | * @{ 48 | */ 49 | 50 | /** @addtogroup SPI 51 | * @{ 52 | */ 53 | #ifdef HAL_SPI_MODULE_ENABLED 54 | 55 | /** @defgroup SPI_Private_Variables SPI Private Variables 56 | * @{ 57 | */ 58 | /* Variable used to determine if device is impacted by implementation of workaround 59 | related to wrong CRC errors detection on SPI2. Conditions in which this workaround has to be applied, are: 60 | - STM32F101CDE/STM32F103CDE 61 | - Revision ID : Z 62 | - SPI2 63 | - In receive only mode, with CRC calculation enabled, at the end of the CRC reception, 64 | the software needs to check the CRCERR flag. If it is found set, read back the SPI_RXCRC: 65 | + If the value is 0, the complete data transfer is successful. 66 | + Otherwise, one or more errors have been detected during the data transfer by CPU or DMA. 67 | If CRCERR is found reset, the complete data transfer is considered successful. 68 | */ 69 | uint8_t uCRCErrorWorkaroundCheck = 0; 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /* Private typedef -----------------------------------------------------------*/ 76 | /* Private define ------------------------------------------------------------*/ 77 | /* Private macro -------------------------------------------------------------*/ 78 | /* Private variables ---------------------------------------------------------*/ 79 | /* Private function prototypes -----------------------------------------------*/ 80 | /* Private functions ---------------------------------------------------------*/ 81 | 82 | /** @addtogroup SPI_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | /** @addtogroup SPI_Exported_Functions_Group1 87 | * 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @brief Initializes the SPI according to the specified parameters 93 | * in the SPI_InitTypeDef and create the associated handle. 94 | * @param hspi: pointer to a SPI_HandleTypeDef structure that contains 95 | * the configuration information for SPI module. 96 | * @retval HAL status 97 | */ 98 | HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi) 99 | { 100 | /* Check the SPI handle allocation */ 101 | if(hspi == NULL) 102 | { 103 | return HAL_ERROR; 104 | } 105 | 106 | /* Check the parameters */ 107 | assert_param(IS_SPI_ALL_INSTANCE(hspi->Instance)); 108 | assert_param(IS_SPI_MODE(hspi->Init.Mode)); 109 | assert_param(IS_SPI_DIRECTION_MODE(hspi->Init.Direction)); 110 | assert_param(IS_SPI_DATASIZE(hspi->Init.DataSize)); 111 | assert_param(IS_SPI_CPOL(hspi->Init.CLKPolarity)); 112 | assert_param(IS_SPI_CPHA(hspi->Init.CLKPhase)); 113 | assert_param(IS_SPI_NSS(hspi->Init.NSS)); 114 | assert_param(IS_SPI_BAUDRATE_PRESCALER(hspi->Init.BaudRatePrescaler)); 115 | assert_param(IS_SPI_FIRST_BIT(hspi->Init.FirstBit)); 116 | assert_param(IS_SPI_TIMODE(hspi->Init.TIMode)); 117 | assert_param(IS_SPI_CRC_CALCULATION(hspi->Init.CRCCalculation)); 118 | assert_param(IS_SPI_CRC_POLYNOMIAL(hspi->Init.CRCPolynomial)); 119 | 120 | if(hspi->State == HAL_SPI_STATE_RESET) 121 | { 122 | /* Init the low level hardware : GPIO, CLOCK, NVIC... */ 123 | HAL_SPI_MspInit(hspi); 124 | } 125 | 126 | hspi->State = HAL_SPI_STATE_BUSY; 127 | 128 | /* Disble the selected SPI peripheral */ 129 | __HAL_SPI_DISABLE(hspi); 130 | 131 | /*----------------------- SPIx CR1 & CR2 Configuration ---------------------*/ 132 | /* Configure : SPI Mode, Communication Mode, Data size, Clock polarity and phase, NSS management, 133 | Communication speed, First bit and CRC calculation state */ 134 | WRITE_REG(hspi->Instance->CR1, (hspi->Init.Mode | hspi->Init.Direction | hspi->Init.DataSize | 135 | hspi->Init.CLKPolarity | hspi->Init.CLKPhase | (hspi->Init.NSS & SPI_CR1_SSM) | 136 | hspi->Init.BaudRatePrescaler | hspi->Init.FirstBit | hspi->Init.CRCCalculation) ); 137 | 138 | /* Configure : NSS management */ 139 | WRITE_REG(hspi->Instance->CR2, (((hspi->Init.NSS >> 16) & SPI_CR2_SSOE) | hspi->Init.TIMode)); 140 | 141 | /*---------------------------- SPIx CRCPOLY Configuration ------------------*/ 142 | /* Configure : CRC Polynomial */ 143 | WRITE_REG(hspi->Instance->CRCPR, hspi->Init.CRCPolynomial); 144 | 145 | #if defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC) 146 | /* Activate the SPI mode (Make sure that I2SMOD bit in I2SCFGR register is reset) */ 147 | CLEAR_BIT(hspi->Instance->I2SCFGR, SPI_I2SCFGR_I2SMOD); 148 | #endif 149 | 150 | #if defined (STM32F101xE) || defined (STM32F103xE) 151 | /* Check RevisionID value for identifying if Device is Rev Z (0x0001) in order to enable workaround for 152 | CRC errors wrongly detected */ 153 | /* Pb is that ES_STM32F10xxCDE also identify an issue in Debug registers access while not in Debug mode. 154 | Revision ID information is only available in Debug mode, so Workaround could not be implemented 155 | to distinguish Rev Z devices (issue present) from more recent version (issue fixed). 156 | So, in case of Revison Z F101 or F103 devices, below variable should be assigned to 1 */ 157 | uCRCErrorWorkaroundCheck = 0; 158 | #else 159 | uCRCErrorWorkaroundCheck = 0; 160 | #endif 161 | 162 | hspi->ErrorCode = HAL_SPI_ERROR_NONE; 163 | hspi->State = HAL_SPI_STATE_READY; 164 | 165 | return HAL_OK; 166 | } 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | /** @addtogroup SPI_Private_Functions 177 | * @{ 178 | */ 179 | 180 | /** 181 | * @brief Checks if encountered CRC error could be corresponding to wrongly detected errors 182 | * according to SPI instance, Device type, and revision ID. 183 | * @param hspi: pointer to a SPI_HandleTypeDef structure that contains 184 | * the configuration information for SPI module. 185 | * @retval CRC error validity (SPI_INVALID_CRC_ERROR or SPI_VALID_CRC_ERROR). 186 | */ 187 | uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi) 188 | { 189 | #if defined (STM32F101xE) || defined (STM32F103xE) 190 | /* Check how to handle this CRC error (workaround to be applied or not) */ 191 | /* If CRC errors could be wrongly detected (issue 2.15.2 in STM32F10xxC/D/E silicon limitations ES (DocID14732 Rev 13) */ 192 | if ( (uCRCErrorWorkaroundCheck != 0) && (hspi->Instance == SPI2) ) 193 | { 194 | if (hspi->Instance->RXCRCR == 0) 195 | { 196 | return (SPI_INVALID_CRC_ERROR); 197 | } 198 | } 199 | return (SPI_VALID_CRC_ERROR); 200 | #else 201 | return (SPI_VALID_CRC_ERROR); 202 | #endif 203 | } 204 | /** 205 | * @} 206 | */ 207 | 208 | #endif /* HAL_SPI_MODULE_ENABLED */ 209 | /** 210 | * @} 211 | */ 212 | 213 | /** 214 | * @} 215 | */ 216 | 217 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 218 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32F1xxCommon/syscalls.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//***** 2 | * @file stdio.c 3 | * @brief Implementation of newlib syscall 4 | ********************************************************************************/ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /***************************************************************************/ 12 | 13 | int _read_r(struct _reent *r, int file, char * ptr, int len) 14 | { 15 | (void)r; 16 | #if defined(STDIN_SD) 17 | if (!len || (file != 0)) { 18 | __errno_r(r) = EINVAL; 19 | return -1; 20 | } 21 | len = sdRead(&STDIN_SD, (uint8_t *)ptr, (size_t)len); 22 | return len; 23 | #else 24 | (void)file; 25 | (void)ptr; 26 | (void)len; 27 | __errno_r(r) = EINVAL; 28 | return -1; 29 | #endif 30 | } 31 | 32 | /***************************************************************************/ 33 | 34 | int _lseek_r(struct _reent *r, int file, int ptr, int dir) 35 | { 36 | (void)r; 37 | (void)file; 38 | (void)ptr; 39 | (void)dir; 40 | 41 | return 0; 42 | } 43 | 44 | /***************************************************************************/ 45 | 46 | int _write_r(struct _reent *r, int file, char * ptr, int len) 47 | { 48 | (void)r; 49 | (void)file; 50 | (void)ptr; 51 | #if defined(STDOUT_SD) 52 | if (file != 1) { 53 | __errno_r(r) = EINVAL; 54 | return -1; 55 | } 56 | sdWrite(&STDOUT_SD, (uint8_t *)ptr, (size_t)len); 57 | #endif 58 | return len; 59 | } 60 | 61 | /***************************************************************************/ 62 | 63 | int _close_r(struct _reent *r, int file) 64 | { 65 | (void)r; 66 | (void)file; 67 | 68 | return 0; 69 | } 70 | 71 | /***************************************************************************/ 72 | 73 | caddr_t _sbrk_r(struct _reent *r, int incr) 74 | { 75 | #if CH_USE_MEMCORE 76 | void *p; 77 | 78 | chDbgCheck(incr > 0, "_sbrk_r"); 79 | 80 | (void)r; 81 | p = chCoreAlloc((size_t)incr); 82 | if (p == NULL) { 83 | __errno_r(r) = ENOMEM; 84 | return (caddr_t) - 1; 85 | } 86 | return (caddr_t)p; 87 | #else 88 | __errno_r(r) = ENOMEM; 89 | return (caddr_t) - 1; 90 | #endif 91 | } 92 | 93 | /***************************************************************************/ 94 | 95 | int _fstat_r(struct _reent *r, int file, struct stat * st) 96 | { 97 | (void)r; 98 | (void)file; 99 | 100 | memset(st, 0, sizeof(*st)); 101 | st->st_mode = S_IFCHR; 102 | return 0; 103 | } 104 | 105 | /***************************************************************************/ 106 | 107 | int _isatty_r(struct _reent *r, int fd) 108 | { 109 | (void)r; 110 | (void)fd; 111 | 112 | return 1; 113 | } 114 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usb_device.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : USB_DEVICE 4 | * @version : v1.0_Cube 5 | * @brief : Header for usb_device file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __usb_device_H 35 | #define __usb_device_H 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "stm32f1xx.h" 42 | #include "stm32f1xx_hal.h" 43 | #include "usbd_def.h" 44 | 45 | extern USBD_HandleTypeDef hUsbDeviceFS; 46 | 47 | /* USB_Device init function */ 48 | 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif /*__usb_device_H */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_conf.h 4 | * @version : v1.0_Cube 5 | * @brief : Header for usbd_conf file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __USBD_CONF__H__ 35 | #define __USBD_CONF__H__ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include 41 | #include 42 | #include 43 | #include "stm32f1xx.h" 44 | #include "stm32f1xx_hal.h" 45 | #include "usbd_def.h" 46 | 47 | /** @addtogroup USBD_OTG_DRIVER 48 | * @{ 49 | */ 50 | 51 | /** @defgroup USBD_CONF 52 | * @brief usb otg low level driver configuration file 53 | * @{ 54 | */ 55 | 56 | /** @defgroup USBD_CONF_Exported_Defines 57 | * @{ 58 | */ 59 | 60 | /*---------- -----------*/ 61 | #define USBD_MAX_NUM_INTERFACES 1 62 | /*---------- -----------*/ 63 | #define USBD_MAX_NUM_CONFIGURATION 1 64 | /*---------- -----------*/ 65 | #define USBD_MAX_STR_DESC_SIZ 512 66 | /*---------- -----------*/ 67 | #define USBD_SUPPORT_USER_STRING 0 68 | /*---------- -----------*/ 69 | #define USBD_DEBUG_LEVEL 0 70 | /*---------- -----------*/ 71 | #define USBD_SELF_POWERED 1 72 | /*---------- -----------*/ 73 | #define USBD_CDC_INTERVAL 1000 74 | /*---------- -----------*/ 75 | #define MAX_STATIC_ALLOC_SIZE 512 76 | /****************************************/ 77 | /* #define for FS and HS identification */ 78 | #define DEVICE_FS 0 79 | 80 | /** @defgroup USBD_Exported_Macros 81 | * @{ 82 | */ 83 | 84 | /* Memory management macros */ 85 | #define USBD_malloc (uint32_t *)USBD_static_malloc 86 | #define USBD_free USBD_static_free 87 | #define USBD_memset /* Not used */ 88 | #define USBD_memcpy /* Not used */ 89 | 90 | #define USBD_Delay HAL_Delay 91 | 92 | /* For footprint reasons and since only one allocation is handled in the HID class 93 | driver, the malloc/free is changed into a static allocation method */ 94 | void *USBD_static_malloc(uint32_t size); 95 | void USBD_static_free(void *p); 96 | 97 | /* DEBUG macros */ 98 | #if (USBD_DEBUG_LEVEL > 0) 99 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 100 | printf("\n"); 101 | #else 102 | #define USBD_UsrLog(...) 103 | #endif 104 | 105 | 106 | #if (USBD_DEBUG_LEVEL > 1) 107 | 108 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 109 | printf(__VA_ARGS__);\ 110 | printf("\n"); 111 | #else 112 | #define USBD_ErrLog(...) 113 | #endif 114 | 115 | 116 | #if (USBD_DEBUG_LEVEL > 2) 117 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 118 | printf(__VA_ARGS__);\ 119 | printf("\n"); 120 | #else 121 | #define USBD_DbgLog(...) 122 | #endif 123 | 124 | /** 125 | * @} 126 | */ 127 | 128 | 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** @defgroup USBD_CONF_Exported_Types 135 | * @{ 136 | */ 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USBD_CONF_Exported_Macros 142 | * @{ 143 | */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** @defgroup USBD_CONF_Exported_Variables 149 | * @{ 150 | */ 151 | /** 152 | * @} 153 | */ 154 | 155 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype 156 | * @{ 157 | */ 158 | /** 159 | * @} 160 | */ 161 | #ifdef __cplusplus 162 | } 163 | #endif 164 | 165 | #endif //__USBD_CONF__H__ 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | /** 172 | * @} 173 | */ 174 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 175 | 176 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for usbd_core.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 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 __USBD_CORE_H 30 | #define __USBD_CORE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_conf.h" 38 | #include "usbd_def.h" 39 | #include "usbd_ioreq.h" 40 | #include "usbd_ctlreq.h" 41 | 42 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CORE 47 | * @brief This file is the Header file for usbd_core.c file 48 | * @{ 49 | */ 50 | 51 | 52 | /** @defgroup USBD_CORE_Exported_Defines 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | 71 | 72 | /** @defgroup USBD_CORE_Exported_Macros 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_CORE_Exported_Variables 81 | * @{ 82 | */ 83 | #define USBD_SOF USBD_LL_SOF 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 89 | * @{ 90 | */ 91 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 92 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 93 | USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev); 94 | USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev); 95 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 96 | 97 | USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev); 98 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 99 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 100 | 101 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 102 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 103 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 104 | 105 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 106 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 107 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 108 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 109 | 110 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 111 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 112 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 113 | 114 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 116 | 117 | /* USBD Low Level Driver */ 118 | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev); 119 | USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev); 120 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 121 | USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev); 122 | USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev, 123 | uint8_t ep_addr, 124 | uint8_t ep_type, 125 | uint16_t ep_mps); 126 | 127 | USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 128 | USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 129 | USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 130 | USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 131 | uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 132 | USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr); 133 | USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev, 134 | uint8_t ep_addr, 135 | uint8_t *pbuf, 136 | uint16_t size); 137 | 138 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 139 | uint8_t ep_addr, 140 | uint8_t *pbuf, 141 | uint16_t size); 142 | 143 | uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 144 | void USBD_LL_Delay (uint32_t Delay); 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | 154 | #endif /* __USBD_CORE_H */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | 164 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 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_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_desc.h 4 | * @version : v1.0_Cube 5 | * @brief : Header for usbd_desc file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __USBD_DESC__H__ 36 | #define __USBD_DESC__H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "usbd_def.h" 43 | 44 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USB_DESC 49 | * @brief general defines for the usb device library file 50 | * @{ 51 | */ 52 | 53 | /** @defgroup USB_DESC_Exported_Defines 54 | * @{ 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** @defgroup USBD_DESC_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_DESC_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_DESC_Exported_Variables 76 | * @{ 77 | */ 78 | extern USBD_DescriptorsTypeDef FS_Desc; 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __USBD_DESC_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 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 __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_midi.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_midi.h 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief header file for the usbd_midi.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 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_MIDI_H 30 | #define __USB_MIDI_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_ioreq.h" 38 | #include "usbd_def.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup usbd_cdc 45 | * @brief This file is the Header file for usbd_midi.c 46 | * @{ 47 | */ 48 | 49 | 50 | /** @defgroup usbd_midi_Exported_Defines 51 | * @{ 52 | */ 53 | 54 | // Configuration descriptor: bmAttributes 55 | #define USB_DSC_CNFG_ATR_BASE 0x80 // D7: base attribute, always 1 56 | #define USB_DSC_CNFG_ATR_SELF_POWERED 0x40 // D6: bus-powered: 0, self-powered: 1, both: 1 57 | #define USB_DSC_CNFG_ATR_BUS_POWERED 0x00 58 | #define USB_DSC_CNFG_ATR_REMOTEWAKEUP 0x20 // D5: remote-wakeup disabled: 0, enabled: 1 59 | 60 | // Configuration descriptor: bMaxPower 61 | #define USB_DSC_CNFG_MAXPOWER( x ) (((x) + 1) / 2) // 1 unit = 2mA 62 | 63 | // allowed numbers: 1..8 64 | #ifndef USB_MIDI_NUM_PORTS 65 | #define USB_MIDI_NUM_PORTS 1 66 | #endif 67 | 68 | // size of IN/OUT pipe (FS configuration) 69 | #ifndef USB_MIDI_DATA_FS_IN_SIZE 70 | #define USB_MIDI_DATA_FS_IN_SIZE 64 71 | #endif 72 | #ifndef USB_MIDI_DATA_FS_OUT_SIZE 73 | #define USB_MIDI_DATA_FS_OUT_SIZE 64 74 | #endif 75 | // size of IN/OUT pipe (HS configuration) 76 | #ifndef USB_MIDI_DATA_HS_IN_SIZE 77 | #define USB_MIDI_DATA_HS_IN_SIZE 64 78 | #endif 79 | #ifndef USB_MIDI_DATA_HS_OUT_SIZE 80 | #define USB_MIDI_DATA_HS_OUT_SIZE 64 81 | #endif 82 | 83 | // endpoint assignments (don't change!) 84 | #define USB_MIDI_DATA_OUT_EP 0x01 85 | #define USB_MIDI_DATA_IN_EP 0x81 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | 92 | 93 | /** @defgroup USBD_CORE_Exported_Variables 94 | * @{ 95 | */ 96 | 97 | typedef struct 98 | { 99 | int8_t(*Init)(void); 100 | int8_t(*DeInit)(void); 101 | int8_t(*Receive)(uint8_t *, uint32_t *); 102 | 103 | } USBD_MIDI_ItfTypeDef; 104 | 105 | typedef struct 106 | { 107 | uint8_t *RxBuffer; 108 | uint8_t *TxBuffer; 109 | uint32_t RxLength; 110 | uint32_t TxLength; 111 | 112 | __IO uint32_t TxState; 113 | __IO uint32_t RxState; 114 | } USBD_MIDI_HandleTypeDef; 115 | 116 | extern USBD_ClassTypeDef USBD_MIDI; 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup USB_CORE_Exported_Functions 123 | * @{ 124 | */ 125 | uint8_t USBD_MIDI_RegisterInterface(USBD_HandleTypeDef *pdev, 126 | USBD_MIDI_ItfTypeDef *fops); 127 | 128 | uint8_t USBD_MIDI_SetTxBuffer(USBD_HandleTypeDef *pdev, 129 | uint8_t *pbuff, 130 | uint16_t length); 131 | 132 | uint8_t USBD_MIDI_SetRxBuffer(USBD_HandleTypeDef *pdev, 133 | uint8_t *pbuff); 134 | 135 | uint8_t USBD_MIDI_TransmitPacket(USBD_HandleTypeDef *pdev); 136 | 137 | uint8_t USBD_MIDI_ReceivePacket(USBD_HandleTypeDef *pdev); 138 | 139 | uint8_t USBD_MIDI_IsTransmitterBusy(USBD_HandleTypeDef *pdev); 140 | uint8_t USBD_MIDI_IsReceiverBusy(USBD_HandleTypeDef *pdev); 141 | /** 142 | * @} 143 | */ 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif /* __USB_MIDI_H */ 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 159 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Include/usbd_midi_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_cdc_if.h 4 | * @brief : Header for usbd_cdc_if file. 5 | ****************************************************************************** 6 | * COPYRIGHT(c) 2017 STMicroelectronics 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | ****************************************************************************** 31 | */ 32 | 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __USBD_MIDI_IF_H 35 | #define __USBD_MIDI_IF_H 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "usbd_midi.h" 42 | /* USER CODE BEGIN INCLUDE */ 43 | /* USER CODE END INCLUDE */ 44 | 45 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_MIDI_IF 50 | * @brief header 51 | * @{ 52 | */ 53 | 54 | typedef enum { 55 | NoteOff = 0x8, 56 | NoteOn = 0x9, 57 | PolyPressure = 0xa, 58 | CC = 0xb, 59 | ProgramChange = 0xc, 60 | Aftertouch = 0xd, 61 | PitchBend = 0xe 62 | } midi_event_t; 63 | 64 | 65 | typedef union { 66 | struct { 67 | uint32_t ALL; 68 | }; 69 | struct { 70 | uint8_t cin_cable; 71 | uint8_t evnt0; 72 | uint8_t evnt1; 73 | uint8_t evnt2; 74 | }; 75 | struct { 76 | uint8_t type : 4; 77 | uint8_t cable : 4; 78 | uint8_t chn : 4; 79 | uint8_t event : 4; 80 | uint8_t value1; 81 | uint8_t value2; 82 | }; 83 | struct { 84 | uint8_t cin : 4; 85 | uint8_t dummy1_cable : 4; 86 | uint8_t dummy1_chn : 4; 87 | uint8_t dummy1_event : 4; 88 | uint8_t note : 8; 89 | uint8_t velocity : 8; 90 | }; 91 | struct { 92 | uint8_t dummy2_cin : 4; 93 | uint8_t dummy2_cable : 4; 94 | uint8_t dummy2_chn : 4; 95 | uint8_t dummy2_event : 4; 96 | uint8_t cc_number : 8; 97 | uint8_t value : 8; 98 | }; 99 | } midi_package_t; 100 | 101 | 102 | /** @defgroup USBD_MIDI_IF_Exported_Types 103 | * @{ 104 | */ 105 | /* USER CODE BEGIN EXPORTED_TYPES */ 106 | /* USER CODE END EXPORTED_TYPES */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup USBD_CDC_IF_Exported_Macros 113 | * @{ 114 | */ 115 | /* USER CODE BEGIN EXPORTED_MACRO */ 116 | /* USER CODE END EXPORTED_MACRO */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup USBD_AUDIO_IF_Exported_Variables 123 | * @{ 124 | */ 125 | //extern USBD_MIDI_ItfTypeDef USBD_Interface_fops_FS; 126 | 127 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 128 | /* USER CODE END EXPORTED_VARIABLES */ 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** @defgroup USBD_MIDI_IF_Exported_FunctionsPrototype 135 | * @{ 136 | */ 137 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 138 | 139 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 140 | /* USER CODE END EXPORTED_FUNCTIONS */ 141 | /** 142 | * @} 143 | */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | #ifdef __cplusplus 154 | } 155 | #endif 156 | 157 | #endif /* __USBD_CDC_IF_H */ 158 | 159 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 160 | -------------------------------------------------------------------------------- /usb_synth/LibOS/STM32f1xxUSB/Source/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @version V2.4.1 6 | * @date 19-June-2015 7 | * @brief This file provides the IO requests APIs for control endpoints. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 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 "usbd_ioreq.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | 36 | /** @defgroup USBD_IOREQ 37 | * @brief control I/O requests module 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Private_Defines 50 | * @{ 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USBD_IOREQ_Private_Variables 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | 83 | /** @defgroup USBD_IOREQ_Private_Functions 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @brief USBD_CtlSendData 89 | * send data on the ctl pipe 90 | * @param pdev: device instance 91 | * @param buff: pointer to data buffer 92 | * @param len: length of data to be sent 93 | * @retval status 94 | */ 95 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 96 | uint8_t *pbuf, 97 | uint16_t len) 98 | { 99 | /* Set EP0 State */ 100 | pdev->ep0_state = USBD_EP0_DATA_IN; 101 | pdev->ep_in[0].total_length = len; 102 | pdev->ep_in[0].rem_length = len; 103 | /* Start the transfer */ 104 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); 105 | 106 | return USBD_OK; 107 | } 108 | 109 | /** 110 | * @brief USBD_CtlContinueSendData 111 | * continue sending data on the ctl pipe 112 | * @param pdev: device instance 113 | * @param buff: pointer to data buffer 114 | * @param len: length of data to be sent 115 | * @retval status 116 | */ 117 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 118 | uint8_t *pbuf, 119 | uint16_t len) 120 | { 121 | /* Start the next transfer */ 122 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); 123 | 124 | return USBD_OK; 125 | } 126 | 127 | /** 128 | * @brief USBD_CtlPrepareRx 129 | * receive data on the ctl pipe 130 | * @param pdev: device instance 131 | * @param buff: pointer to data buffer 132 | * @param len: length of data to be received 133 | * @retval status 134 | */ 135 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 136 | uint8_t *pbuf, 137 | uint16_t len) 138 | { 139 | /* Set EP0 State */ 140 | pdev->ep0_state = USBD_EP0_DATA_OUT; 141 | pdev->ep_out[0].total_length = len; 142 | pdev->ep_out[0].rem_length = len; 143 | /* Start the transfer */ 144 | USBD_LL_PrepareReceive (pdev, 145 | 0, 146 | pbuf, 147 | len); 148 | 149 | return USBD_OK; 150 | } 151 | 152 | /** 153 | * @brief USBD_CtlContinueRx 154 | * continue receive data on the ctl pipe 155 | * @param pdev: device instance 156 | * @param buff: pointer to data buffer 157 | * @param len: length of data to be received 158 | * @retval status 159 | */ 160 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 161 | uint8_t *pbuf, 162 | uint16_t len) 163 | { 164 | 165 | USBD_LL_PrepareReceive (pdev, 166 | 0, 167 | pbuf, 168 | len); 169 | return USBD_OK; 170 | } 171 | /** 172 | * @brief USBD_CtlSendStatus 173 | * send zero lzngth packet on the ctl pipe 174 | * @param pdev: device instance 175 | * @retval status 176 | */ 177 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev) 178 | { 179 | 180 | /* Set EP0 State */ 181 | pdev->ep0_state = USBD_EP0_STATUS_IN; 182 | 183 | /* Start the transfer */ 184 | USBD_LL_Transmit (pdev, 0x00, NULL, 0); 185 | 186 | return USBD_OK; 187 | } 188 | 189 | /** 190 | * @brief USBD_CtlReceiveStatus 191 | * receive zero lzngth packet on the ctl pipe 192 | * @param pdev: device instance 193 | * @retval status 194 | */ 195 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev) 196 | { 197 | /* Set EP0 State */ 198 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 199 | 200 | /* Start the transfer */ 201 | USBD_LL_PrepareReceive ( pdev, 202 | 0, 203 | NULL, 204 | 0); 205 | 206 | return USBD_OK; 207 | } 208 | 209 | 210 | /** 211 | * @brief USBD_GetRxCount 212 | * returns the received data length 213 | * @param pdev: device instance 214 | * @param ep_addr: endpoint address 215 | * @retval Rx Data blength 216 | */ 217 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , uint8_t ep_addr) 218 | { 219 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 220 | } 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | 227 | /** 228 | * @} 229 | */ 230 | 231 | 232 | /** 233 | * @} 234 | */ 235 | 236 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 237 | -------------------------------------------------------------------------------- /usb_synth/LibOS/Source/sysHelpers.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* Collection of various system helper functions */ 3 | /* */ 4 | /* Copyright (C) 2017 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | /*****************************************************************************/ 12 | /* Includes */ 13 | /*****************************************************************************/ 14 | #include 15 | 16 | /////////////////////////////////////////////////////////////////////////////// 17 | /// @brief Fills the given memory region with zeros 18 | /// @param in_destination memory address to fill with zeros 19 | /// @param in_size Number of bytes to fill 20 | void sysMemZero(void* in_destination, size_t in_size) 21 | { 22 | memset(in_destination, 0, in_size); 23 | } 24 | 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /// @brief Copies the given memory region 27 | /// @param in_destination Address where the memory if copied to 28 | /// @param in_source Address copy memory content from 29 | /// @param in_size Number of bytes to copy 30 | void sysMemCopy(void* in_destination, void* in_source, size_t in_size) 31 | { 32 | memcpy(in_destination, in_source, in_size); 33 | } -------------------------------------------------------------------------------- /usb_synth/LibOS/Source/sysTimer.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* System timer (1ms) routines */ 3 | /* */ 4 | /* Copyright (C) 2014-2015 Laszlo Arvai */ 5 | /* All rights reserved. */ 6 | /* */ 7 | /* This software may be modified and distributed under the terms */ 8 | /* of the GNU General Public License. See the LICENSE file for details. */ 9 | /*****************************************************************************/ 10 | 11 | /*****************************************************************************/ 12 | /* Includes */ 13 | /*****************************************************************************/ 14 | #include 15 | 16 | /*****************************************************************************/ 17 | /* Function implementation */ 18 | /*****************************************************************************/ 19 | 20 | /////////////////////////////////////////////////////////////////////////////// 21 | /// @brief Initializes system timer 22 | void sysTimerInitialize(void) 23 | { 24 | halSystemTimerInitialize(); 25 | } 26 | 27 | /////////////////////////////////////////////////////////////////////////////// 28 | /// @brief Busy wait for the given time (in ms) 29 | void sysTimerDelay(sysTick in_delay_ms) 30 | { 31 | sysTick start_time = sysTimerGetTimestamp(); 32 | sysTick diff_time; 33 | 34 | do 35 | { 36 | diff_time = sysTimerGetTimestamp() - start_time; 37 | } while( diff_time < in_delay_ms ); 38 | } 39 | 40 | /////////////////////////////////////////////////////////////////////////////// 41 | /// @brief Gets elapsed time since a timestamp (in ms) 42 | /// @param in_start_time_ms Time from the elapsed time is calculated 43 | /// @return Elapsed time since the given timestamp 44 | sysTick sysTimerGetTimeSince(sysTick in_start_time_ms) 45 | { 46 | sysTick diff_time; 47 | 48 | diff_time = sysTimerGetTimestamp() - in_start_time_ms; 49 | 50 | return diff_time; 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /usb_synth/MIDI_USB_Synth.comarker: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /usb_synth/MIDI_USB_Synth/Debug/bin/MIDIUSB.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/MIDI_USB_Synth/Debug/bin/MIDIUSB.bin -------------------------------------------------------------------------------- /usb_synth/MIDI_USB_Synth/Debug/bin/MIDIUSB.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/MIDI_USB_Synth/Debug/bin/MIDIUSB.elf -------------------------------------------------------------------------------- /usb_synth/MIDI_USB_Synth/Debug/bin/history.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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /usb_synth/README.md: -------------------------------------------------------------------------------- 1 | # MIDIUSB - Firmware files 2 | MIDI to USB converter cable using STM32F103 microcontroller. This folder contains the source code needed to compile the firmware using CooCox IDE. 3 | 4 | If you want to produce more than one unit, the USB serial number needs to be changed, so the host computer can distinguish between different instances. The serial number is located in the usbd_midi_desc.c file. Please see the USBD_SERIALNUMBER_STRING_FS define. 5 | -------------------------------------------------------------------------------- /usb_synth/Source/appMain.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theawsomeavr/stm32-Synth/c21e5e1ccb606bb21fc35bde6367c7043b7902fc/usb_synth/Source/appMain.c -------------------------------------------------------------------------------- /usb_synth/link.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") 2 | /* Internal Memory Map*/ 3 | MEMORY 4 | { 5 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x00020000 6 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00005000 7 | } 8 | 9 | _eram = 0x20000000 + 0x00005000; 10 | SECTIONS 11 | { 12 | .text : 13 | { 14 | KEEP(*(.isr_vector)) 15 | *(.text*) 16 | 17 | KEEP(*(.init)) 18 | KEEP(*(.fini)) 19 | 20 | /* .ctors */ 21 | *crtbegin.o(.ctors) 22 | *crtbegin?.o(.ctors) 23 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) 24 | *(SORT(.ctors.*)) 25 | *(.ctors) 26 | 27 | /* .dtors */ 28 | *crtbegin.o(.dtors) 29 | *crtbegin?.o(.dtors) 30 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) 31 | *(SORT(.dtors.*)) 32 | *(.dtors) 33 | 34 | *(.rodata*) 35 | 36 | KEEP(*(.eh_fram e*)) 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 | __etext = .; 51 | 52 | /* _sidata is used in coide startup code */ 53 | _sidata = __etext; 54 | 55 | .data : AT (__etext) 56 | { 57 | __data_start__ = .; 58 | 59 | /* _sdata is used in coide startup code */ 60 | _sdata = __data_start__; 61 | 62 | *(vtable) 63 | *(.data*) 64 | 65 | . = ALIGN(4); 66 | /* preinit data */ 67 | PROVIDE_HIDDEN (__preinit_array_start = .); 68 | KEEP(*(.preinit_array)) 69 | PROVIDE_HIDDEN (__preinit_array_end = .); 70 | 71 | . = ALIGN(4); 72 | /* init data */ 73 | PROVIDE_HIDDEN (__init_array_start = .); 74 | KEEP(*(SORT(.init_array.*))) 75 | KEEP(*(.init_array)) 76 | PROVIDE_HIDDEN (__init_array_end = .); 77 | 78 | . = ALIGN(4); 79 | /* finit data */ 80 | PROVIDE_HIDDEN (__fini_array_start = .); 81 | KEEP(*(SORT(.fini_array.*))) 82 | KEEP(*(.fini_array)) 83 | PROVIDE_HIDDEN (__fini_array_end = .); 84 | 85 | KEEP(*(.jcr*)) 86 | . = ALIGN(4); 87 | /* All data end */ 88 | __data_end__ = .; 89 | 90 | /* _edata is used in coide startup code */ 91 | _edata = __data_end__; 92 | } > ram 93 | 94 | .bss : 95 | { 96 | . = ALIGN(4); 97 | __bss_start__ = .; 98 | _sbss = __bss_start__; 99 | *(.bss*) 100 | *(COMMON) 101 | . = ALIGN(4); 102 | __bss_end__ = .; 103 | _ebss = __bss_end__; 104 | } > ram 105 | 106 | .heap (COPY): 107 | { 108 | __end__ = .; 109 | _end = __end__; 110 | end = __end__; 111 | *(.heap*) 112 | __HeapLimit = .; 113 | } > ram 114 | 115 | /* .stack_dummy section doesn't contains any symbols. It is only 116 | * used for linker to calculate size of stack sections, and assign 117 | * values to stack symbols later */ 118 | .co_stack (NOLOAD): 119 | { 120 | . = ALIGN(8); 121 | *(.co_stack .co_stack.*) 122 | } > ram 123 | 124 | /* Set stack top to end of ram , and stack limit move down by 125 | * size of stack_dummy section */ 126 | __StackTop = ORIGIN(ram ) + LENGTH(ram ); 127 | __StackLimit = __StackTop - SIZEOF(.co_stack); 128 | PROVIDE(__stack = __StackTop); 129 | 130 | /* Check if data + heap + stack exceeds ram limit */ 131 | ASSERT(__StackLimit >= __HeapLimit, "region ram overflowed with stack") 132 | } --------------------------------------------------------------------------------