├── .gitignore
├── Makefile
├── README.md
├── inc
├── main.h
├── stm32f4xx_conf.h
├── stm32f4xx_it.h
├── usb_conf.h
├── usbd_cdc_vcp.h
├── usbd_conf.h
└── usbd_midi_user.h
├── lib
├── Conf
│ ├── ffconf.h
│ ├── usb_conf.h
│ ├── usbd_conf.h
│ ├── usbd_desc.h
│ └── usbh_conf.h
├── Core
│ ├── cmsis
│ │ ├── arm_common_tables.h
│ │ ├── arm_math.h
│ │ ├── core_cm0.h
│ │ ├── core_cm3.h
│ │ ├── core_cm4.h
│ │ ├── core_cm4_simd.h
│ │ ├── core_cmFunc.h
│ │ └── core_cmInstr.h
│ └── stm32
│ │ ├── stm32f4xx.h
│ │ ├── stm32f4xx_conf_template.h
│ │ └── system_stm32f4xx.h
├── Makefile
├── StdPeriph
│ ├── Makefile
│ ├── inc
│ │ ├── misc.h
│ │ ├── stm32f4xx_adc.h
│ │ ├── stm32f4xx_can.h
│ │ ├── stm32f4xx_crc.h
│ │ ├── stm32f4xx_cryp.h
│ │ ├── stm32f4xx_dac.h
│ │ ├── stm32f4xx_dbgmcu.h
│ │ ├── stm32f4xx_dcmi.h
│ │ ├── stm32f4xx_dma.h
│ │ ├── stm32f4xx_exti.h
│ │ ├── stm32f4xx_flash.h
│ │ ├── stm32f4xx_fsmc.h
│ │ ├── stm32f4xx_gpio.h
│ │ ├── stm32f4xx_hash.h
│ │ ├── stm32f4xx_i2c.h
│ │ ├── stm32f4xx_iwdg.h
│ │ ├── stm32f4xx_pwr.h
│ │ ├── stm32f4xx_rcc.h
│ │ ├── stm32f4xx_rng.h
│ │ ├── stm32f4xx_rtc.h
│ │ ├── stm32f4xx_sdio.h
│ │ ├── stm32f4xx_spi.h
│ │ ├── stm32f4xx_syscfg.h
│ │ ├── stm32f4xx_tim.h
│ │ ├── stm32f4xx_usart.h
│ │ └── stm32f4xx_wwdg.h
│ └── src
│ │ ├── misc.c
│ │ ├── stm32f4xx_adc.c
│ │ ├── stm32f4xx_can.c
│ │ ├── stm32f4xx_crc.c
│ │ ├── stm32f4xx_cryp.c
│ │ ├── stm32f4xx_cryp_aes.c
│ │ ├── stm32f4xx_cryp_des.c
│ │ ├── stm32f4xx_cryp_tdes.c
│ │ ├── stm32f4xx_dac.c
│ │ ├── stm32f4xx_dbgmcu.c
│ │ ├── stm32f4xx_dcmi.c
│ │ ├── stm32f4xx_dma.c
│ │ ├── stm32f4xx_exti.c
│ │ ├── stm32f4xx_flash.c
│ │ ├── stm32f4xx_fsmc.c
│ │ ├── stm32f4xx_gpio.c
│ │ ├── stm32f4xx_hash.c
│ │ ├── stm32f4xx_hash_md5.c
│ │ ├── stm32f4xx_hash_sha1.c
│ │ ├── stm32f4xx_i2c.c
│ │ ├── stm32f4xx_iwdg.c
│ │ ├── stm32f4xx_pwr.c
│ │ ├── stm32f4xx_rcc.c
│ │ ├── stm32f4xx_rng.c
│ │ ├── stm32f4xx_rtc.c
│ │ ├── stm32f4xx_sdio.c
│ │ ├── stm32f4xx_spi.c
│ │ ├── stm32f4xx_syscfg.c
│ │ ├── stm32f4xx_tim.c
│ │ ├── stm32f4xx_usart.c
│ │ └── stm32f4xx_wwdg.c
├── USB_Device
│ ├── Class
│ │ ├── audio
│ │ │ ├── inc
│ │ │ │ ├── usbd_audio_core.h
│ │ │ │ └── usbd_audio_out_if.h
│ │ │ └── src
│ │ │ │ ├── usbd_audio_core.c
│ │ │ │ └── usbd_audio_out_if.c
│ │ ├── cdc
│ │ │ ├── Makefile
│ │ │ ├── inc
│ │ │ │ ├── usbd_cdc_core.h
│ │ │ │ └── usbd_cdc_if_template.h
│ │ │ └── src
│ │ │ │ ├── usbd_cdc_core.c
│ │ │ │ └── usbd_cdc_if_template.c
│ │ ├── dfu
│ │ │ ├── inc
│ │ │ │ ├── usbd_dfu_core.h
│ │ │ │ ├── usbd_dfu_mal.h
│ │ │ │ ├── usbd_flash_if.h
│ │ │ │ ├── usbd_mem_if_template.h
│ │ │ │ └── usbd_otp_if.h
│ │ │ └── src
│ │ │ │ ├── usbd_dfu_core.c
│ │ │ │ ├── usbd_dfu_mal.c
│ │ │ │ ├── usbd_flash_if.c
│ │ │ │ ├── usbd_mem_if_template.c
│ │ │ │ └── usbd_otp_if.c
│ │ ├── hid
│ │ │ ├── inc
│ │ │ │ └── usbd_hid_core.h
│ │ │ └── src
│ │ │ │ └── usbd_hid_core.c
│ │ ├── midi
│ │ │ ├── Makefile
│ │ │ ├── inc
│ │ │ │ └── usbd_midi_core.h
│ │ │ ├── libusbdevmidi.a
│ │ │ ├── src
│ │ │ │ └── usbd_midi_core.c
│ │ │ └── usbd_midi_core.o
│ │ └── msc
│ │ │ ├── inc
│ │ │ ├── usbd_msc_bot.h
│ │ │ ├── usbd_msc_core.h
│ │ │ ├── usbd_msc_data.h
│ │ │ ├── usbd_msc_mem.h
│ │ │ └── usbd_msc_scsi.h
│ │ │ └── src
│ │ │ ├── usbd_msc_bot.c
│ │ │ ├── usbd_msc_core.c
│ │ │ ├── usbd_msc_data.c
│ │ │ ├── usbd_msc_scsi.c
│ │ │ └── usbd_storage_template.c
│ └── Core
│ │ ├── Makefile
│ │ ├── inc
│ │ ├── usbd_conf_template.h
│ │ ├── usbd_core.h
│ │ ├── usbd_def.h
│ │ ├── usbd_ioreq.h
│ │ ├── usbd_req.h
│ │ └── usbd_usr.h
│ │ └── src
│ │ ├── usbd_core.c
│ │ ├── usbd_ioreq.c
│ │ └── usbd_req.c
├── USB_Host
│ ├── Class
│ │ ├── HID
│ │ │ ├── inc
│ │ │ │ ├── usbh_hid_core.h
│ │ │ │ ├── usbh_hid_keybd.h
│ │ │ │ └── usbh_hid_mouse.h
│ │ │ └── src
│ │ │ │ ├── usbh_hid_core.c
│ │ │ │ ├── usbh_hid_keybd.c
│ │ │ │ └── usbh_hid_mouse.c
│ │ └── MSC
│ │ │ ├── Makefile
│ │ │ ├── inc
│ │ │ ├── usbh_msc_bot.h
│ │ │ ├── usbh_msc_core.h
│ │ │ └── usbh_msc_scsi.h
│ │ │ └── src
│ │ │ ├── usbh_msc_bot.c
│ │ │ ├── usbh_msc_core.c
│ │ │ ├── usbh_msc_fatfs.c
│ │ │ └── usbh_msc_scsi.c
│ └── Core
│ │ ├── Makefile
│ │ ├── inc
│ │ ├── usbh_conf_template.h
│ │ ├── usbh_core.h
│ │ ├── usbh_def.h
│ │ ├── usbh_hcs.h
│ │ ├── usbh_ioreq.h
│ │ └── usbh_stdreq.h
│ │ └── src
│ │ ├── usbh_core.c
│ │ ├── usbh_hcs.c
│ │ ├── usbh_ioreq.c
│ │ └── usbh_stdreq.c
├── USB_OTG
│ ├── Makefile
│ ├── inc
│ │ ├── usb_bsp.h
│ │ ├── usb_conf_template.h
│ │ ├── usb_core.h
│ │ ├── usb_dcd.h
│ │ ├── usb_dcd_int.h
│ │ ├── usb_defines.h
│ │ ├── usb_hcd.h
│ │ ├── usb_hcd_int.h
│ │ ├── usb_otg.h
│ │ └── usb_regs.h
│ └── src
│ │ ├── usb_bsp_template.c
│ │ ├── usb_core.c
│ │ ├── usb_dcd.c
│ │ ├── usb_dcd_int.c
│ │ ├── usb_hcd.c
│ │ ├── usb_hcd_int.c
│ │ └── usb_otg.c
├── fat_fs
│ ├── Makefile
│ ├── inc
│ │ ├── diskio.h
│ │ ├── fattime.h
│ │ ├── ff.h
│ │ └── integer.h
│ └── src
│ │ ├── diskio.c
│ │ ├── fattime.c
│ │ ├── ff.c
│ │ └── option
│ │ ├── ccsbcs.c
│ │ └── syncobj.c
└── startup_stm32f4xx.s
├── src
├── main.c
├── stm32f4xx_it.c
├── system_stm32f4xx.c
├── usb_bsp.c
├── usbd_desc.c
├── usbd_midi_user.c
└── usbd_usr.c
└── stm32_flash.ld
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Sources
2 |
3 | SRCS = main.c stm32f4xx_it.c system_stm32f4xx.c
4 |
5 | # USB
6 | SRCS += usbd_usr.c usbd_desc.c usb_bsp.c
7 | SRCS += usbd_midi_user.c
8 |
9 | # Project name
10 |
11 | PROJ_NAME=stm32f4_usb_midi
12 | OUTPATH=build
13 |
14 | ###################################################
15 |
16 | # Check for valid float argument
17 | # NOTE that you have to run make clan after
18 | # changing these as hardfloat and softfloat are not
19 | # binary compatible
20 | ifneq ($(FLOAT_TYPE), hard)
21 | ifneq ($(FLOAT_TYPE), soft)
22 | override FLOAT_TYPE = hard
23 | #override FLOAT_TYPE = soft
24 | endif
25 | endif
26 |
27 | ###################################################
28 |
29 | BINPATH=~/sat/bin
30 | CC=$(BINPATH)/arm-none-eabi-gcc
31 | OBJCOPY=$(BINPATH)/arm-none-eabi-objcopy
32 | SIZE=$(BINPATH)/arm-none-eabi-size
33 |
34 | CFLAGS = -std=gnu99 -g -O2 -Wall -Tstm32_flash.ld
35 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4
36 |
37 | ifeq ($(FLOAT_TYPE), hard)
38 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion -DUSE_MIDI
39 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
40 | else
41 | CFLAGS += -msoft-float
42 | endif
43 |
44 | ###################################################
45 |
46 | vpath %.c src
47 | vpath %.a lib
48 |
49 | ROOT=$(shell pwd)
50 |
51 | # Includes
52 | CFLAGS += -Iinc -Ilib/Core/cmsis -Ilib/Core/stm32
53 | CFLAGS += -Ilib/Conf
54 |
55 | # Library paths
56 | LIBPATHS = -Llib/StdPeriph -Llib/USB_Device/Core
57 | LIBPATHS += -Llib/USB_OTG -Llib/USB_Device/Class/midi
58 |
59 | # Libraries to link
60 | LIBS = -lm -lstdperiph -lusbdevcore -lusbcore -lusbdevmidi
61 |
62 | # Extra includes
63 | CFLAGS += -Ilib/StdPeriph/inc
64 | CFLAGS += -Ilib/USB_OTG/inc
65 | CFLAGS += -Ilib/USB_Device/Core/inc
66 | CFLAGS += -Ilib/USB_Device/Class/cdc/inc
67 | CFLAGS += -Ilib/USB_Device/Class/midi/inc
68 |
69 | # add startup file to build
70 | SRCS += lib/startup_stm32f4xx.s
71 |
72 | OBJS = $(SRCS:.c=.o)
73 |
74 | ###################################################
75 |
76 | .PHONY: lib proj
77 |
78 | all: lib proj
79 | $(SIZE) $(OUTPATH)/$(PROJ_NAME).elf
80 |
81 | lib:
82 | $(MAKE) -C lib FLOAT_TYPE=$(FLOAT_TYPE)
83 |
84 | proj: $(OUTPATH)/$(PROJ_NAME).elf
85 |
86 | $(OUTPATH)/$(PROJ_NAME).elf: $(SRCS)
87 | $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS)
88 | $(OBJCOPY) -O ihex $(OUTPATH)/$(PROJ_NAME).elf $(OUTPATH)/$(PROJ_NAME).hex
89 | $(OBJCOPY) -O binary $(OUTPATH)/$(PROJ_NAME).elf $(OUTPATH)/$(PROJ_NAME).bin
90 |
91 | clean:
92 | rm -f *.o
93 | rm -f $(OUTPATH)/$(PROJ_NAME).elf
94 | rm -f $(OUTPATH)/$(PROJ_NAME).hex
95 | rm -f $(OUTPATH)/$(PROJ_NAME).bin
96 | $(MAKE) clean -C lib # Remove this line if you don't want to clean the libs as well
97 |
98 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | STM32 USB MIDI
2 | ===============
3 |
4 | This is my usb midi device class for stm32 MCUs. The user interface for the class is located under src/usbd_midi_user.c and /inc/usbd_midi_user.h. The actual class can be found under /lib/USB_Device/Class/midi/src and /lib/USB_Device/Class/midi/inc.
5 |
6 | Compilation
7 | -----------
8 | Download and install the following software for your platform
9 | * The gcc-arm-none-eabi toolchain.
10 | * openOCD.
11 | * st-link (optional)
12 | * The ST firmware - [Download from ST](http://www.st.com/web/en/catalog/tools/PF257904#)
13 | * Specify the folder of the firmware in the Makefile and run make.
14 | * Upload the resuling binary to the board using openOCD or st-link.
15 |
16 | Usage
17 | -----
18 | After programming the MCU it should be detected as a midi device by any standard OS such as Windows, OS X and Linux. If you are using a stm32f4-discovery board the blue button should generate a test note which is sent to the host.
19 |
--------------------------------------------------------------------------------
/inc/main.h:
--------------------------------------------------------------------------------
1 | /*
2 | * main.h
3 | *
4 | * Created on: 10 jul 2012
5 | * Author: BenjaminVe
6 | */
7 |
8 | #ifndef MAIN_H_
9 | #define MAIN_H_
10 |
11 | // Function prototypes
12 | void timing_handler();
13 |
14 | #endif /* MAIN_H_ */
15 |
--------------------------------------------------------------------------------
/inc/stm32f4xx_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_conf.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 19-September-2011
7 | * @brief Library configuration file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | *
© COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM32F4xx_CONF_H
24 | #define __STM32F4xx_CONF_H
25 |
26 | #if defined (HSE_VALUE)
27 | /* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
28 | #undef HSE_VALUE
29 | #define HSE_VALUE ((uint32_t)8000000)
30 | #endif /* HSE_VALUE */
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | /* Uncomment the line below to enable peripheral header file inclusion */
34 | #include "stm32f4xx_adc.h"
35 | #include "stm32f4xx_can.h"
36 | #include "stm32f4xx_crc.h"
37 | #include "stm32f4xx_cryp.h"
38 | #include "stm32f4xx_dac.h"
39 | #include "stm32f4xx_dbgmcu.h"
40 | #include "stm32f4xx_dcmi.h"
41 | #include "stm32f4xx_dma.h"
42 | #include "stm32f4xx_exti.h"
43 | #include "stm32f4xx_flash.h"
44 | #include "stm32f4xx_fsmc.h"
45 | #include "stm32f4xx_hash.h"
46 | #include "stm32f4xx_gpio.h"
47 | #include "stm32f4xx_i2c.h"
48 | #include "stm32f4xx_iwdg.h"
49 | #include "stm32f4xx_pwr.h"
50 | #include "stm32f4xx_rcc.h"
51 | #include "stm32f4xx_rng.h"
52 | #include "stm32f4xx_rtc.h"
53 | #include "stm32f4xx_sdio.h"
54 | #include "stm32f4xx_spi.h"
55 | #include "stm32f4xx_syscfg.h"
56 | #include "stm32f4xx_tim.h"
57 | #include "stm32f4xx_usart.h"
58 | #include "stm32f4xx_wwdg.h"
59 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
60 |
61 | /* Exported types ------------------------------------------------------------*/
62 | /* Exported constants --------------------------------------------------------*/
63 |
64 | /* If an external clock source is used, then the value of the following define
65 | should be set to the value of the external clock source, else, if no external
66 | clock is used, keep this define commented */
67 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
68 |
69 |
70 | /* Uncomment the line below to expanse the "assert_param" macro in the
71 | Standard Peripheral Library drivers code */
72 | /* #define USE_FULL_ASSERT 1 */
73 |
74 | /* Exported macro ------------------------------------------------------------*/
75 | #ifdef USE_FULL_ASSERT
76 |
77 | /**
78 | * @brief The assert_param macro is used for function's parameters check.
79 | * @param expr: If expr is false, it calls assert_failed function
80 | * which reports the name of the source file and the source
81 | * line number of the call that failed.
82 | * If expr is true, it returns no value.
83 | * @retval None
84 | */
85 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
86 | /* Exported functions ------------------------------------------------------- */
87 | void assert_failed(uint8_t* file, uint32_t line);
88 | #else
89 | #define assert_param(expr) ((void)0)
90 | #endif /* USE_FULL_ASSERT */
91 |
92 | #endif /* __STM32F4xx_CONF_H */
93 |
94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
95 |
--------------------------------------------------------------------------------
/inc/stm32f4xx_it.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file GPIO/IOToggle/stm32f4xx_it.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 19-September-2011
7 | * @brief This file contains the headers of the interrupt handlers.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM32F4xx_IT_H
24 | #define __STM32F4xx_IT_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f4xx.h"
32 |
33 | /* Exported types ------------------------------------------------------------*/
34 | /* Exported constants --------------------------------------------------------*/
35 | /* Exported macro ------------------------------------------------------------*/
36 | /* Exported functions ------------------------------------------------------- */
37 |
38 | void NMI_Handler(void);
39 | void HardFault_Handler(void);
40 | void MemManage_Handler(void);
41 | void BusFault_Handler(void);
42 | void UsageFault_Handler(void);
43 | void SVC_Handler(void);
44 | void DebugMon_Handler(void);
45 | void PendSV_Handler(void);
46 | void SysTick_Handler(void);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif /* __STM32F4xx_IT_H */
53 |
54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
55 |
--------------------------------------------------------------------------------
/inc/usbd_cdc_vcp.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_cdc_vcp.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header for usbd_cdc_vcp.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CDC_VCP_H
24 | #define __USBD_CDC_VCP_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm32f4xx_conf.h"
28 |
29 | #include "usbd_cdc_core.h"
30 | #include "usbd_conf.h"
31 | #include
32 |
33 | /* Exported typef ------------------------------------------------------------*/
34 | /* The following structures groups all needed parameters to be configured for the
35 | ComPort. These parameters can modified on the fly by the host through CDC class
36 | command class requests. */
37 | typedef struct
38 | {
39 | uint32_t bitrate;
40 | uint8_t format;
41 | uint8_t paritytype;
42 | uint8_t datatype;
43 | }LINE_CODING;
44 |
45 | /* Exported constants --------------------------------------------------------*/
46 | /* The following define is used to route the USART IRQ handler to be used.
47 | The IRQ handler function is implemented in the usbd_cdc_vcp.c file. */
48 | #ifdef USE_STM322xG_EVAL
49 | #define EVAL_COM_IRQHandler USART3_IRQHandler
50 | #elif defined(USE_STM3210C_EVAL)
51 | #define EVAL_COM_IRQHandler USART2_IRQHandler
52 | #endif /* USE_STM322xG_EVAL */
53 |
54 | void VCP_put_char(uint8_t buf);
55 | void VCP_send_str(uint8_t* buf);
56 | int VCP_get_char(uint8_t *buf);
57 | int VCP_get_string(uint8_t *buf);
58 | void VCP_send_buffer(uint8_t* buf, int len);
59 |
60 | #define DEFAULT_CONFIG 0
61 | #define OTHER_CONFIG 1
62 |
63 | /* Exported macro ------------------------------------------------------------*/
64 | /* Exported functions ------------------------------------------------------- */
65 |
66 | #endif /* __USBD_CDC_VCP_H */
67 |
68 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
69 |
--------------------------------------------------------------------------------
/inc/usbd_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_conf.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief USB Device configuration file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CONF__H__
24 | #define __USBD_CONF__H__
25 |
26 | /** @defgroup USB_CONF_Exported_Defines
27 | * @{
28 | */
29 | #define USBD_CFG_MAX_NUM 1
30 | #define USBD_ITF_MAX_NUM 1
31 | #define USB_MAX_STR_DESC_SIZ 50
32 |
33 | /** @defgroup USB_VCP_Class_Layer_Parameter
34 | * @{
35 | */
36 | #define CDC_IN_EP 0x81 /* EP1 for data IN */
37 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */
38 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */
39 |
40 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
41 | #ifdef USE_USB_OTG_HS
42 | #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */
43 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */
44 |
45 | #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */
46 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer:
47 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */
48 | #else
49 | #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */
50 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */
51 |
52 | #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */
53 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer:
54 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */
55 | #endif /* USE_USB_OTG_HS */
56 |
57 | #define APP_FOPS MIDI_fops
58 | /**
59 | * @}
60 | */
61 |
62 | /** @defgroup USB_CONF_Exported_Types
63 | * @{
64 | */
65 | /**
66 | * @}
67 | */
68 |
69 |
70 | /** @defgroup USB_CONF_Exported_Macros
71 | * @{
72 | */
73 | /**
74 | * @}
75 | */
76 |
77 | /** @defgroup USB_CONF_Exported_Variables
78 | * @{
79 | */
80 | /**
81 | * @}
82 | */
83 |
84 | /** @defgroup USB_CONF_Exported_FunctionsPrototype
85 | * @{
86 | */
87 | /**
88 | * @}
89 | */
90 |
91 |
92 | #endif //__USBD_CONF__H__
93 |
94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
95 |
96 |
--------------------------------------------------------------------------------
/inc/usbd_midi_user.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file usbd_midi_user.h
3 | * @author Philip Karlsson
4 | * @version V1.0.0
5 | * @date 29-November-2014
6 | * @brief The header for the unser interface to usbd_midi_core
7 | */
8 |
9 | #ifndef __USBD_MIDI_USER_H
10 | #define __USBD_MIDI_USER_H
11 | /* Includes ------- */
12 |
13 | #include "stm32f4xx_conf.h"
14 |
15 | #include "usbd_midi_core.h"
16 | #include "usbd_conf.h"
17 |
18 | extern MIDI_IF_Prop_TypeDef MIDI_fops;
19 |
20 | extern void send_MIDI_msg(uint8_t *msg, uint16_t length);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/lib/Conf/usbd_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_conf.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief USB Device configuration file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CONF__H__
24 | #define __USBD_CONF__H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm32f4xx.h"
28 |
29 | /** @defgroup USB_CONF_Exported_Defines
30 | * @{
31 | */
32 | #define USBD_CFG_MAX_NUM 1
33 | #define USBD_ITF_MAX_NUM 1
34 | #define USB_MAX_STR_DESC_SIZ 50
35 |
36 | /** @defgroup USB_VCP_Class_Layer_Parameter
37 | * @{
38 | */
39 | #define CDC_IN_EP 0x81 /* EP1 for data IN */
40 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */
41 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */
42 |
43 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
44 | #ifdef USE_USB_OTG_HS
45 | #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */
46 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */
47 |
48 | #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */
49 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer:
50 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */
51 | #else
52 | #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */
53 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */
54 |
55 | #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */
56 |
57 |
58 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer:
59 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */
60 | #endif /* USE_USB_OTG_HS */
61 |
62 | #define APP_FOPS VCP_fops
63 |
64 | /*-------------------------- MIDI specific defines -------------------------- */
65 | #define MIDI_OUT_EP 0x01
66 | #define MIDI_IN_EP 0x81
67 | #define MIDI_DATA_IN_PACKET_SIZE 0x40
68 | #define MIDI_DATA_OUT_PACKET_SIZE 0x40
69 |
70 | #define MIDI_IN_FRAME_INTERVAL 1
71 |
72 |
73 |
74 |
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /** @defgroup USB_CONF_Exported_Types
81 | * @{
82 | */
83 | /**
84 | * @}
85 | */
86 |
87 |
88 | /** @defgroup USB_CONF_Exported_Macros
89 | * @{
90 | */
91 | /**
92 | * @}
93 | */
94 |
95 | /** @defgroup USB_CONF_Exported_Variables
96 | * @{
97 | */
98 | /**
99 | * @}
100 | */
101 |
102 | /** @defgroup USB_CONF_Exported_FunctionsPrototype
103 | * @{
104 | */
105 | /**
106 | * @}
107 | */
108 |
109 |
110 | #endif //__USBD_CONF__H__
111 |
112 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
113 |
114 |
--------------------------------------------------------------------------------
/lib/Conf/usbd_desc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_desc.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 19-September-2011
7 | * @brief header file for the usbd_desc.c file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 |
24 | #ifndef __USB_DESC_H
25 | #define __USB_DESC_H
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "usbd_def.h"
29 |
30 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
31 | * @{
32 | */
33 |
34 | /** @defgroup USB_DESC
35 | * @brief general defines for the usb device library file
36 | * @{
37 | */
38 |
39 | /** @defgroup USB_DESC_Exported_Defines
40 | * @{
41 | */
42 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
43 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
44 | #define USB_STRING_DESCRIPTOR_TYPE 0x03
45 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
46 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
47 | #define USB_SIZ_DEVICE_DESC 18
48 | #define USB_SIZ_STRING_LANGID 4
49 |
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @defgroup USBD_DESC_Exported_TypesDefinitions
56 | * @{
57 | */
58 | /**
59 | * @}
60 | */
61 |
62 |
63 |
64 | /** @defgroup USBD_DESC_Exported_Macros
65 | * @{
66 | */
67 | /**
68 | * @}
69 | */
70 |
71 | /** @defgroup USBD_DESC_Exported_Variables
72 | * @{
73 | */
74 | extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC];
75 | extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ];
76 | extern uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC];
77 | extern uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC];
78 | extern uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID];
79 | extern USBD_DEVICE USR_desc;
80 | /**
81 | * @}
82 | */
83 |
84 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype
85 | * @{
86 | */
87 |
88 |
89 | uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length);
90 | uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length);
91 | uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length);
92 | uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length);
93 | uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length);
94 | uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length);
95 | uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length);
96 |
97 | #ifdef USB_SUPPORT_USER_STRING_DESC
98 | uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length);
99 | #endif /* USB_SUPPORT_USER_STRING_DESC */
100 |
101 | /**
102 | * @}
103 | */
104 |
105 | #endif /* __USBD_DESC_H */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /**
112 | * @}
113 | */
114 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
115 |
--------------------------------------------------------------------------------
/lib/Conf/usbh_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_conf_template
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief General USB Host library configuration
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBH_CONF__H__
24 | #define __USBH_CONF__H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | /** @addtogroup USBH_OTG_DRIVER
28 | * @{
29 | */
30 |
31 | /** @defgroup USBH_CONF
32 | * @brief usb otg low level driver configuration file
33 | * @{
34 | */
35 |
36 | /** @defgroup USBH_CONF_Exported_Defines
37 | * @{
38 | */
39 |
40 | #define USBH_MAX_NUM_ENDPOINTS 2
41 | #define USBH_MAX_NUM_INTERFACES 2
42 | #ifdef USE_USB_OTG_FS
43 | #define USBH_MSC_MPS_SIZE 0x40
44 | #else
45 | #define USBH_MSC_MPS_SIZE 0x200
46 | #endif
47 |
48 | /**
49 | * @}
50 | */
51 |
52 |
53 | /** @defgroup USBH_CONF_Exported_Types
54 | * @{
55 | */
56 | /**
57 | * @}
58 | */
59 |
60 |
61 | /** @defgroup USBH_CONF_Exported_Macros
62 | * @{
63 | */
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USBH_CONF_Exported_Variables
69 | * @{
70 | */
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup USBH_CONF_Exported_FunctionsPrototype
76 | * @{
77 | */
78 | /**
79 | * @}
80 | */
81 |
82 |
83 | #endif //__USBH_CONF__H__
84 |
85 |
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
94 |
95 |
--------------------------------------------------------------------------------
/lib/Core/cmsis/arm_common_tables.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 11. November 2010
5 | * $Revision: V1.0.2
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 | * Version 1.0.2 2010/11/11
15 | * Documentation updated.
16 | *
17 | * Version 1.0.1 2010/10/05
18 | * Production release and review comments incorporated.
19 | *
20 | * Version 1.0.0 2010/09/20
21 | * Production release and review comments incorporated.
22 | * -------------------------------------------------------------------- */
23 |
24 | #ifndef _ARM_COMMON_TABLES_H
25 | #define _ARM_COMMON_TABLES_H
26 |
27 | #include "arm_math.h"
28 |
29 | extern uint16_t armBitRevTable[256];
30 | extern q15_t armRecipTableQ15[64];
31 | extern q31_t armRecipTableQ31[64];
32 | extern const q31_t realCoefAQ31[1024];
33 | extern const q31_t realCoefBQ31[1024];
34 |
35 | #endif /* ARM_COMMON_TABLES_H */
36 |
--------------------------------------------------------------------------------
/lib/Core/stm32/stm32f4xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ripxorip/stm32_usb_midi/dd55877615d26585896cf0c71597f2d91506a094/lib/Core/stm32/stm32f4xx.h
--------------------------------------------------------------------------------
/lib/Core/stm32/stm32f4xx_conf_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file IO_Toggle/stm32f4xx_conf.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 19-September-2011
7 | * @brief Library configuration file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM32F4xx_CONF_H
24 | #define __STM32F4xx_CONF_H
25 |
26 | #if defined (HSE_VALUE)
27 | /* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
28 | #undef HSE_VALUE
29 | #define HSE_VALUE ((uint32_t)8000000)
30 | #endif /* HSE_VALUE */
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | /* Uncomment the line below to enable peripheral header file inclusion */
34 | #include "stm32f4xx_adc.h"
35 | #include "stm32f4xx_can.h"
36 | #include "stm32f4xx_crc.h"
37 | #include "stm32f4xx_cryp.h"
38 | #include "stm32f4xx_dac.h"
39 | #include "stm32f4xx_dbgmcu.h"
40 | #include "stm32f4xx_dcmi.h"
41 | #include "stm32f4xx_dma.h"
42 | #include "stm32f4xx_exti.h"
43 | #include "stm32f4xx_flash.h"
44 | #include "stm32f4xx_fsmc.h"
45 | #include "stm32f4xx_hash.h"
46 | #include "stm32f4xx_gpio.h"
47 | #include "stm32f4xx_i2c.h"
48 | #include "stm32f4xx_iwdg.h"
49 | #include "stm32f4xx_pwr.h"
50 | #include "stm32f4xx_rcc.h"
51 | #include "stm32f4xx_rng.h"
52 | #include "stm32f4xx_rtc.h"
53 | #include "stm32f4xx_sdio.h"
54 | #include "stm32f4xx_spi.h"
55 | #include "stm32f4xx_syscfg.h"
56 | #include "stm32f4xx_tim.h"
57 | #include "stm32f4xx_usart.h"
58 | #include "stm32f4xx_wwdg.h"
59 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
60 |
61 | /* Exported types ------------------------------------------------------------*/
62 | /* Exported constants --------------------------------------------------------*/
63 |
64 | /* If an external clock source is used, then the value of the following define
65 | should be set to the value of the external clock source, else, if no external
66 | clock is used, keep this define commented */
67 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
68 |
69 |
70 | /* Uncomment the line below to expanse the "assert_param" macro in the
71 | Standard Peripheral Library drivers code */
72 | /* #define USE_FULL_ASSERT 1 */
73 |
74 | /* Exported macro ------------------------------------------------------------*/
75 | #ifdef USE_FULL_ASSERT
76 |
77 | /**
78 | * @brief The assert_param macro is used for function's parameters check.
79 | * @param expr: If expr is false, it calls assert_failed function
80 | * which reports the name of the source file and the source
81 | * line number of the call that failed.
82 | * If expr is true, it returns no value.
83 | * @retval None
84 | */
85 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
86 | /* Exported functions ------------------------------------------------------- */
87 | void assert_failed(uint8_t* file, uint32_t line);
88 | #else
89 | #define assert_param(expr) ((void)0)
90 | #endif /* USE_FULL_ASSERT */
91 |
92 | #endif /* __STM32F4xx_CONF_H */
93 |
94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
95 |
--------------------------------------------------------------------------------
/lib/Core/stm32/system_stm32f4xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f4xx.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 30-September-2011
7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /** @addtogroup CMSIS
23 | * @{
24 | */
25 |
26 | /** @addtogroup stm32f4xx_system
27 | * @{
28 | */
29 |
30 | /**
31 | * @brief Define to prevent recursive inclusion
32 | */
33 | #ifndef __SYSTEM_STM32F4XX_H
34 | #define __SYSTEM_STM32F4XX_H
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /** @addtogroup STM32F4xx_System_Includes
41 | * @{
42 | */
43 |
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @addtogroup STM32F4xx_System_Exported_types
50 | * @{
51 | */
52 |
53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
54 |
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /** @addtogroup STM32F4xx_System_Exported_Constants
61 | * @{
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 |
68 | /** @addtogroup STM32F4xx_System_Exported_Macros
69 | * @{
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @addtogroup STM32F4xx_System_Exported_Functions
77 | * @{
78 | */
79 |
80 | extern void SystemInit(void);
81 | extern void SystemCoreClockUpdate(void);
82 | /**
83 | * @}
84 | */
85 |
86 | #ifdef __cplusplus
87 | }
88 | #endif
89 |
90 | #endif /*__SYSTEM_STM32F4XX_H */
91 |
92 | /**
93 | * @}
94 | */
95 |
96 | /**
97 | * @}
98 | */
99 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
100 |
--------------------------------------------------------------------------------
/lib/Makefile:
--------------------------------------------------------------------------------
1 | # Build all libraries
2 |
3 | # Check for valid float argument
4 | ifneq ($(FLOAT_TYPE), hard)
5 | ifneq ($(FLOAT_TYPE), soft)
6 | override FLOAT_TYPE = hard
7 | #override FLOAT_TYPE = soft
8 | endif
9 | endif
10 |
11 | all:
12 | $(MAKE) -C StdPeriph FLOAT_TYPE=$(FLOAT_TYPE)
13 | $(MAKE) -C USB_OTG FLOAT_TYPE=$(FLOAT_TYPE)
14 | $(MAKE) -C USB_Device/Core FLOAT_TYPE=$(FLOAT_TYPE)
15 | $(MAKE) -C USB_Device/Class/cdc FLOAT_TYPE=$(FLOAT_TYPE)
16 | $(MAKE) -C USB_Device/Class/midi FLOAT_TYPE=$(FLOAT_TYPE)
17 | # $(MAKE) -C USB_Host/Core FLOAT_TYPE=$(FLOAT_TYPE)
18 | # $(MAKE) -C USB_Host/Class/MSC FLOAT_TYPE=$(FLOAT_TYPE)
19 | $(MAKE) -C fat_fs FLOAT_TYPE=$(FLOAT_TYPE)
20 |
21 | clean:
22 | $(MAKE) clean -C StdPeriph
23 | $(MAKE) clean -C USB_OTG
24 | $(MAKE) clean -C USB_Device/Core
25 | $(MAKE) clean -C USB_Device/Class/cdc
26 | # $(MAKE) clean -C USB_Host/Core
27 | # $(MAKE) clean -C USB_Host/Class/MSC
28 | $(MAKE) clean -C fat_fs
--------------------------------------------------------------------------------
/lib/StdPeriph/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../Core/cmsis -I../Core/stm32
34 |
35 | # Sources
36 | SRCS = misc.c stm32f4xx_dma.c stm32f4xx_rcc.c stm32f4xx_adc.c \
37 | stm32f4xx_exti.c stm32f4xx_rng.c stm32f4xx_can.c stm32f4xx_flash.c \
38 | stm32f4xx_rtc.c stm32f4xx_crc.c stm32f4xx_fsmc.c stm32f4xx_sdio.c \
39 | stm32f4xx_cryp_aes.c stm32f4xx_gpio.c stm32f4xx_spi.c \
40 | stm32f4xx_cryp.c stm32f4xx_hash.c stm32f4xx_syscfg.c \
41 | stm32f4xx_cryp_des.c stm32f4xx_hash_md5.c stm32f4xx_tim.c \
42 | stm32f4xx_cryp_tdes.c stm32f4xx_hash_sha1.c stm32f4xx_usart.c \
43 | stm32f4xx_dac.c stm32f4xx_i2c.c stm32f4xx_wwdg.c \
44 | stm32f4xx_dbgmcu.c stm32f4xx_iwdg.c \
45 | stm32f4xx_dcmi.c stm32f4xx_pwr.c
46 |
47 |
48 | OBJS = $(SRCS:.c=.o)
49 | LIBNAME = libstdperiph.a
50 |
51 | all: $(LIBNAME)
52 |
53 | %.o : %.c
54 | $(CC) $(CFLAGS) -c -o $@ $^
55 |
56 | $(LIBNAME): $(OBJS)
57 | $(AR) -r $@ $(OBJS)
58 |
59 | clean:
60 | rm -f $(OBJS) $(LIBNAME)
61 |
--------------------------------------------------------------------------------
/lib/StdPeriph/inc/stm32f4xx_crc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_crc.h
4 | * @author MCD Application Team
5 | * @version V1.0.2
6 | * @date 05-March-2012
7 | * @brief This file contains all the functions prototypes for the CRC firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2012 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F4xx_CRC_H
31 | #define __STM32F4xx_CRC_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup CRC
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup CRC_Exported_Constants
52 | * @{
53 | */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /* Exported macro ------------------------------------------------------------*/
60 | /* Exported functions --------------------------------------------------------*/
61 |
62 | void CRC_ResetDR(void);
63 | uint32_t CRC_CalcCRC(uint32_t Data);
64 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
65 | uint32_t CRC_GetCRC(void);
66 | void CRC_SetIDRegister(uint8_t IDValue);
67 | uint8_t CRC_GetIDRegister(void);
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif /* __STM32F4xx_CRC_H */
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
84 |
--------------------------------------------------------------------------------
/lib/StdPeriph/inc/stm32f4xx_dbgmcu.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_dbgmcu.h
4 | * @author MCD Application Team
5 | * @version V1.0.2
6 | * @date 05-March-2012
7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2012 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __STM32F4xx_DBGMCU_H
30 | #define __STM32F4xx_DBGMCU_H
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | /* Includes ------------------------------------------------------------------*/
37 | #include "stm32f4xx.h"
38 |
39 | /** @addtogroup STM32F4xx_StdPeriph_Driver
40 | * @{
41 | */
42 |
43 | /** @addtogroup DBGMCU
44 | * @{
45 | */
46 |
47 | /* Exported types ------------------------------------------------------------*/
48 | /* Exported constants --------------------------------------------------------*/
49 |
50 | /** @defgroup DBGMCU_Exported_Constants
51 | * @{
52 | */
53 | #define DBGMCU_SLEEP ((uint32_t)0x00000001)
54 | #define DBGMCU_STOP ((uint32_t)0x00000002)
55 | #define DBGMCU_STANDBY ((uint32_t)0x00000004)
56 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00))
57 |
58 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001)
59 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002)
60 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004)
61 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00000008)
62 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010)
63 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020)
64 | #define DBGMCU_TIM12_STOP ((uint32_t)0x00000040)
65 | #define DBGMCU_TIM13_STOP ((uint32_t)0x00000080)
66 | #define DBGMCU_TIM14_STOP ((uint32_t)0x00000100)
67 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400)
68 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800)
69 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000)
70 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000)
71 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000)
72 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x00800000)
73 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000)
74 | #define DBGMCU_CAN2_STOP ((uint32_t)0x04000000)
75 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xF91FE200) == 0x00) && ((PERIPH) != 0x00))
76 |
77 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001)
78 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002)
79 | #define DBGMCU_TIM9_STOP ((uint32_t)0x00010000)
80 | #define DBGMCU_TIM10_STOP ((uint32_t)0x00020000)
81 | #define DBGMCU_TIM11_STOP ((uint32_t)0x00040000)
82 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8FFFC) == 0x00) && ((PERIPH) != 0x00))
83 | /**
84 | * @}
85 | */
86 |
87 | /* Exported macro ------------------------------------------------------------*/
88 | /* Exported functions --------------------------------------------------------*/
89 | uint32_t DBGMCU_GetREVID(void);
90 | uint32_t DBGMCU_GetDEVID(void);
91 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState);
92 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState);
93 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState);
94 |
95 | #ifdef __cplusplus
96 | }
97 | #endif
98 |
99 | #endif /* __STM32F4xx_DBGMCU_H */
100 |
101 | /**
102 | * @}
103 | */
104 |
105 | /**
106 | * @}
107 | */
108 |
109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
110 |
--------------------------------------------------------------------------------
/lib/StdPeriph/inc/stm32f4xx_iwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_iwdg.h
4 | * @author MCD Application Team
5 | * @version V1.0.2
6 | * @date 05-March-2012
7 | * @brief This file contains all the functions prototypes for the IWDG
8 | * firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2012 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F4xx_IWDG_H
31 | #define __STM32F4xx_IWDG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup IWDG
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup IWDG_Exported_Constants
52 | * @{
53 | */
54 |
55 | /** @defgroup IWDG_WriteAccess
56 | * @{
57 | */
58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555)
59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000)
60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \
61 | ((ACCESS) == IWDG_WriteAccess_Disable))
62 | /**
63 | * @}
64 | */
65 |
66 | /** @defgroup IWDG_prescaler
67 | * @{
68 | */
69 | #define IWDG_Prescaler_4 ((uint8_t)0x00)
70 | #define IWDG_Prescaler_8 ((uint8_t)0x01)
71 | #define IWDG_Prescaler_16 ((uint8_t)0x02)
72 | #define IWDG_Prescaler_32 ((uint8_t)0x03)
73 | #define IWDG_Prescaler_64 ((uint8_t)0x04)
74 | #define IWDG_Prescaler_128 ((uint8_t)0x05)
75 | #define IWDG_Prescaler_256 ((uint8_t)0x06)
76 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \
77 | ((PRESCALER) == IWDG_Prescaler_8) || \
78 | ((PRESCALER) == IWDG_Prescaler_16) || \
79 | ((PRESCALER) == IWDG_Prescaler_32) || \
80 | ((PRESCALER) == IWDG_Prescaler_64) || \
81 | ((PRESCALER) == IWDG_Prescaler_128)|| \
82 | ((PRESCALER) == IWDG_Prescaler_256))
83 | /**
84 | * @}
85 | */
86 |
87 | /** @defgroup IWDG_Flag
88 | * @{
89 | */
90 | #define IWDG_FLAG_PVU ((uint16_t)0x0001)
91 | #define IWDG_FLAG_RVU ((uint16_t)0x0002)
92 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU))
93 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /* Exported macro ------------------------------------------------------------*/
103 | /* Exported functions --------------------------------------------------------*/
104 |
105 | /* Prescaler and Counter configuration functions ******************************/
106 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess);
107 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler);
108 | void IWDG_SetReload(uint16_t Reload);
109 | void IWDG_ReloadCounter(void);
110 |
111 | /* IWDG activation function ***************************************************/
112 | void IWDG_Enable(void);
113 |
114 | /* Flag management function ***************************************************/
115 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG);
116 |
117 | #ifdef __cplusplus
118 | }
119 | #endif
120 |
121 | #endif /* __STM32F4xx_IWDG_H */
122 |
123 | /**
124 | * @}
125 | */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
132 |
--------------------------------------------------------------------------------
/lib/StdPeriph/inc/stm32f4xx_rng.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_rng.h
4 | * @author MCD Application Team
5 | * @version V1.0.2
6 | * @date 05-March-2012
7 | * @brief This file contains all the functions prototypes for the Random
8 | * Number Generator(RNG) firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2012 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F4xx_RNG_H
31 | #define __STM32F4xx_RNG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup RNG
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup RNG_Exported_Constants
52 | * @{
53 | */
54 |
55 | /** @defgroup RNG_flags_definition
56 | * @{
57 | */
58 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */
59 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */
60 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */
61 |
62 | #define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \
63 | ((RNG_FLAG) == RNG_FLAG_CECS) || \
64 | ((RNG_FLAG) == RNG_FLAG_SECS))
65 | #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \
66 | ((RNG_FLAG) == RNG_FLAG_SECS))
67 | /**
68 | * @}
69 | */
70 |
71 | /** @defgroup RNG_interrupts_definition
72 | * @{
73 | */
74 | #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */
75 | #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */
76 |
77 | #define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00))
78 | #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI))
79 | /**
80 | * @}
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /* Exported macro ------------------------------------------------------------*/
88 | /* Exported functions --------------------------------------------------------*/
89 |
90 | /* Function used to set the RNG configuration to the default reset state *****/
91 | void RNG_DeInit(void);
92 |
93 | /* Configuration function *****************************************************/
94 | void RNG_Cmd(FunctionalState NewState);
95 |
96 | /* Get 32 bit Random number function ******************************************/
97 | uint32_t RNG_GetRandomNumber(void);
98 |
99 | /* Interrupts and flags management functions **********************************/
100 | void RNG_ITConfig(FunctionalState NewState);
101 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG);
102 | void RNG_ClearFlag(uint8_t RNG_FLAG);
103 | ITStatus RNG_GetITStatus(uint8_t RNG_IT);
104 | void RNG_ClearITPendingBit(uint8_t RNG_IT);
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /*__STM32F4xx_RNG_H */
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
121 |
--------------------------------------------------------------------------------
/lib/StdPeriph/inc/stm32f4xx_wwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_wwdg.h
4 | * @author MCD Application Team
5 | * @version V1.0.2
6 | * @date 05-March-2012
7 | * @brief This file contains all the functions prototypes for the WWDG firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2012 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F4xx_WWDG_H
31 | #define __STM32F4xx_WWDG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup WWDG
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup WWDG_Exported_Constants
52 | * @{
53 | */
54 |
55 | /** @defgroup WWDG_Prescaler
56 | * @{
57 | */
58 |
59 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000)
60 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080)
61 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100)
62 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180)
63 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \
64 | ((PRESCALER) == WWDG_Prescaler_2) || \
65 | ((PRESCALER) == WWDG_Prescaler_4) || \
66 | ((PRESCALER) == WWDG_Prescaler_8))
67 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F)
68 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F))
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /**
75 | * @}
76 | */
77 |
78 | /* Exported macro ------------------------------------------------------------*/
79 | /* Exported functions --------------------------------------------------------*/
80 |
81 | /* Function used to set the WWDG configuration to the default reset state ****/
82 | void WWDG_DeInit(void);
83 |
84 | /* Prescaler, Refresh window and Counter configuration functions **************/
85 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler);
86 | void WWDG_SetWindowValue(uint8_t WindowValue);
87 | void WWDG_EnableIT(void);
88 | void WWDG_SetCounter(uint8_t Counter);
89 |
90 | /* WWDG activation function ***************************************************/
91 | void WWDG_Enable(uint8_t Counter);
92 |
93 | /* Interrupts and flags management functions **********************************/
94 | FlagStatus WWDG_GetFlagStatus(void);
95 | void WWDG_ClearFlag(void);
96 |
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
101 | #endif /* __STM32F4xx_WWDG_H */
102 |
103 | /**
104 | * @}
105 | */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
112 |
--------------------------------------------------------------------------------
/lib/StdPeriph/src/stm32f4xx_crc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_crc.c
4 | * @author MCD Application Team
5 | * @version V1.0.2
6 | * @date 05-March-2012
7 | * @brief This file provides all the CRC firmware functions.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2012 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f4xx_crc.h"
30 |
31 | /** @addtogroup STM32F4xx_StdPeriph_Driver
32 | * @{
33 | */
34 |
35 | /** @defgroup CRC
36 | * @brief CRC driver modules
37 | * @{
38 | */
39 |
40 | /* Private typedef -----------------------------------------------------------*/
41 | /* Private define ------------------------------------------------------------*/
42 | /* Private macro -------------------------------------------------------------*/
43 | /* Private variables ---------------------------------------------------------*/
44 | /* Private function prototypes -----------------------------------------------*/
45 | /* Private functions ---------------------------------------------------------*/
46 |
47 | /** @defgroup CRC_Private_Functions
48 | * @{
49 | */
50 |
51 | /**
52 | * @brief Resets the CRC Data register (DR).
53 | * @param None
54 | * @retval None
55 | */
56 | void CRC_ResetDR(void)
57 | {
58 | /* Reset CRC generator */
59 | CRC->CR = CRC_CR_RESET;
60 | }
61 |
62 | /**
63 | * @brief Computes the 32-bit CRC of a given data word(32-bit).
64 | * @param Data: data word(32-bit) to compute its CRC
65 | * @retval 32-bit CRC
66 | */
67 | uint32_t CRC_CalcCRC(uint32_t Data)
68 | {
69 | CRC->DR = Data;
70 |
71 | return (CRC->DR);
72 | }
73 |
74 | /**
75 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
76 | * @param pBuffer: pointer to the buffer containing the data to be computed
77 | * @param BufferLength: length of the buffer to be computed
78 | * @retval 32-bit CRC
79 | */
80 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
81 | {
82 | uint32_t index = 0;
83 |
84 | for(index = 0; index < BufferLength; index++)
85 | {
86 | CRC->DR = pBuffer[index];
87 | }
88 | return (CRC->DR);
89 | }
90 |
91 | /**
92 | * @brief Returns the current CRC value.
93 | * @param None
94 | * @retval 32-bit CRC
95 | */
96 | uint32_t CRC_GetCRC(void)
97 | {
98 | return (CRC->DR);
99 | }
100 |
101 | /**
102 | * @brief Stores a 8-bit data in the Independent Data(ID) register.
103 | * @param IDValue: 8-bit value to be stored in the ID register
104 | * @retval None
105 | */
106 | void CRC_SetIDRegister(uint8_t IDValue)
107 | {
108 | CRC->IDR = IDValue;
109 | }
110 |
111 | /**
112 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register
113 | * @param None
114 | * @retval 8-bit value of the ID register
115 | */
116 | uint8_t CRC_GetIDRegister(void)
117 | {
118 | return (CRC->IDR);
119 | }
120 |
121 | /**
122 | * @}
123 | */
124 |
125 | /**
126 | * @}
127 | */
128 |
129 | /**
130 | * @}
131 | */
132 |
133 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
134 |
--------------------------------------------------------------------------------
/lib/StdPeriph/src/stm32f4xx_flash.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ripxorip/stm32_usb_midi/dd55877615d26585896cf0c71597f2d91506a094/lib/StdPeriph/src/stm32f4xx_flash.c
--------------------------------------------------------------------------------
/lib/StdPeriph/src/stm32f4xx_rcc.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ripxorip/stm32_usb_midi/dd55877615d26585896cf0c71597f2d91506a094/lib/StdPeriph/src/stm32f4xx_rcc.c
--------------------------------------------------------------------------------
/lib/USB_Device/Class/audio/inc/usbd_audio_out_if.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_audio_out_if.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header file for the usbd_audio_out_if.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 |
24 | #ifndef __USB_AUDIO_OUT_IF_H_
25 | #define __USB_AUDIO_OUT_IF_H_
26 |
27 | #ifdef STM32F2XX
28 | #include "stm322xg_usb_audio_codec.h"
29 | #elif defined(STM32F10X_CL)
30 | #include "stm3210c_usb_audio_codec.h"
31 | #endif /* STM32F2XX */
32 |
33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
34 | * @{
35 | */
36 |
37 | /** @defgroup usbd_audio
38 | * @brief This file is the Header file for USBD_audio.c
39 | * @{
40 | */
41 |
42 |
43 | /** @defgroup usbd_audio_Exported_Defines
44 | * @{
45 | */
46 | /* Audio Commands enmueration */
47 | typedef enum
48 | {
49 | AUDIO_CMD_PLAY = 1,
50 | AUDIO_CMD_PAUSE,
51 | AUDIO_CMD_STOP,
52 | }AUDIO_CMD_TypeDef;
53 |
54 | /* Mute commands */
55 | #define AUDIO_MUTE 0x01
56 | #define AUDIO_UNMUTE 0x00
57 |
58 | /* Functions return value */
59 | #define AUDIO_OK 0x00
60 | #define AUDIO_FAIL 0xFF
61 |
62 | /* Audio Machine States */
63 | #define AUDIO_STATE_INACTIVE 0x00
64 | #define AUDIO_STATE_ACTIVE 0x01
65 | #define AUDIO_STATE_PLAYING 0x02
66 | #define AUDIO_STATE_PAUSED 0x03
67 | #define AUDIO_STATE_STOPPED 0x04
68 | #define AUDIO_STATE_ERROR 0x05
69 |
70 | /**
71 | * @}
72 | */
73 |
74 |
75 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
76 | * @{
77 | */
78 | /**
79 | * @}
80 | */
81 |
82 |
83 |
84 | /** @defgroup USBD_CORE_Exported_Macros
85 | * @{
86 | */
87 | /**
88 | * @}
89 | */
90 |
91 | /** @defgroup USBD_CORE_Exported_Variables
92 | * @{
93 | */
94 |
95 | extern AUDIO_FOPS_TypeDef AUDIO_OUT_fops;
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | /** @defgroup USB_CORE_Exported_Functions
102 | * @{
103 | */
104 | /**
105 | * @}
106 | */
107 |
108 | #endif /* __USB_AUDIO_OUT_IF_H_ */
109 | /**
110 | * @}
111 | */
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
118 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/cdc/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../../../Core/cmsis -I../../../Core/stm32
34 | CFLAGS += -I../../../Conf -I../../../USB_OTG/inc
35 | CFLAGS += -I../../Core/inc
36 |
37 | # Sources
38 | SRCS = usbd_cdc_core.c
39 |
40 | OBJS = $(SRCS:.c=.o)
41 | LIBNAME = libusbdevcdc.a
42 |
43 | all: $(LIBNAME)
44 |
45 | %.o : %.c
46 | $(CC) $(CFLAGS) -c -o $@ $^
47 |
48 | $(LIBNAME): $(OBJS)
49 | $(AR) -r $@ $(OBJS)
50 |
51 | clean:
52 | rm -f $(OBJS) $(LIBNAME)
--------------------------------------------------------------------------------
/lib/USB_Device/Class/cdc/inc/usbd_cdc_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_cdc_core.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header file for the usbd_cdc_core.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 |
24 | #ifndef __USB_CDC_CORE_H_
25 | #define __USB_CDC_CORE_H_
26 |
27 | #include "usbd_ioreq.h"
28 |
29 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
30 | * @{
31 | */
32 |
33 | /** @defgroup usbd_cdc
34 | * @brief This file is the Header file for USBD_cdc.c
35 | * @{
36 | */
37 |
38 | extern void dummySendCDC(void *pdev);
39 |
40 | /** @defgroup usbd_cdc_Exported_Defines
41 | * @{
42 | */
43 | #define USB_CDC_CONFIG_DESC_SIZ (67)
44 | #define USB_CDC_DESC_SIZ (67-9)
45 |
46 | #define CDC_DESCRIPTOR_TYPE 0x21
47 |
48 | #define DEVICE_CLASS_CDC 0x02
49 | #define DEVICE_SUBCLASS_CDC 0x00
50 |
51 |
52 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
53 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
54 | #define USB_STRING_DESCRIPTOR_TYPE 0x03
55 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
56 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
57 |
58 | #define STANDARD_ENDPOINT_DESC_SIZE 0x09
59 |
60 | #define CDC_DATA_IN_PACKET_SIZE *(uint16_t *)(((USB_OTG_CORE_HANDLE *)pdev)->dev.pConfig_descriptor + 57)
61 |
62 | #define CDC_DATA_OUT_PACKET_SIZE *(uint16_t *)(((USB_OTG_CORE_HANDLE *)pdev)->dev.pConfig_descriptor + 64)
63 |
64 | /*---------------------------------------------------------------------*/
65 | /* CDC definitions */
66 | /*---------------------------------------------------------------------*/
67 |
68 | /**************************************************/
69 | /* CDC Requests */
70 | /**************************************************/
71 | #define SEND_ENCAPSULATED_COMMAND 0x00
72 | #define GET_ENCAPSULATED_RESPONSE 0x01
73 | #define SET_COMM_FEATURE 0x02
74 | #define GET_COMM_FEATURE 0x03
75 | #define CLEAR_COMM_FEATURE 0x04
76 | #define SET_LINE_CODING 0x20
77 | #define GET_LINE_CODING 0x21
78 | #define SET_CONTROL_LINE_STATE 0x22
79 | #define SEND_BREAK 0x23
80 | #define NO_CMD 0xFF
81 |
82 | /**
83 | * @}
84 | */
85 |
86 |
87 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
88 | * @{
89 | */
90 | typedef struct _CDC_IF_PROP
91 | {
92 | uint16_t (*pIf_Init) (void);
93 | uint16_t (*pIf_DeInit) (void);
94 | uint16_t (*pIf_Ctrl) (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
95 | uint16_t (*pIf_DataTx) (uint8_t* Buf, uint32_t Len);
96 | uint16_t (*pIf_DataRx) (uint8_t* Buf, uint32_t Len);
97 | }
98 | CDC_IF_Prop_TypeDef;
99 | /**
100 | * @}
101 | */
102 |
103 |
104 |
105 | /** @defgroup USBD_CORE_Exported_Macros
106 | * @{
107 | */
108 |
109 | /**
110 | * @}
111 | */
112 |
113 | /** @defgroup USBD_CORE_Exported_Variables
114 | * @{
115 | */
116 |
117 | extern USBD_Class_cb_TypeDef USBD_CDC_cb;
118 | /**
119 | * @}
120 | */
121 |
122 | /** @defgroup USB_CORE_Exported_Functions
123 | * @{
124 | */
125 | /**
126 | * @}
127 | */
128 |
129 | #endif // __USB_CDC_CORE_H_
130 | /**
131 | * @}
132 | */
133 |
134 | /**
135 | * @}
136 | */
137 |
138 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
139 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/cdc/inc/usbd_cdc_if_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_cdc_if_template.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header for dfu_mal.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CDC_IF_TEMPLATE_H
24 | #define __USBD_CDC_IF_TEMPLATE_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #ifdef STM32F2XX
28 | #include "stm32f2xx.h"
29 | #elif defined(STM32F10X_CL)
30 | #include "stm32f10x.h"
31 | #endif /* STM32F2XX */
32 |
33 | #include "usbd_conf.h"
34 | #include "usbd_cdc_core.h"
35 |
36 | /* Exported types ------------------------------------------------------------*/
37 | /* Exported constants --------------------------------------------------------*/
38 |
39 | extern CDC_IF_Prop_TypeDef TEMPLATE_fops;
40 |
41 | /* Exported macro ------------------------------------------------------------*/
42 | /* Exported functions ------------------------------------------------------- */
43 | #endif /* __USBD_CDC_IF_TEMPLATE_H */
44 |
45 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
46 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/dfu/inc/usbd_dfu_mal.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_dfu_mal.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header for usbd_dfu_mal.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __DFU_MAL_H
24 | #define __DFU_MAL_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #ifdef STM32F2XX
28 | #include "stm32f2xx.h"
29 | #elif defined(STM32F10X_CL)
30 | #include "stm32f10x.h"
31 | #endif /* STM32F2XX */
32 |
33 | #include "usbd_conf.h"
34 | #include "usbd_dfu_core.h"
35 |
36 | /* Exported types ------------------------------------------------------------*/
37 | typedef struct _DFU_MAL_PROP
38 | {
39 | const uint8_t* pStrDesc;
40 | uint16_t (*pMAL_Init) (void);
41 | uint16_t (*pMAL_DeInit) (void);
42 | uint16_t (*pMAL_Erase) (uint32_t Add);
43 | uint16_t (*pMAL_Write) (uint32_t Add, uint32_t Len);
44 | uint8_t *(*pMAL_Read) (uint32_t Add, uint32_t Len);
45 | uint16_t (*pMAL_CheckAdd) (uint32_t Add);
46 | const uint32_t EraseTiming;
47 | const uint32_t WriteTiming;
48 | }
49 | DFU_MAL_Prop_TypeDef;
50 |
51 |
52 | /* Exported constants --------------------------------------------------------*/
53 | #define MAL_OK 0
54 | #define MAL_FAIL 1
55 |
56 | /* utils macro ---------------------------------------------------------------*/
57 | #define _1st_BYTE(x) (uint8_t)((x)&0xFF) /* 1st addressing cycle */
58 | #define _2nd_BYTE(x) (uint8_t)(((x)&0xFF00)>>8) /* 2nd addressing cycle */
59 | #define _3rd_BYTE(x) (uint8_t)(((x)&0xFF0000)>>16) /* 3rd addressing cycle */
60 | #define _4th_BYTE(x) (uint8_t)(((x)&0xFF000000)>>24) /* 4th addressing cycle */
61 |
62 | /* Exported macro ------------------------------------------------------------*/
63 | #define SET_POLLING_TIMING(x) buffer[1] = _1st_BYTE(x);\
64 | buffer[2] = _2nd_BYTE(x);\
65 | buffer[3] = _3rd_BYTE(x);
66 |
67 | /* Exported functions ------------------------------------------------------- */
68 |
69 | uint16_t MAL_Init (void);
70 | uint16_t MAL_DeInit (void);
71 | uint16_t MAL_Erase (uint32_t SectorAddress);
72 | uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength);
73 | uint8_t *MAL_Read (uint32_t SectorAddress, uint32_t DataLength);
74 | uint16_t MAL_GetStatus(uint32_t SectorAddress ,uint8_t Cmd, uint8_t *buffer);
75 |
76 | extern uint8_t MAL_Buffer[XFERSIZE]; /* RAM Buffer for Downloaded Data */
77 | #endif /* __DFU_MAL_H */
78 |
79 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
80 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/dfu/inc/usbd_flash_if.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_flash_if.h
4 | * @author MCD Application Team
5 | * @version V1.0.0RC1
6 | * @date 18-March-2011
7 | * @brief Header for usbd_flash_if.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __FLASH_IF_MAL_H
24 | #define __FLASH_IF_MAL_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbd_dfu_mal.h"
28 |
29 | /* Exported types ------------------------------------------------------------*/
30 | /* Exported constants --------------------------------------------------------*/
31 | #define FLASH_START_ADD 0x08000000
32 |
33 | #ifdef STM32F2XX
34 | #define FLASH_END_ADD 0x08100000
35 | #define FLASH_IF_STRING "@Internal Flash /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg"
36 | #elif defined(STM32F10X_CL)
37 | #define FLASH_END_ADD 0x08040000
38 | #define FLASH_IF_STRING "@Internal Flash /0x08000000/06*002Ka,122*002Kg"
39 | #endif /* STM32F2XX */
40 |
41 |
42 | extern DFU_MAL_Prop_TypeDef DFU_Flash_cb;
43 |
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* Exported functions ------------------------------------------------------- */
46 |
47 | #endif /* __FLASH_IF_MAL_H */
48 |
49 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
50 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/dfu/inc/usbd_mem_if_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_mem_if_template.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header for usbd_mem_if_template.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MEM_IF_MAL_H
24 | #define __MEM_IF_MAL_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #ifdef STM32F2XX
28 | #include "stm32f2xx.h"
29 | #endif /* STM32F2XX */
30 | #include "usbd_dfu_mal.h"
31 |
32 | /* Exported types ------------------------------------------------------------*/
33 | /* Exported constants --------------------------------------------------------*/
34 | #define MEM_START_ADD 0x00000000 /* Dummy start address */
35 | #define MEM_END_ADD (uint32_t)(MEM_START_ADD + (5 * 1024)) /* Dummy Size = 5KB */
36 |
37 | #define MEM_IF_STRING "@Dummy Memory /0x00000000/01*002Kg,03*001Kg"
38 |
39 | extern DFU_MAL_Prop_TypeDef DFU_Mem_cb;
40 |
41 | /* Exported macro ------------------------------------------------------------*/
42 | /* Exported functions ------------------------------------------------------- */
43 |
44 | #endif /* __MEM_IF_MAL_H */
45 |
46 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
47 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/dfu/inc/usbd_otp_if.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_otp_if.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header for usbd_otp_if.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __OTP_IF_MAL_H
24 | #define __OTP_IF_MAL_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbd_dfu_mal.h"
28 |
29 | /* Exported types ------------------------------------------------------------*/
30 | /* Exported constants --------------------------------------------------------*/
31 | #define OTP_START_ADD 0x1FFF7800
32 | #define OTP_END_ADD (uint32_t)(OTP_START_ADD + 528)
33 |
34 | #define OTP_IF_STRING "@OTP Area /0x1FFF7800/01*512 g,01*016 g"
35 |
36 | extern DFU_MAL_Prop_TypeDef DFU_Otp_cb;
37 |
38 | /* Exported macro ------------------------------------------------------------*/
39 | /* Exported functions ------------------------------------------------------- */
40 |
41 | #endif /* __OTP_IF_MAL_H */
42 |
43 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
44 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/dfu/src/usbd_mem_if_template.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_mem_if_template.c
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Specific media access Layer for a template memory. This file is
8 | provided as template example showing how to implement a new memory
9 | interface based on pre-defined API.
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 | *
20 | * © COPYRIGHT 2011 STMicroelectronics
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes ------------------------------------------------------------------*/
25 | #include "usbd_mem_if_template.h"
26 | #include "usbd_dfu_mal.h"
27 |
28 | /* Private typedef -----------------------------------------------------------*/
29 | /* Private define ------------------------------------------------------------*/
30 | /* Private macro -------------------------------------------------------------*/
31 |
32 | /* Private function prototypes -----------------------------------------------*/
33 | uint16_t MEM_If_Init(void);
34 | uint16_t MEM_If_Erase (uint32_t Add);
35 | uint16_t MEM_If_Write (uint32_t Add, uint32_t Len);
36 | uint8_t *MEM_If_Read (uint32_t Add, uint32_t Len);
37 | uint16_t MEM_If_DeInit(void);
38 | uint16_t MEM_If_CheckAdd(uint32_t Add);
39 |
40 |
41 | /* Private variables ---------------------------------------------------------*/
42 | DFU_MAL_Prop_TypeDef DFU_Mem_cb =
43 | {
44 | MEM_IF_STRING,
45 | MEM_If_Init,
46 | MEM_If_DeInit,
47 | MEM_If_Erase,
48 | MEM_If_Write,
49 | MEM_If_Read,
50 | MEM_If_CheckAdd,
51 | 10, /* Erase Time in ms */
52 | 10 /* Programming Time in ms */
53 | };
54 |
55 | /* Private functions ---------------------------------------------------------*/
56 |
57 | /**
58 | * @brief MEM_If_Init
59 | * Memory initialization routine.
60 | * @param None
61 | * @retval MAL_OK if operation is successeful, MAL_FAIL else.
62 | */
63 | uint16_t MEM_If_Init(void)
64 | {
65 | return MAL_OK;
66 | }
67 |
68 | /**
69 | * @brief MEM_If_DeInit
70 | * Memory deinitialization routine.
71 | * @param None
72 | * @retval MAL_OK if operation is successeful, MAL_FAIL else.
73 | */
74 | uint16_t MEM_If_DeInit(void)
75 | {
76 | return MAL_OK;
77 | }
78 |
79 | /**
80 | * @brief MEM_If_Erase
81 | * Erase sector.
82 | * @param Add: Address of sector to be erased.
83 | * @retval MAL_OK if operation is successeful, MAL_FAIL else.
84 | */
85 | uint16_t MEM_If_Erase(uint32_t Add)
86 | {
87 | return MAL_OK;
88 | }
89 |
90 | /**
91 | * @brief MEM_If_Write
92 | * Memory write routine.
93 | * @param Add: Address to be written to.
94 | * @param Len: Number of data to be written (in bytes).
95 | * @retval MAL_OK if operation is successeful, MAL_FAIL else.
96 | */
97 | uint16_t MEM_If_Write(uint32_t Add, uint32_t Len)
98 | {
99 | return MAL_OK;
100 | }
101 |
102 | /**
103 | * @brief MEM_If_Read
104 | * Memory read routine.
105 | * @param Add: Address to be read from.
106 | * @param Len: Number of data to be read (in bytes).
107 | * @retval Pointer to the phyisical address where data should be read.
108 | */
109 | uint8_t *MEM_If_Read (uint32_t Add, uint32_t Len)
110 | {
111 | /* Return a valid address to avoid HardFault */
112 | return (uint8_t*)(MAL_Buffer);
113 | }
114 |
115 | /**
116 | * @brief MEM_If_CheckAdd
117 | * Check if the address is an allowed address for this memory.
118 | * @param Add: Address to be checked.
119 | * @param Len: Number of data to be read (in bytes).
120 | * @retval MAL_OK if the address is allowed, MAL_FAIL else.
121 | */
122 | uint16_t MEM_If_CheckAdd(uint32_t Add)
123 | {
124 | if ((Add >= MEM_START_ADD) && (Add < MEM_END_ADD))
125 | {
126 | return MAL_OK;
127 | }
128 | else
129 | {
130 | return MAL_FAIL;
131 | }
132 | }
133 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
134 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/dfu/src/usbd_otp_if.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_otp_if.c
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Specific media access Layer for OTP (One Time Programming) memory.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "usbd_otp_if.h"
24 | #include "usbd_dfu_mal.h"
25 |
26 | /* Private typedef -----------------------------------------------------------*/
27 | /* Private define ------------------------------------------------------------*/
28 | /* Private macro -------------------------------------------------------------*/
29 |
30 | /* Private function prototypes -----------------------------------------------*/
31 | uint16_t OTP_If_Write (uint32_t Add, uint32_t Len);
32 | uint8_t *OTP_If_Read (uint32_t Add, uint32_t Len);
33 | uint16_t OTP_If_DeInit(void);
34 | uint16_t OTP_If_CheckAdd(uint32_t Add);
35 |
36 |
37 | /* Private variables ---------------------------------------------------------*/
38 | DFU_MAL_Prop_TypeDef DFU_Otp_cb =
39 | {
40 | OTP_IF_STRING,
41 | NULL, /* Init not supported*/
42 | NULL, /* DeInit not supported */
43 | NULL, /* Erase not supported */
44 | OTP_If_Write,
45 | OTP_If_Read,
46 | OTP_If_CheckAdd,
47 | 1, /* Erase Time in ms */
48 | 10 /* Programming Time in ms */
49 | };
50 |
51 | /* Private functions ---------------------------------------------------------*/
52 |
53 | /**
54 | * @brief OTP_If_Write
55 | * Memory write routine.
56 | * @param Add: Address to be written to.
57 | * @param Len: Number of data to be written (in bytes).
58 | * @retval MAL_OK if operation is successeful, MAL_FAIL else.
59 | */
60 | uint16_t OTP_If_Write(uint32_t Add, uint32_t Len)
61 | {
62 | uint32_t idx = 0;
63 |
64 | if (Len & 0x3) /* Not an aligned data */
65 | {
66 | for (idx = Len; idx < ((Len & 0xFFFC) + 4); idx++)
67 | {
68 | MAL_Buffer[idx] = 0xFF;
69 | }
70 | }
71 |
72 | /* Data received are Word multiple */
73 | for (idx = 0; idx < Len; idx = idx + 4)
74 | {
75 | FLASH_ProgramWord(Add, *(uint32_t *)(MAL_Buffer + idx));
76 | Add += 4;
77 | }
78 | return MAL_OK;
79 | }
80 |
81 | /**
82 | * @brief OTP_If_Read
83 | * Memory read routine.
84 | * @param Add: Address to be read from.
85 | * @param Len: Number of data to be read (in bytes).
86 | * @retval Pointer to the phyisical address where data should be read.
87 | */
88 | uint8_t *OTP_If_Read (uint32_t Add, uint32_t Len)
89 | {
90 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
91 | uint32_t idx = 0;
92 | for (idx = 0; idx < Len; idx += 4)
93 | {
94 | *(uint32_t*)(MAL_Buffer + idx) = *(uint32_t *)(Add + idx);
95 | }
96 | return (uint8_t*)(MAL_Buffer);
97 | #else
98 | return (uint8_t*)(Add);
99 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
100 | }
101 |
102 | /**
103 | * @brief OTP_If_CheckAdd
104 | * Check if the address is an allowed address for this memory.
105 | * @param Add: Address to be checked.
106 | * @param Len: Number of data to be read (in bytes).
107 | * @retval MAL_OK if the address is allowed, MAL_FAIL else.
108 | */
109 | uint16_t OTP_If_CheckAdd(uint32_t Add)
110 | {
111 | if ((Add >= OTP_START_ADD) && (Add < OTP_END_ADD))
112 | {
113 | return MAL_OK;
114 | }
115 | else
116 | {
117 | return MAL_FAIL;
118 | }
119 | }
120 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
121 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/hid/inc/usbd_hid_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_hid_core.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header file for the usbd_hid_core.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 |
24 | #ifndef __USB_HID_CORE_H_
25 | #define __USB_HID_CORE_H_
26 |
27 | #include "usbd_ioreq.h"
28 |
29 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
30 | * @{
31 | */
32 |
33 | /** @defgroup USBD_HID
34 | * @brief This file is the Header file for USBD_msc.c
35 | * @{
36 | */
37 |
38 |
39 | /** @defgroup USBD_HID_Exported_Defines
40 | * @{
41 | */
42 | #define USB_HID_CONFIG_DESC_SIZ 34
43 | #define USB_HID_DESC_SIZ 9
44 | #define HID_MOUSE_REPORT_DESC_SIZE 74
45 |
46 | #define HID_DESCRIPTOR_TYPE 0x21
47 | #define HID_REPORT_DESC 0x22
48 |
49 |
50 | #define HID_REQ_SET_PROTOCOL 0x0B
51 | #define HID_REQ_GET_PROTOCOL 0x03
52 |
53 | #define HID_REQ_SET_IDLE 0x0A
54 | #define HID_REQ_GET_IDLE 0x02
55 |
56 | #define HID_REQ_SET_REPORT 0x09
57 | #define HID_REQ_GET_REPORT 0x01
58 | /**
59 | * @}
60 | */
61 |
62 |
63 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
64 | * @{
65 | */
66 |
67 |
68 | /**
69 | * @}
70 | */
71 |
72 |
73 |
74 | /** @defgroup USBD_CORE_Exported_Macros
75 | * @{
76 | */
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | /** @defgroup USBD_CORE_Exported_Variables
83 | * @{
84 | */
85 |
86 | extern USBD_Class_cb_TypeDef USBD_HID_cb;
87 | /**
88 | * @}
89 | */
90 |
91 | /** @defgroup USB_CORE_Exported_Functions
92 | * @{
93 | */
94 | uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev,
95 | uint8_t *report,
96 | uint16_t len);
97 | /**
98 | * @}
99 | */
100 |
101 | #endif // __USB_HID_CORE_H_
102 | /**
103 | * @}
104 | */
105 |
106 | /**
107 | * @}
108 | */
109 |
110 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
111 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/midi/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../../../Core/cmsis -I../../../Core/stm32
34 | CFLAGS += -I../../../Conf -I../../../USB_OTG/inc
35 | CFLAGS += -I../../Core/inc
36 |
37 | # Sources
38 | SRCS = usbd_midi_core.c
39 |
40 | OBJS = $(SRCS:.c=.o)
41 | LIBNAME = libusbdevmidi.a
42 |
43 | all: $(LIBNAME)
44 |
45 | %.o : %.c
46 | $(CC) $(CFLAGS) -c -o $@ $^
47 |
48 | $(LIBNAME): $(OBJS)
49 | $(AR) -r $@ $(OBJS)
50 |
51 | clean:
52 | rm -f $(OBJS) $(LIBNAME)
--------------------------------------------------------------------------------
/lib/USB_Device/Class/midi/inc/usbd_midi_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file usbd_midi_core.h
3 | * @author Philip Karlsson
4 | * @version V1.0.0
5 | * @date 29-November-2014
6 | * @brief This is the header for the implementation of the midi class.
7 | *
8 | */
9 |
10 | #ifndef __USB_MIDI_CORE_H_
11 | #define __USB_MIDI_CORE_H_
12 |
13 | #include "usbd_ioreq.h"
14 |
15 | /* The structure of the callbacks related to the midi core driver.. */
16 | extern USBD_Class_cb_TypeDef USBD_MIDI_cb;
17 |
18 | /* User callbacks for the midi driver */
19 | typedef struct _MIDI_IF_PROP
20 | {
21 | uint16_t (*pIf_MidiRx) (uint8_t *msg, uint16_t length);
22 | uint16_t (*pIf_MidiTx) (uint8_t *msg, uint16_t length);
23 | }
24 | MIDI_IF_Prop_TypeDef;
25 |
26 | extern void usbd_midi_init_driver(MIDI_IF_Prop_TypeDef *addr);
27 |
28 |
29 | extern uint8_t APP_Rx_Buffer [APP_RX_DATA_SIZE];
30 |
31 | extern uint32_t APP_Rx_ptr_in;
32 | extern uint32_t APP_Rx_ptr_out;
33 | extern uint32_t APP_Rx_length;
34 |
35 | extern uint8_t USB_Tx_State;
36 |
37 |
38 | #endif // __USB_CDC_CORE_H_
39 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/midi/libusbdevmidi.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ripxorip/stm32_usb_midi/dd55877615d26585896cf0c71597f2d91506a094/lib/USB_Device/Class/midi/libusbdevmidi.a
--------------------------------------------------------------------------------
/lib/USB_Device/Class/midi/usbd_midi_core.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ripxorip/stm32_usb_midi/dd55877615d26585896cf0c71597f2d91506a094/lib/USB_Device/Class/midi/usbd_midi_core.o
--------------------------------------------------------------------------------
/lib/USB_Device/Class/msc/inc/usbd_msc_bot.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_msc_bot.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header for the usbd_msc_bot.c file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 |
24 | #include "usbd_core.h"
25 |
26 | /* Define to prevent recursive inclusion -------------------------------------*/
27 | #ifndef __USBD_MSC_BOT_H
28 | #define __USBD_MSC_BOT_H
29 |
30 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
31 | * @{
32 | */
33 |
34 | /** @defgroup MSC_BOT
35 | * @brief This file is the Header file for usbd_bot.c
36 | * @{
37 | */
38 |
39 |
40 | /** @defgroup USBD_CORE_Exported_Defines
41 | * @{
42 | */
43 | #define BOT_IDLE 0 /* Idle state */
44 | #define BOT_DATA_OUT 1 /* Data Out state */
45 | #define BOT_DATA_IN 2 /* Data In state */
46 | #define BOT_LAST_DATA_IN 3 /* Last Data In Last */
47 | #define BOT_SEND_DATA 4 /* Send Immediate data */
48 |
49 | #define BOT_CBW_SIGNATURE 0x43425355
50 | #define BOT_CSW_SIGNATURE 0x53425355
51 | #define BOT_CBW_LENGTH 31
52 | #define BOT_CSW_LENGTH 13
53 |
54 | /* CSW Status Definitions */
55 | #define CSW_CMD_PASSED 0x00
56 | #define CSW_CMD_FAILED 0x01
57 | #define CSW_PHASE_ERROR 0x02
58 |
59 | /* BOT Status */
60 | #define BOT_STATE_NORMAL 0
61 | #define BOT_STATE_RECOVERY 1
62 | #define BOT_STATE_ERROR 2
63 |
64 |
65 | #define DIR_IN 0
66 | #define DIR_OUT 1
67 | #define BOTH_DIR 2
68 |
69 | /**
70 | * @}
71 | */
72 |
73 | /** @defgroup MSC_CORE_Private_TypesDefinitions
74 | * @{
75 | */
76 |
77 | typedef struct _MSC_BOT_CBW
78 | {
79 | uint32_t dSignature;
80 | uint32_t dTag;
81 | uint32_t dDataLength;
82 | uint8_t bmFlags;
83 | uint8_t bLUN;
84 | uint8_t bCBLength;
85 | uint8_t CB[16];
86 | }
87 | MSC_BOT_CBW_TypeDef;
88 |
89 |
90 | typedef struct _MSC_BOT_CSW
91 | {
92 | uint32_t dSignature;
93 | uint32_t dTag;
94 | uint32_t dDataResidue;
95 | uint8_t bStatus;
96 | }
97 | MSC_BOT_CSW_TypeDef;
98 |
99 | /**
100 | * @}
101 | */
102 |
103 |
104 | /** @defgroup USBD_CORE_Exported_Types
105 | * @{
106 | */
107 |
108 | extern uint8_t MSC_BOT_Data[];
109 | extern uint16_t MSC_BOT_DataLen;
110 | extern uint8_t MSC_BOT_State;
111 | extern uint8_t MSC_BOT_BurstMode;
112 | extern MSC_BOT_CBW_TypeDef MSC_BOT_cbw;
113 | extern MSC_BOT_CSW_TypeDef MSC_BOT_csw;
114 | /**
115 | * @}
116 | */
117 | /** @defgroup USBD_CORE_Exported_FunctionsPrototypes
118 | * @{
119 | */
120 | void MSC_BOT_Init (USB_OTG_CORE_HANDLE *pdev);
121 | void MSC_BOT_Reset (USB_OTG_CORE_HANDLE *pdev);
122 | void MSC_BOT_DeInit (USB_OTG_CORE_HANDLE *pdev);
123 | void MSC_BOT_DataIn (USB_OTG_CORE_HANDLE *pdev,
124 | uint8_t epnum);
125 |
126 | void MSC_BOT_DataOut (USB_OTG_CORE_HANDLE *pdev,
127 | uint8_t epnum);
128 |
129 | void MSC_BOT_SendCSW (USB_OTG_CORE_HANDLE *pdev,
130 | uint8_t CSW_Status);
131 |
132 | void MSC_BOT_CplClrFeature (USB_OTG_CORE_HANDLE *pdev,
133 | uint8_t epnum);
134 | /**
135 | * @}
136 | */
137 |
138 | #endif /* __USBD_MSC_BOT_H */
139 | /**
140 | * @}
141 | */
142 |
143 | /**
144 | * @}
145 | */
146 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
147 |
148 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/msc/inc/usbd_msc_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_msc_core.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header for the usbd_msc_core.c file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef _USB_MSC_CORE_H_
24 | #define _USB_MSC_CORE_H_
25 |
26 | #include "usbd_ioreq.h"
27 |
28 | /** @addtogroup USBD_MSC_BOT
29 | * @{
30 | */
31 |
32 | /** @defgroup USBD_MSC
33 | * @brief This file is the Header file for USBD_msc.c
34 | * @{
35 | */
36 |
37 |
38 | /** @defgroup USBD_BOT_Exported_Defines
39 | * @{
40 | */
41 |
42 |
43 | #define BOT_GET_MAX_LUN 0xFE
44 | #define BOT_RESET 0xFF
45 | #define USB_MSC_CONFIG_DESC_SIZ 32
46 |
47 | #define MSC_EPIN_SIZE *(uint16_t *)(((USB_OTG_CORE_HANDLE *)pdev)->dev.pConfig_descriptor + 22)
48 |
49 | #define MSC_EPOUT_SIZE *(uint16_t *)(((USB_OTG_CORE_HANDLE *)pdev)->dev.pConfig_descriptor + 29)
50 |
51 | /**
52 | * @}
53 | */
54 |
55 | /** @defgroup USB_CORE_Exported_Types
56 | * @{
57 | */
58 |
59 | extern USBD_Class_cb_TypeDef USBD_MSC_cb;
60 | /**
61 | * @}
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 | #endif // _USB_MSC_CORE_H_
68 | /**
69 | * @}
70 | */
71 |
72 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
73 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/msc/inc/usbd_msc_data.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_msc_data.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header for the usbd_msc_data.c file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 |
24 | #ifndef _USBD_MSC_DATA_H_
25 | #define _USBD_MSC_DATA_H_
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "usbd_conf.h"
29 |
30 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
31 | * @{
32 | */
33 |
34 | /** @defgroup USB_INFO
35 | * @brief general defines for the usb device library file
36 | * @{
37 | */
38 |
39 | /** @defgroup USB_INFO_Exported_Defines
40 | * @{
41 | */
42 | #define MODE_SENSE6_LEN 8
43 | #define MODE_SENSE10_LEN 8
44 | #define LENGTH_INQUIRY_PAGE00 7
45 | #define LENGTH_FORMAT_CAPACITIES 20
46 |
47 | /**
48 | * @}
49 | */
50 |
51 |
52 | /** @defgroup USBD_INFO_Exported_TypesDefinitions
53 | * @{
54 | */
55 | /**
56 | * @}
57 | */
58 |
59 |
60 |
61 | /** @defgroup USBD_INFO_Exported_Macros
62 | * @{
63 | */
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | /** @defgroup USBD_INFO_Exported_Variables
70 | * @{
71 | */
72 | extern const uint8_t MSC_Page00_Inquiry_Data[];
73 | extern const uint8_t MSC_Mode_Sense6_data[];
74 | extern const uint8_t MSC_Mode_Sense10_data[] ;
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /** @defgroup USBD_INFO_Exported_FunctionsPrototype
81 | * @{
82 | */
83 |
84 | /**
85 | * @}
86 | */
87 |
88 | #endif /* _USBD_MSC_DATA_H_ */
89 |
90 | /**
91 | * @}
92 | */
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
99 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/msc/inc/usbd_msc_mem.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_msc_mem.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header for the STORAGE DISK file file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 |
24 | #ifndef __USBD_MEM_H
25 | #define __USBD_MEM_H
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbd_def.h"
28 |
29 |
30 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
31 | * @{
32 | */
33 |
34 | /** @defgroup USBD_MEM
35 | * @brief header file for the storage disk file
36 | * @{
37 | */
38 |
39 | /** @defgroup USBD_MEM_Exported_Defines
40 | * @{
41 | */
42 | #define USBD_STD_INQUIRY_LENGTH 36
43 | /**
44 | * @}
45 | */
46 |
47 |
48 | /** @defgroup USBD_MEM_Exported_TypesDefinitions
49 | * @{
50 | */
51 |
52 | typedef struct _USBD_STORAGE
53 | {
54 | int8_t (* Init) (uint8_t lun);
55 | int8_t (* GetCapacity) (uint8_t lun, uint32_t *block_num, uint32_t *block_size);
56 | int8_t (* IsReady) (uint8_t lun);
57 | int8_t (* IsWriteProtected) (uint8_t lun);
58 | int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
59 | int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
60 | int8_t (* GetMaxLun)(void);
61 | int8_t *pInquiry;
62 |
63 | }USBD_STORAGE_cb_TypeDef;
64 | /**
65 | * @}
66 | */
67 |
68 |
69 |
70 | /** @defgroup USBD_MEM_Exported_Macros
71 | * @{
72 | */
73 |
74 | /**
75 | * @}
76 | */
77 |
78 | /** @defgroup USBD_MEM_Exported_Variables
79 | * @{
80 | */
81 |
82 | /**
83 | * @}
84 | */
85 |
86 | /** @defgroup USBD_MEM_Exported_FunctionsPrototype
87 | * @{
88 | */
89 | extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops;
90 | /**
91 | * @}
92 | */
93 |
94 | #endif /* __USBD_MEM_H */
95 | /**
96 | * @}
97 | */
98 |
99 | /**
100 | * @}
101 | */
102 |
103 | /**
104 | * @}
105 | */
106 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
107 |
--------------------------------------------------------------------------------
/lib/USB_Device/Class/msc/src/usbd_msc_data.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_msc_data.c
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief This file provides all the vital inquiry pages and sense data.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "usbd_msc_data.h"
24 |
25 |
26 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
27 | * @{
28 | */
29 |
30 |
31 | /** @defgroup MSC_DATA
32 | * @brief Mass storage info/data module
33 | * @{
34 | */
35 |
36 | /** @defgroup MSC_DATA_Private_TypesDefinitions
37 | * @{
38 | */
39 | /**
40 | * @}
41 | */
42 |
43 |
44 | /** @defgroup MSC_DATA_Private_Defines
45 | * @{
46 | */
47 | /**
48 | * @}
49 | */
50 |
51 |
52 | /** @defgroup MSC_DATA_Private_Macros
53 | * @{
54 | */
55 | /**
56 | * @}
57 | */
58 |
59 |
60 | /** @defgroup MSC_DATA_Private_Variables
61 | * @{
62 | */
63 |
64 |
65 | /* USB Mass storage Page 0 Inquiry Data */
66 | const uint8_t MSC_Page00_Inquiry_Data[] = {//7
67 | 0x00,
68 | 0x00,
69 | 0x00,
70 | (LENGTH_INQUIRY_PAGE00 - 4),
71 | 0x00,
72 | 0x80,
73 | 0x83
74 | };
75 | /* USB Mass storage sense 6 Data */
76 | const uint8_t MSC_Mode_Sense6_data[] = {
77 | 0x00,
78 | 0x00,
79 | 0x00,
80 | 0x00,
81 | 0x00,
82 | 0x00,
83 | 0x00,
84 | 0x00
85 | };
86 | /* USB Mass storage sense 10 Data */
87 | const uint8_t MSC_Mode_Sense10_data[] = {
88 | 0x00,
89 | 0x06,
90 | 0x00,
91 | 0x00,
92 | 0x00,
93 | 0x00,
94 | 0x00,
95 | 0x00
96 | };
97 | /**
98 | * @}
99 | */
100 |
101 |
102 | /** @defgroup MSC_DATA_Private_FunctionPrototypes
103 | * @{
104 | */
105 | /**
106 | * @}
107 | */
108 |
109 |
110 | /** @defgroup MSC_DATA_Private_Functions
111 | * @{
112 | */
113 |
114 | /**
115 | * @}
116 | */
117 |
118 |
119 | /**
120 | * @}
121 | */
122 |
123 |
124 | /**
125 | * @}
126 | */
127 |
128 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
129 |
--------------------------------------------------------------------------------
/lib/USB_Device/Core/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../../Core/cmsis -I../../Core/stm32
34 | CFLAGS += -I../../Conf -I../../USB_OTG/inc
35 |
36 | # Sources
37 | SRCS = usbd_core.c usbd_ioreq.c usbd_req.c
38 |
39 | OBJS = $(SRCS:.c=.o)
40 | LIBNAME = libusbdevcore.a
41 |
42 | all: $(LIBNAME)
43 |
44 | %.o : %.c
45 | $(CC) $(CFLAGS) -c -o $@ $^
46 |
47 | $(LIBNAME): $(OBJS)
48 | $(AR) -r $@ $(OBJS)
49 |
50 | clean:
51 | rm -f $(OBJS) $(LIBNAME)
52 |
--------------------------------------------------------------------------------
/lib/USB_Device/Core/inc/usbd_conf_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_conf_template.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief usb device configuration template file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CONF__H__
24 | #define __USBD_CONF__H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm32f2xx.h"
28 |
29 |
30 |
31 | /** @defgroup USB_CONF_Exported_Defines
32 | * @{
33 | */
34 | #define USE_USB_OTG_HS
35 |
36 | #define USBD_CFG_MAX_NUM 1
37 | #define USB_MAX_STR_DESC_SIZ 64
38 | #define USBD_EP0_MAX_PACKET_SIZE 64
39 |
40 | /**
41 | * @}
42 | */
43 |
44 |
45 | /** @defgroup USB_CONF_Exported_Types
46 | * @{
47 | */
48 | /**
49 | * @}
50 | */
51 |
52 |
53 | /** @defgroup USB_CONF_Exported_Macros
54 | * @{
55 | */
56 | /**
57 | * @}
58 | */
59 |
60 | /** @defgroup USB_CONF_Exported_Variables
61 | * @{
62 | */
63 | /**
64 | * @}
65 | */
66 |
67 | /** @defgroup USB_CONF_Exported_FunctionsPrototype
68 | * @{
69 | */
70 | /**
71 | * @}
72 | */
73 |
74 |
75 | #endif //__USBD_CONF__H__
76 |
77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
78 |
79 |
--------------------------------------------------------------------------------
/lib/USB_Device/Core/inc/usbd_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_core.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header file for usbd_core.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CORE_H
24 | #define __USBD_CORE_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usb_dcd.h"
28 | #include "usbd_def.h"
29 | #include "usbd_conf.h"
30 |
31 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
32 | * @{
33 | */
34 |
35 | /** @defgroup USBD_CORE
36 | * @brief This file is the Header file for usbd_core.c file
37 | * @{
38 | */
39 |
40 |
41 | /** @defgroup USBD_CORE_Exported_Defines
42 | * @{
43 | */
44 |
45 | typedef enum {
46 | USBD_OK = 0,
47 | USBD_BUSY,
48 | USBD_FAIL,
49 | }USBD_Status;
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
56 | * @{
57 | */
58 |
59 |
60 | /**
61 | * @}
62 | */
63 |
64 |
65 |
66 | /** @defgroup USBD_CORE_Exported_Macros
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @defgroup USBD_CORE_Exported_Variables
75 | * @{
76 | */
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype
83 | * @{
84 | */
85 | void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
86 | USB_OTG_CORE_ID_TypeDef coreID,
87 | USBD_DEVICE *pDevice,
88 | USBD_Class_cb_TypeDef *class_cb,
89 | USBD_Usr_cb_TypeDef *usr_cb);
90 |
91 | USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev);
92 |
93 | USBD_Status USBD_ClrCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx);
94 |
95 | USBD_Status USBD_SetCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx);
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | #endif /* __USBD_CORE_H */
102 |
103 | /**
104 | * @}
105 | */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/lib/USB_Device/Core/inc/usbd_ioreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header file for the usbd_ioreq.c file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 |
24 | #ifndef __USBD_IOREQ_H_
25 | #define __USBD_IOREQ_H_
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "usbd_def.h"
29 | #include "usbd_core.h"
30 |
31 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
32 | * @{
33 | */
34 |
35 | /** @defgroup USBD_IOREQ
36 | * @brief header file for the usbd_ioreq.c file
37 | * @{
38 | */
39 |
40 | /** @defgroup USBD_IOREQ_Exported_Defines
41 | * @{
42 | */
43 | /**
44 | * @}
45 | */
46 |
47 |
48 | /** @defgroup USBD_IOREQ_Exported_Types
49 | * @{
50 | */
51 |
52 |
53 | /**
54 | * @}
55 | */
56 |
57 |
58 |
59 | /** @defgroup USBD_IOREQ_Exported_Macros
60 | * @{
61 | */
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | /** @defgroup USBD_IOREQ_Exported_Variables
68 | * @{
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
76 | * @{
77 | */
78 |
79 | USBD_Status USBD_CtlSendData (USB_OTG_CORE_HANDLE *pdev,
80 | uint8_t *buf,
81 | uint16_t len);
82 |
83 | USBD_Status USBD_CtlContinueSendData (USB_OTG_CORE_HANDLE *pdev,
84 | uint8_t *pbuf,
85 | uint16_t len);
86 |
87 | USBD_Status USBD_CtlPrepareRx (USB_OTG_CORE_HANDLE *pdev,
88 | uint8_t *pbuf,
89 | uint16_t len);
90 |
91 | USBD_Status USBD_CtlContinueRx (USB_OTG_CORE_HANDLE *pdev,
92 | uint8_t *pbuf,
93 | uint16_t len);
94 |
95 | USBD_Status USBD_CtlSendStatus (USB_OTG_CORE_HANDLE *pdev);
96 |
97 | USBD_Status USBD_CtlReceiveStatus (USB_OTG_CORE_HANDLE *pdev);
98 |
99 | uint16_t USBD_GetRxCount (USB_OTG_CORE_HANDLE *pdev ,
100 | uint8_t epnum);
101 |
102 | /**
103 | * @}
104 | */
105 |
106 | #endif /* __USBD_IOREQ_H_ */
107 |
108 | /**
109 | * @}
110 | */
111 |
112 | /**
113 | * @}
114 | */
115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
116 |
--------------------------------------------------------------------------------
/lib/USB_Device/Core/inc/usbd_req.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_req.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief header file for the usbd_req.c file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 |
24 | #ifndef __USB_REQUEST_H_
25 | #define __USB_REQUEST_H_
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "usbd_def.h"
29 | #include "usbd_core.h"
30 | #include "usbd_conf.h"
31 |
32 |
33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
34 | * @{
35 | */
36 |
37 | /** @defgroup USBD_REQ
38 | * @brief header file for the usbd_ioreq.c file
39 | * @{
40 | */
41 |
42 | /** @defgroup USBD_REQ_Exported_Defines
43 | * @{
44 | */
45 | /**
46 | * @}
47 | */
48 |
49 |
50 | /** @defgroup USBD_REQ_Exported_Types
51 | * @{
52 | */
53 | /**
54 | * @}
55 | */
56 |
57 |
58 |
59 | /** @defgroup USBD_REQ_Exported_Macros
60 | * @{
61 | */
62 | /**
63 | * @}
64 | */
65 |
66 | /** @defgroup USBD_REQ_Exported_Variables
67 | * @{
68 | */
69 | /**
70 | * @}
71 | */
72 |
73 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype
74 | * @{
75 | */
76 |
77 | USBD_Status USBD_StdDevReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req);
78 | USBD_Status USBD_StdItfReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req);
79 | USBD_Status USBD_StdEPReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req);
80 | void USBD_ParseSetupRequest( USB_OTG_CORE_HANDLE *pdev,
81 | USB_SETUP_REQ *req);
82 |
83 | void USBD_CtlError( USB_OTG_CORE_HANDLE *pdev,
84 | USB_SETUP_REQ *req);
85 |
86 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
87 | /**
88 | * @}
89 | */
90 |
91 | #endif /* __USB_REQUEST_H_ */
92 |
93 | /**
94 | * @}
95 | */
96 |
97 | /**
98 | * @}
99 | */
100 |
101 |
102 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
103 |
--------------------------------------------------------------------------------
/lib/USB_Device/Core/inc/usbd_usr.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_usr.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 22-July-2011
7 | * @brief Header file for usbd_usr.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_USR_H__
24 | #define __USBD_USR_H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbd_core.h"
28 |
29 |
30 | /** @addtogroup USBD_USER
31 | * @{
32 | */
33 |
34 | /** @addtogroup USBD_MSC_DEMO_USER_CALLBACKS
35 | * @{
36 | */
37 |
38 | /** @defgroup USBD_USR
39 | * @brief This file is the Header file for usbd_usr.c
40 | * @{
41 | */
42 |
43 |
44 | /** @defgroup USBD_USR_Exported_Types
45 | * @{
46 | */
47 |
48 | extern USBD_Usr_cb_TypeDef USR_cb;
49 | extern USBD_Usr_cb_TypeDef USR_FS_cb;
50 | extern USBD_Usr_cb_TypeDef USR_HS_cb;
51 |
52 |
53 |
54 | /**
55 | * @}
56 | */
57 |
58 |
59 |
60 | /** @defgroup USBD_USR_Exported_Defines
61 | * @{
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USBD_USR_Exported_Macros
69 | * @{
70 | */
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup USBD_USR_Exported_Variables
76 | * @{
77 | */
78 |
79 | void USBD_USR_Init(void);
80 | void USBD_USR_DeviceReset (uint8_t speed);
81 | void USBD_USR_DeviceConfigured (void);
82 | void USBD_USR_DeviceSuspended(void);
83 | void USBD_USR_DeviceResumed(void);
84 |
85 | void USBD_USR_DeviceConnected(void);
86 | void USBD_USR_DeviceDisconnected(void);
87 |
88 | void USBD_USR_FS_Init(void);
89 | void USBD_USR_FS_DeviceReset (uint8_t speed);
90 | void USBD_USR_FS_DeviceConfigured (void);
91 | void USBD_USR_FS_DeviceSuspended(void);
92 | void USBD_USR_FS_DeviceResumed(void);
93 |
94 | void USBD_USR_FS_DeviceConnected(void);
95 | void USBD_USR_FS_DeviceDisconnected(void);
96 |
97 | void USBD_USR_HS_Init(void);
98 | void USBD_USR_HS_DeviceReset (uint8_t speed);
99 | void USBD_USR_HS_DeviceConfigured (void);
100 | void USBD_USR_HS_DeviceSuspended(void);
101 | void USBD_USR_HS_DeviceResumed(void);
102 |
103 | void USBD_USR_HS_DeviceConnected(void);
104 | void USBD_USR_HS_DeviceDisconnected(void);
105 |
106 | /**
107 | * @}
108 | */
109 |
110 | /** @defgroup USBD_USR_Exported_FunctionsPrototype
111 | * @{
112 | */
113 | /**
114 | * @}
115 | */
116 |
117 | #endif /*__USBD_USR_H__*/
118 |
119 | /**
120 | * @}
121 | */
122 |
123 | /**
124 | * @}
125 | */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
132 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/lib/USB_Host/Class/HID/inc/usbh_hid_keybd.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_hid_keybd.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief This file contains all the prototypes for the usbh_hid_keybd.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive -----------------------------------------------*/
23 | #ifndef __USBH_HID_KEYBD_H
24 | #define __USBH_HID_KEYBD_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usb_conf.h"
28 | #include "usbh_hid_core.h"
29 |
30 | /** @addtogroup USBH_LIB
31 | * @{
32 | */
33 |
34 | /** @addtogroup USBH_CLASS
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_HID_CLASS
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_HID_KEYBD
43 | * @brief This file is the Header file for USBH_HID_KEYBD.c
44 | * @{
45 | */
46 |
47 |
48 | /** @defgroup USBH_HID_KEYBD_Exported_Types
49 | * @{
50 | */
51 |
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | /** @defgroup USBH_HID_KEYBD_Exported_Defines
58 | * @{
59 | */
60 | //#define QWERTY_KEYBOARD
61 | #define AZERTY_KEYBOARD
62 |
63 | #define KBD_LEFT_CTRL 0x01
64 | #define KBD_LEFT_SHIFT 0x02
65 | #define KBD_LEFT_ALT 0x04
66 | #define KBD_LEFT_GUI 0x08
67 | #define KBD_RIGHT_CTRL 0x10
68 | #define KBD_RIGHT_SHIFT 0x20
69 | #define KBD_RIGHT_ALT 0x40
70 | #define KBD_RIGHT_GUI 0x80
71 |
72 | #define KBR_MAX_NBR_PRESSED 6
73 |
74 | /**
75 | * @}
76 | */
77 |
78 | /** @defgroup USBH_HID_KEYBD_Exported_Macros
79 | * @{
80 | */
81 | /**
82 | * @}
83 | */
84 |
85 | /** @defgroup USBH_HID_KEYBD_Exported_Variables
86 | * @{
87 | */
88 |
89 | extern HID_cb_TypeDef HID_KEYBRD_cb;
90 | /**
91 | * @}
92 | */
93 |
94 | /** @defgroup USBH_HID_KEYBD_Exported_FunctionsPrototype
95 | * @{
96 | */
97 | void USR_KEYBRD_Init (void);
98 | void USR_KEYBRD_ProcessData (uint8_t pbuf);
99 | /**
100 | * @}
101 | */
102 |
103 | #endif /* __USBH_HID_KEYBD_H */
104 |
105 | /**
106 | * @}
107 | */
108 |
109 | /**
110 | * @}
111 | */
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | /**
118 | * @}
119 | */
120 |
121 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
122 |
123 |
--------------------------------------------------------------------------------
/lib/USB_Host/Class/HID/inc/usbh_hid_mouse.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_hid_mouse.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief This file contains all the prototypes for the usbh_hid_mouse.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 |
23 | /* Define to prevent recursive ----------------------------------------------*/
24 | #ifndef __USBH_HID_MOUSE_H
25 | #define __USBH_HID_MOUSE_H
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "usbh_hid_core.h"
29 |
30 | /** @addtogroup USBH_LIB
31 | * @{
32 | */
33 |
34 | /** @addtogroup USBH_CLASS
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_HID_CLASS
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_HID_MOUSE
43 | * @brief This file is the Header file for USBH_HID_MOUSE.c
44 | * @{
45 | */
46 |
47 |
48 | /** @defgroup USBH_HID_MOUSE_Exported_Types
49 | * @{
50 | */
51 | typedef struct _HID_MOUSE_Data
52 | {
53 | uint8_t x;
54 | uint8_t y;
55 | uint8_t z; /* Not Supported */
56 | uint8_t button;
57 | }
58 | HID_MOUSE_Data_TypeDef;
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /** @defgroup USBH_HID_MOUSE_Exported_Defines
65 | * @{
66 | */
67 | /**
68 | * @}
69 | */
70 |
71 | /** @defgroup USBH_HID_MOUSE_Exported_Macros
72 | * @{
73 | */
74 | /**
75 | * @}
76 | */
77 |
78 | /** @defgroup USBH_HID_MOUSE_Exported_Variables
79 | * @{
80 | */
81 |
82 | extern HID_cb_TypeDef HID_MOUSE_cb;
83 | extern HID_MOUSE_Data_TypeDef HID_MOUSE_Data;
84 | /**
85 | * @}
86 | */
87 |
88 | /** @defgroup USBH_HID_MOUSE_Exported_FunctionsPrototype
89 | * @{
90 | */
91 | void USR_MOUSE_Init (void);
92 | void USR_MOUSE_ProcessData (HID_MOUSE_Data_TypeDef *data);
93 | /**
94 | * @}
95 | */
96 |
97 | #endif /* __USBH_HID_MOUSE_H */
98 |
99 | /**
100 | * @}
101 | */
102 |
103 | /**
104 | * @}
105 | */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /**
112 | * @}
113 | */
114 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
115 |
--------------------------------------------------------------------------------
/lib/USB_Host/Class/HID/src/usbh_hid_mouse.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_hid_mouse.c
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief This file is the application layer for USB Host HID Mouse Handling.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "usbh_hid_mouse.h"
24 |
25 |
26 | /** @addtogroup USBH_LIB
27 | * @{
28 | */
29 |
30 | /** @addtogroup USBH_CLASS
31 | * @{
32 | */
33 |
34 | /** @addtogroup USBH_HID_CLASS
35 | * @{
36 | */
37 |
38 | /** @defgroup USBH_HID_MOUSE
39 | * @brief This file includes HID Layer Handlers for USB Host HID class.
40 | * @{
41 | */
42 |
43 | /** @defgroup USBH_HID_MOUSE_Private_TypesDefinitions
44 | * @{
45 | */
46 | /**
47 | * @}
48 | */
49 |
50 |
51 | /** @defgroup USBH_HID_MOUSE_Private_Defines
52 | * @{
53 | */
54 | /**
55 | * @}
56 | */
57 |
58 |
59 | /** @defgroup USBH_HID_MOUSE_Private_Macros
60 | * @{
61 | */
62 | /**
63 | * @}
64 | */
65 |
66 | /** @defgroup USBH_HID_MOUSE_Private_FunctionPrototypes
67 | * @{
68 | */
69 | static void MOUSE_Init (void);
70 | static void MOUSE_Decode(uint8_t *data);
71 | /**
72 | * @}
73 | */
74 |
75 |
76 | /** @defgroup USBH_HID_MOUSE_Private_Variables
77 | * @{
78 | */
79 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
80 | #if defined (__CC_ARM) /*!< ARM Compiler */
81 | __align(4)
82 | #elif defined ( __ICCARM__ ) /*!< IAR Compiler */
83 | #pragma data_alignment=4
84 | #elif defined (__GNUC__) /*!< GNU Compiler */
85 | #pragma pack(4)
86 | #elif defined (__TASKING__) /*!< TASKING Compiler */
87 | __align(4)
88 | #endif /* __CC_ARM */
89 | #endif
90 |
91 |
92 | HID_MOUSE_Data_TypeDef HID_MOUSE_Data;
93 | HID_cb_TypeDef HID_MOUSE_cb =
94 | {
95 | MOUSE_Init,
96 | MOUSE_Decode,
97 | };
98 | /**
99 | * @}
100 | */
101 |
102 |
103 | /** @defgroup USBH_HID_MOUSE_Private_Functions
104 | * @{
105 | */
106 |
107 | /**
108 | * @brief MOUSE_Init
109 | * Init Mouse State.
110 | * @param None
111 | * @retval None
112 | */
113 | static void MOUSE_Init ( void)
114 | {
115 | /* Call User Init*/
116 | USR_MOUSE_Init();
117 | }
118 |
119 | /**
120 | * @brief MOUSE_Decode
121 | * Decode Mouse data
122 | * @param data : Pointer to Mouse HID data buffer
123 | * @retval None
124 | */
125 | static void MOUSE_Decode(uint8_t *data)
126 | {
127 | HID_MOUSE_Data.button = data[0];
128 |
129 | HID_MOUSE_Data.x = data[1];
130 | HID_MOUSE_Data.y = data[2];
131 |
132 | USR_MOUSE_ProcessData(&HID_MOUSE_Data);
133 |
134 | }
135 | /**
136 | * @}
137 | */
138 |
139 | /**
140 | * @}
141 | */
142 |
143 | /**
144 | * @}
145 | */
146 |
147 | /**
148 | * @}
149 | */
150 |
151 |
152 | /**
153 | * @}
154 | */
155 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
156 |
--------------------------------------------------------------------------------
/lib/USB_Host/Class/MSC/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../../../Core/cmsis -I../../../Core/stm32
34 | CFLAGS += -I../../../Conf -I../../../USB_OTG/inc
35 | CFLAGS += -I../../Core/inc
36 | CFLAGS += -I../../../fat_fs/inc
37 |
38 | # Sources
39 | SRCS = usbh_msc_bot.c usbh_msc_core.c usbh_msc_fatfs.c usbh_msc_scsi.c
40 |
41 | OBJS = $(SRCS:.c=.o)
42 | LIBNAME = libusbhostmsc.a
43 |
44 | all: $(LIBNAME)
45 |
46 | %.o : %.c
47 | $(CC) $(CFLAGS) -c -o $@ $^
48 |
49 | $(LIBNAME): $(OBJS)
50 | $(AR) -r $@ $(OBJS)
51 |
52 | clean:
53 | rm -f $(OBJS) $(LIBNAME)
54 |
--------------------------------------------------------------------------------
/lib/USB_Host/Class/MSC/inc/usbh_msc_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_msc_core.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief This file contains all the prototypes for the usbh_msc_core.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive ----------------------------------------------*/
23 | #ifndef __USBH_MSC_CORE_H
24 | #define __USBH_MSC_CORE_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbh_core.h"
28 | #include "usbh_stdreq.h"
29 | #include "usb_bsp.h"
30 | #include "usbh_ioreq.h"
31 | #include "usbh_hcs.h"
32 | #include "usbh_msc_core.h"
33 | #include "usbh_msc_scsi.h"
34 | #include "usbh_msc_bot.h"
35 |
36 | /** @addtogroup USBH_LIB
37 | * @{
38 | */
39 |
40 | /** @addtogroup USBH_CLASS
41 | * @{
42 | */
43 |
44 | /** @addtogroup USBH_MSC_CLASS
45 | * @{
46 | */
47 |
48 | /** @defgroup USBH_MSC_CORE
49 | * @brief This file is the Header file for usbh_msc_core.c
50 | * @{
51 | */
52 |
53 |
54 | /** @defgroup USBH_MSC_CORE_Exported_Types
55 | * @{
56 | */
57 |
58 |
59 | /* Structure for MSC process */
60 | typedef struct _MSC_Process
61 | {
62 | uint8_t hc_num_in;
63 | uint8_t hc_num_out;
64 | uint8_t MSBulkOutEp;
65 | uint8_t MSBulkInEp;
66 | uint16_t MSBulkInEpSize;
67 | uint16_t MSBulkOutEpSize;
68 | uint8_t buff[USBH_MSC_MPS_SIZE];
69 | uint8_t maxLun;
70 | }
71 | MSC_Machine_TypeDef;
72 |
73 |
74 | /**
75 | * @}
76 | */
77 |
78 |
79 |
80 | /** @defgroup USBH_MSC_CORE_Exported_Defines
81 | * @{
82 | */
83 |
84 | #define USB_REQ_BOT_RESET 0xFF
85 | #define USB_REQ_GET_MAX_LUN 0xFE
86 |
87 |
88 | /**
89 | * @}
90 | */
91 |
92 | /** @defgroup USBH_MSC_CORE_Exported_Macros
93 | * @{
94 | */
95 | /**
96 | * @}
97 | */
98 |
99 | /** @defgroup USBH_MSC_CORE_Exported_Variables
100 | * @{
101 | */
102 | extern USBH_Class_cb_TypeDef USBH_MSC_cb;
103 | extern MSC_Machine_TypeDef MSC_Machine;
104 | extern uint8_t MSCErrorCount;
105 |
106 | /**
107 | * @}
108 | */
109 |
110 | /** @defgroup USBH_MSC_CORE_Exported_FunctionsPrototype
111 | * @{
112 | */
113 |
114 |
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | #endif /* __USBH_MSC_CORE_H */
121 |
122 |
123 | /**
124 | * @}
125 | */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /**
132 | * @}
133 | */
134 |
135 | /**
136 | * @}
137 | */
138 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/lib/USB_Host/Class/MSC/inc/usbh_msc_scsi.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_msc_scsi.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Header file for usbh_msc_scsi.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive ----------------------------------------------*/
23 | #ifndef __USBH_MSC_SCSI_H__
24 | #define __USBH_MSC_SCSI_H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbh_stdreq.h"
28 |
29 |
30 | /** @addtogroup USBH_LIB
31 | * @{
32 | */
33 |
34 | /** @addtogroup USBH_CLASS
35 | * @{
36 | */
37 |
38 | /** @addtogroup USBH_MSC_CLASS
39 | * @{
40 | */
41 |
42 | /** @defgroup USBH_MSC_SCSI
43 | * @brief This file is the Header file for usbh_msc_scsi.c
44 | * @{
45 | */
46 |
47 |
48 | /** @defgroup USBH_MSC_SCSI_Exported_Types
49 | * @{
50 | */
51 | typedef enum {
52 | USBH_MSC_OK = 0,
53 | USBH_MSC_FAIL = 1,
54 | USBH_MSC_PHASE_ERROR = 2,
55 | USBH_MSC_BUSY = 3
56 | }USBH_MSC_Status_TypeDef;
57 |
58 | typedef enum {
59 | CMD_UNINITIALIZED_STATE =0,
60 | CMD_SEND_STATE,
61 | CMD_WAIT_STATUS
62 | } CMD_STATES_TypeDef;
63 |
64 |
65 |
66 | typedef struct __MassStorageParameter
67 | {
68 | uint32_t MSCapacity;
69 | uint32_t MSSenseKey;
70 | uint16_t MSPageLength;
71 | uint8_t MSBulkOutEp;
72 | uint8_t MSBulkInEp;
73 | uint8_t MSWriteProtect;
74 | } MassStorageParameter_TypeDef;
75 | /**
76 | * @}
77 | */
78 |
79 |
80 |
81 | /** @defgroup USBH_MSC_SCSI_Exported_Defines
82 | * @{
83 | */
84 |
85 |
86 |
87 | #define OPCODE_TEST_UNIT_READY 0X00
88 | #define OPCODE_READ_CAPACITY10 0x25
89 | #define OPCODE_MODE_SENSE6 0x1A
90 | #define OPCODE_READ10 0x28
91 | #define OPCODE_WRITE10 0x2A
92 | #define OPCODE_REQUEST_SENSE 0x03
93 |
94 | #define DESC_REQUEST_SENSE 0X00
95 | #define ALLOCATION_LENGTH_REQUEST_SENSE 63
96 | #define XFER_LEN_READ_CAPACITY10 8
97 | #define XFER_LEN_MODE_SENSE6 63
98 |
99 | #define MASK_MODE_SENSE_WRITE_PROTECT 0x80
100 | #define MODE_SENSE_PAGE_CONTROL_FIELD 0x00
101 | #define MODE_SENSE_PAGE_CODE 0x3F
102 | #define DISK_WRITE_PROTECTED 0x01
103 | /**
104 | * @}
105 | */
106 |
107 | /** @defgroup USBH_MSC_SCSI_Exported_Macros
108 | * @{
109 | */
110 | /**
111 | * @}
112 | */
113 |
114 | /** @defgroup _Exported_Variables
115 | * @{
116 | */
117 | extern MassStorageParameter_TypeDef USBH_MSC_Param;
118 | /**
119 | * @}
120 | */
121 |
122 | /** @defgroup USBH_MSC_SCSI_Exported_FunctionsPrototype
123 | * @{
124 | */
125 | uint8_t USBH_MSC_TestUnitReady(USB_OTG_CORE_HANDLE *pdev);
126 | uint8_t USBH_MSC_ReadCapacity10(USB_OTG_CORE_HANDLE *pdev);
127 | uint8_t USBH_MSC_ModeSense6(USB_OTG_CORE_HANDLE *pdev);
128 | uint8_t USBH_MSC_RequestSense(USB_OTG_CORE_HANDLE *pdev);
129 | uint8_t USBH_MSC_Write10(USB_OTG_CORE_HANDLE *pdev,
130 | uint8_t *,
131 | uint32_t ,
132 | uint32_t );
133 | uint8_t USBH_MSC_Read10(USB_OTG_CORE_HANDLE *pdev,
134 | uint8_t *,
135 | uint32_t ,
136 | uint32_t );
137 | void USBH_MSC_StateMachine(USB_OTG_CORE_HANDLE *pdev);
138 |
139 | /**
140 | * @}
141 | */
142 |
143 | #endif //__USBH_MSC_SCSI_H__
144 |
145 |
146 | /**
147 | * @}
148 | */
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /**
155 | * @}
156 | */
157 |
158 | /**
159 | * @}
160 | */
161 |
162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
163 |
164 |
--------------------------------------------------------------------------------
/lib/USB_Host/Core/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../../Core/cmsis -I../../Core/stm32
34 | CFLAGS += -I../../Conf -I../../USB_OTG/inc
35 |
36 | # Sources
37 | SRCS = usbh_core.c usbh_hcs.c usbh_ioreq.c usbh_stdreq.c
38 |
39 | OBJS = $(SRCS:.c=.o)
40 | LIBNAME = libusbhostcore.a
41 |
42 | all: $(LIBNAME)
43 |
44 | %.o : %.c
45 | $(CC) $(CFLAGS) -c -o $@ $^
46 |
47 | $(LIBNAME): $(OBJS)
48 | $(AR) -r $@ $(OBJS)
49 |
50 | clean:
51 | rm -f $(OBJS) $(LIBNAME)
52 |
--------------------------------------------------------------------------------
/lib/USB_Host/Core/inc/usbh_conf_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_conf_template
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief General USB Host library configuration
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBH_CONF__H__
24 | #define __USBH_CONF__H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | /** @addtogroup USBH_OTG_DRIVER
28 | * @{
29 | */
30 |
31 | /** @defgroup USBH_CONF
32 | * @brief usb otg low level driver configuration file
33 | * @{
34 | */
35 |
36 | /** @defgroup USBH_CONF_Exported_Defines
37 | * @{
38 | */
39 |
40 | #define USBH_MAX_NUM_ENDPOINTS 2
41 | #define USBH_MAX_NUM_INTERFACES 2
42 | #ifdef USE_USB_OTG_FS
43 | #define USBH_MSC_MPS_SIZE 0x40
44 | #else
45 | #define USBH_MSC_MPS_SIZE 0x200
46 | #endif
47 |
48 | /**
49 | * @}
50 | */
51 |
52 |
53 | /** @defgroup USBH_CONF_Exported_Types
54 | * @{
55 | */
56 | /**
57 | * @}
58 | */
59 |
60 |
61 | /** @defgroup USBH_CONF_Exported_Macros
62 | * @{
63 | */
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USBH_CONF_Exported_Variables
69 | * @{
70 | */
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup USBH_CONF_Exported_FunctionsPrototype
76 | * @{
77 | */
78 | /**
79 | * @}
80 | */
81 |
82 |
83 | #endif //__USBH_CONF__H__
84 |
85 |
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
94 |
95 |
--------------------------------------------------------------------------------
/lib/USB_Host/Core/inc/usbh_hcs.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_hcs.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Header file for usbh_hcs.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive ----------------------------------------------*/
23 | #ifndef __USBH_HCS_H
24 | #define __USBH_HCS_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usbh_core.h"
28 |
29 |
30 |
31 | /** @addtogroup USBH_LIB
32 | * @{
33 | */
34 |
35 | /** @addtogroup USBH_LIB_CORE
36 | * @{
37 | */
38 |
39 | /** @defgroup USBH_HCS
40 | * @brief This file is the header file for usbh_hcs.c
41 | * @{
42 | */
43 |
44 | /** @defgroup USBH_HCS_Exported_Defines
45 | * @{
46 | */
47 | #define HC_MAX 8
48 |
49 | #define HC_OK 0x0000
50 | #define HC_USED 0x8000
51 | #define HC_ERROR 0xFFFF
52 | #define HC_USED_MASK 0x7FFF
53 | /**
54 | * @}
55 | */
56 |
57 | /** @defgroup USBH_HCS_Exported_Types
58 | * @{
59 | */
60 | /**
61 | * @}
62 | */
63 |
64 |
65 | /** @defgroup USBH_HCS_Exported_Macros
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBH_HCS_Exported_Variables
73 | * @{
74 | */
75 | /**
76 | * @}
77 | */
78 |
79 | /** @defgroup USBH_HCS_Exported_FunctionsPrototype
80 | * @{
81 | */
82 |
83 | uint8_t USBH_Alloc_Channel(USB_OTG_CORE_HANDLE *pdev, uint8_t ep_addr);
84 |
85 | uint8_t USBH_Free_Channel (USB_OTG_CORE_HANDLE *pdev, uint8_t idx);
86 |
87 | uint8_t USBH_DeAllocate_AllChannel (USB_OTG_CORE_HANDLE *pdev);
88 |
89 | uint8_t USBH_Open_Channel (USB_OTG_CORE_HANDLE *pdev,
90 | uint8_t ch_num,
91 | uint8_t dev_address,
92 | uint8_t speed,
93 | uint8_t ep_type,
94 | uint16_t mps);
95 |
96 | uint8_t USBH_Modify_Channel (USB_OTG_CORE_HANDLE *pdev,
97 | uint8_t hc_num,
98 | uint8_t dev_address,
99 | uint8_t speed,
100 | uint8_t ep_type,
101 | uint16_t mps);
102 | /**
103 | * @}
104 | */
105 |
106 |
107 |
108 | #endif /* __USBH_HCS_H */
109 |
110 |
111 | /**
112 | * @}
113 | */
114 |
115 | /**
116 | * @}
117 | */
118 |
119 | /**
120 | * @}
121 | */
122 |
123 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
124 |
125 |
126 |
--------------------------------------------------------------------------------
/lib/USB_Host/Core/inc/usbh_ioreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_ioreq.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Header file for usbh_ioreq.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive ----------------------------------------------*/
23 | #ifndef __USBH_IOREQ_H
24 | #define __USBH_IOREQ_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usb_conf.h"
28 | #include "usbh_core.h"
29 | #include "usbh_def.h"
30 |
31 |
32 | /** @addtogroup USBH_LIB
33 | * @{
34 | */
35 |
36 | /** @addtogroup USBH_LIB_CORE
37 | * @{
38 | */
39 |
40 | /** @defgroup USBH_IOREQ
41 | * @brief This file is the header file for usbh_ioreq.c
42 | * @{
43 | */
44 |
45 |
46 | /** @defgroup USBH_IOREQ_Exported_Defines
47 | * @{
48 | */
49 | #define USBH_SETUP_PKT_SIZE 8
50 | #define USBH_EP0_EP_NUM 0
51 | #define USBH_MAX_PACKET_SIZE 0x40
52 | /**
53 | * @}
54 | */
55 |
56 |
57 | /** @defgroup USBH_IOREQ_Exported_Types
58 | * @{
59 | */
60 | /**
61 | * @}
62 | */
63 |
64 |
65 | /** @defgroup USBH_IOREQ_Exported_Macros
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBH_IOREQ_Exported_Variables
73 | * @{
74 | */
75 | /**
76 | * @}
77 | */
78 |
79 | /** @defgroup USBH_IOREQ_Exported_FunctionsPrototype
80 | * @{
81 | */
82 | USBH_Status USBH_CtlSendSetup ( USB_OTG_CORE_HANDLE *pdev,
83 | uint8_t *buff,
84 | uint8_t hc_num);
85 |
86 | USBH_Status USBH_CtlSendData ( USB_OTG_CORE_HANDLE *pdev,
87 | uint8_t *buff,
88 | uint8_t length,
89 | uint8_t hc_num);
90 |
91 | USBH_Status USBH_CtlReceiveData( USB_OTG_CORE_HANDLE *pdev,
92 | uint8_t *buff,
93 | uint8_t length,
94 | uint8_t hc_num);
95 |
96 | USBH_Status USBH_BulkReceiveData( USB_OTG_CORE_HANDLE *pdev,
97 | uint8_t *buff,
98 | uint16_t length,
99 | uint8_t hc_num);
100 |
101 | USBH_Status USBH_BulkSendData ( USB_OTG_CORE_HANDLE *pdev,
102 | uint8_t *buff,
103 | uint16_t length,
104 | uint8_t hc_num);
105 |
106 | USBH_Status USBH_InterruptReceiveData( USB_OTG_CORE_HANDLE *pdev,
107 | uint8_t *buff,
108 | uint8_t length,
109 | uint8_t hc_num);
110 |
111 | USBH_Status USBH_InterruptSendData( USB_OTG_CORE_HANDLE *pdev,
112 | uint8_t *buff,
113 | uint8_t length,
114 | uint8_t hc_num);
115 |
116 | USBH_Status USBH_CtlReq (USB_OTG_CORE_HANDLE *pdev,
117 | USBH_HOST *phost,
118 | uint8_t *buff,
119 | uint16_t length);
120 | /**
121 | * @}
122 | */
123 |
124 | #endif /* __USBH_IOREQ_H */
125 |
126 | /**
127 | * @}
128 | */
129 |
130 | /**
131 | * @}
132 | */
133 |
134 | /**
135 | * @}
136 | */
137 |
138 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
139 |
140 |
141 |
--------------------------------------------------------------------------------
/lib/USB_Host/Core/inc/usbh_stdreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbh_stdreq.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Header file for usbh_stdreq.c
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive ----------------------------------------------*/
23 | #ifndef __USBH_STDREQ_H
24 | #define __USBH_STDREQ_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 |
28 | #include "usb_conf.h"
29 | #include "usb_hcd.h"
30 | #include "usbh_core.h"
31 | #include "usbh_def.h"
32 |
33 | /** @addtogroup USBH_LIB
34 | * @{
35 | */
36 |
37 | /** @addtogroup USBH_LIB_CORE
38 | * @{
39 | */
40 |
41 | /** @defgroup USBH_STDREQ
42 | * @brief This file is the
43 | * @{
44 | */
45 |
46 |
47 | /** @defgroup USBH_STDREQ_Exported_Defines
48 | * @{
49 | */
50 | /*Standard Feature Selector for clear feature command*/
51 | #define FEATURE_SELECTOR_ENDPOINT 0X00
52 | #define FEATURE_SELECTOR_DEVICE 0X01
53 |
54 |
55 | #define INTERFACE_DESC_TYPE 0x04
56 | #define ENDPOINT_DESC_TYPE 0x05
57 | #define INTERFACE_DESC_SIZE 0x09
58 |
59 |
60 | #define USBH_HID_CLASS 0x03
61 |
62 | /**
63 | * @}
64 | */
65 |
66 |
67 | /** @defgroup USBH_STDREQ_Exported_Types
68 | * @{
69 | */
70 | /**
71 | * @}
72 | */
73 |
74 |
75 | /** @defgroup USBH_STDREQ_Exported_Macros
76 | * @{
77 | */
78 | /**
79 | * @}
80 | */
81 |
82 | /** @defgroup USBH_STDREQ_Exported_Variables
83 | * @{
84 | */
85 | /**
86 | * @}
87 | */
88 |
89 | /** @defgroup USBH_STDREQ_Exported_FunctionsPrototype
90 | * @{
91 | */
92 | USBH_Status USBH_GetDescriptor(USB_OTG_CORE_HANDLE *pdev,
93 | USBH_HOST *phost,
94 | uint8_t req_type,
95 | uint16_t value_idx,
96 | uint8_t* buff,
97 | uint16_t length );
98 |
99 | USBH_Status USBH_Get_DevDesc(USB_OTG_CORE_HANDLE *pdev,
100 | USBH_HOST *phost,
101 | uint8_t length);
102 |
103 | USBH_Status USBH_Get_StringDesc(USB_OTG_CORE_HANDLE *pdev,
104 | USBH_HOST *phost,
105 | uint8_t string_index,
106 | uint8_t *buff,
107 | uint16_t length);
108 |
109 | USBH_Status USBH_SetCfg(USB_OTG_CORE_HANDLE *pdev,
110 | USBH_HOST *phost,
111 | uint16_t configuration_value);
112 |
113 | USBH_Status USBH_Get_CfgDesc(USB_OTG_CORE_HANDLE *pdev,
114 | USBH_HOST *phost,
115 | uint16_t length);
116 |
117 | USBH_Status USBH_SetAddress(USB_OTG_CORE_HANDLE *pdev,
118 | USBH_HOST *phost,
119 | uint8_t DeviceAddress);
120 |
121 | USBH_Status USBH_ClrFeature(USB_OTG_CORE_HANDLE *pdev,
122 | USBH_HOST *phost,
123 | uint8_t ep_num, uint8_t hc_num);
124 |
125 | USBH_Status USBH_Issue_ClrFeature(USB_OTG_CORE_HANDLE *pdev,
126 | USBH_HOST *phost,
127 | uint8_t ep_num);
128 | /**
129 | * @}
130 | */
131 |
132 | #endif /* __USBH_STDREQ_H */
133 |
134 | /**
135 | * @}
136 | */
137 |
138 | /**
139 | * @}
140 | */
141 |
142 | /**
143 | * @}
144 | */
145 |
146 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
147 |
148 |
149 |
--------------------------------------------------------------------------------
/lib/USB_OTG/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -Iinc -I../Core/cmsis -I../Core/stm32
34 | CFLAGS += -I../Conf
35 |
36 | # Sources
37 | SRCS = usb_core.c usb_dcd.c usb_dcd_int.c usb_hcd.c
38 | SRCS += usb_hcd_int.c usb_otg.c
39 |
40 | OBJS = $(SRCS:.c=.o)
41 | LIBNAME = libusbcore.a
42 |
43 | all: $(LIBNAME)
44 |
45 | %.o : %.c
46 | $(CC) $(CFLAGS) -c -o $@ $^
47 |
48 | $(LIBNAME): $(OBJS)
49 | $(AR) -r $@ $(OBJS)
50 |
51 | clean:
52 | rm -f $(OBJS) $(LIBNAME)
53 |
--------------------------------------------------------------------------------
/lib/USB_OTG/inc/usb_bsp.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_bsp.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Specific api's relative to the used hardware platform
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USB_BSP__H__
24 | #define __USB_BSP__H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usb_core.h"
28 | #include "stm32f4xx.h"
29 |
30 | /** @addtogroup USB_OTG_DRIVER
31 | * @{
32 | */
33 |
34 | /** @defgroup USB_BSP
35 | * @brief This file is the
36 | * @{
37 | */
38 |
39 |
40 | /** @defgroup USB_BSP_Exported_Defines
41 | * @{
42 | */
43 | /**
44 | * @}
45 | */
46 |
47 |
48 | /** @defgroup USB_BSP_Exported_Types
49 | * @{
50 | */
51 | /**
52 | * @}
53 | */
54 |
55 |
56 | /** @defgroup USB_BSP_Exported_Macros
57 | * @{
58 | */
59 | /**
60 | * @}
61 | */
62 |
63 | /** @defgroup USB_BSP_Exported_Variables
64 | * @{
65 | */
66 | /**
67 | * @}
68 | */
69 |
70 | /** @defgroup USB_BSP_Exported_FunctionsPrototype
71 | * @{
72 | */
73 | void BSP_Init(void);
74 |
75 | void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev);
76 | void USB_OTG_BSP_uDelay (const uint32_t usec);
77 | void USB_OTG_BSP_mDelay (const uint32_t msec);
78 | void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev);
79 | #ifdef USE_HOST_MODE
80 | void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev);
81 | void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state);
82 | #endif
83 | /**
84 | * @}
85 | */
86 |
87 | #endif //__USB_BSP__H__
88 |
89 | /**
90 | * @}
91 | */
92 |
93 | /**
94 | * @}
95 | */
96 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
97 |
98 |
--------------------------------------------------------------------------------
/lib/USB_OTG/inc/usb_dcd_int.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_dcd_int.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Peripheral Device Interface Layer
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef USB_DCD_INT_H__
24 | #define USB_DCD_INT_H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usb_dcd.h"
28 |
29 |
30 |
31 | /** @addtogroup USB_OTG_DRIVER
32 | * @{
33 | */
34 |
35 | /** @defgroup USB_DCD_INT
36 | * @brief This file is the
37 | * @{
38 | */
39 |
40 |
41 | /** @defgroup USB_DCD_INT_Exported_Defines
42 | * @{
43 | */
44 |
45 | typedef struct _USBD_DCD_INT
46 | {
47 | uint8_t (* DataOutStage) (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum);
48 | uint8_t (* DataInStage) (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum);
49 | uint8_t (* SetupStage) (USB_OTG_CORE_HANDLE *pdev);
50 | uint8_t (* SOF) (USB_OTG_CORE_HANDLE *pdev);
51 | uint8_t (* Reset) (USB_OTG_CORE_HANDLE *pdev);
52 | uint8_t (* Suspend) (USB_OTG_CORE_HANDLE *pdev);
53 | uint8_t (* Resume) (USB_OTG_CORE_HANDLE *pdev);
54 | uint8_t (* IsoINIncomplete) (USB_OTG_CORE_HANDLE *pdev);
55 | uint8_t (* IsoOUTIncomplete) (USB_OTG_CORE_HANDLE *pdev);
56 |
57 | uint8_t (* DevConnected) (USB_OTG_CORE_HANDLE *pdev);
58 | uint8_t (* DevDisconnected) (USB_OTG_CORE_HANDLE *pdev);
59 |
60 | }USBD_DCD_INT_cb_TypeDef;
61 |
62 | extern USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops;
63 | /**
64 | * @}
65 | */
66 |
67 |
68 | /** @defgroup USB_DCD_INT_Exported_Types
69 | * @{
70 | */
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup USB_DCD_INT_Exported_Macros
76 | * @{
77 | */
78 |
79 | #define CLEAR_IN_EP_INTR(epnum,intr) \
80 | diepint.d32=0; \
81 | diepint.b.intr = 1; \
82 | USB_OTG_WRITE_REG32(&pdev->regs.INEP_REGS[epnum]->DIEPINT,diepint.d32);
83 |
84 | #define CLEAR_OUT_EP_INTR(epnum,intr) \
85 | doepint.d32=0; \
86 | doepint.b.intr = 1; \
87 | USB_OTG_WRITE_REG32(&pdev->regs.OUTEP_REGS[epnum]->DOEPINT,doepint.d32);
88 |
89 | /**
90 | * @}
91 | */
92 |
93 | /** @defgroup USB_DCD_INT_Exported_Variables
94 | * @{
95 | */
96 | /**
97 | * @}
98 | */
99 |
100 | /** @defgroup USB_DCD_INT_Exported_FunctionsPrototype
101 | * @{
102 | */
103 |
104 | uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
105 |
106 | /**
107 | * @}
108 | */
109 |
110 |
111 | #endif // USB_DCD_INT_H__
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | /**
118 | * @}
119 | */
120 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
121 |
122 |
--------------------------------------------------------------------------------
/lib/USB_OTG/inc/usb_hcd.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_hcd.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Host layer Header file
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USB_HCD_H__
24 | #define __USB_HCD_H__
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "usb_regs.h"
28 | #include "usb_core.h"
29 |
30 |
31 | /** @addtogroup USB_OTG_DRIVER
32 | * @{
33 | */
34 |
35 | /** @defgroup USB_HCD
36 | * @brief This file is the
37 | * @{
38 | */
39 |
40 |
41 | /** @defgroup USB_HCD_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USB_HCD_Exported_Types
50 | * @{
51 | */
52 | /**
53 | * @}
54 | */
55 |
56 |
57 | /** @defgroup USB_HCD_Exported_Macros
58 | * @{
59 | */
60 | /**
61 | * @}
62 | */
63 |
64 | /** @defgroup USB_HCD_Exported_Variables
65 | * @{
66 | */
67 | /**
68 | * @}
69 | */
70 |
71 | /** @defgroup USB_HCD_Exported_FunctionsPrototype
72 | * @{
73 | */
74 | uint32_t HCD_Init (USB_OTG_CORE_HANDLE *pdev ,
75 | USB_OTG_CORE_ID_TypeDef coreID);
76 | uint32_t HCD_HC_Init (USB_OTG_CORE_HANDLE *pdev ,
77 | uint8_t hc_num);
78 | uint32_t HCD_SubmitRequest (USB_OTG_CORE_HANDLE *pdev ,
79 | uint8_t hc_num) ;
80 | uint32_t HCD_GetCurrentSpeed (USB_OTG_CORE_HANDLE *pdev);
81 | uint32_t HCD_ResetPort (USB_OTG_CORE_HANDLE *pdev);
82 | uint32_t HCD_IsDeviceConnected (USB_OTG_CORE_HANDLE *pdev);
83 | uint32_t HCD_GetCurrentFrame (USB_OTG_CORE_HANDLE *pdev) ;
84 | URB_STATE HCD_GetURB_State (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num);
85 | uint32_t HCD_GetXferCnt (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num);
86 | HC_STATUS HCD_GetHCState (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num) ;
87 | /**
88 | * @}
89 | */
90 |
91 | #endif //__USB_HCD_H__
92 |
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
102 |
103 |
--------------------------------------------------------------------------------
/lib/USB_OTG/inc/usb_hcd_int.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_hcd_int.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief Peripheral Device Interface Layer
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __HCD_INT_H__
24 | #define __HCD_INT_H__
25 |
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "usb_hcd.h"
29 |
30 |
31 | /** @addtogroup USB_OTG_DRIVER
32 | * @{
33 | */
34 |
35 | /** @defgroup USB_HCD_INT
36 | * @brief This file is the
37 | * @{
38 | */
39 |
40 |
41 | /** @defgroup USB_HCD_INT_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USB_HCD_INT_Exported_Types
50 | * @{
51 | */
52 | /**
53 | * @}
54 | */
55 |
56 |
57 | /** @defgroup USB_HCD_INT_Exported_Macros
58 | * @{
59 | */
60 |
61 | #define CLEAR_HC_INT(HC_REGS, intr) \
62 | {\
63 | USB_OTG_HCINTn_TypeDef hcint_clear; \
64 | hcint_clear.d32 = 0; \
65 | hcint_clear.b.intr = 1; \
66 | USB_OTG_WRITE_REG32(&((HC_REGS)->HCINT), hcint_clear.d32);\
67 | }\
68 |
69 | #define MASK_HOST_INT_CHH(hc_num) { USB_OTG_HCGINTMSK_TypeDef GINTMSK; \
70 | GINTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK); \
71 | GINTMSK.b.chhltd = 0; \
72 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK, GINTMSK.d32);}
73 |
74 | #define UNMASK_HOST_INT_CHH(hc_num) { USB_OTG_HCGINTMSK_TypeDef GINTMSK; \
75 | GINTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK); \
76 | GINTMSK.b.chhltd = 1; \
77 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK, GINTMSK.d32);}
78 |
79 | #define MASK_HOST_INT_ACK(hc_num) { USB_OTG_HCGINTMSK_TypeDef GINTMSK; \
80 | GINTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK); \
81 | GINTMSK.b.ack = 0; \
82 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK, GINTMSK.d32);}
83 |
84 | #define UNMASK_HOST_INT_ACK(hc_num) { USB_OTG_HCGINTMSK_TypeDef GINTMSK; \
85 | GINTMSK.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK); \
86 | GINTMSK.b.ack = 1; \
87 | USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCGINTMSK, GINTMSK.d32);}
88 |
89 | /**
90 | * @}
91 | */
92 |
93 | /** @defgroup USB_HCD_INT_Exported_Variables
94 | * @{
95 | */
96 | /**
97 | * @}
98 | */
99 |
100 | /** @defgroup USB_HCD_INT_Exported_FunctionsPrototype
101 | * @{
102 | */
103 | /* Callbacks handler */
104 | void ConnectCallback_Handler(USB_OTG_CORE_HANDLE *pdev);
105 | void Disconnect_Callback_Handler(USB_OTG_CORE_HANDLE *pdev);
106 | void Overcurrent_Callback_Handler(USB_OTG_CORE_HANDLE *pdev);
107 | uint32_t USBH_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
108 |
109 | /**
110 | * @}
111 | */
112 |
113 |
114 |
115 | #endif //__HCD_INT_H__
116 |
117 |
118 | /**
119 | * @}
120 | */
121 |
122 | /**
123 | * @}
124 | */
125 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
126 |
127 |
--------------------------------------------------------------------------------
/lib/USB_OTG/inc/usb_otg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_otg.h
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief OTG Core Header
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USB_OTG__
24 | #define __USB_OTG__
25 |
26 |
27 | /** @addtogroup USB_OTG_DRIVER
28 | * @{
29 | */
30 |
31 | /** @defgroup USB_OTG
32 | * @brief This file is the
33 | * @{
34 | */
35 |
36 |
37 | /** @defgroup USB_OTG_Exported_Defines
38 | * @{
39 | */
40 |
41 |
42 | void USB_OTG_InitiateSRP(void);
43 | void USB_OTG_InitiateHNP(uint8_t state , uint8_t mode);
44 | void USB_OTG_Switchback (USB_OTG_CORE_HANDLE *pdev);
45 | uint32_t USB_OTG_GetCurrentState (USB_OTG_CORE_HANDLE *pdev);
46 |
47 | uint32_t STM32_USBO_OTG_ISR_Handler(USB_OTG_CORE_HANDLE *pdev);
48 | /**
49 | * @}
50 | */
51 |
52 |
53 | /** @defgroup USB_OTG_Exported_Types
54 | * @{
55 | */
56 | /**
57 | * @}
58 | */
59 |
60 |
61 | /** @defgroup USB_OTG_Exported_Macros
62 | * @{
63 | */
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USB_OTG_Exported_Variables
69 | * @{
70 | */
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup USB_OTG_Exported_FunctionsPrototype
76 | * @{
77 | */
78 | /**
79 | * @}
80 | */
81 |
82 |
83 | #endif //__USB_OTG__
84 |
85 |
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
94 |
95 |
--------------------------------------------------------------------------------
/lib/USB_OTG/src/usb_bsp_template.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_bsp.c
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief This file is responsible to offer board support package and is
8 | * configurable by user.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Includes ------------------------------------------------------------------*/
24 | #include "usb_bsp.h"
25 |
26 | /** @addtogroup USB_OTG_DRIVER
27 | * @{
28 | */
29 |
30 | /** @defgroup USB_BSP
31 | * @brief This file is responsible to offer board support package
32 | * @{
33 | */
34 |
35 | /** @defgroup USB_BSP_Private_Defines
36 | * @{
37 | */
38 | /**
39 | * @}
40 | */
41 |
42 |
43 | /** @defgroup USB_BSP_Private_TypesDefinitions
44 | * @{
45 | */
46 | /**
47 | * @}
48 | */
49 |
50 |
51 |
52 |
53 |
54 | /** @defgroup USB_BSP_Private_Macros
55 | * @{
56 | */
57 | /**
58 | * @}
59 | */
60 |
61 | /** @defgroup USBH_BSP_Private_Variables
62 | * @{
63 | */
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | /** @defgroup USBH_BSP_Private_FunctionPrototypes
70 | * @{
71 | */
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USB_BSP_Private_Functions
77 | * @{
78 | */
79 |
80 |
81 | /**
82 | * @brief USB_OTG_BSP_Init
83 | * Initilizes BSP configurations
84 | * @param None
85 | * @retval None
86 | */
87 |
88 | void USB_OTG_BSP_Init(void)
89 | {
90 |
91 | }
92 | /**
93 | * @brief USB_OTG_BSP_EnableInterrupt
94 | * Enabele USB Global interrupt
95 | * @param None
96 | * @retval None
97 | */
98 | void USB_OTG_BSP_EnableInterrupt(void)
99 | {
100 |
101 | }
102 |
103 | /**
104 | * @brief BSP_Drive_VBUS
105 | * Drives the Vbus signal through IO
106 | * @param speed : Full, Low
107 | * @param state : VBUS states
108 | * @retval None
109 | */
110 |
111 | void USB_OTG_BSP_DriveVBUS(uint32_t speed, uint8_t state)
112 | {
113 |
114 | }
115 |
116 | /**
117 | * @brief USB_OTG_BSP_ConfigVBUS
118 | * Configures the IO for the Vbus and OverCurrent
119 | * @param Speed : Full, Low
120 | * @retval None
121 | */
122 |
123 | void USB_OTG_BSP_ConfigVBUS(uint32_t speed)
124 | {
125 |
126 | }
127 |
128 | /**
129 | * @brief USB_OTG_BSP_TimeInit
130 | * Initialises delay unit Systick timer /Timer2
131 | * @param None
132 | * @retval None
133 | */
134 | void USB_OTG_BSP_TimeInit ( void )
135 | {
136 |
137 | }
138 |
139 | /**
140 | * @brief USB_OTG_BSP_uDelay
141 | * This function provides delay time in micro sec
142 | * @param usec : Value of delay required in micro sec
143 | * @retval None
144 | */
145 | void USB_OTG_BSP_uDelay (const uint32_t usec)
146 | {
147 |
148 | uint32_t count = 0;
149 | const uint32_t utime = (120 * usec / 7);
150 | do
151 | {
152 | if ( ++count > utime )
153 | {
154 | return ;
155 | }
156 | }
157 | while (1);
158 |
159 | }
160 |
161 |
162 | /**
163 | * @brief USB_OTG_BSP_mDelay
164 | * This function provides delay time in milli sec
165 | * @param msec : Value of delay required in milli sec
166 | * @retval None
167 | */
168 | void USB_OTG_BSP_mDelay (const uint32_t msec)
169 | {
170 |
171 | USB_OTG_BSP_uDelay(msec * 1000);
172 |
173 | }
174 |
175 |
176 | /**
177 | * @brief USB_OTG_BSP_TimerIRQ
178 | * Time base IRQ
179 | * @param None
180 | * @retval None
181 | */
182 |
183 | void USB_OTG_BSP_TimerIRQ (void)
184 | {
185 |
186 | }
187 |
188 | /**
189 | * @}
190 | */
191 |
192 | /**
193 | * @}
194 | */
195 |
196 | /**
197 | * @}
198 | */
199 |
200 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
201 |
--------------------------------------------------------------------------------
/lib/USB_OTG/src/usb_otg.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usb_otg.c
4 | * @author MCD Application Team
5 | * @version V2.0.0
6 | * @date 22-July-2011
7 | * @brief OTG Core Layer
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | #include "usb_conf.h"
23 | #ifdef USE_OTG_MODE
24 | /* Includes ------------------------------------------------------------------*/
25 | #include "usb_defines.h"
26 | #include "usb_regs.h"
27 | #include "usb_core.h"
28 | #include "usb_otg.h"
29 |
30 | /** @addtogroup USB_OTG_DRIVER
31 | * @{
32 | */
33 |
34 | /** @defgroup USB_OTG
35 | * @brief This file is the interface between EFSL ans Host mass-storage class
36 | * @{
37 | */
38 |
39 |
40 | /** @defgroup USB_OTG_Private_Defines
41 | * @{
42 | */
43 | /**
44 | * @}
45 | */
46 |
47 |
48 | /** @defgroup USB_OTG_Private_TypesDefinitions
49 | * @{
50 | */
51 | /**
52 | * @}
53 | */
54 |
55 |
56 |
57 | /** @defgroup USB_OTG_Private_Macros
58 | * @{
59 | */
60 | /**
61 | * @}
62 | */
63 |
64 |
65 | /** @defgroup USB_OTG_Private_Variables
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 |
73 | /** @defgroup USB_OTG_Private_FunctionPrototypes
74 | * @{
75 | */
76 |
77 | static uint32_t USB_OTG_Read_itr(USB_OTG_CORE_HANDLE *pdev);
78 |
79 | /**
80 | * @}
81 | */
82 |
83 |
84 | /** @defgroup USB_OTG_Private_Functions
85 | * @{
86 | */
87 |
88 |
89 | /* OTG Interrupt Handler */
90 |
91 |
92 | /**
93 | * @brief STM32_USBO_OTG_ISR_Handler
94 | *
95 | * @param None
96 | * @retval : None
97 | */
98 | uint32_t STM32_USBO_OTG_ISR_Handler(USB_OTG_CORE_HANDLE *pdev)
99 | {
100 | uint32_t retval = 0;
101 | USB_OTG_GINTSTS_TypeDef gintsts ;
102 | gintsts.d32 = 0;
103 |
104 | gintsts.d32 = USB_OTG_Read_itr(pdev);
105 | if (gintsts.d32 == 0)
106 | {
107 | return 0;
108 | }
109 | if (gintsts.b.otgintr)
110 | {
111 | retval |= 1;//USB_OTG_HandleOTG_ISR(pdev);
112 | }
113 | if (gintsts.b.conidstschng)
114 | {
115 | retval |= 2;//USB_OTG_HandleConnectorIDStatusChange_ISR(pdev);
116 | }
117 | if (gintsts.b.sessreqintr)
118 | {
119 | retval |= 3;//USB_OTG_HandleSessionRequest_ISR(pdev);
120 | }
121 | return retval;
122 | }
123 |
124 |
125 | /**
126 | * @brief USB_OTG_Read_itr
127 | * returns the Core Interrupt register
128 | * @param None
129 | * @retval : status
130 | */
131 | static uint32_t USB_OTG_Read_itr(USB_OTG_CORE_HANDLE *pdev)
132 | {
133 | USB_OTG_GINTSTS_TypeDef gintsts;
134 | USB_OTG_GINTMSK_TypeDef gintmsk;
135 | USB_OTG_GINTMSK_TypeDef gintmsk_common;
136 |
137 |
138 | gintsts.d32 = 0;
139 | gintmsk.d32 = 0;
140 | gintmsk_common.d32 = 0;
141 |
142 | /* OTG interrupts */
143 | gintmsk_common.b.sessreqintr = 1;
144 | gintmsk_common.b.conidstschng = 1;
145 | gintmsk_common.b.otgintr = 1;
146 |
147 | gintsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GINTSTS);
148 | gintmsk.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GINTMSK);
149 | return ((gintsts.d32 & gintmsk.d32 ) & gintmsk_common.d32);
150 | }
151 |
152 |
153 | /**
154 | * @brief USB_OTG_GetCurrentState
155 | * Return current OTG State
156 | * @param None
157 | * @retval : None
158 | */
159 | uint32_t USB_OTG_GetCurrentState (USB_OTG_CORE_HANDLE *pdev)
160 | {
161 | return pdev->otg.OTG_State;
162 | }
163 |
164 |
165 | /**
166 | * @}
167 | */
168 |
169 | /**
170 | * @}
171 | */
172 |
173 | /**
174 | * @}
175 | */
176 | #endif
177 |
178 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
179 |
--------------------------------------------------------------------------------
/lib/fat_fs/Makefile:
--------------------------------------------------------------------------------
1 | BINPATH=~/sat/bin
2 |
3 | CC=$(BINPATH)/arm-none-eabi-gcc
4 | AR=$(BINPATH)/arm-none-eabi-ar
5 |
6 | ###################################################
7 |
8 | # Check for valid float argument
9 | ifneq ($(FLOAT_TYPE), hard)
10 | ifneq ($(FLOAT_TYPE), soft)
11 | override FLOAT_TYPE = hard
12 | #override FLOAT_TYPE = soft
13 | endif
14 | endif
15 |
16 | ###################################################
17 |
18 | vpath %.c src
19 |
20 | CFLAGS = -g -O2 -Wall
21 | CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m4
22 |
23 | ifeq ($(FLOAT_TYPE), hard)
24 | CFLAGS += -fsingle-precision-constant -Wdouble-promotion
25 | CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
26 | else
27 | CFLAGS += -msoft-float
28 | endif
29 |
30 | CFLAGS += -ffreestanding -nostdlib
31 |
32 | # Includes
33 | CFLAGS += -I../Core/cmsis -I../Core/stm32
34 | CFLAGS += -Iinc -I../Conf
35 |
36 | # Sources
37 | SRCS = ff.c fattime.c
38 |
39 | OBJS = $(SRCS:.c=.o)
40 | LIBNAME = libfatfs.a
41 |
42 | all: $(LIBNAME)
43 |
44 | %.o : %.c
45 | $(CC) $(CFLAGS) -c -o $@ $^
46 |
47 | $(LIBNAME): $(OBJS)
48 | $(AR) -r $@ $(OBJS)
49 |
50 | clean:
51 | rm -f $(OBJS) $(LIBNAME)
52 |
--------------------------------------------------------------------------------
/lib/fat_fs/inc/diskio.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------------
2 | / Low level disk interface modlue include file R0.07 (C)ChaN, 2009
3 | /-----------------------------------------------------------------------*/
4 |
5 | #ifndef _DISKIO
6 |
7 | #define _READONLY 0 /* 1: Read-only mode */
8 | #define _USE_IOCTL 1
9 |
10 | #include "integer.h"
11 | //#include "usbh_msc_core.h"
12 |
13 | /* Status of Disk Functions */
14 | typedef BYTE DSTATUS;
15 |
16 | /* Results of Disk Functions */
17 | typedef enum {
18 | RES_OK = 0, /* 0: Successful */
19 | RES_ERROR, /* 1: R/W Error */
20 | RES_WRPRT, /* 2: Write Protected */
21 | RES_NOTRDY, /* 3: Not Ready */
22 | RES_PARERR /* 4: Invalid Parameter */
23 | } DRESULT;
24 |
25 |
26 | /*---------------------------------------*/
27 | /* Prototypes for disk control functions */
28 |
29 | BOOL assign_drives (int argc, char *argv[]);
30 | DSTATUS disk_initialize (BYTE);
31 | DSTATUS disk_status (BYTE);
32 | DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
33 | #if _READONLY == 0
34 | DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
35 | #endif
36 | DRESULT disk_ioctl (BYTE, BYTE, void*);
37 |
38 |
39 |
40 | /* Disk Status Bits (DSTATUS) */
41 |
42 | #define STA_NOINIT 0x01 /* Drive not initialized */
43 | #define STA_NODISK 0x02 /* No medium in the drive */
44 | #define STA_PROTECT 0x04 /* Write protected */
45 |
46 |
47 | /* Command code for disk_ioctrl() */
48 |
49 | /* Generic command */
50 | #define CTRL_SYNC 0 /* Mandatory for write functions */
51 | #define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
52 | #define GET_SECTOR_SIZE 2
53 | #define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
54 | #define CTRL_POWER 4
55 | #define CTRL_LOCK 5
56 | #define CTRL_EJECT 6
57 | /* MMC/SDC command */
58 | #define MMC_GET_TYPE 10
59 | #define MMC_GET_CSD 11
60 | #define MMC_GET_CID 12
61 | #define MMC_GET_OCR 13
62 | #define MMC_GET_SDSTAT 14
63 | /* ATA/CF command */
64 | #define ATA_GET_REV 20
65 | #define ATA_GET_MODEL 21
66 | #define ATA_GET_SN 22
67 |
68 | #define _DISKIO
69 | #endif
70 |
--------------------------------------------------------------------------------
/lib/fat_fs/inc/fattime.h:
--------------------------------------------------------------------------------
1 | #ifndef FATTIME_H_
2 |
3 | #include "integer.h"
4 |
5 | DWORD get_fattime (void);
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/lib/fat_fs/inc/integer.h:
--------------------------------------------------------------------------------
1 | /*-------------------------------------------*/
2 | /* Integer type definitions for FatFs module */
3 | /*-------------------------------------------*/
4 |
5 | #ifndef _INTEGER
6 |
7 | #if 0
8 | #include
9 | #else
10 |
11 | #include "usb_conf.h"
12 |
13 | /* These types must be 16-bit, 32-bit or larger integer */
14 | typedef int INT;
15 | typedef unsigned int UINT;
16 |
17 | /* These types must be 8-bit integer */
18 | typedef signed char CHAR;
19 | typedef unsigned char UCHAR;
20 | typedef unsigned char BYTE;
21 |
22 | /* These types must be 16-bit integer */
23 | typedef short SHORT;
24 | typedef unsigned short USHORT;
25 | typedef unsigned short WORD;
26 | typedef unsigned short WCHAR;
27 |
28 | /* These types must be 32-bit integer */
29 | typedef long LONG;
30 | typedef unsigned long ULONG;
31 | typedef unsigned long DWORD;
32 |
33 | /* Boolean type */
34 | // typedef enum { FALSE = 0, TRUE } BOOL;
35 | #include
36 | typedef bool BOOL;
37 | #ifndef FALSE
38 | #define FALSE false
39 | #define TRUE true
40 | #endif
41 |
42 |
43 | #endif
44 |
45 | #define _INTEGER
46 | #endif
47 |
--------------------------------------------------------------------------------
/lib/fat_fs/src/fattime.c:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "integer.h"
4 | #include "fattime.h"
5 | //#include "rtc.h" //RPi
6 |
7 | DWORD get_fattime (void)
8 | {
9 | return 0;
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/lib/fat_fs/src/option/syncobj.c:
--------------------------------------------------------------------------------
1 | /*------------------------------------------------------------------------*/
2 | /* Sample code of OS dependent synchronization object controls */
3 | /* for FatFs R0.07d (C)ChaN, 2009 */
4 | /*------------------------------------------------------------------------*/
5 |
6 | #include // Win32
7 | //#include // uC/OS-II
8 |
9 | #include "../ff.h"
10 |
11 | #if _FS_REENTRANT
12 |
13 | /*------------------------------------------------------------------------*/
14 | /* Create a Synchronization Object for a Volume
15 | /*------------------------------------------------------------------------*/
16 | /* This function is called in f_mount function to create a new
17 | / synchronization object, such as semaphore and mutex. When a FALSE is
18 | / returned, the f_mount function fails with FR_INT_ERR.
19 | */
20 |
21 | BOOL ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
22 | BYTE vol, /* Corresponding logical drive being processed */
23 | _SYNC_t *sobj /* Pointer to return the created sync object */
24 | )
25 | {
26 | BOOL ret;
27 |
28 | *sobj = CreateMutex(NULL, FALSE, NULL); // Win32
29 | ret = (*sobj != INVALID_HANDLE_VALUE) ? TRUE : FALSE; //
30 |
31 | // *sobj = VolumeSemId[vol]; // uITRON (give a static created sync object)
32 | // ret = TRUE; // The initial value of the semaphore must be 1.
33 |
34 | // *sobj = OSMutexCreate(0, &err); // uC/OS-II
35 | // ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
36 |
37 | return ret;
38 | }
39 |
40 |
41 |
42 | /*------------------------------------------------------------------------*/
43 | /* Delete a Synchronization Object */
44 | /*------------------------------------------------------------------------*/
45 | /* This function is called in f_mount function to delete a synchronization
46 | / object that created with ff_cre_syncobj function. When a FALSE is
47 | / returned, the f_mount function fails with FR_INT_ERR.
48 | */
49 |
50 | BOOL ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
51 | _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
52 | )
53 | {
54 | BOOL ret;
55 |
56 | ret = CloseHandle(sobj); // Win32
57 |
58 | // ret = TRUE; // uITRON (nothing to do)
59 |
60 | // OSMutexDel(sobj, OS_DEL_ALWAYS, &err); // uC/OS-II
61 | // ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
62 |
63 | return ret;
64 | }
65 |
66 |
67 |
68 | /*------------------------------------------------------------------------*/
69 | /* Request Grant to Access the Volume */
70 | /*------------------------------------------------------------------------*/
71 | /* This function is called on entering file functions to lock the volume.
72 | / When a FALSE is returned, the file function fails with FR_TIMEOUT.
73 | */
74 |
75 | BOOL ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
76 | _SYNC_t sobj /* Sync object to wait */
77 | )
78 | {
79 | BOOL ret;
80 |
81 | ret = (WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0) ? TRUE : FALSE; // Win32
82 |
83 | // ret = (wai_sem(sobj) == E_OK) ? TRUE : FALSE; // uITRON
84 |
85 | // OSMutexPend(sobj, _FS_TIMEOUT, &err)); // uC/OS-II
86 | // ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
87 |
88 | return ret;
89 | }
90 |
91 |
92 |
93 | /*------------------------------------------------------------------------*/
94 | /* Release Grant to Access the Volume */
95 | /*------------------------------------------------------------------------*/
96 | /* This function is called on leaving file functions to unlock the volume.
97 | */
98 |
99 | void ff_rel_grant (
100 | _SYNC_t sobj /* Sync object to be signaled */
101 | )
102 | {
103 | ReleaseMutex(sobj); // Win32
104 |
105 | // sig_sem(sobj); // uITRON
106 |
107 | // OSMutexPost(sobj); // uC/OS-II
108 | }
109 |
110 |
111 | #else
112 |
113 | #error This file is not needed in this configuration.
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/src/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file main.c
3 | * @author Philip Karlsson
4 | * @version V1.0.0
5 | * @date 29-November-2014
6 | * @brief This file contains a simple example usage of the new midi device class.
7 | *
8 | */
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | #include "stm32f4xx_conf.h"
16 | #include "stm32f4xx.h"
17 | #include "main.h"
18 |
19 | // Midi
20 | #include "usbd_usr.h"
21 | #include "usbd_desc.h"
22 |
23 | #include "usbd_midi_core.h"
24 | #include "usbd_midi_user.h"
25 |
26 | #define BUTTON (GPIOA->IDR & GPIO_Pin_0)
27 |
28 | // Private variables
29 | volatile uint32_t time_var1, time_var2;
30 | __ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_dev __ALIGN_END;
31 |
32 | // Private function prototypes
33 | void Delay(volatile uint32_t nCount);
34 | void init();
35 | void calculation_test();
36 |
37 | int main(void) {
38 | // Simple midi messages for test notes..
39 | uint8_t noteOn[4];
40 | noteOn[0] = 0x08;
41 | noteOn[1] = 0x90;
42 | noteOn[2] = 0x47;
43 | noteOn[3] = 0x47;
44 |
45 | uint8_t noteOff[4];
46 | noteOff[0] = 0x08;
47 | noteOff[1] = 0x80;
48 | noteOff[2] = 0x47;
49 | noteOff[3] = 0x47;
50 |
51 | init();
52 |
53 |
54 | int active = 0;
55 |
56 | for(;;) {
57 | if (BUTTON) {
58 | // Debounce
59 | Delay(10);
60 | if (BUTTON) {
61 | if(!active){
62 | active = 1;
63 | GPIO_SetBits(GPIOD, GPIO_Pin_12);
64 | send_MIDI_msg(noteOn, 4); // Send to usbd_midi_user
65 | }
66 | }
67 | else{
68 | active = 0;
69 | GPIO_ResetBits(GPIOD, GPIO_Pin_12);
70 | send_MIDI_msg(noteOff, 4);
71 | Delay(10);
72 | }
73 |
74 | }
75 | }
76 |
77 | return 0;
78 | }
79 |
80 |
81 | void init() {
82 | GPIO_InitTypeDef GPIO_InitStructure;
83 |
84 | // ---------- SysTick timer -------- //
85 | if (SysTick_Config(SystemCoreClock / 1000)) {
86 | // Capture error
87 | while (1){};
88 | }
89 |
90 | // ---------- GPIO -------- //
91 | // GPIOD Periph clock enable
92 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
93 |
94 | // Configure PD12, PD13, PD14 and PD15 in output pushpull mode
95 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
96 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
97 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
98 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
99 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
100 | GPIO_Init(GPIOD, &GPIO_InitStructure);
101 |
102 | // ------------- USB -------------- //
103 | /* Initialize the midi driver */
104 | usbd_midi_init_driver(&MIDI_fops);
105 | /* Make the connection and initialize to USB_OTG/usbdc_core */
106 | USBD_Init(&USB_OTG_dev,
107 | USB_OTG_FS_CORE_ID,
108 | &USR_desc,
109 | &USBD_MIDI_cb,
110 | &USR_cb);
111 | }
112 |
113 | /*
114 | * Called from systick handler
115 | */
116 | void timing_handler() {
117 | if (time_var1) {
118 | time_var1--;
119 | }
120 |
121 | time_var2++;
122 | }
123 |
124 | /*
125 | * Delay a number of systick cycles (1ms)
126 | */
127 | void Delay(volatile uint32_t nCount) {
128 | time_var1 = nCount;
129 | while(time_var1){};
130 | }
131 |
132 | /*
133 | * Dummy function to avoid compiler error
134 | */
135 | void _init() {
136 |
137 | }
138 |
139 |
--------------------------------------------------------------------------------
/src/stm32f4xx_it.c:
--------------------------------------------------------------------------------
1 | #include "stm32f4xx_it.h"
2 | #include "stm32f4xx_conf.h"
3 | #include "main.h"
4 |
5 | #include "usb_core.h"
6 | #include "usbd_core.h"
7 | //#include "usbd_cdc_core.h"
8 |
9 | extern uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
10 | extern USB_OTG_CORE_HANDLE USB_OTG_dev;
11 |
12 | #ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED
13 | extern uint32_t USBD_OTG_EP1IN_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
14 | extern uint32_t USBD_OTG_EP1OUT_ISR_Handler (USB_OTG_CORE_HANDLE *pdev);
15 | #endif
16 |
17 | /**
18 | * @brief This function handles NMI exception.
19 | * @param None
20 | * @retval None
21 | */
22 | void NMI_Handler(void)
23 | {
24 | }
25 |
26 | /**
27 | * @brief This function handles Hard Fault exception.
28 | * @param None
29 | * @retval None
30 | */
31 | void HardFault_Handler(void)
32 | {
33 | /* Go to infinite loop when Hard Fault exception occurs */
34 | while (1)
35 | {
36 | }
37 | }
38 |
39 | /**
40 | * @brief This function handles Memory Manage exception.
41 | * @param None
42 | * @retval None
43 | */
44 | void MemManage_Handler(void)
45 | {
46 | /* Go to infinite loop when Memory Manage exception occurs */
47 | while (1)
48 | {
49 | }
50 | }
51 |
52 | /**
53 | * @brief This function handles Bus Fault exception.
54 | * @param None
55 | * @retval None
56 | */
57 | void BusFault_Handler(void)
58 | {
59 | /* Go to infinite loop when Bus Fault exception occurs */
60 | while (1)
61 | {
62 | }
63 | }
64 |
65 | /**
66 | * @brief This function handles Usage Fault exception.
67 | * @param None
68 | * @retval None
69 | */
70 | void UsageFault_Handler(void)
71 | {
72 | /* Go to infinite loop when Usage Fault exception occurs */
73 | while (1)
74 | {
75 | }
76 | }
77 |
78 | /**
79 | * @brief This function handles SVCall exception.
80 | * @param None
81 | * @retval None
82 | */
83 | void SVC_Handler(void)
84 | {
85 | }
86 |
87 | /**
88 | * @brief This function handles Debug Monitor exception.
89 | * @param None
90 | * @retval None
91 | */
92 | void DebugMon_Handler(void)
93 | {
94 | }
95 |
96 | /**
97 | * @brief This function handles PendSVC exception.
98 | * @param None
99 | * @retval None
100 | */
101 | void PendSV_Handler(void)
102 | {
103 | }
104 |
105 | /**
106 | * @brief This function handles SysTick Handler.
107 | * @param None
108 | * @retval None
109 | */
110 | void SysTick_Handler(void)
111 | {
112 | timing_handler();
113 | }
114 |
115 | /******************************************************************************/
116 | /* STM32F4xx Peripherals Interrupt Handlers */
117 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
118 | /* available peripheral interrupt handler's name please refer to the startup */
119 | /* file (startup_stm32f4xx.s). */
120 | /******************************************************************************/
121 |
122 | #ifdef USE_USB_OTG_FS
123 | void OTG_FS_WKUP_IRQHandler(void)
124 | {
125 | if(USB_OTG_dev.cfg.low_power)
126 | {
127 | *(uint32_t *)(0xE000ED10) &= 0xFFFFFFF9 ;
128 | SystemInit();
129 | USB_OTG_UngateClock(&USB_OTG_dev);
130 | }
131 | EXTI_ClearITPendingBit(EXTI_Line18);
132 | }
133 | #endif
134 |
135 | /**
136 | * @brief This function handles EXTI15_10_IRQ Handler.
137 | * @param None
138 | * @retval None
139 | */
140 | #ifdef USE_USB_OTG_HS
141 | void OTG_HS_WKUP_IRQHandler(void)
142 | {
143 | if(USB_OTG_dev.cfg.low_power)
144 | {
145 | *(uint32_t *)(0xE000ED10) &= 0xFFFFFFF9 ;
146 | SystemInit();
147 | USB_OTG_UngateClock(&USB_OTG_dev);
148 | }
149 | EXTI_ClearITPendingBit(EXTI_Line20);
150 | }
151 | #endif
152 |
153 | /**
154 | * @brief This function handles OTG_HS Handler.
155 | * @param None
156 | * @retval None
157 | */
158 | #ifdef USE_USB_OTG_HS
159 | void OTG_HS_IRQHandler(void)
160 | #else
161 | void OTG_FS_IRQHandler(void)
162 | #endif
163 | {
164 | USBD_OTG_ISR_Handler (&USB_OTG_dev);
165 | }
166 |
167 | #ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED
168 | /**
169 | * @brief This function handles EP1_IN Handler.
170 | * @param None
171 | * @retval None
172 | */
173 | void OTG_HS_EP1_IN_IRQHandler(void)
174 | {
175 | USBD_OTG_EP1IN_ISR_Handler (&USB_OTG_dev);
176 | }
177 |
178 | /**
179 | * @brief This function handles EP1_OUT Handler.
180 | * @param None
181 | * @retval None
182 | */
183 | void OTG_HS_EP1_OUT_IRQHandler(void)
184 | {
185 | USBD_OTG_EP1OUT_ISR_Handler (&USB_OTG_dev);
186 | }
187 | #endif
188 |
--------------------------------------------------------------------------------
/src/usbd_midi_user.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file usbd_midi_user.c
3 | * @author Philip Karlsson
4 | * @version V1.0.0
5 | * @date 29-November-2014
6 | * @brief This file contains user interface to the midi class driver.
7 | *
8 | * This is the implementation of the user interface to usbd_midi_core. MIDI_DataRx
9 | * is called whenever new midi data has arrived to the device. In order to send data
10 | * call send_MIDI_msg with the appropriate midi message to be sent to the host.
11 | */
12 |
13 | /* Includes */
14 | #include "usbd_midi_user.h"
15 | #include "stm32f4xx_conf.h"
16 |
17 |
18 | /* Private functions ------------
19 | *
20 | *
21 | */
22 |
23 | static uint16_t MIDI_DataRx(uint8_t *msg, uint16_t length);
24 | static uint16_t MIDI_DataTx(uint8_t *msg, uint16_t length);
25 |
26 | MIDI_IF_Prop_TypeDef MIDI_fops = {MIDI_DataRx, MIDI_DataTx};
27 |
28 | /* This is the callback function that is called
29 | * whenever a midi message is revieved.
30 | */
31 | static uint16_t MIDI_DataRx(uint8_t *msg, uint16_t length){
32 | return 0;
33 | }
34 |
35 | /* This function is called in order to send a midi message
36 | * over USB.
37 | */
38 | void send_MIDI_msg(uint8_t *msg, uint16_t length){
39 | MIDI_DataTx(msg, length);
40 | }
41 |
42 | static uint16_t MIDI_DataTx(uint8_t *msg, uint16_t length){
43 | uint32_t i = 0;
44 | while (i < length) {
45 | APP_Rx_Buffer[APP_Rx_ptr_in] = *(msg + i);
46 | APP_Rx_ptr_in++;
47 | i++;
48 | /* To avoid buffer overflow */
49 | if (APP_Rx_ptr_in == APP_RX_DATA_SIZE) {
50 | APP_Rx_ptr_in = 0;
51 | }
52 | }
53 |
54 | return USBD_OK;
55 | }
56 |
--------------------------------------------------------------------------------
/src/usbd_usr.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_usr.c
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 19-September-2011
7 | * @brief This file includes the user application layer
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | #include "usbd_usr.h"
23 | #include "usbd_ioreq.h"
24 |
25 | USBD_Usr_cb_TypeDef USR_cb =
26 | {
27 | USBD_USR_Init,
28 | USBD_USR_DeviceReset,
29 | USBD_USR_DeviceConfigured,
30 | USBD_USR_DeviceSuspended,
31 | USBD_USR_DeviceResumed,
32 |
33 | USBD_USR_DeviceConnected,
34 | USBD_USR_DeviceDisconnected,
35 | };
36 |
37 |
38 | /**
39 | * @brief USBD_USR_Init
40 | * Displays the message on LCD for host lib initialization
41 | * @param None
42 | * @retval None
43 | */
44 | void USBD_USR_Init(void)
45 | {
46 |
47 | }
48 |
49 | /**
50 | * @brief USBD_USR_DeviceReset
51 | * Displays the message on LCD on device Reset Event
52 | * @param speed : device speed
53 | * @retval None
54 | */
55 | void USBD_USR_DeviceReset(uint8_t speed )
56 | {
57 | switch (speed)
58 | {
59 | case USB_OTG_SPEED_HIGH:
60 | break;
61 |
62 | case USB_OTG_SPEED_FULL:
63 | break;
64 | default:
65 | break;
66 |
67 | }
68 | }
69 |
70 |
71 | /**
72 | * @brief USBD_USR_DeviceConfigured
73 | * Displays the message on LCD on device configuration Event
74 | * @param None
75 | * @retval Staus
76 | */
77 | void USBD_USR_DeviceConfigured (void)
78 | {
79 | }
80 |
81 |
82 | /**
83 | * @brief USBD_USR_DeviceConnected
84 | * Displays the message on LCD on device connection Event
85 | * @param None
86 | * @retval Staus
87 | */
88 | void USBD_USR_DeviceConnected (void)
89 | {
90 | }
91 |
92 |
93 | /**
94 | * @brief USBD_USR_DeviceDisonnected
95 | * Displays the message on LCD on device disconnection Event
96 | * @param None
97 | * @retval Staus
98 | */
99 | void USBD_USR_DeviceDisconnected (void)
100 | {
101 | }
102 |
103 | /**
104 | * @brief USBD_USR_DeviceSuspended
105 | * Displays the message on LCD on device suspend Event
106 | * @param None
107 | * @retval None
108 | */
109 | void USBD_USR_DeviceSuspended(void)
110 | {
111 | /* Users can do their application actions here for the USB-Reset */
112 | }
113 |
114 |
115 | /**
116 | * @brief USBD_USR_DeviceResumed
117 | * Displays the message on LCD on device resume Event
118 | * @param None
119 | * @retval None
120 | */
121 | void USBD_USR_DeviceResumed(void)
122 | {
123 | /* Users can do their application actions here for the USB-Reset */
124 | }
125 |
126 |
127 |
--------------------------------------------------------------------------------
/stm32_flash.ld:
--------------------------------------------------------------------------------
1 | ENTRY(Reset_Handler)
2 |
3 | /* Highest address of the user mode stack */
4 | _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
5 |
6 | /* Generate a link error if heap and stack don't fit into RAM */
7 | _Min_Heap_Size = 0; /* required amount of heap */
8 | _Min_Stack_Size = 0x400; /* required amount of stack */
9 |
10 | /* Specify the memory areas */
11 | MEMORY
12 | {
13 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
14 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
15 | CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
16 | }
17 |
18 | SECTIONS
19 | {
20 | .isr_vector :
21 | {
22 | . = ALIGN(4);
23 | KEEP(*(.isr_vector))
24 | . = ALIGN(4);
25 | } >FLASH
26 |
27 | .text :
28 | {
29 | . = ALIGN(4);
30 | *(.text) /* .text sections (code) */
31 | *(.text*) /* .text* sections (code) */
32 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
33 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
34 | *(.glue_7) /* glue arm to thumb code */
35 | *(.glue_7t) /* glue thumb to arm code */
36 | *(.eh_frame)
37 |
38 | KEEP (*(.init))
39 | KEEP (*(.fini))
40 |
41 | . = ALIGN(4);
42 | _etext = .; /* define a global symbols at end of code */
43 | _exit = .;
44 | } >FLASH
45 |
46 |
47 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
48 | .ARM : {
49 | __exidx_start = .;
50 | *(.ARM.exidx*)
51 | __exidx_end = .;
52 | } >FLASH
53 |
54 | .preinit_array :
55 | {
56 | PROVIDE_HIDDEN (__preinit_array_start = .);
57 | KEEP (*(.preinit_array*))
58 | PROVIDE_HIDDEN (__preinit_array_end = .);
59 | } >FLASH
60 | .init_array :
61 | {
62 | PROVIDE_HIDDEN (__init_array_start = .);
63 | KEEP (*(SORT(.init_array.*)))
64 | KEEP (*(.init_array*))
65 | PROVIDE_HIDDEN (__init_array_end = .);
66 | } >FLASH
67 | .fini_array :
68 | {
69 | PROVIDE_HIDDEN (__fini_array_start = .);
70 | KEEP (*(.fini_array*))
71 | KEEP (*(SORT(.fini_array.*)))
72 | PROVIDE_HIDDEN (__fini_array_end = .);
73 | } >FLASH
74 |
75 | /* used by the startup to initialize data */
76 | _sidata = .;
77 |
78 | /* Initialized data sections goes into RAM, load LMA copy after code */
79 | .data : AT ( _sidata )
80 | {
81 | . = ALIGN(4);
82 | _sdata = .; /* create a global symbol at data start */
83 | *(.data) /* .data sections */
84 | *(.data*) /* .data* sections */
85 |
86 | . = ALIGN(4);
87 | _edata = .; /* define a global symbol at data end */
88 | } >RAM
89 |
90 | /* Uninitialized data section */
91 | . = ALIGN(4);
92 | .bss :
93 | {
94 | /* This is used by the startup in order to initialize the .bss secion */
95 | _sbss = .; /* define a global symbol at bss start */
96 | __bss_start__ = _sbss;
97 | *(.bss)
98 | *(.bss*)
99 | *(COMMON)
100 |
101 | . = ALIGN(4);
102 | _ebss = .; /* define a global symbol at bss end */
103 | __bss_end__ = _ebss;
104 | } >RAM
105 |
106 | /* User_heap_stack section, used to check that there is enough RAM left */
107 | ._user_heap_stack :
108 | {
109 | . = ALIGN(4);
110 | PROVIDE ( end = . );
111 | PROVIDE ( _end = . );
112 | . = . + _Min_Heap_Size;
113 | . = . + _Min_Stack_Size;
114 | . = ALIGN(4);
115 | } >RAM
116 | }
117 |
--------------------------------------------------------------------------------