From eb8048e98e4cecf1b75a1ec46eed6f705166ae65 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Sun, 20 Mar 2022 21:19:40 +0800 Subject: add musb host demo with es32f3xx --- demo/es32/usb_host/ES32F369x/Inc/FreeRTOSConfig.h | 311 +++++++++ demo/es32/usb_host/ES32F369x/Inc/ald_conf.h | 213 +++++++ demo/es32/usb_host/ES32F369x/Inc/main.h | 47 ++ demo/es32/usb_host/ES32F369x/Inc/usb_config.h | 60 ++ .../es32/usb_host/ES32F369x/MDK-ARM/example.uvoptx | 705 +++++++++++++++++++++ .../usb_host/ES32F369x/MDK-ARM/example.uvprojx | 594 +++++++++++++++++ demo/es32/usb_host/ES32F369x/Src/irq.c | 181 ++++++ demo/es32/usb_host/ES32F369x/Src/main.c | 178 ++++++ .../ES32F369x/copy Drivers from es32 sdk here.txt | 0 9 files changed, 2289 insertions(+) create mode 100644 demo/es32/usb_host/ES32F369x/Inc/FreeRTOSConfig.h create mode 100644 demo/es32/usb_host/ES32F369x/Inc/ald_conf.h create mode 100644 demo/es32/usb_host/ES32F369x/Inc/main.h create mode 100644 demo/es32/usb_host/ES32F369x/Inc/usb_config.h create mode 100644 demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvoptx create mode 100644 demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvprojx create mode 100644 demo/es32/usb_host/ES32F369x/Src/irq.c create mode 100644 demo/es32/usb_host/ES32F369x/Src/main.c create mode 100644 demo/es32/usb_host/ES32F369x/copy Drivers from es32 sdk here.txt diff --git a/demo/es32/usb_host/ES32F369x/Inc/FreeRTOSConfig.h b/demo/es32/usb_host/ES32F369x/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..c5eb9baa --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/Inc/FreeRTOSConfig.h @@ -0,0 +1,311 @@ +/* + FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. Full license text is available on the following + link: http://www.freertos.org/a00114.html + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * + * * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * + * * + *************************************************************************** + + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? + + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + +*/ + + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + + +//针对不同的编译器调用不同的stdint.h文件 +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + //extern uint32_t SystemCoreClock; +#endif + +//断言 + +#define configASSERT(x) +/************************************************************************ + * FreeRTOS基础配置配置选项 + *********************************************************************/ +/* 置1:RTOS使用抢占式调度器;置0:RTOS使用协作式调度器(时间片) + * + * 注:在多任务管理机制上,操作系统可以分为抢占式和协作式两种。 + * 协作式操作系统是任务主动释放CPU后,切换到下一个任务。 + * 任务切换的时机完全取决于正在运行的任务。 + */ +#define configUSE_PREEMPTION 1 + +//1使能时间片调度(默认式使能的) +#define configUSE_TIME_SLICING 1 + +/* 某些运行FreeRTOS的硬件有两种方法选择下一个要执行的任务: + * 通用方法和特定于硬件的方法(以下简称“特殊方法”)。 + * + * 通用方法: + * 1.configUSE_PORT_OPTIMISED_TASK_SELECTION 为 0 或者硬件不支持这种特殊方法。 + * 2.可以用于所有FreeRTOS支持的硬件 + * 3.完全用C实现,效率略低于特殊方法。 + * 4.不强制要求限制最大可用优先级数目 + * 特殊方法: + * 1.必须将configUSE_PORT_OPTIMISED_TASK_SELECTION设置为1。 + * 2.依赖一个或多个特定架构的汇编指令(一般是类似计算前导零[CLZ]指令)。 + * 3.比通用方法更高效 + * 4.一般强制限定最大可用优先级数目为32 + * 一般是硬件计算前导零指令,如果所使用的,MCU没有这些硬件指令的话此宏应该设置为0! + */ +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 + +/* 置1:使能低功耗tickless模式;置0:保持系统节拍(tick)中断一直运行 + * 假设开启低功耗的话可能会导致下载出现问题,因为程序在睡眠中,可用以下办法解决 + * + * 下载方法: + * 1.将开发版正常连接好 + * 2.按住复位按键,点击下载瞬间松开复位按键 + * + * 1.通过跳线帽将 BOOT 0 接高电平(3.3V) + * 2.重新上电,下载 + * + * 1.使用FlyMcu擦除一下芯片,然后进行下载 + * STMISP -> 清除芯片(z) + */ +#define configUSE_TICKLESS_IDLE 0 + +/* + * 写入实际的CPU内核时钟频率,也就是CPU指令执行频率,通常称为Fclk + * Fclk为供给CPU内核的时钟信号,我们所说的cpu主频为 XX MHz, + * 就是指的这个时钟信号,相应的,1/Fclk即为cpu时钟周期; + */ +#define configCPU_CLOCK_HZ (72000000) + +//RTOS系统节拍中断的频率。即一秒中断的次数,每次中断RTOS都会进行任务调度 +#define configTICK_RATE_HZ (( TickType_t )1000) + +//可使用的最大优先级 +#define configMAX_PRIORITIES (32) + +//空闲任务使用的堆栈大小 +#define configMINIMAL_STACK_SIZE ((unsigned short)128) + +//任务名字字符串长度 +#define configMAX_TASK_NAME_LEN (16) + + //系统节拍计数器变量数据类型,1表示为16位无符号整形,0表示为32位无符号整形 +#define configUSE_16_BIT_TICKS 0 + +//空闲任务放弃CPU使用权给其他同优先级的用户任务 +#define configIDLE_SHOULD_YIELD 1 + +//启用队列 +#define configUSE_QUEUE_SETS 1 + +//开启任务通知功能,默认开启 +#define configUSE_TASK_NOTIFICATIONS 1 + +//使用互斥信号量 +#define configUSE_MUTEXES 1 + +//使用递归互斥信号量 +#define configUSE_RECURSIVE_MUTEXES 0 + +//为1时使用计数信号量 +#define configUSE_COUNTING_SEMAPHORES 1 + +/* 设置可以注册的信号量和消息队列个数 */ +#define configQUEUE_REGISTRY_SIZE 10 + +#define configUSE_APPLICATION_TASK_TAG 0 + + +/***************************************************************** + FreeRTOS与内存申请有关配置选项 +*****************************************************************/ +//支持动态内存申请 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +//支持静态内存 +#define configSUPPORT_STATIC_ALLOCATION 0 +//系统所有总的堆大小 +#define configTOTAL_HEAP_SIZE ((size_t)(36*1024)) + + +/*************************************************************** + FreeRTOS与钩子函数有关的配置选项 +**************************************************************/ +/* 置1:使用空闲钩子(Idle Hook类似于回调函数);置0:忽略空闲钩子 + * + * 空闲任务钩子是一个函数,这个函数由用户来实现, + * FreeRTOS规定了函数的名字和参数:void vApplicationIdleHook(void ), + * 这个函数在每个空闲任务周期都会被调用 + * 对于已经删除的RTOS任务,空闲任务可以释放分配给它们的堆栈内存。 + * 因此必须保证空闲任务可以被CPU执行 + * 使用空闲钩子函数设置CPU进入省电模式是很常见的 + * 不可以调用会引起空闲任务阻塞的API函数 + */ +#define configUSE_IDLE_HOOK 0 + +/* 置1:使用时间片钩子(Tick Hook);置0:忽略时间片钩子 + * + * + * 时间片钩子是一个函数,这个函数由用户来实现, + * FreeRTOS规定了函数的名字和参数:void vApplicationTickHook(void ) + * 时间片中断可以周期性的调用 + * 函数必须非常短小,不能大量使用堆栈, + * 不能调用以”FromISR" 或 "FROM_ISR”结尾的API函数 + */ + /*xTaskIncrementTick函数是在xPortSysTickHandler中断函数中被调用的。因此,vApplicationTickHook()函数执行的时间必须很短才行*/ +#define configUSE_TICK_HOOK 0 + +//使用内存申请失败钩子函数 +#define configUSE_MALLOC_FAILED_HOOK 0 + +/* + * 大于0时启用堆栈溢出检测功能,如果使用此功能 + * 用户必须提供一个栈溢出钩子函数,如果使用的话 + * 此值可以为1或者2,因为有两种栈溢出检测方法 */ +#define configCHECK_FOR_STACK_OVERFLOW 0 + + +/******************************************************************** + FreeRTOS与运行时间和任务状态收集有关的配置选项 +**********************************************************************/ +//启用运行时间统计功能 +#define configGENERATE_RUN_TIME_STATS 0 + //启用可视化跟踪调试 +#define configUSE_TRACE_FACILITY 0 +/* 与宏configUSE_TRACE_FACILITY同时为1时会编译下面3个函数 + * prvWriteNameToBuffer() + * vTaskList(), + * vTaskGetRunTimeStats() +*/ +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 + + +/******************************************************************** + FreeRTOS与协程有关的配置选项 +*********************************************************************/ +//启用协程,启用协程以后必须添加文件croutine.c +#define configUSE_CO_ROUTINES 0 +//协程的有效优先级数目 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + + +/*********************************************************************** + FreeRTOS与软件定时器有关的配置选项 +**********************************************************************/ + //启用软件定时器 +#define configUSE_TIMERS 0 +//软件定时器优先级 +#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-1) +//软件定时器队列长度 +#define configTIMER_QUEUE_LENGTH 10 +//软件定时器任务堆栈大小 +#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE*2) + +/************************************************************ + FreeRTOS可选函数配置选项 +************************************************************/ +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 0 +//#define INCLUDE_xTaskGetCurrentTaskHandle 1 +//#define INCLUDE_uxTaskGetStackHighWaterMark 0 +//#define INCLUDE_xTaskGetIdleTaskHandle 0 + + +/****************************************************************** + FreeRTOS与中断有关的配置选项 +******************************************************************/ +#ifdef __NVIC_PRIO_BITS + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif +//中断最低优先级 +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +//系统可管理的最高中断优先级 +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) /* 240 */ + +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - 4) ) + + +/**************************************************************** + FreeRTOS与中断服务函数有关的配置选项 +****************************************************************/ +#define xPortPendSVHandler PendSV_Handler +#define vPortSVCHandler SVC_Handler + + +/* 以下为使用Percepio Tracealyzer需要的东西,不需要时将 configUSE_TRACE_FACILITY 定义为 0 */ +#if ( configUSE_TRACE_FACILITY == 1 ) +#include "trcRecorder.h" +#define INCLUDE_xTaskGetCurrentTaskHandle 1 // 启用一个可选函数(该函数被 Trace源码使用,默认该值为0 表示不用) +#endif + + +#endif /* FREERTOS_CONFIG_H */ + diff --git a/demo/es32/usb_host/ES32F369x/Inc/ald_conf.h b/demo/es32/usb_host/ES32F369x/Inc/ald_conf.h new file mode 100644 index 00000000..e0123e76 --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/Inc/ald_conf.h @@ -0,0 +1,213 @@ +/** + ********************************************************************************* + * + * @file ald_conf.h + * @brief Enable/Disable the peripheral module. + * + * @version V1.0 + * @date 26 Jun 2019 + * @author AE Team + * @note + * Change Logs: + * Date Author Notes + * 26 Jun 2019 AE Team The first version + * + * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************** + */ + + +#ifndef __ALD_CONF_H__ +#define __ALD_CONF_H__ + + +#define ALD_DMA +#define ALD_GPIO +#define ALD_UART +#define ALD_I2C +#define ALD_CMU +#define ALD_RMU +#define ALD_PMU +#define ALD_WDT +#define ALD_LCD +#define ALD_RTC +#define ALD_CAN +#define ALD_FLASH +#define ALD_ADC +#define ALD_CRC +#define ALD_CRYPT +#define ALD_TIMER +#define ALD_LPTIM +#define ALD_PIS +#define ALD_SPI +#define ALD_CALC +#define ALD_ACMP +#define ALD_OPAMP +#define ALD_TRNG +#define ALD_TSENSE +#define ALD_BKPC +#define ALD_DAC +#define ALD_IAP +#define ALD_I2S +#define ALD_ECC +#define ALD_NAND +#define ALD_QSPI +#define ALD_NOR +#define ALD_SRAM +#define ALD_USB +#define ALD_NOR_LCD +#define ALD_SYSCFG +#define ALD_RTCHW +#if defined(ALD_NAND) || defined(ALD_NOR) || defined(ALD_SRAM) +#define ALD_EBI +#endif + +#ifdef ALD_GPIO + #include "ald_gpio.h" +#endif /*ALD_GPIO */ + +#ifdef ALD_DMA + #include "ald_dma.h" +#endif /* ALD_DMA */ + +#ifdef ALD_UART + #include "ald_uart.h" +#endif /* ALD_UART */ + +#ifdef ALD_I2C + #include "ald_i2c.h" +#endif /* ALD_I2C */ + +#ifdef ALD_CMU + #include "ald_cmu.h" +#endif /* ALD_CMU */ + +#ifdef ALD_RMU + #include "ald_rmu.h" +#endif /* ALD_RMU */ + +#ifdef ALD_PMU + #include "ald_pmu.h" +#endif /* ALD_PUM */ + +#ifdef ALD_WDT + #include "ald_wdt.h" +#endif /* ALD_WDT */ + +#ifdef ALD_RTC + #include "ald_rtc.h" +#endif /* ALD_RTC */ + +#ifdef ALD_FLASH + #include "ald_flash.h" +#endif /*ALD_FLASH*/ + +#ifdef ALD_ADC + #include "ald_adc.h" +#endif /* ALD_ADC */ + +#ifdef ALD_CRC + #include "ald_crc.h" +#endif /* ALD_CRC */ + +#ifdef ALD_CRYPT + #include "ald_crypt.h" +#endif /* ALD_CRYPT */ + +#ifdef ALD_TIMER + #include "ald_timer.h" +#endif /* ALD_TIMER */ + +#ifdef ALD_PIS + #include "ald_pis.h" +#endif /* ALD_PIS */ + +#ifdef ALD_SPI + #include "ald_spi.h" +#endif /* ALD_SPI */ + +#ifdef ALD_CALC + #include "ald_calc.h" +#endif /* ALD_CALC */ + +#ifdef ALD_ACMP + #include "ald_acmp.h" +#endif /* ALD_ACMP */ + +#ifdef ALD_TRNG + #include "ald_trng.h" +#endif /* ALD_TRNG */ + +#ifdef ALD_TSENSE + #include "ald_tsense.h" +#endif /* ALD_TSENSE */ + +#ifdef ALD_BKPC + #include "ald_bkpc.h" +#endif /* ALD_BKPC */ + +#ifdef ALD_DAC + #include "ald_dac.h" +#endif /* ALD_DAC */ + +#ifdef ALD_IAP + #include "ald_iap.h" +#endif /* ALD_IAP */ + +#ifdef ALD_CAN + #include "ald_can.h" +#endif /* ALD_CAN */ + +#ifdef ALD_QSPI + #include "ald_qspi.h" +#endif /* ALD_QSPI */ + +#ifdef ALD_USB + #include "ald_usb.h" +#endif /* ALD_USB */ + +#ifdef ALD_SRAM + #include "ald_sram.h" +#endif /* ALD_SRAM */ + +#ifdef ALD_EBI + #include "ald_ebi.h" +#endif /* ALD_EBI */ + +#ifdef ALD_NAND + #include "ald_nand.h" +#endif /* ALD_NAND */ + +#ifdef ALD_NOR_LCD + #include "ald_nor_lcd.h" +#endif /* ALD_NOR_LCD */ + +#ifdef ALD_I2S + #include "ald_i2s.h" +#endif /* ALD_I2S */ + +#ifdef ALD_SYSCFG + #include "ald_syscfg.h" +#endif /* ALD_SYSCFG */ + +#ifdef ALD_RTCHW + #include "ald_rtchw.h" +#endif /* ALD_RTCHW */ + +#define TICK_INT_PRIORITY 3 + +#endif diff --git a/demo/es32/usb_host/ES32F369x/Inc/main.h b/demo/es32/usb_host/ES32F369x/Inc/main.h new file mode 100644 index 00000000..6060da8b --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/Inc/main.h @@ -0,0 +1,47 @@ +/** + ********************************************************************************* + * + * @file main.h + * @brief Header file for DEMO + * + * @version V1.0 + * @date 26 Jun 2019 + * @author AE Team + * @note + * Change Logs: + * Date Author Notes + * 26 Jun 2019 AE Team The first version + * + * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************** + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#include "ald_conf.h" + +typedef struct env_s { + uint8_t conn; + uint8_t update; + uint32_t button; + int32_t x_pos; + int32_t y_pos; +} env_t; + +extern env_t env; +#endif diff --git a/demo/es32/usb_host/ES32F369x/Inc/usb_config.h b/demo/es32/usb_host/ES32F369x/Inc/usb_config.h new file mode 100644 index 00000000..9a428ac1 --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/Inc/usb_config.h @@ -0,0 +1,60 @@ +#ifndef _USB_CONFIG_H +#define _USB_CONFIG_H + +/* USB DEVICE Configuration */ + +/* USB HOST Configuration */ +#ifndef CONFIG_USBHOST_RHPORTS +#define CONFIG_USBHOST_RHPORTS 1 +#endif + +#ifndef CONFIG_USBHOST_EHPORTS +#define CONFIG_USBHOST_EHPORTS 4 +#endif + +#ifndef CONFIG_USBHOST_INTF_NUM +#define CONFIG_USBHOST_INTF_NUM 6 +#endif + +#ifndef CONFIG_USBHOST_EP_NUM +#define CONFIG_USBHOST_EP_NUM 2 +#endif + +#ifndef CONFIG_USBHOST_HPWORKQ_PRIO +#define CONFIG_USBHOST_HPWORKQ_PRIO 5 +#endif +#ifndef CONFIG_USBHOST_HPWORKQ_STACKSIZE +#define CONFIG_USBHOST_HPWORKQ_STACKSIZE 2048 +#endif + +#ifndef CONFIG_USBHOST_LPWORKQ_PRIO +#define CONFIG_USBHOST_LPWORKQ_PRIO 1 +#endif +#ifndef CONFIG_USBHOST_LPWORKQ_STACKSIZE +#define CONFIG_USBHOST_LPWORKQ_STACKSIZE 2048 +#endif + +#ifndef CONFIG_USBHOST_PSC_PRIO +#define CONFIG_USBHOST_PSC_PRIO 4 +#endif +#ifndef CONFIG_USBHOST_PSC_STACKSIZE +#define CONFIG_USBHOST_PSC_STACKSIZE 4096 +#endif + +#ifndef CONFIG_USBHOST_DEV_NAMELEN +#define CONFIG_USBHOST_DEV_NAMELEN 16 +#endif + +#define CONFIG_USBHOST_ASYNCH +//#define CONFIG_USBHOST_GET_STRING_DESC + +/* EHCI Configuration */ +#define CONFIG_USB_EHCI_HCCR_BASE (0x20072000) +#define CONFIG_USB_EHCI_HCOR_BASE (0x20072000 + 0x10) +#define CONFIG_USB_EHCI_QH_NUM (10) +#define CONFIG_USB_EHCI_QTD_NUM (10) +// #define CONFIG_USB_EHCI_INFO_ENABLE +// #define CONFIG_USB_ECHI_HCOR_RESERVED +// #define CONFIG_USB_EHCI_CONFIGFLAG + +#endif \ No newline at end of file diff --git a/demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvoptx b/demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvoptx new file mode 100644 index 00000000..ddca724c --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvoptx @@ -0,0 +1,705 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + target + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 6 + + + + + + + + + + + STLink\ST-LINKIII-KEIL_SWO.dll + + + + 0 + ST-LINKIII-KEIL_SWO + -U066EFF555453774987091527 -O207 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0es32f36xx.FLM -FS00 -FL080000 -FP0($$Device:ES32F3696LT$Flash\es32f36xx.FLM) + + + 0 + CMSIS_AGDI + -X"essemi CMSIS-DAP" -U0001A000000A -O495 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0es32f36xx.FLM -FS00 -FL080000 -FP0($$Device:ES32F3696LT$Flash\es32f36xx.FLM) + + + 0 + DLGUARM + (105=-1,-1,-1,-1,0) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0es32f36xx -FL080000 -FS00 -FP0($$Device:ES32F3696LT$Flash\es32f36xx.FLM) + + + 0 + JL2CM3 + -U788594195 -O78 -S5 -ZTIFSpeedSel1000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO23 -FD20000000 -FC4000 -FN1 -FF0es32f36xx.FLM -FS00 -FL080000 -FP0($$Device:ES32F3696LT$Flash\es32f36xx.FLM) + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGDARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0) + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + -T0 + + + + + 0 + 0 + 174 + 1 +
14404
+ 0 + 0 + 0 + 0 + 0 + 1 + ..\..\..\..\..\class\hid\usbh_hid.c + + \\out\../../../../../class/hid/usbh_hid.c\174 +
+ + 1 + 0 + 175 + 1 +
14412
+ 0 + 0 + 0 + 0 + 0 + 1 + ..\..\..\..\..\class\hid\usbh_hid.c + + \\out\../../../../../class/hid/usbh_hid.c\175 +
+ + 2 + 0 + 88 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\..\..\class\hid\usbh_hid.c + + +
+
+ + + 0 + 1 + class_driver + + + 1 + 1 + report_buffer + + + + + 1 + 1 + 0x40086510 + 0 + + + + + 2 + 2 + 0x40000000 + 0 + + + + + 3 + 2 + 0x00000000 + 0 + + + + + 4 + 2 + 0x5000 + 0 + + + + 0 + + + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + +
+
+ + + startup + 1 + 0 + 0 + 0 + + 1 + 1 + 2 + 0 + 0 + 0 + ..\Drivers\CMSIS\Device\EastSoft\ES32F36xx\Startup\keil\startup_es32f36xx.s + startup_es32f36xx.s + 0 + 0 + + + + + ald + 0 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_bkpc.c + ald_bkpc.c + 0 + 0 + + + 2 + 3 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_cmu.c + ald_cmu.c + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_dma.c + ald_dma.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_gpio.c + ald_gpio.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_pmu.c + ald_pmu.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_rmu.c + ald_rmu.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_uart.c + ald_uart.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_usb.c + ald_usb.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\ald_iap.c + ald_iap.c + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\Drivers\ALD\ES32F36xx\Source\utils.c + utils.c + 0 + 0 + + + + + app + 0 + 0 + 0 + 0 + + 3 + 12 + 1 + 0 + 0 + 0 + ..\Src\main.c + main.c + 0 + 0 + + + 3 + 13 + 1 + 0 + 0 + 0 + ..\Src\irq.c + irq.c + 0 + 0 + + + 3 + 14 + 1 + 0 + 0 + 0 + ..\..\..\..\usb_host.c + usb_host.c + 0 + 0 + + + + + CherryUSB + 1 + 0 + 0 + 0 + + 4 + 15 + 1 + 0 + 0 + 0 + ..\..\..\..\..\core\usbh_core.c + usbh_core.c + 0 + 0 + + + 4 + 16 + 1 + 0 + 0 + 0 + ..\..\..\..\..\class\cdc\usbh_cdc_acm.c + usbh_cdc_acm.c + 0 + 0 + + + 4 + 17 + 1 + 0 + 0 + 0 + ..\..\..\..\..\class\msc\usbh_msc.c + usbh_msc.c + 0 + 0 + + + 4 + 18 + 1 + 0 + 0 + 0 + ..\..\..\..\..\class\hid\usbh_hid.c + usbh_hid.c + 0 + 0 + + + 4 + 19 + 1 + 0 + 0 + 0 + ..\..\..\..\..\class\hub\usbh_hub.c + usbh_hub.c + 0 + 0 + + + 4 + 20 + 1 + 0 + 0 + 0 + ..\..\..\..\..\osal\usb_osal_freertos.c + usb_osal_freertos.c + 0 + 0 + + + 4 + 21 + 1 + 0 + 0 + 0 + ..\..\..\..\..\osal\usb_workq.c + usb_workq.c + 0 + 0 + + + 4 + 22 + 1 + 0 + 0 + 0 + ..\..\..\..\..\port\musb\usb_hc_musb.c + usb_hc_musb.c + 0 + 0 + + + + + FreeRTOS + 0 + 0 + 0 + 0 + + 5 + 23 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\croutine.c + croutine.c + 0 + 0 + + + 5 + 24 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\event_groups.c + event_groups.c + 0 + 0 + + + 5 + 25 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\list.c + list.c + 0 + 0 + + + 5 + 26 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\queue.c + queue.c + 0 + 0 + + + 5 + 27 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\tasks.c + tasks.c + 0 + 0 + + + 5 + 28 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\timers.c + timers.c + 0 + 0 + + + 5 + 29 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\portable\MemMang\heap_4.c + heap_4.c + 0 + 0 + + + 5 + 30 + 1 + 0 + 0 + 0 + ..\..\..\..\..\third_party\FreeRTOS-10.4\portable\GCC\ARM_CM3\port.c + port.c + 0 + 0 + + + +
diff --git a/demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvprojx b/demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvprojx new file mode 100644 index 00000000..6e740d5c --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/MDK-ARM/example.uvprojx @@ -0,0 +1,594 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + target + 0x4 + ARM-ADS + 6140001::V6.14.1::ARMCLANG + 6140001::V6.14.1::ARMCLANG + 1 + + + ES32F3696LT + Eastsoft + Eastsoft.ES32_DFP.1.0.10 + http://www.essemi.com/index/article/download?id=921 + IRAM(0x20000000,0x00018000) IROM(0x00000000,0x00080000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0es32f36xx -FS00 -FL080000 -FP0($$Device:ES32F3696LT$Flash\es32f36xx.FLM)) + 0 + $$Device:ES32F3696LT$Device\Include\es32f36xx.h + + + + + + + + + + $$Device:ES32F3696LT$SVD\es32f3xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\obj\ + out + 1 + 0 + 1 + 1 + 1 + .\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -MPU + DCM.DLL + -pCM3 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x18000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x80000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x18000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 2 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 3 + 0 + 0 + 0 + 0 + 0 + 3 + 3 + 1 + 1 + 0 + 0 + 0 + + + USE_ASSERT,ES32F36xx,USBD_CDC_HS + + ..\Drivers\CMSIS\Include;..\Drivers\CMSIS\Device\EastSoft\ES32F36xx\Include;..\Drivers\ALD\ES32F36xx\Include;..\Inc;..\..\..\..\..\common;..\..\..\..\..\core;..\..\..\..\..\class\cdc;..\..\..\..\..\class\hid;..\..\..\..\..\class\msc;..\..\..\..\..\class\hub;..\..\..\..\..\osal;..\..\..\..\..\third_party\FreeRTOS-10.4\include;..\..\..\..\..\third_party\FreeRTOS-10.4\portable\GCC\ARM_CM3 + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x00000000 + + + + + + + + + + + + + startup + + + startup_es32f36xx.s + 2 + ..\Drivers\CMSIS\Device\EastSoft\ES32F36xx\Startup\keil\startup_es32f36xx.s + + + + + ald + + + ald_bkpc.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_bkpc.c + + + ald_cmu.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_cmu.c + + + ald_dma.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_dma.c + + + ald_gpio.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_gpio.c + + + ald_pmu.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_pmu.c + + + ald_rmu.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_rmu.c + + + ald_uart.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_uart.c + + + ald_usb.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_usb.c + + + ald_iap.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\ald_iap.c + + + utils.c + 1 + ..\Drivers\ALD\ES32F36xx\Source\utils.c + + + + + app + + + main.c + 1 + ..\Src\main.c + + + irq.c + 1 + ..\Src\irq.c + + + usb_host.c + 1 + ..\..\..\..\usb_host.c + + + + + CherryUSB + + + usbh_core.c + 1 + ..\..\..\..\..\core\usbh_core.c + + + usbh_cdc_acm.c + 1 + ..\..\..\..\..\class\cdc\usbh_cdc_acm.c + + + usbh_msc.c + 1 + ..\..\..\..\..\class\msc\usbh_msc.c + + + usbh_hid.c + 1 + ..\..\..\..\..\class\hid\usbh_hid.c + + + usbh_hub.c + 1 + ..\..\..\..\..\class\hub\usbh_hub.c + + + usb_osal_freertos.c + 1 + ..\..\..\..\..\osal\usb_osal_freertos.c + + + usb_workq.c + 1 + ..\..\..\..\..\osal\usb_workq.c + + + usb_hc_musb.c + 1 + ..\..\..\..\..\port\musb\usb_hc_musb.c + + + + + FreeRTOS + + + croutine.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\croutine.c + + + event_groups.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\event_groups.c + + + list.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\list.c + + + queue.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\queue.c + + + tasks.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\tasks.c + + + timers.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\timers.c + + + heap_4.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\portable\MemMang\heap_4.c + + + port.c + 1 + ..\..\..\..\..\third_party\FreeRTOS-10.4\portable\GCC\ARM_CM3\port.c + + + + + + + + + + + + + RTE\Device\ES32F0031XNLN\startup_es32f0xx.s + + + + + + RTE\Device\ES32F0334LX\startup_es32f0xx.s + + + + + + RTE\Device\ES32F0356NLXN\startup_es32f0xx.s + + + + + + RTE\Device\ES32F0396XNLN\startup_es32f0xx.s + + + + + + + +
diff --git a/demo/es32/usb_host/ES32F369x/Src/irq.c b/demo/es32/usb_host/ES32F369x/Src/irq.c new file mode 100644 index 00000000..a4b75de9 --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/Src/irq.c @@ -0,0 +1,181 @@ +/** + ********************************************************************************* + * + * @file irq.c + * @brief Interrupt handler + * + * @version V1.0 + * @date 26 Jun 2019 + * @author AE Team + * @note + * Change Logs: + * Date Author Notes + * 26 Jun 2019 AE Team The first version + * + * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************** + */ + +#include "main.h" +#include "utils.h" +#include "ald_cmu.h" +#ifdef ALD_DMA +#include "ald_dma.h" +#endif +#include "FreeRTOS.h" +#include "task.h" + +/** @addtogroup Projects_Examples_ALD + * @{ + */ + +/** @addtogroup Examples + * @{ + */ + +/** + * @brief NMI IRQ handler + * @retval None + */ +void NMI_Handler(void) +{ + /* Added Emergency operation */ + return; +} + +/** + * @brief Hardfault IRQ handler + * @retval None + */ +void HardFault_Handler(void) +{ + /* Added debug information */ + while (1) + ; +} + +/** + * @brief MemManage IRQ handler + * @retval None + */ +void MemManage_Handler(void) +{ + /* Added debug information */ + while (1) + ; +} + +/** + * @brief BusFault IRQ handler + * @retval None + */ +void BusFault_Handler(void) +{ + /* Added debug information */ + while (1) + ; +} + +/** + * @brief UsageFault IRQ handler + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Added debug information */ + while (1) + ; +} + +/** + * @brief Supervisor Call IRQ handler + * @retval None + */ +//void SVC_Handler(void) +//{ +// /* Added system callback */ +// return; +//} + +/** + * @brief Debug Monitor IRQ handler + * @retval None + */ +void DebugMon_Handler(void) +{ + /* Added debug operation */ + return; +} + +///** +// * @brief PendSV IRQ handler +// * @retval None +// */ +//void PendSV_Handler(void) +//{ +// /* Added thread switching operation */ +// return; +//} + +/** + * @brief SysTick IRQ handler + * @retval None + */ +void SysTick_Handler(void) +{ + ald_inc_tick(); + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED){ + xPortSysTickHandler(); +} + return; +} + +#ifdef ALD_DMA +/** + * @brief DMA IRQ#66 handler + * @retval None + */ +void DMA_Handler(void) +{ + ald_dma_irq_handler(); +} +#endif + + +/** + * @brief USB IRQ#70 handler + * @retval None + */ +//void USB_INT_Handler() +//{ +// usb0_device_int_handler(); +//} + +/** + * @brief USB_DMA IRQ#71 handler + * @retval None + */ +//void USB_DMA_Handler() +//{ +// usb0_dma_int_handler(); +//} +/** + * @} + */ +/** + * @} + */ diff --git a/demo/es32/usb_host/ES32F369x/Src/main.c b/demo/es32/usb_host/ES32F369x/Src/main.c new file mode 100644 index 00000000..89fffd46 --- /dev/null +++ b/demo/es32/usb_host/ES32F369x/Src/main.c @@ -0,0 +1,178 @@ +/** + ********************************************************************************* + * + * @file main.c + * @brief Main file for DEMO + * + * @version V1.0 + * @date 26 Jun 2019 + * @author AE Team + * @note + * Change Logs: + * Date Author Notes + * 26 Jun 2019 AE Team The first version + * + * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************** + */ +#include "main.h" +#include "stdio.h" +#include "FreeRTOS.h" +#include "task.h" +#include "usbh_core.h" + +static void vtask_led(void *pvParameters); +uart_handle_t h_uart = { 0 }; +/** @addtogroup Projects_Examples_USB + * @{ + */ +int fputc(int ch, FILE *f) +{ + ald_uart_send(&h_uart, (uint8_t *)&ch, 1, 1000); + return ch; +} + +/** + * @brief Initializate pin of USB. + * @retval None + */ +void usb_pin_init(void) +{ + gpio_init_t x; + + /* Initialize vbus pin */ + x.mode = GPIO_MODE_OUTPUT; + x.odos = GPIO_PUSH_PULL; + x.pupd = GPIO_PUSH_UP; + x.podrv = GPIO_OUT_DRIVE_6; + x.nodrv = GPIO_OUT_DRIVE_6; + x.flt = GPIO_FILTER_DISABLE; + x.type = GPIO_TYPE_TTL; + x.func = GPIO_FUNC_5; + ald_gpio_init(GPIOB, GPIO_PIN_15, &x); + + return; +} +/** + * @brief Initializate pin of uart module. + * @retval None + */ +void uart_pin_init(void) +{ + gpio_init_t x; + + /* Initialize tx pin */ + x.mode = GPIO_MODE_OUTPUT; + x.odos = GPIO_PUSH_PULL; + x.pupd = GPIO_PUSH_UP; + x.podrv = GPIO_OUT_DRIVE_1; + x.nodrv = GPIO_OUT_DRIVE_0_1; + x.flt = GPIO_FILTER_DISABLE; + x.type = GPIO_TYPE_TTL; + x.func = GPIO_FUNC_3; + ald_gpio_init(GPIOB, GPIO_PIN_10, &x); + + /* Initialize rx pin */ + x.mode = GPIO_MODE_INPUT; + x.odos = GPIO_PUSH_PULL; + x.pupd = GPIO_PUSH_UP; + x.podrv = GPIO_OUT_DRIVE_1; + x.nodrv = GPIO_OUT_DRIVE_0_1; + x.flt = GPIO_FILTER_DISABLE; + x.type = GPIO_TYPE_TTL; + x.func = GPIO_FUNC_3; + ald_gpio_init(GPIOB, GPIO_PIN_11, &x); + + /* Initialize uart */ + h_uart.perh = UART0; + h_uart.init.baud = 115200; + h_uart.init.word_length = UART_WORD_LENGTH_8B; + h_uart.init.stop_bits = UART_STOP_BITS_1; + h_uart.init.parity = UART_PARITY_NONE; + h_uart.init.mode = UART_MODE_UART; + h_uart.init.fctl = UART_HW_FLOW_CTL_DISABLE; + h_uart.tx_cplt_cbk = NULL; + h_uart.rx_cplt_cbk = NULL; + h_uart.error_cbk = NULL; + ald_uart_init(&h_uart); +} + +void usb_hc_low_level_init(void) +{ + ald_pmu_perh_power_config(PMU_POWER_USB, ENABLE); + ald_cmu_perh_clock_config(CMU_PERH_USB, ENABLE); + ald_cmu_perh_clock_config(CMU_PERH_GPIO, ENABLE); + ald_cmu_usb_clock_config(CMU_USB_CLOCK_SEL_HOSC, CMU_USB_DIV_1); + ald_rmu_reset_periperal(RMU_PERH_USB); + ald_mcu_irq_config(USB_INT_IRQn, 2, 2, ENABLE); + ald_mcu_irq_config(USB_DMA_IRQn, 2, 2, ENABLE); + usb_pin_init(); +} + +void delay(uint32_t delay_us) +{ + while (delay_us--) { + } +} +/** + * @brief Test main function + * @retval Status. + */ +int main() +{ + int i; + + /* Initialize ALD */ + ald_cmu_init(); + /* Configure system clock */ + ald_cmu_pll1_config(CMU_PLL1_INPUT_HOSC_3, CMU_PLL1_OUTPUT_48M); + ald_cmu_clock_config(CMU_CLOCK_PLL1, 48000000); + ald_cmu_perh_clock_config(CMU_PERH_ALL, ENABLE); + + uart_pin_init(); + printf("\rSystem start...\r\n"); + + usbh_initialize(); + vTaskStartScheduler(); + while (1) { + + } +} + +/** + * @brief led task entry function + * @param parameter: user's paramter + * @retval None + */ +static void vtask_led(void *pvParameters) +{ + TickType_t xlast_wake_time; + const TickType_t xfreq = 500; + + xlast_wake_time = xTaskGetTickCount(); + + while(1) { + printf("test\r\n"); + vTaskDelayUntil(&xlast_wake_time, pdMS_TO_TICKS(xfreq)); + } +} +/** + * @} + */ +/** + * @} + */ diff --git a/demo/es32/usb_host/ES32F369x/copy Drivers from es32 sdk here.txt b/demo/es32/usb_host/ES32F369x/copy Drivers from es32 sdk here.txt new file mode 100644 index 00000000..e69de29b -- cgit v1.3.1