├── bulk-example ├── bulk-example.pdf ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F3xx │ │ │ │ └── Include │ │ │ │ ├── stm32f3xx.h │ │ │ │ ├── stm32f303xc.h │ │ │ │ └── system_stm32f3xx.h │ │ └── Include │ │ │ ├── core_cmFunc.h │ │ │ ├── core_cmInstr.h │ │ │ ├── core_cmSimd.h │ │ │ ├── arm_const_structs.h │ │ │ └── arm_common_tables.h │ └── STM32F3xx_HAL_Driver │ │ ├── Inc │ │ ├── stm32f3xx_hal_spi_ex.h │ │ ├── stm32f3xx_hal_pcd_ex.h │ │ ├── stm32f3xx_hal_def.h │ │ ├── stm32f3xx_hal_i2c_ex.h │ │ └── stm32f3xx_hal_pwr.h │ │ └── Src │ │ ├── stm32f3xx_hal_spi_ex.c │ │ ├── stm32f3xx_hal_pwr_ex.c │ │ └── stm32f3xx_hal_pcd_ex.c ├── Inc │ ├── usb_device.h │ ├── usbd_bulk_if.h │ ├── usbd_conf.h │ ├── target_config.h │ ├── usbd_bulk.h │ ├── stm32f3xx_it.h │ ├── gpio.h │ ├── spi.h │ └── mxconstants.h ├── Src │ ├── stm32f3xx_it.c │ ├── usb_device.c │ ├── stm32f3xx_hal_msp.c │ ├── usbd_bulk_if.c │ ├── bulk.c │ ├── gpio.c │ ├── main.c │ ├── spi.c │ ├── usbd_desc.c │ ├── usbd_bulk.c │ └── usbd_conf.c ├── Makefile ├── bulk-example.txt ├── Middlewares │ └── ST │ │ └── STM32_USB_Device_Library │ │ ├── Core │ │ ├── Inc │ │ │ ├── usbd_ctlreq.h │ │ │ ├── usbd_ioreq.h │ │ │ └── usbd_core.h │ │ └── Src │ │ │ └── usbd_ioreq.c │ │ └── Class │ │ └── CDC │ │ └── Inc │ │ └── usbd_cdc.h ├── .mxproject ├── usbecho.c └── usbtest.c ├── README.md ├── .gitignore ├── LICENSE ├── gpdsc2make.py ├── gpdsc.mk └── stm32f3xx.ld /bulk-example/bulk-example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geoffreymbrown/stm32usb-bulk/HEAD/bulk-example/bulk-example.pdf -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Device/ST/STM32F3xx/Include/stm32f3xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geoffreymbrown/stm32usb-bulk/HEAD/bulk-example/Drivers/CMSIS/Device/ST/STM32F3xx/Include/stm32f3xx.h -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Device/ST/STM32F3xx/Include/stm32f303xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geoffreymbrown/stm32usb-bulk/HEAD/bulk-example/Drivers/CMSIS/Device/ST/STM32F3xx/Include/stm32f303xc.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stm32usb-bulk 2 | 3 | Example of a usb bulk device using stm32cube libraries for the 4 | stm32f3discovery board. 5 | 6 | You will need to modify paths in gpdsc.mk to point to gcc toolchain. 7 | 8 | You will need libusb-1.0 to build the two test tools usbtest and usbecho. 9 | 10 | 11 | -------------------------------------------------------------------------------- /bulk-example/Inc/usb_device.h: -------------------------------------------------------------------------------- 1 | #ifndef __usb_device_H 2 | #define __usb_device_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include "usbd_def.h" 8 | extern USBD_HandleTypeDef hUsbDeviceFS; 9 | void MX_USB_DEVICE_Init(void); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | #endif /*__usb_device_H */ 15 | 16 | -------------------------------------------------------------------------------- /bulk-example/Inc/usbd_bulk_if.h: -------------------------------------------------------------------------------- 1 | #ifndef __USBD_BULK_IF_H 2 | #define __USBD_BULK_IF_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "usbd_bulk.h" 9 | extern USBD_BULK_ItfTypeDef USBD_Interface_fops_FS; 10 | uint8_t BULK_Transmit_FS(uint8_t* Buf, uint16_t Len); 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif /* __USBD_BULK_IF_H */ 16 | 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | -------------------------------------------------------------------------------- /bulk-example/Src/stm32f3xx_it.c: -------------------------------------------------------------------------------- 1 | #include "stm32f3xx_hal.h" 2 | #include "stm32f3xx.h" 3 | #include "stm32f3xx_it.h" 4 | extern PCD_HandleTypeDef hpcd_USB_FS; 5 | 6 | void SysTick_Handler(void) 7 | { 8 | extern void Toggle_Leds(); 9 | Toggle_Leds(); 10 | HAL_IncTick(); 11 | HAL_SYSTICK_IRQHandler(); 12 | } 13 | 14 | void USB_LP_CAN_RX0_IRQHandler(void) 15 | { 16 | HAL_PCD_IRQHandler(&hpcd_USB_FS); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bulk-example/Src/usb_device.c: -------------------------------------------------------------------------------- 1 | #include "usb_device.h" 2 | #include "usbd_core.h" 3 | #include "usbd_bulk.h" 4 | #include "usbd_bulk_if.h" 5 | 6 | USBD_HandleTypeDef hUsbDeviceFS; 7 | extern USBD_DescriptorsTypeDef FS_Desc; 8 | 9 | void MX_USB_DEVICE_Init(void) 10 | { 11 | /* Init Device Library,Add Supported Class and Start the library*/ 12 | USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); 13 | USBD_RegisterClass(&hUsbDeviceFS, &USBD_BULK); 14 | USBD_BULK_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS); 15 | USBD_Start(&hUsbDeviceFS); 16 | } 17 | -------------------------------------------------------------------------------- /bulk-example/Src/stm32f3xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | #include "stm32f3xx_hal.h" 2 | 3 | extern void Error_Handler(void); 4 | /* USER CODE BEGIN 0 */ 5 | 6 | /* USER CODE END 0 */ 7 | 8 | void HAL_MspInit(void) 9 | { 10 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 11 | 12 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); 13 | 14 | /* System interrupt init*/ 15 | /* MemoryManagement_IRQn interrupt configuration */ 16 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 17 | /* BusFault_IRQn interrupt configuration */ 18 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 19 | /* UsageFault_IRQn interrupt configuration */ 20 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 21 | /* SVCall_IRQn interrupt configuration */ 22 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); 23 | /* DebugMonitor_IRQn interrupt configuration */ 24 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 25 | /* PendSV_IRQn interrupt configuration */ 26 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 27 | /* SysTick_IRQn interrupt configuration */ 28 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /bulk-example/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = ../ 2 | 3 | # compiler flags 4 | 5 | CFLAGS = -g -O1 -I./Inc 6 | AFLAGS = -g 7 | LDFLAGS = -nostdlib 8 | 9 | vpath %.c ./Src 10 | 11 | # additional source files 12 | 13 | CSOURCE = usbd_bulk.c usbd_bulk_if.c bulk.c 14 | 15 | ASMSOURCE = 16 | 17 | # additional files to delete at clean (none) 18 | 19 | CLEANOTHER= usbtest usbecho 20 | 21 | all: usbtest usbecho 22 | 23 | usbtest: usbtest.c 24 | gcc -I/usr/local/include/libusb-1.0 -L/usr/local/lib usbtest.c -o usbtest -lusb-1.0 25 | 26 | usbecho: usbecho.c 27 | gcc -I/usr/local/include/libusb-1.0 -L/usr/local/lib usbecho.c -o usbecho -lusb-1.0 28 | 29 | # hal files to exclude from build 30 | 31 | CEXCLUDE = stm32f3xx_hal_i2c.c stm32f3xx_hal_i2c_ex.c 32 | CEXCLUDE += stm32f3xx_hal_flash.c stm32f3xx_hal_flash_ex.c 33 | CEXCLUDE += stm32f3xx_hal_pwr.c stm32f3xx_hal_pwr_ex.c 34 | CEXCLUDE += stm32f3xx_hal_tim.c stm32f3xx_hal_tim_ex.c 35 | CEXCLUDE += stm32f3xx_hal_dma.c stm32f3xx_hal_spi.c spi.c 36 | CEXCLUDE += usbd_cdc.c usbd_cdc_if.c 37 | 38 | # load template make file 39 | 40 | -include $(TEMPLATEROOT)/gpdsc.mk 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Geoffrey Brown 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bulk-example/Inc/usbd_conf.h: -------------------------------------------------------------------------------- 1 | #ifndef __USBD_CONF__H__ 2 | #define __USBD_CONF__H__ 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | /* Includes ------------------------------------------------------------------*/ 7 | 8 | #include 9 | #include "stm32f3xx.h" 10 | #include "stm32f3xx_hal.h" 11 | #include "usbd_def.h" 12 | 13 | #define USBD_MAX_NUM_INTERFACES 1 14 | #define USBD_MAX_NUM_CONFIGURATION 1 15 | #define USBD_MAX_STR_DESC_SIZ 512 16 | #define USBD_SUPPORT_USER_STRING 0 17 | #define USBD_DEBUG_LEVEL 0 18 | #define USBD_SELF_POWERED 1 19 | #define USBD_BULKC_INTERVAL 1000 20 | #define DEVICE_FS 0 21 | 22 | /* Memory management macros */ 23 | 24 | #define USBD_malloc (uint32_t *)USBD_static_malloc 25 | #define USBD_free USBD_static_free 26 | #define USBD_memset /* Not used */ 27 | #define USBD_memcpy /* Not used */ 28 | 29 | #define USBD_Delay HAL_Delay 30 | 31 | void *USBD_static_malloc(uint32_t size); 32 | void USBD_static_free(void *p); 33 | 34 | /* DEBUG macros */ 35 | 36 | #define USBD_UsrLog(...) 37 | #define USBD_ErrLog(...) 38 | #define USBD_DbgLog(...) 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif //__USBD_CONF__H__ 44 | -------------------------------------------------------------------------------- /gpdsc2make.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import untangle 5 | import os 6 | 7 | incs = dict() 8 | cvpath = dict() 9 | svpath = dict() 10 | csources = [] 11 | asmsources = [] 12 | 13 | def processfile(file): 14 | """ 15 | Gather all the information about files 16 | """ 17 | if (os.path.sep == '/'): 18 | name = file['name'].replace('\\','/') 19 | else: 20 | name = file['name'] 21 | 22 | (dir,base) = os.path.split(name) 23 | 24 | if (file['category'] == 'header'): 25 | incs[dir] = 1 26 | elif (file['category'] == 'sourceC') | (file['category'] == 'source'): 27 | cvpath[dir] = 1 28 | csources.append(base) 29 | elif (file['category'] == 'sourceAsm'): 30 | if (file['condition'] == 'GCC Toolchain'): 31 | svpath[dir] = 1 32 | asmsources.append(base) 33 | 34 | def makegen(path): 35 | """ 36 | process a single gpdsc file 37 | """ 38 | obj = untangle.parse(path) 39 | 40 | print "# Vendor: " , obj.package.vendor.cdata 41 | 42 | for file in obj.package.generators.generator.project_files.file: 43 | processfile(file) 44 | 45 | for component in obj.package.components.component: 46 | for file in component.files.file: 47 | processfile(file) 48 | 49 | print "# Include paths\n" 50 | 51 | for i in incs.keys(): 52 | print "INC += -I" + i 53 | 54 | print "\n# Source paths\n" 55 | 56 | for cv in cvpath.keys(): 57 | print "vpath %.c", cv 58 | 59 | for sv in svpath.keys(): 60 | print "vpath %.s", sv 61 | 62 | print "\n# Sources\n" 63 | 64 | for cf in csources: 65 | print "CSOURCE +=", cf 66 | 67 | for af in asmsources: 68 | print "ASMSOURCE +=", af 69 | 70 | 71 | def main(): 72 | makegen(sys.argv[1]) 73 | 74 | if __name__ == "__main__": 75 | main() 76 | -------------------------------------------------------------------------------- /bulk-example/Src/usbd_bulk_if.c: -------------------------------------------------------------------------------- 1 | #include "usbd_bulk_if.h" 2 | 3 | #define APP_RX_DATA_SIZE 64 4 | extern int8_t Receive_FS(uint8_t* Buf,uint32_t *Len); 5 | 6 | static uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; 7 | 8 | USBD_HandleTypeDef *hUsbDevice_0; 9 | extern USBD_HandleTypeDef hUsbDeviceFS; 10 | 11 | static int8_t BULK_Init_FS (void); 12 | static int8_t BULK_DeInit_FS (void); 13 | static int8_t BULK_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length); 14 | static int8_t BULK_Receive_FS (uint8_t* Buf, uint32_t *Len); 15 | 16 | // should be const, but annoying ST library is not declared const 17 | 18 | USBD_BULK_ItfTypeDef USBD_Interface_fops_FS = 19 | { 20 | BULK_Init_FS, 21 | BULK_DeInit_FS, 22 | BULK_Receive_FS 23 | }; 24 | 25 | static int8_t BULK_Init_FS(void) 26 | { 27 | hUsbDevice_0 = &hUsbDeviceFS; 28 | // here's where the input buffer gets set to kick off 29 | // the receiver 30 | USBD_BULK_SetRxBuffer(hUsbDevice_0,UserRxBufferFS); 31 | HAL_GPIO_WritePin(GPIOE,LD4_Pin,1); 32 | return (USBD_OK); 33 | } 34 | 35 | static int8_t BULK_DeInit_FS(void) 36 | { 37 | HAL_GPIO_WritePin(GPIOE,LD4_Pin,0); 38 | hUsbDevice_0=NULL; 39 | return (USBD_OK); 40 | } 41 | 42 | static int8_t BULK_Receive_FS (uint8_t* Buf, uint32_t *Len) 43 | { 44 | return Receive_FS(Buf, Len); 45 | } 46 | 47 | uint8_t BULK_Transmit_FS(uint8_t* Buf, uint16_t Len) 48 | { 49 | uint8_t result = USBD_OK; 50 | USBD_BULK_HandleTypeDef *hcdc; 51 | hcdc = (USBD_BULK_HandleTypeDef*)hUsbDevice_0->pClassData; 52 | 53 | if (hUsbDevice_0 == NULL) 54 | return -1; 55 | 56 | USBD_BULK_SetTxBuffer(hUsbDevice_0, Buf, Len); 57 | if ((result = USBD_BULK_TransmitPacket(hUsbDevice_0) != USBD_OK)) 58 | return result; 59 | 60 | // blocking transmit -- need to wait until transmit is complete 61 | // move this up to stlink level 62 | 63 | while (((volatile uint32_t) hcdc->TxState)) {} 64 | return result; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /bulk-example/Src/bulk.c: -------------------------------------------------------------------------------- 1 | #include "stm32f3xx_hal.h" 2 | #include "usb_device.h" 3 | #include "usbd_bulk_if.h" 4 | 5 | #define QUEUE_SIZE 256 6 | extern USBD_HandleTypeDef *hUsbDevice_0; 7 | static volatile int rxKick = 0; 8 | volatile int rxEOF = 0; 9 | 10 | uint8_t txbuf[256] __attribute__((aligned(4))); 11 | static struct Queue rxQ; 12 | 13 | struct Queue { 14 | uint32_t pRD, pWR; 15 | uint8_t q[QUEUE_SIZE]; 16 | }; 17 | 18 | #define QueueAvail(q) ((QUEUE_SIZE + (q)->pWR - (q)->pRD) % QUEUE_SIZE) 19 | #define QueueSpace(q) (QUEUE_SIZE - 1 - QueueAvail(q)) 20 | 21 | static int Enqueue(struct Queue *q, const uint8_t *data, uint32_t len){ 22 | int i; 23 | len = MIN(len,QueueSpace(q)); 24 | for (i = 0; i < len; i++) { 25 | q->q[q->pWR] = data[i]; 26 | q->pWR = (q->pWR + 1) % QUEUE_SIZE; 27 | } 28 | return len; 29 | } 30 | 31 | static int Dequeue(struct Queue *q, uint8_t *data, uint32_t len){ 32 | int i; 33 | len = MIN(len,QueueAvail(q)); 34 | for (i = 0; i < len; i++){ 35 | data[i] = q->q[q->pRD]; 36 | q->pRD = (q->pRD + 1) % QUEUE_SIZE; 37 | } 38 | return len; 39 | } 40 | 41 | int8_t Receive_FS (uint8_t* Buf, uint32_t *Len){ 42 | int count = *Len; 43 | 44 | if (*Len && ((Enqueue(&rxQ, Buf, *Len) != *Len))) { 45 | // Shouldn't happen ! this is an overflow 46 | } 47 | 48 | HAL_GPIO_WritePin(GPIOE,LD7_Pin, *Len == 0); 49 | if (*Len == 0) 50 | rxEOF = 1; 51 | // HAL_GPIO_WritePin(GPIOE,LD8_Pin, *Len == 64); 52 | 53 | // release receive buffer ? Only if there's enough space 54 | // for the next packet 55 | 56 | if (USB_FS_MAX_PACKET_SIZE >= QueueSpace(&rxQ)) { 57 | rxKick = 1; 58 | } else { 59 | USBD_BULK_ReceivePacket(hUsbDevice_0); 60 | } 61 | return (USBD_OK); 62 | } 63 | 64 | uint32_t bulk_read_cnt(void) { 65 | return QueueAvail(&rxQ); 66 | } 67 | 68 | uint32_t bulk_read(uint8_t *pBuf, uint32_t buf_len) { 69 | 70 | uint32_t cnt = Dequeue(&rxQ, pBuf, buf_len); 71 | 72 | // release receive buffer 73 | 74 | if (rxKick && (USB_FS_MAX_PACKET_SIZE <= QueueSpace(&rxQ))) { 75 | // HAL_GPIO_TogglePin(GPIOE,LD5_Pin); 76 | rxKick = 0; 77 | USBD_BULK_ReceivePacket(hUsbDevice_0); 78 | } 79 | 80 | return cnt; 81 | } 82 | 83 | -------------------------------------------------------------------------------- /bulk-example/Inc/target_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file target_config.h 3 | * @brief 4 | * 5 | * DAPLink Interface Firmware 6 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef TARGET_CONFIG_H 23 | #define TARGET_CONFIG_H 24 | 25 | #include "stddef.h" 26 | #include "stdint.h" 27 | 28 | #include "flash_blob.h" 29 | //#include "macro.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | @addtogroup 37 | @{ 38 | */ 39 | 40 | // This can vary from target to target and should be in the structure or flash blob 41 | #define TARGET_AUTO_INCREMENT_PAGE_SIZE (1024) 42 | 43 | /** 44 | @struct target_cfg_t 45 | @brief The firmware configuration struct has unique about the chip its running on. 46 | */ 47 | typedef struct target_cfg { 48 | uint32_t sector_size; /*!< Number of bytes in a sector used by flash erase and filesystem */ 49 | uint32_t sector_cnt; /*!< Number of sectors a device has */ 50 | uint32_t flash_start; /*!< Address of the application entry point */ 51 | uint32_t flash_end; /*!< Address where the flash ends */ 52 | uint32_t ram_start; /*!< Lowest contigous RAM address the application uses */ 53 | uint32_t ram_end; /*!< Highest contigous RAM address the application uses */ 54 | program_target_t *flash_algo; /*!< A pointer to the flash algorithm structure */ 55 | uint8_t erase_reset; /*!< Reset after performing an erase */ 56 | } target_cfg_t; 57 | 58 | extern target_cfg_t target_device; 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /bulk-example/Inc/usbd_bulk.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB_BULK_H 2 | #define __USB_BULK_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | #include "usbd_ioreq.h" 10 | 11 | #define BULK_IN_EP 0x81 /* EP1 for data IN */ 12 | #define BULK_OUT_EP 0x02 /* EP1 for data OUT */ 13 | 14 | 15 | /* BULK Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 16 | 17 | #define BULK_DATA_HS_MAX_PACKET_SIZE 64 18 | #define BULK_DATA_FS_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ 19 | #define BULK_CMD_PACKET_SIZE 8 /* Control Endpoint Packet size */ 20 | 21 | #define USB_BULK_CONFIG_DESC_SIZ 32 22 | 23 | #define BULK_DATA_FS_IN_PACKET_SIZE BULK_DATA_FS_MAX_PACKET_SIZE 24 | #define BULK_DATA_FS_OUT_PACKET_SIZE BULK_DATA_FS_MAX_PACKET_SIZE 25 | 26 | typedef struct _USBD_BULK_Itf 27 | { 28 | int8_t (* Init) (void); 29 | int8_t (* DeInit) (void); 30 | int8_t (* Receive) (uint8_t *, uint32_t *); 31 | 32 | }USBD_BULK_ItfTypeDef; 33 | 34 | 35 | typedef struct 36 | { 37 | uint32_t data[BULK_DATA_HS_MAX_PACKET_SIZE/4]; /* Force 32bits alignment */ 38 | uint32_t RxLength; 39 | uint32_t TxLength; 40 | uint8_t *RxBuffer; 41 | uint8_t *TxBuffer; 42 | __IO uint32_t TxState; 43 | __IO uint32_t RxState; 44 | } 45 | USBD_BULK_HandleTypeDef; 46 | 47 | // should be const, but annoying st library discards const 48 | 49 | extern USBD_ClassTypeDef USBD_BULK; 50 | #define USBD_BULK_CLASS &USBD_BULK 51 | 52 | uint8_t USBD_BULK_RegisterInterface (USBD_HandleTypeDef *pdev, 53 | USBD_BULK_ItfTypeDef *fops); 54 | 55 | uint8_t USBD_BULK_SetTxBuffer (USBD_HandleTypeDef *pdev, 56 | uint8_t *pbuff, 57 | uint16_t length); 58 | 59 | uint8_t USBD_BULK_SetRxBuffer (USBD_HandleTypeDef *pdev, 60 | uint8_t *pbuff); 61 | 62 | uint8_t USBD_BULK_ReceivePacket (USBD_HandleTypeDef *pdev); 63 | 64 | uint8_t USBD_BULK_TransmitPacket (USBD_HandleTypeDef *pdev); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* __USB_BULK_H */ 71 | -------------------------------------------------------------------------------- /bulk-example/bulk-example.txt: -------------------------------------------------------------------------------- 1 | Configuration bulk-example 2 | STM32CubeMX 4.17.0 3 | Date 12/09/2016 4 | MCU STM32F303VCTx 5 | 6 | 7 | 8 | PERIPHERALS MODES FUNCTIONS PINS 9 | RCC BYPASS Clock Source RCC_OSC_IN PF0-OSC_IN 10 | SPI3 Half-Duplex Master SPI3_MOSI PC12 11 | SPI3 Half-Duplex Master SPI3_SCK PC10 12 | SYS Serial Wire SYS_JTCK-SWCLK PA14 13 | SYS Serial Wire SYS_JTMS-SWDIO PA13 14 | SYS SysTick SYS_VS_Systick VP_SYS_VS_Systick 15 | USB Device (FS) USB_DM PA11 16 | USB Device (FS) USB_DP PA12 17 | 18 | 19 | 20 | Pin Nb PINs FUNCTIONs LABELs 21 | 1 PE2 GPIO_EXTI2 DRDY [LSM303DLHC_DRDY] 22 | 2 PE3 GPIO_Output CS_I2C/SPI [L3GD20_CS_I2C/SPI] 23 | 3 PE4 GPIO_EXTI4 MEMS_INT3 [LSM303DLHC_INT1] 24 | 4 PE5 GPIO_EXTI5 MEMS_INT4 [LSM303DLHC_INT2] 25 | 8 PC14-OSC32_IN* RCC_OSC32_IN OSC32_IN 26 | 9 PC15-OSC32_OUT* RCC_OSC32_OUT OSC32_OUT 27 | 12 PF0-OSC_IN RCC_OSC_IN OSC_IN 28 | 13 PF1-OSC_OUT* RCC_OSC_OUT OSC_OUT 29 | 23 PA0 GPIO_Input B1 [Blue PushButton] 30 | 30 PA5* SPI1_SCK SPI1_SCK [L3GD20_SCL/SPC] 31 | 31 PA6* SPI1_MISO SPI1_MISO [L3GD20_SA0/SDO] 32 | 32 PA7* SPI1_MOSI SPI1_MISO [L3GD20_SDA/SDI/SDO] 33 | 39 PE8 GPIO_Output LD4 [Blue Led] 34 | 40 PE9 GPIO_Output LD3 [Red Led] 35 | 41 PE10 GPIO_Output LD5 [Orange Led] 36 | 42 PE11 GPIO_Output LD7 [Green Led] 37 | 43 PE12 GPIO_Output LD9 [Blue Led] 38 | 44 PE13 GPIO_Output LD10 [Red Led] 39 | 45 PE14 GPIO_Output LD8 [Orange Led] 40 | 46 PE15 GPIO_Output LD6 [Green Led] 41 | 70 PA11 USB_DM DM 42 | 71 PA12 USB_DP DP 43 | 72 PA13 SYS_JTMS-SWDIO SWDIO 44 | 76 PA14 SYS_JTCK-SWCLK SWCLK 45 | 78 PC10 SPI3_SCK tgt_swclk 46 | 79 PC11 GPIO_Output tgt_nReset 47 | 80 PC12 SPI3_MOSI tgt_swdio 48 | 89 PB3* SYS_JTDO-TRACESWO SWO 49 | 92 PB6* I2C1_SCL I2C1_SCL [LSM303DLHC_SCL] 50 | 93 PB7* I2C1_SDA I2C1_SDA [LSM303DLHC_SDA] 51 | 97 PE0 GPIO_EXTI0 MEMS_INT1 [L3GD20_INT1] 52 | 98 PE1 GPIO_EXTI1 MEMS_INT2 [L3GD20_DRDY/INT2] 53 | 54 | 55 | 56 | SOFTWARE PROJECT 57 | 58 | Project Settings : 59 | Project Name : bulk-example 60 | Project Folder : /Users/geobrown/stm32cubef3bulk/bulk-example 61 | Toolchain / IDE : Other Toolchains (GPDSC) 62 | Firmware Package Name and Version : STM32Cube FW_F3 V1.6.0 63 | 64 | 65 | Code Generation Settings : 66 | STM32Cube Firmware Library Package : Copy only the necessary library files 67 | Generate peripheral initialization as a pair of '.c/.h' files per peripheral : Yes 68 | Backup previously generated files when re-generating : No 69 | Delete previously generated files when not re-generated : Yes 70 | Set all free pins as analog (to optimize the power consumption) : No 71 | 72 | 73 | Toolchains Settings : 74 | Compiler Optimizations : Balanced Size/Speed 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /bulk-example/Inc/stm32f3xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __STM32F3xx_IT_H 36 | #define __STM32F3xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | /* Exported types ------------------------------------------------------------*/ 44 | /* Exported constants --------------------------------------------------------*/ 45 | /* Exported macro ------------------------------------------------------------*/ 46 | /* Exported functions ------------------------------------------------------- */ 47 | 48 | void SysTick_Handler(void); 49 | void USB_LP_CAN_RX0_IRQHandler(void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* __STM32F3xx_IT_H */ 56 | 57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 58 | -------------------------------------------------------------------------------- /bulk-example/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.h 4 | * Description : This file contains all the functions prototypes for 5 | * the gpio 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Define to prevent recursive inclusion -------------------------------------*/ 36 | #ifndef __gpio_H 37 | #define __gpio_H 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f3xx_hal.h" 44 | 45 | /* USER CODE BEGIN Includes */ 46 | 47 | /* USER CODE END Includes */ 48 | 49 | /* USER CODE BEGIN Private defines */ 50 | 51 | /* USER CODE END Private defines */ 52 | 53 | void MX_GPIO_Init(void); 54 | 55 | /* USER CODE BEGIN Prototypes */ 56 | 57 | /* USER CODE END Prototypes */ 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | #endif /*__ pinoutConfig_H */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 73 | -------------------------------------------------------------------------------- /bulk-example/Inc/spi.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : SPI.h 4 | * Description : This file provides code for the configuration 5 | * of the SPI instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __spi_H 36 | #define __spi_H 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "stm32f3xx_hal.h" 43 | 44 | /* USER CODE BEGIN Includes */ 45 | 46 | /* USER CODE END Includes */ 47 | 48 | extern SPI_HandleTypeDef hspi3; 49 | 50 | /* USER CODE BEGIN Private defines */ 51 | 52 | /* USER CODE END Private defines */ 53 | 54 | extern void Error_Handler(void); 55 | 56 | void MX_SPI3_Init(void); 57 | 58 | /* USER CODE BEGIN Prototypes */ 59 | 60 | /* USER CODE END Prototypes */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif /*__ spi_H */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /bulk-example/Src/gpio.c: -------------------------------------------------------------------------------- 1 | #include "gpio.h" 2 | 3 | /** Configure pins as 4 | * Analog 5 | * Input 6 | * Output 7 | * EVENT_OUT 8 | * EXTI 9 | PA5 ------> SPI1_SCK 10 | PA6 ------> SPI1_MISO 11 | PA7 ------> SPI1_MOSI 12 | PB6 ------> I2C1_SCL 13 | PB7 ------> I2C1_SDA 14 | */ 15 | void MX_GPIO_Init(void) 16 | { 17 | 18 | GPIO_InitTypeDef GPIO_InitStruct; 19 | 20 | /* GPIO Ports Clock Enable */ 21 | 22 | __HAL_RCC_GPIOE_CLK_ENABLE(); 23 | __HAL_RCC_GPIOC_CLK_ENABLE(); 24 | __HAL_RCC_GPIOF_CLK_ENABLE(); 25 | __HAL_RCC_GPIOA_CLK_ENABLE(); 26 | __HAL_RCC_GPIOB_CLK_ENABLE(); 27 | 28 | /*Configure GPIO pins : PEPin PEPin PEPin PEPin 29 | PEPin */ 30 | GPIO_InitStruct.Pin = DRDY_Pin|MEMS_INT3_Pin|MEMS_INT4_Pin|MEMS_INT1_Pin 31 | |MEMS_INT2_Pin; 32 | GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; 33 | GPIO_InitStruct.Pull = GPIO_NOPULL; 34 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 35 | 36 | /*Configure GPIO pins : PEPin PEPin PEPin PEPin 37 | PEPin PEPin PEPin PEPin 38 | PEPin */ 39 | GPIO_InitStruct.Pin = CS_I2C_SPI_Pin|LD4_Pin|LD3_Pin|LD5_Pin 40 | |LD7_Pin|LD9_Pin|LD10_Pin|LD8_Pin 41 | |LD6_Pin; 42 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 43 | GPIO_InitStruct.Pull = GPIO_NOPULL; 44 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 45 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 46 | 47 | /*Configure GPIO pin : PtPin */ 48 | GPIO_InitStruct.Pin = B1_Pin; 49 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 50 | GPIO_InitStruct.Pull = GPIO_NOPULL; 51 | HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); 52 | 53 | /*Configure GPIO pins : PA5 PA6 PAPin */ 54 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|SPI1_MISO_Pin; 55 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 56 | GPIO_InitStruct.Pull = GPIO_NOPULL; 57 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 58 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; 59 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 60 | 61 | /*Configure GPIO pin : PtPin */ 62 | GPIO_InitStruct.Pin = tgt_nReset_Pin; 63 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; 64 | GPIO_InitStruct.Pull = GPIO_NOPULL; 65 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 66 | HAL_GPIO_Init(tgt_nReset_GPIO_Port, &GPIO_InitStruct); 67 | 68 | /*Configure GPIO pins : PB6 PB7 */ 69 | GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; 70 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 71 | GPIO_InitStruct.Pull = GPIO_PULLUP; 72 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 73 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; 74 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 75 | 76 | /*Configure GPIO pin Output Level */ 77 | HAL_GPIO_WritePin(GPIOE, CS_I2C_SPI_Pin|LD4_Pin|LD3_Pin|LD5_Pin 78 | |LD7_Pin|LD9_Pin|LD10_Pin|LD8_Pin 79 | |LD6_Pin, GPIO_PIN_RESET); 80 | 81 | /*Configure GPIO pin Output Level */ 82 | HAL_GPIO_WritePin(tgt_nReset_GPIO_Port, tgt_nReset_Pin, GPIO_PIN_SET); 83 | 84 | } 85 | -------------------------------------------------------------------------------- /bulk-example/Src/main.c: -------------------------------------------------------------------------------- 1 | #include "stm32f3xx_hal.h" 2 | #include "spi.h" 3 | #include "usb_device.h" 4 | #include "gpio.h" 5 | 6 | 7 | #include "usbd_bulk_if.h" 8 | #include "unistd.h" 9 | 10 | void SystemClock_Config(void); 11 | void Error_Handler(void); 12 | 13 | void __libc_init_array(){} 14 | uint8_t BULK_Transmit_FS(uint8_t* Buf, uint16_t Len); 15 | uint32_t bulk_read(uint8_t *pBuf, uint32_t buf_len); 16 | extern volatile int rxEOF; 17 | 18 | void Toggle_Leds(void) 19 | { 20 | static uint32_t ticks; 21 | 22 | if(ticks++ == 500) 23 | { 24 | HAL_GPIO_TogglePin(GPIOE,LD6_Pin); 25 | ticks = 0; 26 | } 27 | } 28 | 29 | 30 | int main(void) 31 | { 32 | HAL_Init(); 33 | SystemClock_Config(); 34 | 35 | MX_GPIO_Init(); 36 | // MX_SPI3_Init(); 37 | MX_USB_DEVICE_Init(); 38 | 39 | while (1) 40 | { 41 | uint8_t buf[256]; 42 | uint32_t len; 43 | 44 | if ((len = bulk_read(buf, sizeof(buf)))) { 45 | HAL_GPIO_TogglePin(GPIOE,LD4_Pin); 46 | BULK_Transmit_FS(buf, len); 47 | } else { 48 | if (rxEOF) { 49 | HAL_GPIO_WritePin(GPIOE,LD7_Pin, 0); 50 | rxEOF = 0; 51 | BULK_Transmit_FS(buf, 0); 52 | } 53 | // if (!(len &63)) 54 | // BULK_Transmit_FS(buf, 0); 55 | } 56 | } 57 | } 58 | 59 | void SystemClock_Config(void) 60 | { 61 | 62 | RCC_OscInitTypeDef RCC_OscInitStruct; 63 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 64 | RCC_PeriphCLKInitTypeDef PeriphClkInit; 65 | 66 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 67 | RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; 68 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 69 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 70 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 71 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; 72 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 73 | { 74 | Error_Handler(); 75 | } 76 | 77 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 78 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 79 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 80 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 81 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 82 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; 83 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 84 | { 85 | Error_Handler(); 86 | } 87 | 88 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 89 | PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; 90 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) 91 | { 92 | Error_Handler(); 93 | } 94 | 95 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 96 | 97 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 98 | 99 | /* SysTick_IRQn interrupt configuration */ 100 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 101 | } 102 | 103 | void Error_Handler(void) 104 | { 105 | while(1) 106 | { 107 | } 108 | } 109 | 110 | #ifdef USE_FULL_ASSERT 111 | 112 | void assert_failed(uint8_t* file, uint32_t line) 113 | { 114 | } 115 | #endif 116 | 117 | -------------------------------------------------------------------------------- /bulk-example/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /bulk-example/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousLibFiles] 2 | LibFiles=Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_pcd.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_pcd_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_spi.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_spi_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_tim.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_tim_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_def.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_rcc.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_rcc_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_gpio.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_gpio_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_dma_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_dma.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_cortex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_pwr.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_pwr_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_flash.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_flash_ex.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_i2c.h;Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_i2c_ex.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pcd.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pcd_ex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_spi.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_spi_ex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_tim.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_tim_ex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc_ex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_gpio.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_dma.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_cortex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr_ex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_flash.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_flash_ex.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_i2c.c;Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_i2c_ex.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c;Drivers/CMSIS/Device/ST/STM32F3xx/Include/stm32f303xc.h;Drivers/CMSIS/Device/ST/STM32F3xx/Include/stm32f3xx.h;Drivers/CMSIS/Device/ST/STM32F3xx/Include/system_stm32f3xx.h;Drivers/CMSIS/Device/ST/STM32F3xx/Source/Templates/system_stm32f3xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 3 | 4 | [] 5 | SourceFiles=;null; 6 | 7 | -------------------------------------------------------------------------------- /bulk-example/usbecho.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | 9 | int main(void) 10 | { 11 | int result; 12 | struct libusb_device_descriptor desc; 13 | struct libusb_config_descriptor *config; 14 | 15 | libusb_device **list; 16 | libusb_device *my_device = NULL; 17 | 18 | result = libusb_init(NULL); 19 | libusb_set_debug(NULL, 3); 20 | 21 | ssize_t count = libusb_get_device_list(NULL, &list); 22 | for (int i = 0; i < count; i++) { 23 | libusb_device *device = list[i]; 24 | result = libusb_get_device_descriptor(device, &desc); 25 | if(desc.idVendor == 0x483 && desc.idProduct == 0x5740){ 26 | 27 | printf("\nDevice Descriptors: "); 28 | printf("\n\tVendor ID : %x",desc.idVendor); 29 | printf("\n\tProduct ID : %x",desc.idProduct); 30 | printf("\n\tSerial Number : %x",desc.iSerialNumber); 31 | printf("\n\tSize of Device Descriptor : %d",desc.bLength); 32 | printf("\n\tType of Descriptor : %d",desc.bDescriptorType); 33 | printf("\n\tUSB Specification Release Number : %d",desc.bcdUSB); 34 | printf("\n\tDevice Release Number : %d",desc.bcdDevice); 35 | printf("\n\tDevice Class : %d",desc.bDeviceClass); 36 | printf("\n\tDevice Sub-Class : %d",desc.bDeviceSubClass); 37 | printf("\n\tDevice Protocol : %d",desc.bDeviceProtocol); 38 | printf("\n\tMax. Packet Size : %d",desc.bMaxPacketSize0); 39 | printf("\n\tNo. of Configurations : %d\n",desc.bNumConfigurations); 40 | 41 | my_device = device; 42 | break; 43 | } 44 | } 45 | 46 | if (my_device == NULL) { 47 | printf("can't find device\n"); 48 | exit(1); 49 | } 50 | 51 | if(my_device != NULL) { 52 | char buf[256]; 53 | libusb_device_handle *handle; 54 | result = libusb_open(my_device, &handle); 55 | int kernelActive = libusb_kernel_driver_active(handle, 0); 56 | if(kernelActive == 1) { 57 | result = libusb_detach_kernel_driver(handle, 0); 58 | } 59 | result = libusb_claim_interface (handle, 0); 60 | if (result) 61 | printf("couldn't claim interface \n"); 62 | // result = libusb_control_transfer(handle,0x21,34,0x0003,0,NULL,0,0); 63 | 64 | char *end; 65 | while ((end = fgets(buf, sizeof buf, stdin))) { 66 | int t; 67 | int res; 68 | size_t size = strlen(buf) + 1; 69 | if ((t = libusb_bulk_transfer(handle, 70 | 0x02, (unsigned char *) buf, 71 | size, 72 | &res, 73 | 3000))) { 74 | printf("[!] send request failed %s\n", libusb_error_name(t)); 75 | break; 76 | } 77 | printf("sent %d bytes of %zu \n", res, size); 78 | if (!(res & 63)){ // send zlp 79 | libusb_bulk_transfer(handle, 80 | 0x02, (unsigned char *) buf, 81 | 0, 82 | &res, 83 | 3000); 84 | } 85 | 86 | buf[0] = 0; 87 | res = 0; 88 | 89 | if ((t = libusb_bulk_transfer(handle, 90 | 0x81, (unsigned char *) buf, 91 | 256, 92 | &res, 93 | 3000))) { 94 | printf("[!] receive reuest failed %s\n", libusb_error_name(t)); 95 | buf[0] = 0; 96 | break; 97 | } 98 | printf("received %d bytes: %s\n", res, buf); 99 | } 100 | libusb_release_interface (handle, 0); 101 | if(kernelActive == 1) { 102 | result = libusb_attach_kernel_driver(handle, 0); 103 | } 104 | libusb_close(handle); 105 | } 106 | libusb_free_device_list(list, 1); 107 | libusb_exit(NULL); 108 | return EXIT_SUCCESS; 109 | } 110 | -------------------------------------------------------------------------------- /gpdsc.mk: -------------------------------------------------------------------------------- 1 | V = 1 2 | 3 | # name of executable 4 | 5 | ELF=$(notdir $(CURDIR)).elf 6 | BIN=$(notdir $(CURDIR)).bin 7 | MKFRAG=$(notdir $(CURDIR)).mk 8 | GPDSC=$(notdir $(CURDIR)).gpdsc 9 | 10 | # Tool path 11 | 12 | TOOLROOT=/l/arm2/devtools/bin/ 13 | 14 | # Tools 15 | 16 | GPDSC2MK=python $(TEMPLATEROOT)/gpdsc2make.py 17 | 18 | CC_0 = @echo -n "Compiling $< "; $(CC_1) 19 | CC_1 = $(TOOLROOT)/arm-none-eabi-gcc 20 | CC = $(CC_$(V)) 21 | 22 | GAS_0 = @echo -n "Assembling $< "; $(GAS_1) 23 | GAS_1 = $(TOOLROOT)/arm-none-eabi-gcc 24 | GAS = $(GAS_$(V)) 25 | 26 | 27 | DD_0 = @echo " "; $(DD_1) 28 | DD_1 = $(TOOLROOT)/arm-none-eabi-gcc 29 | DD = $(DD_$(V)) 30 | 31 | LD_0 = @echo "Linking $@"; $(LD_1) 32 | LD_1=$(TOOLROOT)/arm-none-eabi-gcc 33 | LD = $(LD_$(V)) 34 | 35 | DL_0 = @echo -n "Downloading"; $(DL_1) 36 | DL_1=st-flash 37 | DL = $(DL_$(V)) 38 | 39 | OC_0 = @echo "Creating Bin Downloadable File"; $(OC_1) 40 | OC_1=$(TOOLROOT)/arm-none-eabi-objcopy 41 | OC = $(OC_$(V)) 42 | 43 | GP_0 = @echo " "; $(GP_1) 44 | GP_1=grep 45 | GP = $(GP_$(V)) 46 | 47 | RM_0 = @echo "Cleaning Directory"; $(RM_1) 48 | RM_1=rm 49 | RM = $(RM_$(V)) 50 | 51 | AR=$(TOOLROOT)/arm-none-eabi-ar 52 | AS=$(TOOLROOT)/arm-none-eabi-as 53 | OBJCOPY=$(TOOLROOT)/arm-none-eabi-objcopy 54 | 55 | # Version 56 | 57 | GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) 58 | CFLAGS += -DVERSION=\"$(GIT_VERSION)\" 59 | 60 | # Code Paths 61 | 62 | vpath %.c $(TEMPLATEROOT)/Src 63 | 64 | 65 | # Processor specific 66 | 67 | ifndef LDSCRIPT 68 | LDSCRIPT = $(TEMPLATEROOT)/stm32f3xx.ld 69 | endif 70 | 71 | # Compilation Flags 72 | 73 | ifdef PROCESSOR 74 | CFLAGS += -D$(PROCESSOR) 75 | else 76 | CFLAGS += -DSTM32F303xC 77 | endif 78 | 79 | # LDLIBS = --specs=nosys.specs -lm 80 | 81 | LDLIBS = #-lm 82 | LDFLAGS+= -T$(LDSCRIPT) -mthumb -mcpu=cortex-m4 83 | CFLAGS+= -mcpu=cortex-m4 -mthumb 84 | CFLAGS+= -Wno-multichar 85 | 86 | # Generate project specific makefile 87 | 88 | all: 89 | 90 | $(MKFRAG): $(GPDSC) 91 | $(GPDSC2MK) $< > $@ 92 | 93 | -include $(MKFRAG) 94 | 95 | CSOURCE := $(sort $(filter-out $(CEXCLUDE),$(CSOURCE))) 96 | #CSOURCE := $(filter-out $(CEXCLUDE),$(CSOURCE)) 97 | OBJS += $(addprefix build/, $(CSOURCE:.c=.o) $(ASMSOURCE:.s=.o)) 98 | CFLAGS += $(INC) 99 | CFLAGS += -I$(TEMPLATEROOT)/Inc 100 | 101 | # Build executable 102 | 103 | $(ELF) : $(OBJS) 104 | $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) 105 | echo $(OBJS:.o=.d) 106 | 107 | # compile and generate dependency info 108 | 109 | build: 110 | @mkdir -p $@ 111 | 112 | build/%.o: %.c | build 113 | $(CC) -c $(CFLAGS) $< -o $@ 114 | $(DD) -MM $(CFLAGS) $< > build/$*.d.tmp 115 | @sed -e 's|.*:|build/$*.o:|' < build/$*.d.tmp > build/$*.d 116 | @sed -e 's/.*://' -e 's/\\$$//' < build/$*.d.tmp | fmt -1 | \ 117 | sed -e 's/^ *//' -e 's/$$/:/' >> build/$*.d 118 | @rm -f build/$*.d.tmp 119 | 120 | build/%.o: %.s | build 121 | $(GAS) -c $(CFLAGS) $< -o $@ 122 | $(DD) -MM $(CFLAGS) $< > build/$*.d.tmp 123 | @sed -e 's|.*:|build/$*.o:|' < build/$*.d.tmp > build/$*.d 124 | @sed -e 's/.*://' -e 's/\\$$//' < build/$*.d.tmp | fmt -1 | \ 125 | sed -e 's/^ *//' -e 's/$$/:/' >> build/$*.d 126 | @rm -f build/$*.d.tmp 127 | 128 | %.bin: %.elf 129 | $(OC) -O binary $< $@ 130 | 131 | clean: 132 | $(RM) -rf build $(ELF) $(CLEANOTHER) $(BIN) $(MKFRAG) st-flash.log 133 | 134 | debug: $(ELF) 135 | arm-none-eabi-gdb $(ELF) 136 | 137 | download: $(BIN) 138 | $(DL)write $(BIN) 0x8000000 > st-flash.log 2>&1 139 | $(GP) -o "jolly" st-flash.log | sed 's/jolly/Success/' 140 | $(GP) -o "Couldn" st-flash.log | sed 's/Couldn/Fail/' 141 | 142 | all: $(ELF) 143 | 144 | # pull in dependencies 145 | 146 | -include $(OBJS:.o=.d) 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_spi_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_spi_ex.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief Header file of SPI HAL Extended module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F3xx_HAL_SPI_EX_H 40 | #define __STM32F3xx_HAL_SPI_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f3xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F3xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup SPIEx 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported constants --------------------------------------------------------*/ 59 | /* Exported macros ------------------------------------------------------------*/ 60 | /* Exported functions --------------------------------------------------------*/ 61 | /** @addtogroup SPIEx_Exported_Functions 62 | * @{ 63 | */ 64 | 65 | /* Initialization and de-initialization functions ****************************/ 66 | /* IO operation functions *****************************************************/ 67 | /** @addtogroup SPIEx_Exported_Functions_Group1 68 | * @{ 69 | */ 70 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi); 71 | /** 72 | * @} 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* __STM32F3xx_HAL_SPI_EX_H */ 92 | 93 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 94 | -------------------------------------------------------------------------------- /bulk-example/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Device/ST/STM32F3xx/Include/system_stm32f3xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f3xx.h 4 | * @author MCD Application Team 5 | * @version V2.3.0 6 | * @date 29-April-2015 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F3xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /** @addtogroup CMSIS 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup stm32f3xx_system 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Define to prevent recursive inclusion 48 | */ 49 | #ifndef __SYSTEM_STM32F3XX_H 50 | #define __SYSTEM_STM32F3XX_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** @addtogroup STM32F3xx_System_Includes 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | /** @addtogroup STM32F3xx_System_Exported_types 66 | * @{ 67 | */ 68 | /* This variable is updated in three ways: 69 | 1) by calling CMSIS function SystemCoreClockUpdate() 70 | 3) by calling HAL API function HAL_RCC_GetHCLKFreq() 71 | 3) by calling HAL API function HAL_RCC_ClockConfig() 72 | Note: If you use this function to configure the system clock; then there 73 | is no need to call the 2 first functions listed above, since SystemCoreClock 74 | variable is updated automatically. 75 | */ 76 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 77 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 78 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 79 | 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @addtogroup STM32F3xx_System_Exported_Constants 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @addtogroup STM32F3xx_System_Exported_Macros 94 | * @{ 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @addtogroup STM32F3xx_System_Exported_Functions 102 | * @{ 103 | */ 104 | 105 | extern void SystemInit(void); 106 | extern void SystemCoreClockUpdate(void); 107 | /** 108 | * @} 109 | */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /*__SYSTEM_STM32F3XX_H */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 125 | -------------------------------------------------------------------------------- /bulk-example/Inc/mxconstants.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : mxconstants.h 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __MXCONSTANT_H 35 | #define __MXCONSTANT_H 36 | /* Includes ------------------------------------------------------------------*/ 37 | 38 | /* USER CODE BEGIN Includes */ 39 | 40 | /* USER CODE END Includes */ 41 | 42 | /* Private define ------------------------------------------------------------*/ 43 | 44 | #define DRDY_Pin GPIO_PIN_2 45 | #define DRDY_GPIO_Port GPIOE 46 | #define CS_I2C_SPI_Pin GPIO_PIN_3 47 | #define CS_I2C_SPI_GPIO_Port GPIOE 48 | #define MEMS_INT3_Pin GPIO_PIN_4 49 | #define MEMS_INT3_GPIO_Port GPIOE 50 | #define MEMS_INT4_Pin GPIO_PIN_5 51 | #define MEMS_INT4_GPIO_Port GPIOE 52 | #define OSC32_IN_Pin GPIO_PIN_14 53 | #define OSC32_IN_GPIO_Port GPIOC 54 | #define OSC32_OUT_Pin GPIO_PIN_15 55 | #define OSC32_OUT_GPIO_Port GPIOC 56 | #define OSC_IN_Pin GPIO_PIN_0 57 | #define OSC_IN_GPIO_Port GPIOF 58 | #define OSC_OUT_Pin GPIO_PIN_1 59 | #define OSC_OUT_GPIO_Port GPIOF 60 | #define B1_Pin GPIO_PIN_0 61 | #define B1_GPIO_Port GPIOA 62 | #define SPI1_MISO_Pin GPIO_PIN_7 63 | #define SPI1_MISO_GPIO_Port GPIOA 64 | #define LD4_Pin GPIO_PIN_8 65 | #define LD4_GPIO_Port GPIOE 66 | #define LD3_Pin GPIO_PIN_9 67 | #define LD3_GPIO_Port GPIOE 68 | #define LD5_Pin GPIO_PIN_10 69 | #define LD5_GPIO_Port GPIOE 70 | #define LD7_Pin GPIO_PIN_11 71 | #define LD7_GPIO_Port GPIOE 72 | #define LD9_Pin GPIO_PIN_12 73 | #define LD9_GPIO_Port GPIOE 74 | #define LD10_Pin GPIO_PIN_13 75 | #define LD10_GPIO_Port GPIOE 76 | #define LD8_Pin GPIO_PIN_14 77 | #define LD8_GPIO_Port GPIOE 78 | #define LD6_Pin GPIO_PIN_15 79 | #define LD6_GPIO_Port GPIOE 80 | #define DM_Pin GPIO_PIN_11 81 | #define DM_GPIO_Port GPIOA 82 | #define DP_Pin GPIO_PIN_12 83 | #define DP_GPIO_Port GPIOA 84 | #define SWDIO_Pin GPIO_PIN_13 85 | #define SWDIO_GPIO_Port GPIOA 86 | #define SWCLK_Pin GPIO_PIN_14 87 | #define SWCLK_GPIO_Port GPIOA 88 | #define tgt_swclk_Pin GPIO_PIN_10 89 | #define tgt_swclk_GPIO_Port GPIOC 90 | #define tgt_nReset_Pin GPIO_PIN_11 91 | #define tgt_nReset_GPIO_Port GPIOC 92 | #define tgt_swdio_Pin GPIO_PIN_12 93 | #define tgt_swdio_GPIO_Port GPIOC 94 | #define SWO_Pin GPIO_PIN_3 95 | #define SWO_GPIO_Port GPIOB 96 | #define MEMS_INT1_Pin GPIO_PIN_0 97 | #define MEMS_INT1_GPIO_Port GPIOE 98 | #define MEMS_INT2_Pin GPIO_PIN_1 99 | #define MEMS_INT2_GPIO_Port GPIOE 100 | /* USER CODE BEGIN Private defines */ 101 | 102 | /* USER CODE END Private defines */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | #endif /* __MXCONSTANT_H */ 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /bulk-example/Src/spi.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : SPI.c 4 | * Description : This file provides code for the configuration 5 | * of the SPI instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "spi.h" 37 | 38 | #include "gpio.h" 39 | 40 | /* USER CODE BEGIN 0 */ 41 | 42 | /* USER CODE END 0 */ 43 | 44 | SPI_HandleTypeDef hspi3; 45 | 46 | /* SPI3 init function */ 47 | void MX_SPI3_Init(void) 48 | { 49 | 50 | hspi3.Instance = SPI3; 51 | hspi3.Init.Mode = SPI_MODE_MASTER; 52 | hspi3.Init.Direction = SPI_DIRECTION_1LINE; 53 | hspi3.Init.DataSize = SPI_DATASIZE_4BIT; 54 | hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; 55 | hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; 56 | hspi3.Init.NSS = SPI_NSS_SOFT; 57 | hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; 58 | hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; 59 | hspi3.Init.TIMode = SPI_TIMODE_DISABLE; 60 | hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 61 | hspi3.Init.CRCPolynomial = 7; 62 | hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; 63 | hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; 64 | if (HAL_SPI_Init(&hspi3) != HAL_OK) 65 | { 66 | Error_Handler(); 67 | } 68 | 69 | } 70 | 71 | void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) 72 | { 73 | 74 | GPIO_InitTypeDef GPIO_InitStruct; 75 | if(spiHandle->Instance==SPI3) 76 | { 77 | /* USER CODE BEGIN SPI3_MspInit 0 */ 78 | 79 | /* USER CODE END SPI3_MspInit 0 */ 80 | /* Peripheral clock enable */ 81 | __HAL_RCC_SPI3_CLK_ENABLE(); 82 | 83 | /**SPI3 GPIO Configuration 84 | PC10 ------> SPI3_SCK 85 | PC12 ------> SPI3_MOSI 86 | */ 87 | GPIO_InitStruct.Pin = tgt_swclk_Pin|tgt_swdio_Pin; 88 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 89 | GPIO_InitStruct.Pull = GPIO_NOPULL; 90 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; 91 | GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; 92 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 93 | 94 | /* USER CODE BEGIN SPI3_MspInit 1 */ 95 | 96 | /* USER CODE END SPI3_MspInit 1 */ 97 | } 98 | } 99 | 100 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) 101 | { 102 | 103 | if(spiHandle->Instance==SPI3) 104 | { 105 | /* USER CODE BEGIN SPI3_MspDeInit 0 */ 106 | 107 | /* USER CODE END SPI3_MspDeInit 0 */ 108 | /* Peripheral clock disable */ 109 | __HAL_RCC_SPI3_CLK_DISABLE(); 110 | 111 | /**SPI3 GPIO Configuration 112 | PC10 ------> SPI3_SCK 113 | PC12 ------> SPI3_MOSI 114 | */ 115 | HAL_GPIO_DeInit(GPIOC, tgt_swclk_Pin|tgt_swdio_Pin); 116 | 117 | } 118 | /* USER CODE BEGIN SPI3_MspDeInit 1 */ 119 | 120 | /* USER CODE END SPI3_MspDeInit 1 */ 121 | } 122 | 123 | /* USER CODE BEGIN 1 */ 124 | 125 | /* USER CODE END 1 */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_spi_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_spi_ex.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief Extended SPI HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * SPI peripheral extended functionalities : 10 | * + IO operation functions 11 | * 12 | ****************************************************************************** 13 | * @attention 14 | * 15 | *

© COPYRIGHT(c) 2016 STMicroelectronics

16 | * 17 | * Redistribution and use in source and binary forms, with or without modification, 18 | * are permitted provided that the following conditions are met: 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | ****************************************************************************** 40 | */ 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f3xx_hal.h" 44 | 45 | /** @addtogroup STM32F3xx_HAL_Driver 46 | * @{ 47 | */ 48 | 49 | /** @defgroup SPIEx SPIEx 50 | * @brief SPI Extended HAL module driver 51 | * @{ 52 | */ 53 | #ifdef HAL_SPI_MODULE_ENABLED 54 | 55 | /* Private typedef -----------------------------------------------------------*/ 56 | /* Private defines -----------------------------------------------------------*/ 57 | /** @defgroup SPIEx_Private_Constants SPIEx Private Constants 58 | * @{ 59 | */ 60 | #define SPI_FIFO_SIZE 4 61 | /** 62 | * @} 63 | */ 64 | 65 | /* Private macros ------------------------------------------------------------*/ 66 | /* Private variables ---------------------------------------------------------*/ 67 | /* Private function prototypes -----------------------------------------------*/ 68 | /* Exported functions ---------------------------------------------------------*/ 69 | 70 | /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions 71 | * @{ 72 | */ 73 | 74 | /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions 75 | * @brief Data transfers functions 76 | * 77 | @verbatim 78 | ============================================================================== 79 | ##### IO operation functions ##### 80 | =============================================================================== 81 | [..] 82 | This subsection provides a set of extended functions to manage the SPI 83 | data transfers. 84 | 85 | (#) Rx data flush function: 86 | (++) HAL_SPIEx_FlushRxFifo() 87 | 88 | @endverbatim 89 | * @{ 90 | */ 91 | 92 | /** 93 | * @brief Flush the RX fifo. 94 | * @param hspi: pointer to a SPI_HandleTypeDef structure that contains 95 | * the configuration information for the specified SPI module. 96 | * @retval HAL status 97 | */ 98 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi) 99 | { 100 | __IO uint32_t tmpreg; 101 | uint8_t count = 0; 102 | while((hspi->Instance->SR & SPI_FLAG_FRLVL) != SPI_FRLVL_EMPTY) 103 | { 104 | count++; 105 | tmpreg = hspi->Instance->DR; 106 | UNUSED(tmpreg); /* To avoid GCC warning */ 107 | if(count == SPI_FIFO_SIZE) 108 | { 109 | return HAL_TIMEOUT; 110 | } 111 | } 112 | return HAL_OK; 113 | } 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | #endif /* HAL_SPI_MODULE_ENABLED */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 134 | -------------------------------------------------------------------------------- /stm32f3xx.ld: -------------------------------------------------------------------------------- 1 | /* 2 | Linker script for STM32F0xx 3 | 4 | modified from 5 | 6 | http://www.codesourcery.com/archives/arm-gnu/msg02972.html 7 | */ 8 | 9 | /* 10 | There will be a link error if there is not this amount of RAM free at the 11 | end. 12 | */ 13 | 14 | _Minimum_Stack_Size = 256; 15 | 16 | ENTRY(Reset_Handler) 17 | 18 | 19 | /* Memory Spaces Definitions */ 20 | 21 | MEMORY 22 | { 23 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 40K 24 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K 25 | } 26 | 27 | __ram_start__ = ORIGIN(RAM); 28 | __ram_size__ = LENGTH(RAM); 29 | __ram_end__ = __ram_start__ + __ram_size__; 30 | _estack = __ram_end__; 31 | /* highest address of the user mode stack */ 32 | 33 | 34 | 35 | PROVIDE ( _Stack_Limit = _estack - _Minimum_Stack_Size ); 36 | 37 | /* Sections Definitions */ 38 | 39 | SECTIONS 40 | { 41 | .text : 42 | { 43 | KEEP(*(.isr_vector)) /* Startup code */ 44 | *(.text) /* code */ 45 | *(.text.*) /* remaining code */ 46 | *(.rodata) /* read-only data (constants) */ 47 | *(.rodata.*) 48 | *(.glue_7) 49 | *(.glue_7t) 50 | *(.vfp11_veneer) 51 | *(.v4_bx) 52 | *(.ARM.extab* .gnu.linkonce.armextab.*) 53 | } >FLASH 54 | 55 | /* for exception handling/unwind - some Newlib functions (in 56 | common with C++ and STDC++) use this. */ 57 | .ARM.extab : 58 | { 59 | *(.ARM.extab* .gnu.linkonce.armextab.*) 60 | 61 | } > FLASH 62 | 63 | __exidx_start = .; 64 | .ARM.exidx : 65 | { 66 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 67 | } > FLASH 68 | __exidx_end = .; 69 | 70 | . = ALIGN(4); 71 | _etext = .; 72 | /* This is used by the startup in order to initialize the .data secion 73 | */ 74 | _sidata = _etext; 75 | 76 | /* This is the initialized data section 77 | The program executes knowing that the data is in the RAM 78 | but the loader puts the initial values in the FLASH (inidata). 79 | It is one task of the startup to copy the initial values from FLASH to 80 | RAM. */ 81 | .data : AT ( _sidata ) 82 | { 83 | . = ALIGN(4); 84 | /* This is used by the startup in order to initialize the .data 85 | secion */ 86 | _sdata = . ; 87 | 88 | *(.data) 89 | *(.data.*) 90 | 91 | . = ALIGN(4); 92 | /* This is used by the startup in order to initialize the .data 93 | secion */ 94 | _edata = . ; 95 | } >RAM 96 | 97 | 98 | /* This is the uninitialized data section */ 99 | .bss : 100 | { 101 | . = ALIGN(4); 102 | /* This is used by the startup in order to initialize the .bss 103 | secion */ 104 | _sbss = .; 105 | __bss_start__ = _sbss; 106 | *(.bss) 107 | *(.bss.*) 108 | *(COMMON) 109 | 110 | . = ALIGN(4); 111 | /* This is used by the startup in order to initialize the .bss 112 | secion */ 113 | _ebss = . ; 114 | __bss_end__ = _ebss; 115 | } >RAM 116 | 117 | PROVIDE ( end = _ebss ); 118 | PROVIDE ( _end = _ebss ); 119 | PROVIDE ( _exit = _ebss ); 120 | PROVIDE (_stackend = ORIGIN(RAM) + LENGTH(RAM) - _Minimum_Stack_Size); 121 | 122 | /* This is the user stack section 123 | This is just to check that there is enough RAM left for the User mode 124 | stack 125 | It should generate an error if it's full. 126 | */ 127 | ._usrstack : 128 | { 129 | . = ALIGN(4); 130 | _susrstack = . ; 131 | 132 | . = . + _Minimum_Stack_Size ; 133 | 134 | . = ALIGN(4); 135 | _eusrstack = . ; 136 | } >RAM 137 | 138 | 139 | 140 | /* after that it's only debugging information. */ 141 | 142 | /* remove the debugging information from the standard libraries */ 143 | /* 144 | DISCARD : 145 | { 146 | libc.a ( * ) 147 | libm.a ( * ) 148 | libgcc.a ( * ) 149 | } 150 | */ 151 | 152 | /* Stabs debugging sections. */ 153 | .stab 0 : { *(.stab) } 154 | .stabstr 0 : { *(.stabstr) } 155 | .stab.excl 0 : { *(.stab.excl) } 156 | .stab.exclstr 0 : { *(.stab.exclstr) } 157 | .stab.index 0 : { *(.stab.index) } 158 | .stab.indexstr 0 : { *(.stab.indexstr) } 159 | .comment 0 : { *(.comment) } 160 | /* DWARF debug sections. 161 | Symbols in the DWARF debugging sections are relative to the beginning 162 | of the section so we begin them at 0. */ 163 | /* DWARF 1 */ 164 | .debug 0 : { *(.debug) } 165 | .line 0 : { *(.line) } 166 | /* GNU DWARF 1 extensions */ 167 | .debug_srcinfo 0 : { *(.debug_srcinfo) } 168 | .debug_sfnames 0 : { *(.debug_sfnames) } 169 | /* DWARF 1.1 and DWARF 2 */ 170 | .debug_aranges 0 : { *(.debug_aranges) } 171 | .debug_pubnames 0 : { *(.debug_pubnames) } 172 | /* DWARF 2 */ 173 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 174 | .debug_abbrev 0 : { *(.debug_abbrev) } 175 | .debug_line 0 : { *(.debug_line) } 176 | .debug_frame 0 : { *(.debug_frame) } 177 | .debug_str 0 : { *(.debug_str) } 178 | .debug_loc 0 : { *(.debug_loc) } 179 | .debug_macinfo 0 : { *(.debug_macinfo) } 180 | /* SGI/MIPS DWARF 2 extensions */ 181 | .debug_weaknames 0 : { *(.debug_weaknames) } 182 | .debug_funcnames 0 : { *(.debug_funcnames) } 183 | .debug_typenames 0 : { *(.debug_typenames) } 184 | .debug_varnames 0 : { *(.debug_varnames) } 185 | } 186 | -------------------------------------------------------------------------------- /bulk-example/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief header file for the usbd_cdc.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_CDC_H 30 | #define __USB_CDC_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_ioreq.h" 38 | 39 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup usbd_cdc 44 | * @brief This file is the Header file for usbd_cdc.c 45 | * @{ 46 | */ 47 | 48 | 49 | /** @defgroup usbd_cdc_Exported_Defines 50 | * @{ 51 | */ 52 | #define CDC_IN_EP 0x81 /* EP1 for data IN */ 53 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ 54 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ 55 | 56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ 58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ 59 | #define CDC_CMD_PACKET_SIZE 8 /* Control Endpoint Packet size */ 60 | 61 | #define USB_CDC_CONFIG_DESC_SIZ 67 62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 64 | 65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 67 | 68 | /*---------------------------------------------------------------------*/ 69 | /* CDC definitions */ 70 | /*---------------------------------------------------------------------*/ 71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00 72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01 73 | #define CDC_SET_COMM_FEATURE 0x02 74 | #define CDC_GET_COMM_FEATURE 0x03 75 | #define CDC_CLEAR_COMM_FEATURE 0x04 76 | #define CDC_SET_LINE_CODING 0x20 77 | #define CDC_GET_LINE_CODING 0x21 78 | #define CDC_SET_CONTROL_LINE_STATE 0x22 79 | #define CDC_SEND_BREAK 0x23 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | 86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | typedef struct 94 | { 95 | uint32_t bitrate; 96 | uint8_t format; 97 | uint8_t paritytype; 98 | uint8_t datatype; 99 | }USBD_CDC_LineCodingTypeDef; 100 | 101 | typedef struct _USBD_CDC_Itf 102 | { 103 | int8_t (* Init) (void); 104 | int8_t (* DeInit) (void); 105 | int8_t (* Control) (uint8_t, uint8_t * , uint16_t); 106 | int8_t (* Receive) (uint8_t *, uint32_t *); 107 | 108 | }USBD_CDC_ItfTypeDef; 109 | 110 | 111 | typedef struct 112 | { 113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4]; /* Force 32bits alignment */ 114 | uint8_t CmdOpCode; 115 | uint8_t CmdLength; 116 | uint8_t *RxBuffer; 117 | uint8_t *TxBuffer; 118 | uint32_t RxLength; 119 | uint32_t TxLength; 120 | 121 | __IO uint32_t TxState; 122 | __IO uint32_t RxState; 123 | } 124 | USBD_CDC_HandleTypeDef; 125 | 126 | 127 | 128 | /** @defgroup USBD_CORE_Exported_Macros 129 | * @{ 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** @defgroup USBD_CORE_Exported_Variables 137 | * @{ 138 | */ 139 | 140 | extern USBD_ClassTypeDef USBD_CDC; 141 | #define USBD_CDC_CLASS &USBD_CDC 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup USB_CORE_Exported_Functions 147 | * @{ 148 | */ 149 | uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev, 150 | USBD_CDC_ItfTypeDef *fops); 151 | 152 | uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev, 153 | uint8_t *pbuff, 154 | uint16_t length); 155 | 156 | uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev, 157 | uint8_t *pbuff); 158 | 159 | uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev); 160 | 161 | uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev); 162 | /** 163 | * @} 164 | */ 165 | 166 | #ifdef __cplusplus 167 | } 168 | #endif 169 | 170 | #endif /* __USB_CDC_H */ 171 | /** 172 | * @} 173 | */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 180 | -------------------------------------------------------------------------------- /bulk-example/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for usbd_core.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CORE_H 30 | #define __USBD_CORE_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_conf.h" 38 | #include "usbd_def.h" 39 | #include "usbd_ioreq.h" 40 | #include "usbd_ctlreq.h" 41 | 42 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 43 | * @{ 44 | */ 45 | 46 | /** @defgroup USBD_CORE 47 | * @brief This file is the Header file for usbd_core.c file 48 | * @{ 49 | */ 50 | 51 | 52 | /** @defgroup USBD_CORE_Exported_Defines 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | 71 | 72 | /** @defgroup USBD_CORE_Exported_Macros 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_CORE_Exported_Variables 81 | * @{ 82 | */ 83 | #define USBD_SOF USBD_LL_SOF 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 89 | * @{ 90 | */ 91 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 92 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 93 | USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev); 94 | USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev); 95 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 96 | 97 | USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev); 98 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 99 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 100 | 101 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 102 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 103 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 104 | 105 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 106 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 107 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 108 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 109 | 110 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 111 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 112 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 113 | 114 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 116 | 117 | /* USBD Low Level Driver */ 118 | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev); 119 | USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev); 120 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 121 | USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev); 122 | USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev, 123 | uint8_t ep_addr, 124 | uint8_t ep_type, 125 | uint16_t ep_mps); 126 | 127 | USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 128 | USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 129 | USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 130 | USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 131 | uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 132 | USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr); 133 | USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev, 134 | uint8_t ep_addr, 135 | uint8_t *pbuf, 136 | uint16_t size); 137 | 138 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 139 | uint8_t ep_addr, 140 | uint8_t *pbuf, 141 | uint16_t size); 142 | 143 | uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 144 | void USBD_LL_Delay (uint32_t Delay); 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | 154 | #endif /* __USBD_CORE_H */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | 164 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief Header file of PCD HAL Extension module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F3xx_HAL_PCD_EX_H 40 | #define __STM32F3xx_HAL_PCD_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32F302xE) || defined(STM32F303xE) || \ 47 | defined(STM32F302xC) || defined(STM32F303xC) || \ 48 | defined(STM32F302x8) || \ 49 | defined(STM32F373xC) 50 | 51 | /* Includes ------------------------------------------------------------------*/ 52 | #include "stm32f3xx_hal_def.h" 53 | 54 | /** @addtogroup STM32F3xx_HAL_Driver 55 | * @{ 56 | */ 57 | 58 | /** @addtogroup PCDEx 59 | * @{ 60 | */ 61 | 62 | /* Exported types ------------------------------------------------------------*/ 63 | /* Exported constants --------------------------------------------------------*/ 64 | /* Exported macros -----------------------------------------------------------*/ 65 | /** @defgroup PCDEx_Exported_Macros PCD Extended Exported Macros 66 | * @{ 67 | */ 68 | /** 69 | * @brief Gets address in an endpoint register. 70 | * @param USBx: USB peripheral instance register address. 71 | * @param bEpNum: Endpoint Number. 72 | * @retval None 73 | */ 74 | 75 | #if defined(STM32F302xC) || defined(STM32F303xC) || \ 76 | defined(STM32F373xC) 77 | 78 | #define PCD_EP_TX_ADDRESS(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8)*2+ ((uint32_t)USBx + 0x400))) 79 | #define PCD_EP_TX_CNT(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8+2)*2+ ((uint32_t)USBx + 0x400))) 80 | #define PCD_EP_RX_ADDRESS(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8+4)*2+ ((uint32_t)USBx + 0x400))) 81 | #define PCD_EP_RX_CNT(USBx, bEpNum) ((uint32_t *)((USBx->BTABLE+bEpNum*8+6)*2+ ((uint32_t)USBx + 0x400))) 82 | 83 | #define PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount) {\ 84 | uint32_t *pdwReg = PCD_EP_RX_CNT(USBx, bEpNum); \ 85 | PCD_SET_EP_CNT_RX_REG(pdwReg, wCount);\ 86 | } 87 | 88 | #endif /* STM32F302xC || STM32F303xC || */ 89 | /* STM32F373xC */ 90 | 91 | 92 | #if defined(STM32F302xE) || defined(STM32F303xE) || \ 93 | defined(STM32F302x8) 94 | 95 | #define PCD_EP_TX_ADDRESS(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8)+ ((uint32_t)USBx + 0x400))) 96 | #define PCD_EP_TX_CNT(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8+2)+ ((uint32_t)USBx + 0x400))) 97 | #define PCD_EP_RX_ADDRESS(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8+4)+ ((uint32_t)USBx + 0x400))) 98 | #define PCD_EP_RX_CNT(USBx, bEpNum) ((uint16_t *)((USBx->BTABLE+bEpNum*8+6)+ ((uint32_t)USBx + 0x400))) 99 | 100 | #define PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount) {\ 101 | uint16_t *pdwReg = PCD_EP_RX_CNT(USBx, bEpNum); \ 102 | PCD_SET_EP_CNT_RX_REG(pdwReg, wCount);\ 103 | } 104 | 105 | #endif /* STM32F302xE || STM32F303xE || */ 106 | /* STM32F302x8 */ 107 | /** 108 | * @} 109 | */ 110 | 111 | /* Exported functions --------------------------------------------------------*/ 112 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 113 | * @{ 114 | */ 115 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 116 | * @{ 117 | */ 118 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 119 | uint16_t ep_addr, 120 | uint16_t ep_kind, 121 | uint32_t pmaadress); 122 | 123 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state); 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | #endif /* STM32F302xE || STM32F303xE || */ 142 | /* STM32F302xC || STM32F303xC || */ 143 | /* STM32F302x8 || */ 144 | /* STM32F373xC */ 145 | 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | 150 | 151 | #endif /* __STM32F3xx_HAL_PCD_EX_H */ 152 | 153 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 154 | -------------------------------------------------------------------------------- /bulk-example/Src/usbd_desc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_desc.c 4 | * @version : v1.0_Cube 5 | * @brief : This file implements the USB Device descriptors 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "usbd_core.h" 37 | #include "usbd_def.h" 38 | #include "usbd_conf.h" 39 | 40 | #define USBD_VID 1155 41 | #define USBD_LANGID_STRING 1033 42 | #define USBD_MANUFACTURER_STRING "Indiana University CS" 43 | #define USBD_PID_FS 22336 44 | #define USBD_PRODUCT_STRING_FS "IU CS Debug Monitor" 45 | #define USBD_SERIALNUMBER_STRING_FS "000000000001" 46 | #define USBD_CONFIGURATION_STRING_FS "Bulk Config" 47 | #define USBD_INTERFACE_STRING_FS "STlink v2 Interface (subset)" 48 | 49 | uint8_t *USBD_FS_DeviceDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 50 | uint8_t *USBD_FS_LangIDStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 51 | uint8_t *USBD_FS_ManufacturerStrDescriptor ( USBD_SpeedTypeDef speed , 52 | uint16_t *length); 53 | uint8_t *USBD_FS_ProductStrDescriptor ( USBD_SpeedTypeDef speed , 54 | uint16_t *length); 55 | uint8_t *USBD_FS_SerialStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 56 | uint8_t *USBD_FS_ConfigStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length); 57 | uint8_t *USBD_FS_InterfaceStrDescriptor( USBD_SpeedTypeDef speed , 58 | uint16_t *length); 59 | 60 | USBD_DescriptorsTypeDef FS_Desc = 61 | { 62 | USBD_FS_DeviceDescriptor, 63 | USBD_FS_LangIDStrDescriptor, 64 | USBD_FS_ManufacturerStrDescriptor, 65 | USBD_FS_ProductStrDescriptor, 66 | USBD_FS_SerialStrDescriptor, 67 | USBD_FS_ConfigStrDescriptor, 68 | USBD_FS_InterfaceStrDescriptor, 69 | }; 70 | 71 | /* USB Standard Device Descriptor */ 72 | __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = 73 | { 74 | 0x12, // bLength 75 | USB_DESC_TYPE_DEVICE, // bDescriptorType 76 | 0x00, // bcdUSB 77 | 0x02, 78 | 0xff, // bDeviceClass 79 | 0x00, // bDeviceSubClass 80 | 0x00, // bDeviceProtocol 81 | USB_MAX_EP0_SIZE, // MaxPacketSize 82 | LOBYTE(USBD_VID), // idVendor 83 | HIBYTE(USBD_VID), // idVendor 84 | LOBYTE(USBD_PID_FS), // idVendor 85 | HIBYTE(USBD_PID_FS), // idVendor 86 | 0x00, // bcdDevice rel. 1.00 87 | 0x01, 88 | USBD_IDX_MFC_STR, // Index of manufacturer string 89 | USBD_IDX_PRODUCT_STR, // Index of product string 90 | USBD_IDX_SERIAL_STR, // Index of serial number string 91 | 1 // bNumConfigurations 92 | } ; 93 | /* USB_DeviceDescriptor */ 94 | 95 | /* USB Standard Device Descriptor */ 96 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = 97 | { 98 | USB_LEN_LANGID_STR_DESC, 99 | USB_DESC_TYPE_STRING, 100 | LOBYTE(USBD_LANGID_STRING), 101 | HIBYTE(USBD_LANGID_STRING), 102 | }; 103 | 104 | 105 | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; 106 | 107 | uint8_t *USBD_FS_DeviceDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 108 | { 109 | *length = sizeof(USBD_FS_DeviceDesc); 110 | return USBD_FS_DeviceDesc; 111 | } 112 | 113 | uint8_t *USBD_FS_LangIDStrDescriptor( USBD_SpeedTypeDef speed , 114 | uint16_t *length) 115 | { 116 | *length = sizeof(USBD_LangIDDesc); 117 | return USBD_LangIDDesc; 118 | } 119 | 120 | uint8_t *USBD_FS_ProductStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 121 | { 122 | USBD_GetString (USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); 123 | return USBD_StrDesc; 124 | } 125 | 126 | uint8_t *USBD_FS_ManufacturerStrDescriptor( USBD_SpeedTypeDef speed , 127 | uint16_t *length) 128 | { 129 | USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length); 130 | return USBD_StrDesc; 131 | } 132 | 133 | uint8_t *USBD_FS_SerialStrDescriptor( USBD_SpeedTypeDef speed , 134 | uint16_t *length) 135 | { 136 | USBD_GetString (USBD_SERIALNUMBER_STRING_FS, USBD_StrDesc, length); 137 | return USBD_StrDesc; 138 | } 139 | 140 | uint8_t *USBD_FS_ConfigStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length) 141 | { 142 | USBD_GetString (USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); 143 | return USBD_StrDesc; 144 | } 145 | 146 | uint8_t *USBD_FS_InterfaceStrDescriptor( USBD_SpeedTypeDef speed , 147 | uint16_t *length) 148 | { 149 | USBD_GetString (USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); 150 | return USBD_StrDesc; 151 | } 152 | -------------------------------------------------------------------------------- /bulk-example/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief This file provides the IO requests APIs for control endpoints. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_ioreq.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | 36 | /** @defgroup USBD_IOREQ 37 | * @brief control I/O requests module 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Private_Defines 50 | * @{ 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USBD_IOREQ_Private_Variables 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | 83 | /** @defgroup USBD_IOREQ_Private_Functions 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @brief USBD_CtlSendData 89 | * send data on the ctl pipe 90 | * @param pdev: device instance 91 | * @param buff: pointer to data buffer 92 | * @param len: length of data to be sent 93 | * @retval status 94 | */ 95 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 96 | uint8_t *pbuf, 97 | uint16_t len) 98 | { 99 | /* Set EP0 State */ 100 | pdev->ep0_state = USBD_EP0_DATA_IN; 101 | pdev->ep_in[0].total_length = len; 102 | pdev->ep_in[0].rem_length = len; 103 | /* Start the transfer */ 104 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); 105 | 106 | return USBD_OK; 107 | } 108 | 109 | /** 110 | * @brief USBD_CtlContinueSendData 111 | * continue sending data on the ctl pipe 112 | * @param pdev: device instance 113 | * @param buff: pointer to data buffer 114 | * @param len: length of data to be sent 115 | * @retval status 116 | */ 117 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 118 | uint8_t *pbuf, 119 | uint16_t len) 120 | { 121 | /* Start the next transfer */ 122 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); 123 | 124 | return USBD_OK; 125 | } 126 | 127 | /** 128 | * @brief USBD_CtlPrepareRx 129 | * receive data on the ctl pipe 130 | * @param pdev: device instance 131 | * @param buff: pointer to data buffer 132 | * @param len: length of data to be received 133 | * @retval status 134 | */ 135 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 136 | uint8_t *pbuf, 137 | uint16_t len) 138 | { 139 | /* Set EP0 State */ 140 | pdev->ep0_state = USBD_EP0_DATA_OUT; 141 | pdev->ep_out[0].total_length = len; 142 | pdev->ep_out[0].rem_length = len; 143 | /* Start the transfer */ 144 | USBD_LL_PrepareReceive (pdev, 145 | 0, 146 | pbuf, 147 | len); 148 | 149 | return USBD_OK; 150 | } 151 | 152 | /** 153 | * @brief USBD_CtlContinueRx 154 | * continue receive data on the ctl pipe 155 | * @param pdev: device instance 156 | * @param buff: pointer to data buffer 157 | * @param len: length of data to be received 158 | * @retval status 159 | */ 160 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 161 | uint8_t *pbuf, 162 | uint16_t len) 163 | { 164 | 165 | USBD_LL_PrepareReceive (pdev, 166 | 0, 167 | pbuf, 168 | len); 169 | return USBD_OK; 170 | } 171 | /** 172 | * @brief USBD_CtlSendStatus 173 | * send zero lzngth packet on the ctl pipe 174 | * @param pdev: device instance 175 | * @retval status 176 | */ 177 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev) 178 | { 179 | 180 | /* Set EP0 State */ 181 | pdev->ep0_state = USBD_EP0_STATUS_IN; 182 | 183 | /* Start the transfer */ 184 | USBD_LL_Transmit (pdev, 0x00, NULL, 0); 185 | 186 | return USBD_OK; 187 | } 188 | 189 | /** 190 | * @brief USBD_CtlReceiveStatus 191 | * receive zero lzngth packet on the ctl pipe 192 | * @param pdev: device instance 193 | * @retval status 194 | */ 195 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev) 196 | { 197 | /* Set EP0 State */ 198 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 199 | 200 | /* Start the transfer */ 201 | USBD_LL_PrepareReceive ( pdev, 202 | 0, 203 | NULL, 204 | 0); 205 | 206 | return USBD_OK; 207 | } 208 | 209 | 210 | /** 211 | * @brief USBD_GetRxCount 212 | * returns the received data length 213 | * @param pdev: device instance 214 | * @param ep_addr: endpoint address 215 | * @retval Rx Data blength 216 | */ 217 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , uint8_t ep_addr) 218 | { 219 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 220 | } 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | 227 | /** 228 | * @} 229 | */ 230 | 231 | 232 | /** 233 | * @} 234 | */ 235 | 236 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 237 | -------------------------------------------------------------------------------- /bulk-example/usbtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int print_configuration(struct libusb_config_descriptor *config) 8 | { 9 | // unsigned char *data; 10 | int index; 11 | 12 | // data = (unsigned char *)malloc(512); 13 | // memset(data,0,512); 14 | 15 | if (config == NULL) 16 | return 0; 17 | index = config->iConfiguration; 18 | 19 | // libusb_get_string_descriptor_ascii(hDevice,index,data,512); 20 | 21 | printf("\nInterface Descriptors: "); 22 | printf("\n\tLength : %d",config->bLength); 23 | printf("\n\tDesc_Type : %d",config->bDescriptorType); 24 | printf("\n\tTotal length : %hu",config->wTotalLength); 25 | printf("\n\tNumber of Interfaces : %d",config->bNumInterfaces); 26 | printf("\n\tConfig_index : %d",config->iConfiguration); 27 | printf("\n\tConfiguration Value : %d",config->bConfigurationValue); 28 | printf("\n\tConfiguration Attributes : %d",config->bmAttributes); 29 | printf("\n\tMaxPower(mA) : %d\n",2*config->MaxPower); 30 | 31 | // free(data); 32 | return 0; 33 | } 34 | 35 | struct libusb_endpoint_descriptor* active_config(struct libusb_device *dev)//,struct libusb_device_handle *handle) 36 | { 37 | struct libusb_device_handle *hDevice_req; 38 | struct libusb_config_descriptor *config; 39 | const struct libusb_endpoint_descriptor *endpoint; 40 | int altsetting_index,interface_index=0,ret_active; 41 | int i,ret_print; 42 | int interface_number; 43 | 44 | // hDevice_req = handle; 45 | 46 | ret_active = libusb_get_active_config_descriptor(dev,&config); 47 | if (ret_active) 48 | return 0; 49 | ret_print = print_configuration(config); 50 | 51 | for(interface_index=0;interface_indexbNumInterfaces;interface_index++) 52 | { 53 | const struct libusb_interface *iface = &config->interface[interface_index]; 54 | for(altsetting_index=0;altsetting_indexnum_altsetting;altsetting_index++) 55 | { 56 | const struct libusb_interface_descriptor *altsetting = &iface->altsetting[altsetting_index]; 57 | 58 | int endpoint_index; 59 | for(endpoint_index=0;endpoint_indexbNumEndpoints;endpoint_index++) 60 | { 61 | const struct libusb_endpoint_descriptor *ep = &altsetting->endpoint[endpoint_index]; 62 | endpoint = ep; 63 | // alt_interface = altsetting->bAlternateSetting; 64 | // interface_number = altsetting->bInterfaceNumber; 65 | 66 | printf("\nEndPoint Descriptors: "); 67 | printf("\n\tSize of EndPoint Descriptor : %d",endpoint->bLength); 68 | printf("\n\tType of Descriptor : %d",endpoint->bDescriptorType); 69 | printf("\n\tEndpoint Address : 0x0%x",endpoint->bEndpointAddress); 70 | printf("\n\tMaximum Packet Size: %x",endpoint->wMaxPacketSize); 71 | printf("\n\tAttributes applied to Endpoint: %d",endpoint->bmAttributes); 72 | printf("\n\tInterval for Polling for data Tranfer : %d\n",endpoint->bInterval); 73 | } 74 | } 75 | } 76 | libusb_free_config_descriptor(NULL); 77 | // return endpoint; 78 | return 0; 79 | } 80 | 81 | 82 | int main(void) 83 | { 84 | int result; 85 | struct libusb_device_descriptor desc; 86 | struct libusb_config_descriptor *config; 87 | 88 | libusb_device **list; 89 | libusb_device *my_device = NULL; 90 | 91 | result = libusb_init(NULL); 92 | libusb_set_debug(NULL, 3); 93 | 94 | ssize_t count = libusb_get_device_list(NULL, &list); 95 | for (int i = 0; i < count; i++) { 96 | libusb_device *device = list[i]; 97 | result = libusb_get_device_descriptor(device, &desc); 98 | if(desc.idVendor == 0x483 && desc.idProduct == 0x5740){//0x3748){// 99 | printf("\nDevice Descriptors: "); 100 | printf("\n\tVendor ID : %x",desc.idVendor); 101 | printf("\n\tProduct ID : %x",desc.idProduct); 102 | printf("\n\tSerial Number : %x", desc.iSerialNumber); 103 | printf("\n\tSize of Device Descriptor : %d",desc.bLength); 104 | printf("\n\tType of Descriptor : %d",desc.bDescriptorType); 105 | printf("\n\tUSB Specification Release Number : %d",desc.bcdUSB); 106 | printf("\n\tDevice Release Number : %d",desc.bcdDevice); 107 | printf("\n\tDevice Class : %d",desc.bDeviceClass); 108 | printf("\n\tDevice Sub-Class : %d",desc.bDeviceSubClass); 109 | printf("\n\tDevice Protocol : %d",desc.bDeviceProtocol); 110 | printf("\n\tMax. Packet Size : %d",desc.bMaxPacketSize0); 111 | printf("\n\tNo. of Configurations : %d\n",desc.bNumConfigurations); 112 | 113 | my_device = device; 114 | break; 115 | } 116 | } 117 | 118 | if (my_device == NULL) { 119 | printf("can't find device\n"); 120 | exit(1); 121 | } 122 | 123 | // can't get the descriptor ! 124 | 125 | // printf("print configuration\n"); 126 | if (!(libusb_get_config_descriptor (my_device, 0, &config))) { 127 | printf("\nConfiguration 0\n"); 128 | printf("\tConfiguration Length %d\n", config->bLength); 129 | printf("\tDescriptor type %d\n", config->bDescriptorType); 130 | printf("\tDescriptor interfaces %d\n", config->bNumInterfaces); 131 | printf("\tDescriptor attributes %d\n", config->bmAttributes); 132 | printf("\tDescriptor max power %d\n", config->MaxPower); 133 | // libusb_free_config_descriptor(config); 134 | config = NULL; 135 | } else { 136 | printf("\ncouldn't open configuration 0\n"); 137 | } 138 | 139 | active_config(my_device); 140 | 141 | if(my_device != NULL) { 142 | libusb_device_handle *handle; 143 | result = libusb_open(my_device, &handle); 144 | /* 145 | printf("libusb_open result %d\n", result); 146 | unsigned char data[512]; 147 | if (libusb_get_descriptor(handle, LIBUSB_DT_CONFIG, 0, data, 512) > 0) { 148 | printf("config 0 descriptor:"); 149 | for (int i = 0; i < data[0]; i++) 150 | printf("%x ", data[i]); 151 | printf("\n"); 152 | } 153 | */ 154 | 155 | char serial[256]; 156 | for (int i = 0; i < 20; i++) { 157 | if ((libusb_get_string_descriptor_ascii(handle,i, 158 | (unsigned char *) serial,256)) < 0) 159 | continue; 160 | printf("\tstring %d : %s\n", i, serial); 161 | } 162 | 163 | int kernelActive = libusb_kernel_driver_active(handle, 0); 164 | if(kernelActive == 1) { 165 | result = libusb_detach_kernel_driver(handle, 0); 166 | } 167 | result = libusb_claim_interface (handle, 0); 168 | if (result) 169 | printf("couldn't claim interface \n"); 170 | // result = libusb_control_transfer(handle,0x21,34,0x0003,0,NULL,0,0); 171 | 172 | libusb_release_interface (handle, 0); 173 | if(kernelActive == 1) { 174 | result = libusb_attach_kernel_driver(handle, 0); 175 | } 176 | libusb_close(handle); 177 | } 178 | libusb_free_device_list(list, 1); 179 | libusb_exit(NULL); 180 | return EXIT_SUCCESS; 181 | } 182 | -------------------------------------------------------------------------------- /bulk-example/Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. October 2015 5 | * $Revision: V.1.4.5 a 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | /* extern const q31_t realCoefAQ31[1024]; */ 50 | /* extern const q31_t realCoefBQ31[1024]; */ 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_def.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief This file contains HAL common defines, enumeration, macros and 8 | * structures definitions. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2016 STMicroelectronics

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

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F3xx_HAL_I2C_EX_H 40 | #define __STM32F3xx_HAL_I2C_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f3xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F3xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup I2CEx I2CEx 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported constants --------------------------------------------------------*/ 59 | 60 | /** @defgroup I2CEx_Exported_Constants I2C Extended Exported Constants 61 | * @{ 62 | */ 63 | 64 | /** @defgroup I2CEx_Analog_Filter I2C Extended Analog Filter 65 | * @{ 66 | */ 67 | #define I2C_ANALOGFILTER_ENABLE ((uint32_t)0x00000000) 68 | #define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup I2CEx_FastModePlus I2C Extended Fast Mode Plus 74 | * @{ 75 | */ 76 | #if defined(SYSCFG_CFGR1_I2C_PB6_FMP) 77 | #define I2C_FASTMODEPLUS_PB6 ((uint32_t)SYSCFG_CFGR1_I2C_PB6_FMP) /*!< Enable Fast Mode Plus on PB6 */ 78 | #endif /* SYSCFG_CFGR1_I2C_PB6_FMP */ 79 | 80 | #if defined(SYSCFG_CFGR1_I2C_PB7_FMP) 81 | #define I2C_FASTMODEPLUS_PB7 ((uint32_t)SYSCFG_CFGR1_I2C_PB7_FMP) /*!< Enable Fast Mode Plus on PB7 */ 82 | #endif /* SYSCFG_CFGR1_I2C_PB7_FMP */ 83 | 84 | #if defined(SYSCFG_CFGR1_I2C_PB8_FMP) 85 | #define I2C_FASTMODEPLUS_PB8 ((uint32_t)SYSCFG_CFGR1_I2C_PB8_FMP) /*!< Enable Fast Mode Plus on PB8 */ 86 | #endif /* SYSCFG_CFGR1_I2C_PB8_FMP */ 87 | 88 | #if defined(SYSCFG_CFGR1_I2C_PB9_FMP) 89 | #define I2C_FASTMODEPLUS_PB9 ((uint32_t)SYSCFG_CFGR1_I2C_PB9_FMP) /*!< Enable Fast Mode Plus on PB9 */ 90 | #endif /* SYSCFG_CFGR1_I2C_PB9_FMP */ 91 | 92 | #if defined(SYSCFG_CFGR1_I2C1_FMP) 93 | #define I2C_FASTMODEPLUS_I2C1 ((uint32_t)SYSCFG_CFGR1_I2C1_FMP) /*!< Enable Fast Mode Plus on I2C1 pins */ 94 | #endif /* SYSCFG_CFGR1_I2C1_FMP */ 95 | 96 | #if defined(SYSCFG_CFGR1_I2C2_FMP) 97 | #define I2C_FASTMODEPLUS_I2C2 ((uint32_t)SYSCFG_CFGR1_I2C2_FMP) /*!< Enable Fast Mode Plus on I2C2 pins */ 98 | #endif /* SYSCFG_CFGR1_I2C2_FMP */ 99 | 100 | #if defined(SYSCFG_CFGR1_I2C3_FMP) 101 | #define I2C_FASTMODEPLUS_I2C3 ((uint32_t)SYSCFG_CFGR1_I2C3_FMP) /*!< Enable Fast Mode Plus on I2C3 pins */ 102 | #endif /* SYSCFG_CFGR1_I2C3_FMP */ 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /* Exported macro ------------------------------------------------------------*/ 112 | /* Exported functions --------------------------------------------------------*/ 113 | 114 | /** @addtogroup I2CEx_Exported_Functions I2C Extended Exported Functions 115 | * @{ 116 | */ 117 | 118 | /** @addtogroup I2CEx_Exported_Functions_Group1 Extended features functions 119 | * @brief Extended features functions 120 | * @{ 121 | */ 122 | 123 | /* Peripheral Control functions ************************************************/ 124 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); 125 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); 126 | HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp (I2C_HandleTypeDef *hi2c); 127 | HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp (I2C_HandleTypeDef *hi2c); 128 | void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus); 129 | void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus); 130 | 131 | /* Private constants ---------------------------------------------------------*/ 132 | /** @defgroup I2CEx_Private_Constants I2C Extended Private Constants 133 | * @{ 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /* Private macros ------------------------------------------------------------*/ 141 | /** @defgroup I2CEx_Private_Macro I2C Extended Private Macros 142 | * @{ 143 | */ 144 | #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ 145 | ((FILTER) == I2C_ANALOGFILTER_DISABLE)) 146 | 147 | #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000F) 148 | 149 | 150 | #if defined(SYSCFG_CFGR1_I2C1_FMP) && defined(SYSCFG_CFGR1_I2C2_FMP) && defined(SYSCFG_CFGR1_I2C3_FMP) 151 | #define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FASTMODEPLUS_PB6) == I2C_FASTMODEPLUS_PB6) || \ 152 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB7) == I2C_FASTMODEPLUS_PB7) || \ 153 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB8) == I2C_FASTMODEPLUS_PB8) || \ 154 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB9) == I2C_FASTMODEPLUS_PB9) || \ 155 | (((__CONFIG__) & I2C_FASTMODEPLUS_I2C1) == I2C_FASTMODEPLUS_I2C1) || \ 156 | (((__CONFIG__) & I2C_FASTMODEPLUS_I2C2) == I2C_FASTMODEPLUS_I2C2) || \ 157 | (((__CONFIG__) & I2C_FASTMODEPLUS_I2C3) == I2C_FASTMODEPLUS_I2C3)) 158 | #elif defined(SYSCFG_CFGR1_I2C1_FMP) && defined(SYSCFG_CFGR1_I2C2_FMP) 159 | #define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FASTMODEPLUS_PB6) == I2C_FASTMODEPLUS_PB6) || \ 160 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB7) == I2C_FASTMODEPLUS_PB7) || \ 161 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB8) == I2C_FASTMODEPLUS_PB8) || \ 162 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB9) == I2C_FASTMODEPLUS_PB9) || \ 163 | (((__CONFIG__) & I2C_FASTMODEPLUS_I2C1) == I2C_FASTMODEPLUS_I2C1) || \ 164 | (((__CONFIG__) & I2C_FASTMODEPLUS_I2C2) == I2C_FASTMODEPLUS_I2C2)) 165 | #elif defined(SYSCFG_CFGR1_I2C1_FMP) 166 | #define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FASTMODEPLUS_PB6) == I2C_FASTMODEPLUS_PB6) || \ 167 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB7) == I2C_FASTMODEPLUS_PB7) || \ 168 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB8) == I2C_FASTMODEPLUS_PB8) || \ 169 | (((__CONFIG__) & I2C_FASTMODEPLUS_PB9) == I2C_FASTMODEPLUS_PB9) || \ 170 | (((__CONFIG__) & I2C_FASTMODEPLUS_I2C1) == I2C_FASTMODEPLUS_I2C1)) 171 | #endif /* SYSCFG_CFGR1_I2C1_FMP && SYSCFG_CFGR1_I2C2_FMP && SYSCFG_CFGR3_I2C1_FMP */ 172 | /** 173 | * @} 174 | */ 175 | 176 | /* Private Functions ---------------------------------------------------------*/ 177 | /** @defgroup I2CEx_Private_Functions I2C Extended Private Functions 178 | * @{ 179 | */ 180 | /* Private functions are defined in stm32f3xx_hal_i2c_ex.c file */ 181 | /** 182 | * @} 183 | */ 184 | 185 | /** 186 | * @} 187 | */ 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | /** 198 | * @} 199 | */ 200 | 201 | 202 | #ifdef __cplusplus 203 | } 204 | #endif 205 | 206 | #endif /* __STM32F3xx_HAL_I2C_EX_H */ 207 | 208 | 209 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 210 | -------------------------------------------------------------------------------- /bulk-example/Src/usbd_bulk.c: -------------------------------------------------------------------------------- 1 | #include "usbd_bulk.h" 2 | #include "usbd_ctlreq.h" 3 | 4 | /* USB BULK device Configuration Descriptor */ 5 | /* should be const but annoying ST library discards const */ 6 | 7 | __ALIGN_BEGIN uint8_t USBD_BULK_CfgFSDesc[USB_BULK_CONFIG_DESC_SIZ] __ALIGN_END = 8 | { 9 | /*Configuration Descriptor*/ 10 | 0x09, /* bLength: Configuration Descriptor size */ 11 | USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ 12 | USB_BULK_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */ 13 | 0x00, 14 | 0x01, /* bNumInterfaces: 1 interface */ 15 | 0x01, /* bConfigurationValue: e */ 16 | 0x00, /* Index of string descriptor */ 17 | 0xC0, /* bmAttributes: self powered */ 18 | 0x32, /* MaxPower 50x2 mA */ 19 | 20 | /*---------------------------------------------------------------------------*/ 21 | 22 | /*Interface Descriptor */ 23 | 0x09, /* bLength: Interface Descriptor size */ 24 | USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */ 25 | 0x00, /* bInterfaceNumber: Number of Interface */ 26 | 0x00, /* bAlternateSetting: Alternate setting */ 27 | 0x02, /* bNumEndpoints: two endpoints used */ 28 | 0xFF, /* bInterfaceClass: Vendor Specific */ 29 | 0x00, /* bInterfaceSubClass: */ 30 | 0x00, /* bInterfaceProtocol: */ 31 | 0x00, /* iInterface: */ 32 | 33 | /*Endpoint OUT Descriptor*/ 34 | 0x07, /* bLength: Endpoint Descriptor size */ 35 | USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ 36 | BULK_OUT_EP, /* bEndpointAddress */ 37 | 0x02, /* bmAttributes: Bulk */ 38 | LOBYTE(BULK_DATA_FS_MAX_PACKET_SIZE),/* wMaxPacketSize: */ 39 | HIBYTE(BULK_DATA_FS_MAX_PACKET_SIZE), 40 | 0x00, /* bInterval: ignore for Bulk transfer */ 41 | 42 | /*Endpoint IN Descriptor*/ 43 | 0x07, /* bLength: Endpoint Descriptor size */ 44 | USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */ 45 | BULK_IN_EP, /* bEndpointAddress */ 46 | 0x02, /* bmAttributes: Bulk */ 47 | LOBYTE(BULK_DATA_FS_MAX_PACKET_SIZE),/* wMaxPacketSize: */ 48 | HIBYTE(BULK_DATA_FS_MAX_PACKET_SIZE), 49 | 0x00 /* bInterval: ignore for Bulk transfer */ 50 | } ; 51 | 52 | static uint8_t USBD_BULK_Init (USBD_HandleTypeDef *pdev, 53 | uint8_t cfgidx) 54 | { 55 | uint8_t ret = 0; 56 | USBD_BULK_HandleTypeDef *hcdc; 57 | 58 | { 59 | /* Open EP IN */ 60 | USBD_LL_OpenEP(pdev, 61 | BULK_IN_EP, 62 | USBD_EP_TYPE_BULK, 63 | BULK_DATA_FS_IN_PACKET_SIZE); 64 | 65 | /* Open EP OUT */ 66 | USBD_LL_OpenEP(pdev, 67 | BULK_OUT_EP, 68 | USBD_EP_TYPE_BULK, 69 | BULK_DATA_FS_OUT_PACKET_SIZE); 70 | } 71 | 72 | pdev->pClassData = USBD_malloc(sizeof (USBD_BULK_HandleTypeDef)); 73 | 74 | if(pdev->pClassData == NULL) 75 | { 76 | ret = 1; 77 | } 78 | else 79 | { 80 | hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 81 | 82 | /* Init physical Interface components */ 83 | 84 | ((USBD_BULK_ItfTypeDef *)pdev->pUserData)->Init(); 85 | 86 | /* Init Xfer states */ 87 | 88 | hcdc->TxState =0; 89 | hcdc->RxState =0; 90 | 91 | /* Prepare Out endpoint to receive next packet */ 92 | 93 | USBD_LL_PrepareReceive(pdev, 94 | BULK_OUT_EP, 95 | hcdc->RxBuffer, 96 | BULK_DATA_FS_OUT_PACKET_SIZE); 97 | } 98 | return ret; 99 | } 100 | 101 | static uint8_t USBD_BULK_DeInit (USBD_HandleTypeDef *pdev, 102 | uint8_t cfgidx) 103 | { 104 | uint8_t ret = 0; 105 | 106 | /* Close EP IN */ 107 | USBD_LL_CloseEP(pdev, 108 | BULK_IN_EP); 109 | 110 | /* Close EP OUT */ 111 | USBD_LL_CloseEP(pdev, 112 | BULK_OUT_EP); 113 | 114 | /* DeInit physical Interface components */ 115 | if(pdev->pClassData != NULL) 116 | { 117 | ((USBD_BULK_ItfTypeDef *)pdev->pUserData)->DeInit(); 118 | USBD_free(pdev->pClassData); 119 | pdev->pClassData = NULL; 120 | } 121 | 122 | return ret; 123 | } 124 | 125 | static uint8_t USBD_BULK_Setup (USBD_HandleTypeDef *pdev, 126 | USBD_SetupReqTypedef *req) 127 | { 128 | static uint8_t ifalt = 0; 129 | 130 | switch (req->bmRequest & USB_REQ_TYPE_MASK) 131 | { 132 | case USB_REQ_TYPE_STANDARD: 133 | switch (req->bRequest) 134 | { 135 | case USB_REQ_GET_INTERFACE : 136 | USBD_CtlSendData (pdev, 137 | &ifalt, 138 | 1); 139 | break; 140 | 141 | case USB_REQ_SET_INTERFACE : 142 | break; 143 | } 144 | 145 | default: 146 | break; 147 | } 148 | return USBD_OK; 149 | } 150 | 151 | static uint8_t USBD_BULK_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum) 152 | { 153 | USBD_BULK_HandleTypeDef *hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 154 | 155 | if(pdev->pClassData != NULL) 156 | { 157 | 158 | hcdc->TxState = 0; 159 | 160 | return USBD_OK; 161 | } 162 | else 163 | { 164 | return USBD_FAIL; 165 | } 166 | } 167 | 168 | static uint8_t USBD_BULK_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) 169 | { 170 | USBD_BULK_HandleTypeDef *hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 171 | 172 | /* Get the received data length */ 173 | hcdc->RxLength = USBD_LL_GetRxDataSize (pdev, epnum); 174 | 175 | /* USB data will be immediately processed, this allow next USB traffic being 176 | NAKed till the end of the application Xfer */ 177 | if(pdev->pClassData != NULL) 178 | { 179 | ((USBD_BULK_ItfTypeDef *)pdev->pUserData)->Receive(hcdc->RxBuffer, 180 | &hcdc->RxLength); 181 | 182 | return USBD_OK; 183 | } 184 | else 185 | { 186 | return USBD_FAIL; 187 | } 188 | } 189 | 190 | static uint8_t USBD_BULK_EP0_RxReady (USBD_HandleTypeDef *pdev) 191 | { 192 | return USBD_OK; 193 | } 194 | 195 | static uint8_t *USBD_BULK_GetFSCfgDesc (uint16_t *length) 196 | { 197 | *length = sizeof (USBD_BULK_CfgFSDesc); 198 | return USBD_BULK_CfgFSDesc; 199 | } 200 | 201 | uint8_t USBD_BULK_RegisterInterface (USBD_HandleTypeDef *pdev, 202 | USBD_BULK_ItfTypeDef *fops) 203 | { 204 | uint8_t ret = USBD_FAIL; 205 | if(fops != NULL) 206 | { 207 | pdev->pUserData= fops; 208 | ret = USBD_OK; 209 | } 210 | 211 | return ret; 212 | } 213 | 214 | uint8_t USBD_BULK_SetTxBuffer (USBD_HandleTypeDef *pdev, 215 | uint8_t *pbuff, 216 | uint16_t length) 217 | { 218 | USBD_BULK_HandleTypeDef *hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 219 | 220 | hcdc->TxBuffer = pbuff; 221 | hcdc->TxLength = length; 222 | 223 | return USBD_OK; 224 | } 225 | 226 | uint8_t USBD_BULK_SetRxBuffer (USBD_HandleTypeDef *pdev, 227 | uint8_t *pbuff) 228 | { 229 | USBD_BULK_HandleTypeDef *hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 230 | 231 | hcdc->RxBuffer = pbuff; 232 | 233 | return USBD_OK; 234 | } 235 | 236 | uint8_t USBD_BULK_TransmitPacket(USBD_HandleTypeDef *pdev) 237 | { 238 | USBD_BULK_HandleTypeDef *hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 239 | 240 | if(pdev->pClassData != NULL) 241 | { 242 | if(((volatile uint32_t)hcdc->TxState) == 0) 243 | { 244 | /* Tx Transfer in progress */ 245 | hcdc->TxState = 1; 246 | 247 | /* Transmit next packet */ 248 | USBD_LL_Transmit(pdev, 249 | BULK_IN_EP, 250 | hcdc->TxBuffer, 251 | hcdc->TxLength); 252 | 253 | return USBD_OK; 254 | } 255 | else 256 | { 257 | return USBD_BUSY; 258 | } 259 | } 260 | else 261 | { 262 | return USBD_FAIL; 263 | } 264 | } 265 | 266 | uint8_t USBD_BULK_ReceivePacket(USBD_HandleTypeDef *pdev) 267 | { 268 | USBD_BULK_HandleTypeDef *hcdc = (USBD_BULK_HandleTypeDef*) pdev->pClassData; 269 | 270 | /* Suspend or Resume USB Out process */ 271 | if(pdev->pClassData != NULL) 272 | { 273 | USBD_LL_PrepareReceive(pdev, 274 | BULK_OUT_EP, 275 | hcdc->RxBuffer, 276 | BULK_DATA_FS_OUT_PACKET_SIZE); 277 | return USBD_OK; 278 | } 279 | else 280 | { 281 | return USBD_FAIL; 282 | } 283 | } 284 | 285 | /* BULK interface class callbacks structure */ 286 | 287 | 288 | USBD_ClassTypeDef USBD_BULK = 289 | { 290 | USBD_BULK_Init, 291 | USBD_BULK_DeInit, 292 | USBD_BULK_Setup, 293 | NULL, /* EP0_TxSent, */ 294 | USBD_BULK_EP0_RxReady, 295 | USBD_BULK_DataIn, 296 | USBD_BULK_DataOut, 297 | NULL, 298 | NULL, 299 | NULL, 300 | USBD_BULK_GetFSCfgDesc, 301 | USBD_BULK_GetFSCfgDesc, 302 | USBD_BULK_GetFSCfgDesc, 303 | NULL, 304 | }; 305 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_pwr.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief Header file of PWR HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F3xx_HAL_PWR_H 40 | #define __STM32F3xx_HAL_PWR_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f3xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F3xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup PWR PWR 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported constants --------------------------------------------------------*/ 59 | /** @defgroup PWR_Exported_Constants PWR Exported Constants 60 | * @{ 61 | */ 62 | 63 | /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins 64 | * @{ 65 | */ 66 | 67 | #define PWR_WAKEUP_PIN1 ((uint32_t)PWR_CSR_EWUP1) /*!< Wakeup pin 1 */ 68 | #define PWR_WAKEUP_PIN2 ((uint32_t)PWR_CSR_EWUP2) /*!< Wakeup pin 2 */ 69 | #define PWR_WAKEUP_PIN3 ((uint32_t)PWR_CSR_EWUP3) /*!< Wakeup pin 3 */ 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode 75 | * @{ 76 | */ 77 | #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000) /*!< Voltage regulator on during STOP mode */ 78 | #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS /*!< Voltage regulator in low-power mode during STOP mode */ 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry 84 | * @{ 85 | */ 86 | #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) /*!< Wait For Interruption instruction to enter SLEEP mode */ 87 | #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) /*!< Wait For Event instruction to enter SLEEP mode */ 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry 93 | * @{ 94 | */ 95 | #define PWR_STOPENTRY_WFI ((uint8_t)0x01) /*!< Wait For Interruption instruction to enter STOP mode */ 96 | #define PWR_STOPENTRY_WFE ((uint8_t)0x02) /*!< Wait For Event instruction to enter STOP mode */ 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup PWR_Flag PWR Flag 102 | * @{ 103 | */ 104 | #define PWR_FLAG_WU PWR_CSR_WUF /*!< Wakeup event from wakeup pin or RTC alarm */ 105 | #define PWR_FLAG_SB PWR_CSR_SBF /*!< Standby flag */ 106 | #define PWR_FLAG_PVDO PWR_CSR_PVDO /*!< Power Voltage Detector output flag */ 107 | #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF /*!< VREFINT reference voltage ready */ 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /* Exported macro ------------------------------------------------------------*/ 117 | /** @defgroup PWR_Exported_Macro PWR Exported Macro 118 | * @{ 119 | */ 120 | 121 | /** @brief Check PWR flag is set or not. 122 | * @param __FLAG__: specifies the flag to check. 123 | * This parameter can be one of the following values: 124 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event 125 | * was received from the WKUP pin or from the RTC alarm (Alarm A 126 | * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup. 127 | * An additional wakeup event is detected if the WKUP pin is enabled 128 | * (by setting the EWUP bit) when the WKUP pin level is already high. 129 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was 130 | * resumed from StandBy mode. 131 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled 132 | * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode 133 | * For this reason, this bit is equal to 0 after Standby or reset 134 | * until the PVDE bit is set. 135 | * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference 136 | * voltage VREFINT is ready. 137 | * @retval The new state of __FLAG__ (TRUE or FALSE). 138 | */ 139 | #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) 140 | 141 | /** @brief Clear the PWR's pending flags. 142 | * @param __FLAG__: specifies the flag to clear. 143 | * This parameter can be one of the following values: 144 | * @arg PWR_FLAG_WU: Wake Up flag 145 | * @arg PWR_FLAG_SB: StandBy flag 146 | */ 147 | #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2) 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /* Private macros --------------------------------------------------------*/ 154 | /** @addtogroup PWR_Private_Macros PWR Private Macros 155 | * @{ 156 | */ 157 | 158 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \ 159 | ((PIN) == PWR_WAKEUP_PIN2) || \ 160 | ((PIN) == PWR_WAKEUP_PIN3)) 161 | 162 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ 163 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) 164 | 165 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) 166 | 167 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | /* Include PWR HAL Extended module */ 174 | #include "stm32f3xx_hal_pwr_ex.h" 175 | 176 | /* Exported functions --------------------------------------------------------*/ 177 | 178 | /** @addtogroup PWR_Exported_Functions PWR Exported Functions 179 | * @{ 180 | */ 181 | 182 | /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 183 | * @{ 184 | */ 185 | 186 | /* Initialization and de-initialization functions *****************************/ 187 | void HAL_PWR_DeInit(void); 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions 194 | * @{ 195 | */ 196 | 197 | /* Peripheral Control functions **********************************************/ 198 | void HAL_PWR_EnableBkUpAccess(void); 199 | void HAL_PWR_DisableBkUpAccess(void); 200 | 201 | /* WakeUp pins configuration functions ****************************************/ 202 | void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); 203 | void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); 204 | 205 | /* Low Power modes configuration functions ************************************/ 206 | void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); 207 | void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); 208 | void HAL_PWR_EnterSTANDBYMode(void); 209 | 210 | void HAL_PWR_EnableSleepOnExit(void); 211 | void HAL_PWR_DisableSleepOnExit(void); 212 | void HAL_PWR_EnableSEVOnPend(void); 213 | void HAL_PWR_DisableSEVOnPend(void); 214 | /** 215 | * @} 216 | */ 217 | 218 | /** 219 | * @} 220 | */ 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | /** 227 | * @} 228 | */ 229 | 230 | #ifdef __cplusplus 231 | } 232 | #endif 233 | 234 | 235 | #endif /* __STM32F3xx_HAL_PWR_H */ 236 | 237 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 238 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_pwr_ex.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief Extended PWR HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the Power Controller (PWR) peripheral: 10 | * + Extended Initialization and de-initialization functions 11 | * + Extended Peripheral Control functions 12 | * 13 | ****************************************************************************** 14 | * @attention 15 | * 16 | *

© COPYRIGHT(c) 2016 STMicroelectronics

17 | * 18 | * Redistribution and use in source and binary forms, with or without modification, 19 | * are permitted provided that the following conditions are met: 20 | * 1. Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * 2. Redistributions in binary form must reproduce the above copyright notice, 23 | * this list of conditions and the following disclaimer in the documentation 24 | * and/or other materials provided with the distribution. 25 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************** 41 | */ 42 | 43 | /* Includes ------------------------------------------------------------------*/ 44 | #include "stm32f3xx_hal.h" 45 | 46 | /** @addtogroup STM32F3xx_HAL_Driver 47 | * @{ 48 | */ 49 | 50 | /** @defgroup PWREx PWREx 51 | * @brief PWREx HAL module driver 52 | * @{ 53 | */ 54 | 55 | #ifdef HAL_PWR_MODULE_ENABLED 56 | 57 | /* Private typedef -----------------------------------------------------------*/ 58 | /* Private define ------------------------------------------------------------*/ 59 | /** @defgroup PWREx_Private_Constants PWR Extended Private Constants 60 | * @{ 61 | */ 62 | #define PVD_MODE_IT ((uint32_t)0x00010000) 63 | #define PVD_MODE_EVT ((uint32_t)0x00020000) 64 | #define PVD_RISING_EDGE ((uint32_t)0x00000001) 65 | #define PVD_FALLING_EDGE ((uint32_t)0x00000002) 66 | /** 67 | * @} 68 | */ 69 | 70 | /* Private macro -------------------------------------------------------------*/ 71 | /* Private variables ---------------------------------------------------------*/ 72 | /* Private function prototypes -----------------------------------------------*/ 73 | /* Exported functions ---------------------------------------------------------*/ 74 | 75 | /** @defgroup PWREx_Exported_Functions PWR Extended Exported Functions 76 | * @{ 77 | */ 78 | 79 | /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Control Functions 80 | * @brief Extended Peripheral Control functions 81 | * 82 | @verbatim 83 | 84 | =============================================================================== 85 | ##### Peripheral Extended control functions ##### 86 | =============================================================================== 87 | *** PVD configuration (present on all other devices than STM32F3x8 devices) *** 88 | ========================= 89 | [..] 90 | (+) The PVD is used to monitor the VDD power supply by comparing it to a 91 | threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR). 92 | (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower 93 | than the PVD threshold. This event is internally connected to the EXTI 94 | line16 and can generate an interrupt if enabled. This is done through 95 | __HAL_PWR_PVD_EXTI_ENABLE_IT() macro 96 | (+) The PVD is stopped in Standby mode. 97 | -@- PVD is not available on STM32F3x8 Product Line 98 | 99 | 100 | *** Voltage regulator *** 101 | ========================= 102 | [..] 103 | (+) The voltage regulator is always enabled after Reset. It works in three different 104 | modes. 105 | In Run mode, the regulator supplies full power to the 1.8V domain (core, memories 106 | and digital peripherals). 107 | In Stop mode, the regulator supplies low power to the 1.8V domain, preserving 108 | contents of registers and SRAM. 109 | In Stop mode, the regulator is powered off. The contents of the registers and SRAM 110 | are lost except for the Standby circuitry and the Backup Domain. 111 | Note: in the STM32F3x8xx devices, the voltage regulator is bypassed and the 112 | microcontroller must be powered from a nominal VDD = 1.8V +/-8% voltage. 113 | 114 | 115 | (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower 116 | than the PVD threshold. This event is internally connected to the EXTI 117 | line16 and can generate an interrupt if enabled. This is done through 118 | __HAL_PWR_PVD_EXTI_ENABLE_IT() macro 119 | (+) The PVD is stopped in Standby mode. 120 | 121 | 122 | *** SDADC power configuration *** 123 | ================================ 124 | [..] 125 | (+) On STM32F373xC/STM32F378xx devices, there are up to 126 | 3 SDADC instances that can be enabled/disabled. 127 | 128 | @endverbatim 129 | * @{ 130 | */ 131 | 132 | #if defined(STM32F302xE) || defined(STM32F303xE) || \ 133 | defined(STM32F302xC) || defined(STM32F303xC) || \ 134 | defined(STM32F303x8) || defined(STM32F334x8) || \ 135 | defined(STM32F301x8) || defined(STM32F302x8) || \ 136 | defined(STM32F373xC) 137 | 138 | /** 139 | * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). 140 | * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration 141 | * information for the PVD. 142 | * @note Refer to the electrical characteristics of your device datasheet for 143 | * more details about the voltage threshold corresponding to each 144 | * detection level. 145 | * @retval None 146 | */ 147 | void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD) 148 | { 149 | /* Check the parameters */ 150 | assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); 151 | assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); 152 | 153 | /* Set PLS[7:5] bits according to PVDLevel value */ 154 | MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel); 155 | 156 | /* Clear any previous config. Keep it clear if no event or IT mode is selected */ 157 | __HAL_PWR_PVD_EXTI_DISABLE_EVENT(); 158 | __HAL_PWR_PVD_EXTI_DISABLE_IT(); 159 | __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); 160 | 161 | /* Configure interrupt mode */ 162 | if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT) 163 | { 164 | __HAL_PWR_PVD_EXTI_ENABLE_IT(); 165 | } 166 | 167 | /* Configure event mode */ 168 | if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT) 169 | { 170 | __HAL_PWR_PVD_EXTI_ENABLE_EVENT(); 171 | } 172 | 173 | /* Configure the edge */ 174 | if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE) 175 | { 176 | __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); 177 | } 178 | 179 | if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE) 180 | { 181 | __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); 182 | } 183 | } 184 | 185 | /** 186 | * @brief Enables the Power Voltage Detector(PVD). 187 | * @retval None 188 | */ 189 | void HAL_PWR_EnablePVD(void) 190 | { 191 | SET_BIT(PWR->CR, PWR_CR_PVDE); 192 | } 193 | 194 | /** 195 | * @brief Disables the Power Voltage Detector(PVD). 196 | * @retval None 197 | */ 198 | void HAL_PWR_DisablePVD(void) 199 | { 200 | CLEAR_BIT(PWR->CR, PWR_CR_PVDE); 201 | } 202 | 203 | /** 204 | * @brief This function handles the PWR PVD interrupt request. 205 | * @note This API should be called under the PVD_IRQHandler(). 206 | * @retval None 207 | */ 208 | void HAL_PWR_PVD_IRQHandler(void) 209 | { 210 | /* Check PWR exti flag */ 211 | if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET) 212 | { 213 | /* PWR PVD interrupt user callback */ 214 | HAL_PWR_PVDCallback(); 215 | 216 | /* Clear PWR Exti pending bit */ 217 | __HAL_PWR_PVD_EXTI_CLEAR_FLAG(); 218 | } 219 | } 220 | 221 | /** 222 | * @brief PWR PVD interrupt callback 223 | * @retval None 224 | */ 225 | __weak void HAL_PWR_PVDCallback(void) 226 | { 227 | /* NOTE : This function Should not be modified, when the callback is needed, 228 | the HAL_PWR_PVDCallback could be implemented in the user file 229 | */ 230 | } 231 | 232 | #endif /* STM32F302xE || STM32F303xE || */ 233 | /* STM32F302xC || STM32F303xC || */ 234 | /* STM32F303x8 || STM32F334x8 || */ 235 | /* STM32F301x8 || STM32F302x8 || */ 236 | /* STM32F373xC */ 237 | 238 | #if defined(STM32F373xC) || defined(STM32F378xx) 239 | 240 | /** 241 | * @brief Enables the SDADC peripheral functionaliy 242 | * @param Analogx: specifies the SDADC peripheral instance. 243 | * This parameter can be: PWR_SDADC_ANALOG1, PWR_SDADC_ANALOG2 or PWR_SDADC_ANALOG3. 244 | * @retval None 245 | */ 246 | void HAL_PWREx_EnableSDADC(uint32_t Analogx) 247 | { 248 | /* Check the parameters */ 249 | assert_param(IS_PWR_SDADC_ANALOG(Analogx)); 250 | 251 | /* Enable PWR clock interface for SDADC use */ 252 | __HAL_RCC_PWR_CLK_ENABLE(); 253 | 254 | PWR->CR |= Analogx; 255 | } 256 | 257 | /** 258 | * @brief Disables the SDADC peripheral functionaliy 259 | * @param Analogx: specifies the SDADC peripheral instance. 260 | * This parameter can be: PWR_SDADC_ANALOG1, PWR_SDADC_ANALOG2 or PWR_SDADC_ANALOG3. 261 | * @retval None 262 | */ 263 | void HAL_PWREx_DisableSDADC(uint32_t Analogx) 264 | { 265 | /* Check the parameters */ 266 | assert_param(IS_PWR_SDADC_ANALOG(Analogx)); 267 | 268 | PWR->CR &= ~Analogx; 269 | } 270 | 271 | #endif /* STM32F373xC || STM32F378xx */ 272 | 273 | /** 274 | * @} 275 | */ 276 | 277 | /** 278 | * @} 279 | */ 280 | 281 | #endif /* HAL_PWR_MODULE_ENABLED */ 282 | /** 283 | * @} 284 | */ 285 | 286 | /** 287 | * @} 288 | */ 289 | 290 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 291 | -------------------------------------------------------------------------------- /bulk-example/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f3xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 01-July-2016 7 | * @brief Extended PCD HAL module driver. 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the USB Peripheral Controller: 10 | * + Configuration of the PMA for EP 11 | * 12 | ****************************************************************************** 13 | * @attention 14 | * 15 | *

© COPYRIGHT(c) 2016 STMicroelectronics

16 | * 17 | * Redistribution and use in source and binary forms, with or without modification, 18 | * are permitted provided that the following conditions are met: 19 | * 1. Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | ****************************************************************************** 40 | */ 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f3xx_hal.h" 44 | 45 | #ifdef HAL_PCD_MODULE_ENABLED 46 | 47 | #if defined(STM32F302xE) || defined(STM32F303xE) || \ 48 | defined(STM32F302xC) || defined(STM32F303xC) || \ 49 | defined(STM32F302x8) || \ 50 | defined(STM32F373xC) 51 | 52 | /** @addtogroup STM32F3xx_HAL_Driver 53 | * @{ 54 | */ 55 | 56 | /** @defgroup PCDEx PCDEx 57 | * @brief PCD Extended HAL module driver 58 | * @{ 59 | */ 60 | 61 | /* Private typedef -----------------------------------------------------------*/ 62 | /* Private define ------------------------------------------------------------*/ 63 | /* Private macro -------------------------------------------------------------*/ 64 | /* Private variables ---------------------------------------------------------*/ 65 | /* Private function prototypes -----------------------------------------------*/ 66 | /* Exported functions ---------------------------------------------------------*/ 67 | 68 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 69 | * @{ 70 | */ 71 | 72 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 73 | * @brief PCDEx control functions 74 | * 75 | @verbatim 76 | =============================================================================== 77 | ##### Extended Peripheral Control functions ##### 78 | =============================================================================== 79 | [..] This section provides functions allowing to: 80 | (+) Update PMA configuration 81 | 82 | @endverbatim 83 | * @{ 84 | */ 85 | 86 | /** 87 | * @brief Configure PMA for EP 88 | * @param hpcd: PCD handle 89 | * @param ep_addr: endpoint address 90 | * @param ep_kind: endpoint Kind 91 | * @arg USB_SNG_BUF: Single Buffer used 92 | * @arg USB_DBL_BUF: Double Buffer used 93 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint 94 | * this parameter is 16-bit value providing the address 95 | * in PMA allocated to endpoint. 96 | * In case of double buffer endpoint this parameter 97 | * is a 32-bit value providing the endpoint buffer 0 address 98 | * in the LSB part of 32-bit value and endpoint buffer 1 address 99 | * in the MSB part of 32-bit value. 100 | * @retval : status 101 | */ 102 | 103 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 104 | uint16_t ep_addr, 105 | uint16_t ep_kind, 106 | uint32_t pmaadress) 107 | 108 | { 109 | PCD_EPTypeDef *ep; 110 | 111 | /* initialize ep structure*/ 112 | if ((0x80 & ep_addr) == 0x80) 113 | { 114 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; 115 | } 116 | else 117 | { 118 | ep = &hpcd->OUT_ep[ep_addr]; 119 | } 120 | 121 | /* Here we check if the endpoint is single or double Buffer*/ 122 | if (ep_kind == PCD_SNG_BUF) 123 | { 124 | /*Single Buffer*/ 125 | ep->doublebuffer = 0; 126 | /*Configure the PMA*/ 127 | ep->pmaadress = (uint16_t)pmaadress; 128 | } 129 | else /*USB_DBL_BUF*/ 130 | { 131 | /*Double Buffer Endpoint*/ 132 | ep->doublebuffer = 1; 133 | /*Configure the PMA*/ 134 | ep->pmaaddr0 = pmaadress & 0xFFFF; 135 | ep->pmaaddr1 = (pmaadress & 0xFFFF0000U) >> 16; 136 | } 137 | 138 | return HAL_OK; 139 | } 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /** @defgroup PCDEx_Private_Functions PCD Extended Private Functions 149 | * @{ 150 | */ 151 | #if defined(STM32F303xC) || \ 152 | defined(STM32F303x8) || defined(STM32F334x8) || \ 153 | defined(STM32F301x8) || \ 154 | defined(STM32F373xC) || defined(STM32F378xx) || \ 155 | defined(STM32F302xC) 156 | 157 | /** 158 | * @brief Copy a buffer from user memory area to packet memory area (PMA) 159 | * @param USBx: USB peripheral instance register address. 160 | * @param pbUsrBuf: pointer to user memory area. 161 | * @param wPMABufAddr: address into PMA. 162 | * @param wNBytes: no. of bytes to be copied. 163 | * @retval None 164 | */ 165 | void PCD_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 166 | { 167 | uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ 168 | uint32_t i, temp1, temp2; 169 | uint16_t *pdwVal; 170 | pdwVal = (uint16_t *)(wPMABufAddr * 2 + (uint32_t)USBx + 0x400); 171 | for (i = n; i != 0; i--) 172 | { 173 | temp1 = (uint16_t) * pbUsrBuf; 174 | pbUsrBuf++; 175 | temp2 = temp1 | (uint16_t) * pbUsrBuf << 8; 176 | *pdwVal++ = temp2; 177 | pdwVal++; 178 | pbUsrBuf++; 179 | } 180 | } 181 | 182 | /** 183 | * @brief Copy a buffer from user memory area to packet memory area (PMA) 184 | * @param USBx: USB peripheral instance register address. 185 | * @param pbUsrBuf: pointer to user memory area. 186 | * @param wPMABufAddr: address into PMA. 187 | * @param wNBytes: no. of bytes to be copied. 188 | * @retval None 189 | */ 190 | void PCD_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 191 | { 192 | uint32_t n = (wNBytes + 1) >> 1;/* /2*/ 193 | uint32_t i; 194 | uint32_t *pdwVal; 195 | pdwVal = (uint32_t *)(wPMABufAddr * 2 + (uint32_t)USBx + 0x400); 196 | for (i = n; i != 0; i--) 197 | { 198 | *(uint16_t*)pbUsrBuf++ = *pdwVal++; 199 | pbUsrBuf++; 200 | } 201 | } 202 | #endif /* STM32F303xC || */ 203 | /* STM32F303x8 || STM32F334x8 || */ 204 | /* STM32F301x8 || */ 205 | /* STM32F373xC || STM32F378xx */ 206 | 207 | #if defined(STM32F302xE) || defined(STM32F303xE) || \ 208 | defined(STM32F302x8) 209 | /** 210 | * @brief Copy a buffer from user memory area to packet memory area (PMA) 211 | * @param USBx: USB peripheral instance register address. 212 | * @param pbUsrBuf: pointer to user memory area. 213 | * @param wPMABufAddr: address into PMA. 214 | * @param wNBytes: no. of bytes to be copied. 215 | * @retval None 216 | */ 217 | void PCD_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 218 | { 219 | uint32_t n = (wNBytes + 1) >> 1; 220 | uint32_t i; 221 | uint16_t temp1, temp2; 222 | uint16_t *pdwVal; 223 | pdwVal = (uint16_t *)(wPMABufAddr + (uint32_t)USBx + 0x400); 224 | 225 | for (i = n; i != 0; i--) 226 | { 227 | temp1 = (uint16_t) * pbUsrBuf; 228 | pbUsrBuf++; 229 | temp2 = temp1 | (uint16_t) * pbUsrBuf << 8; 230 | *pdwVal++ = temp2; 231 | pbUsrBuf++; 232 | } 233 | } 234 | 235 | /** 236 | * @brief Copy a buffer from user memory area to packet memory area (PMA) 237 | * @param USBx: USB peripheral instance register address. 238 | * @param pbUsrBuf: pointer to user memory area. 239 | * @param wPMABufAddr: address into PMA. 240 | * @param wNBytes: no. of bytes to be copied. 241 | * @retval None 242 | */ 243 | void PCD_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 244 | { 245 | uint32_t n = (wNBytes + 1) >> 1; 246 | uint32_t i; 247 | uint16_t *pdwVal; 248 | pdwVal = (uint16_t *)(wPMABufAddr + (uint32_t)USBx + 0x400); 249 | for (i = n; i != 0; i--) 250 | { 251 | *(uint16_t*)pbUsrBuf++ = *pdwVal++; 252 | pbUsrBuf++; 253 | } 254 | } 255 | #endif /* STM32F302xE || STM32F303xE || */ 256 | /* STM32F302xC || */ 257 | /* STM32F302x8 */ 258 | 259 | /** 260 | * @} 261 | */ 262 | 263 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 264 | * @{ 265 | */ 266 | 267 | /** @addtogroup PCDEx_Exported_Functions_Group2 Extended Initialization and de-initialization functions 268 | * @{ 269 | */ 270 | /** 271 | * @brief Software Device Connection 272 | * @param hpcd: PCD handle 273 | * @param state: Device state 274 | * @retval None 275 | */ 276 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) 277 | { 278 | /* Prevent unused argument(s) compilation warning */ 279 | UNUSED(hpcd); 280 | UNUSED(state); 281 | 282 | /* NOTE : This function Should not be modified, when the callback is needed, 283 | the HAL_PCDEx_SetConnectionState could be implenetd in the user file 284 | */ 285 | } 286 | /** 287 | * @} 288 | */ 289 | 290 | /** 291 | * @} 292 | */ 293 | 294 | /** 295 | * @} 296 | */ 297 | 298 | /** 299 | * @} 300 | */ 301 | 302 | #endif /* STM32F302xE || STM32F303xE || */ 303 | /* STM32F302xC || STM32F303xC || */ 304 | /* STM32F302x8 || */ 305 | /* STM32F373xC */ 306 | 307 | #endif /* HAL_PCD_MODULE_ENABLED */ 308 | 309 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 310 | -------------------------------------------------------------------------------- /bulk-example/Src/usbd_conf.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_conf.c 4 | * @version : v1.0_Cube 5 | * @brief : This file implements the board support package for the USB device library 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | #include "stm32f3xx.h" 36 | #include "stm32f3xx_hal.h" 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | #include "usbd_bulk.h" 40 | 41 | 42 | PCD_HandleTypeDef hpcd_USB_FS; 43 | void Error_Handler(void); 44 | 45 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state); 46 | 47 | void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) 48 | { 49 | GPIO_InitTypeDef GPIO_InitStruct; 50 | if(pcdHandle->Instance==USB) 51 | { 52 | /* USER CODE BEGIN USB_MspInit 0 */ 53 | 54 | /* USER CODE END USB_MspInit 0 */ 55 | 56 | /**USB GPIO Configuration 57 | PA11 ------> USB_DM 58 | PA12 ------> USB_DP 59 | */ 60 | GPIO_InitStruct.Pin = DM_Pin|DP_Pin; 61 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 62 | GPIO_InitStruct.Pull = GPIO_NOPULL; 63 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; 64 | GPIO_InitStruct.Alternate = GPIO_AF14_USB; 65 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 66 | 67 | /* Peripheral clock enable */ 68 | __HAL_RCC_USB_CLK_ENABLE(); 69 | 70 | /* Peripheral interrupt init */ 71 | HAL_NVIC_SetPriority(USB_LP_CAN_RX0_IRQn, 0, 0); 72 | HAL_NVIC_EnableIRQ(USB_LP_CAN_RX0_IRQn); 73 | /* USER CODE BEGIN USB_MspInit 1 */ 74 | 75 | /* USER CODE END USB_MspInit 1 */ 76 | } 77 | } 78 | 79 | void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) 80 | { 81 | if(pcdHandle->Instance==USB) 82 | { 83 | /* USER CODE BEGIN USB_MspDeInit 0 */ 84 | 85 | /* USER CODE END USB_MspDeInit 0 */ 86 | /* Peripheral clock disable */ 87 | __HAL_RCC_USB_CLK_DISABLE(); 88 | 89 | /**USB GPIO Configuration 90 | PA11 ------> USB_DM 91 | PA12 ------> USB_DP 92 | */ 93 | HAL_GPIO_DeInit(GPIOA, DM_Pin|DP_Pin); 94 | 95 | /* Peripheral interrupt Deinit*/ 96 | HAL_NVIC_DisableIRQ(USB_LP_CAN_RX0_IRQn); 97 | 98 | /* USER CODE BEGIN USB_MspDeInit 1 */ 99 | 100 | /* USER CODE END USB_MspDeInit 1 */ 101 | } 102 | } 103 | 104 | void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) 105 | { 106 | USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); 107 | } 108 | 109 | void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 110 | { 111 | USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, 112 | hpcd->OUT_ep[epnum].xfer_buff); 113 | } 114 | 115 | void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 116 | { 117 | USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, 118 | hpcd->IN_ep[epnum].xfer_buff); 119 | } 120 | 121 | void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) 122 | { 123 | USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); 124 | } 125 | 126 | void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) 127 | { 128 | USBD_SpeedTypeDef speed = USBD_SPEED_FULL; 129 | 130 | /*Set USB Current Speed*/ 131 | switch (hpcd->Init.speed) 132 | { 133 | case PCD_SPEED_FULL: 134 | speed = USBD_SPEED_FULL; 135 | break; 136 | 137 | default: 138 | speed = USBD_SPEED_FULL; 139 | break; 140 | } 141 | USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); 142 | 143 | /*Reset Device*/ 144 | USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); 145 | } 146 | 147 | void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) 148 | { 149 | /* Inform USB library that core enters in suspend Mode */ 150 | USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); 151 | /*Enter in STOP mode */ 152 | if (hpcd->Init.low_power_enable) 153 | { 154 | /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */ 155 | SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | 156 | SCB_SCR_SLEEPONEXIT_Msk)); 157 | } 158 | } 159 | 160 | void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) 161 | { 162 | USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); 163 | } 164 | 165 | void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 166 | { 167 | USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); 168 | } 169 | 170 | void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) 171 | { 172 | USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); 173 | } 174 | 175 | void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) 176 | { 177 | USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); 178 | } 179 | 180 | void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) 181 | { 182 | USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); 183 | } 184 | 185 | /******************************************************************************* 186 | LL Driver Interface (USB Device Library --> PCD) 187 | *******************************************************************************/ 188 | 189 | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev) 190 | { 191 | /* Init USB_IP */ 192 | /* Link The driver to the stack */ 193 | hpcd_USB_FS.pData = pdev; 194 | pdev->pData = &hpcd_USB_FS; 195 | 196 | hpcd_USB_FS.Instance = USB; 197 | hpcd_USB_FS.Init.dev_endpoints = 8; 198 | hpcd_USB_FS.Init.speed = PCD_SPEED_FULL; 199 | hpcd_USB_FS.Init.ep0_mps = DEP0CTL_MPS_64; 200 | hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED; 201 | hpcd_USB_FS.Init.low_power_enable = DISABLE; 202 | hpcd_USB_FS.Init.battery_charging_enable = DISABLE; 203 | if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK) 204 | { 205 | Error_Handler(); 206 | } 207 | // EP0 208 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x00, PCD_SNG_BUF, 0x18); 209 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x80, PCD_SNG_BUF, 0x58); 210 | // Data 211 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 212 | BULK_IN_EP, 213 | PCD_SNG_BUF, 0xC0); 214 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 215 | BULK_OUT_EP, 216 | PCD_SNG_BUF, 0x110); 217 | // was control interface for cdc 218 | // HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82 , PCD_SNG_BUF, 0x100); 219 | return USBD_OK; 220 | } 221 | 222 | USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev) 223 | { 224 | HAL_PCD_DeInit((PCD_HandleTypeDef*)pdev->pData); 225 | return USBD_OK; 226 | } 227 | 228 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) 229 | { 230 | HAL_PCD_Start((PCD_HandleTypeDef*)pdev->pData); 231 | return USBD_OK; 232 | } 233 | 234 | USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev) 235 | { 236 | HAL_PCD_Stop((PCD_HandleTypeDef*) pdev->pData); 237 | return USBD_OK; 238 | } 239 | 240 | USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev, 241 | uint8_t ep_addr, 242 | uint8_t ep_type, 243 | uint16_t ep_mps) 244 | { 245 | HAL_PCD_EP_Open((PCD_HandleTypeDef*) pdev->pData, 246 | ep_addr, 247 | ep_mps, 248 | ep_type); 249 | 250 | return USBD_OK; 251 | } 252 | 253 | USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 254 | { 255 | HAL_PCD_EP_Close((PCD_HandleTypeDef*) pdev->pData, ep_addr); 256 | return USBD_OK; 257 | } 258 | 259 | USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 260 | { 261 | HAL_PCD_EP_Flush((PCD_HandleTypeDef*) pdev->pData, ep_addr); 262 | return USBD_OK; 263 | } 264 | 265 | USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 266 | { 267 | HAL_PCD_EP_SetStall((PCD_HandleTypeDef*) pdev->pData, ep_addr); 268 | return USBD_OK; 269 | } 270 | 271 | USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 272 | { 273 | HAL_PCD_EP_ClrStall((PCD_HandleTypeDef*) pdev->pData, ep_addr); 274 | return USBD_OK; 275 | } 276 | 277 | uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 278 | { 279 | PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; 280 | 281 | if((ep_addr & 0x80) == 0x80) 282 | { 283 | return hpcd->IN_ep[ep_addr & 0x7F].is_stall; 284 | } 285 | else 286 | { 287 | return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; 288 | } 289 | } 290 | 291 | USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr) 292 | { 293 | HAL_PCD_SetAddress((PCD_HandleTypeDef*) pdev->pData, dev_addr); 294 | return USBD_OK; 295 | } 296 | 297 | USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev, 298 | uint8_t ep_addr, 299 | uint8_t *pbuf, 300 | uint16_t size) 301 | { 302 | HAL_PCD_EP_Transmit((PCD_HandleTypeDef*) pdev->pData, ep_addr, pbuf, size); 303 | return USBD_OK; 304 | } 305 | 306 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 307 | uint8_t ep_addr, 308 | uint8_t *pbuf, 309 | uint16_t size) 310 | { 311 | HAL_PCD_EP_Receive((PCD_HandleTypeDef*) pdev->pData, ep_addr, pbuf, size); 312 | return USBD_OK; 313 | } 314 | 315 | uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 316 | { 317 | return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); 318 | } 319 | 320 | void USBD_LL_Delay (uint32_t Delay) 321 | { 322 | HAL_Delay(Delay); 323 | } 324 | 325 | void *USBD_static_malloc(uint32_t size) 326 | { 327 | static uint32_t mem[((sizeof(USBD_BULK_HandleTypeDef)+3)/4)];//On 32-bit boundary 328 | return mem; 329 | } 330 | 331 | void USBD_static_free(void *p) 332 | { 333 | 334 | } 335 | 336 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) 337 | { 338 | } 339 | 340 | --------------------------------------------------------------------------------