mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-24 12:59:42 +08:00
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
This commit is contained in:
@@ -130,7 +130,9 @@ CONFIG_RT_USING_I2C_BITOPS=y
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_MTD_NOR is not set
|
||||
# CONFIG_RT_USING_MTD_NAND is not set
|
||||
# CONFIG_RT_USING_RTC is not set
|
||||
CONFIG_RT_USING_RTC=y
|
||||
# CONFIG_RT_USING_SOFT_RTC is not set
|
||||
# CONFIG_RTC_SYNC_USING_NTP is not set
|
||||
CONFIG_RT_USING_SDIO=y
|
||||
# CONFIG_RT_USING_SPI is not set
|
||||
# CONFIG_RT_USING_WDT is not set
|
||||
@@ -312,5 +314,5 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
|
||||
# CONFIG_PKG_USING_HELLO is not set
|
||||
# CONFIG_PKG_USING_MULTIBUTTON is not set
|
||||
CONFIG_SOC_IMXRT1052=y
|
||||
CONFIG_RT_USING_UART=y
|
||||
CONFIG_RT_USING_UART1=y
|
||||
CONFIG_RT_USING_HP_RTC=y
|
||||
|
||||
@@ -23,13 +23,15 @@ config SOC_IMXRT1052
|
||||
select ARCH_ARM_CORTEX_M7
|
||||
default y
|
||||
|
||||
config RT_USING_UART
|
||||
bool "Using RT_USING_UART"
|
||||
default y
|
||||
|
||||
if RT_USING_UART
|
||||
if RT_USING_SERIAL
|
||||
config RT_USING_UART1
|
||||
bool "Using RT_USING_UART1"
|
||||
default y
|
||||
default y
|
||||
endif
|
||||
|
||||
|
||||
if RT_USING_RTC
|
||||
config RT_USING_HP_RTC
|
||||
bool "Using RT_USING_HP_RTC"
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ cwd = os.path.join(str(Dir('#')), 'drivers')
|
||||
# add the general drivers.
|
||||
src = Split("""
|
||||
board.c
|
||||
usart.c
|
||||
drv_uart.c
|
||||
hyper_flash_boot.c
|
||||
drv_sdram.c
|
||||
""")
|
||||
@@ -18,6 +18,9 @@ CPPDEFINES = []
|
||||
if GetDepend('RT_USING_PIN'):
|
||||
src += ['drv_pin.c']
|
||||
|
||||
if GetDepend('RT_USING_HP_RTC'):
|
||||
src += ['drv_hp_rtc.c']
|
||||
|
||||
if GetDepend('RT_USING_LWIP'):
|
||||
src += ['drv_eth.c', 'fsl_phy.c']
|
||||
CPPDEFINES += ['FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE']
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "usart.h"
|
||||
#include "drv_uart.h"
|
||||
|
||||
static struct rt_memheap system_heap;
|
||||
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* File : drv_hp_rtc.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006-2013, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-03-15 Liuguang the first version.
|
||||
*/
|
||||
#include "drv_hp_rtc.h"
|
||||
#include <time.h>
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_snvs_hp.h"
|
||||
#include "fsl_snvs_lp.h"
|
||||
|
||||
#ifdef RT_USING_RTC
|
||||
|
||||
#if defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL
|
||||
#error "Please don't define 'FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL'!"
|
||||
#endif
|
||||
|
||||
static time_t get_timestamp(void)
|
||||
{
|
||||
struct tm tm_new = {0};
|
||||
snvs_hp_rtc_datetime_t rtcDate;
|
||||
|
||||
SNVS_HP_RTC_GetDatetime(SNVS, &rtcDate);
|
||||
|
||||
tm_new.tm_sec = rtcDate.second;
|
||||
tm_new.tm_min = rtcDate.minute;
|
||||
tm_new.tm_hour = rtcDate.hour;
|
||||
|
||||
tm_new.tm_mday = rtcDate.day;
|
||||
tm_new.tm_mon = rtcDate.month - 1;
|
||||
tm_new.tm_year = rtcDate.year - 1900;
|
||||
|
||||
return mktime(&tm_new);
|
||||
}
|
||||
|
||||
static int set_timestamp(time_t timestamp)
|
||||
{
|
||||
struct tm *p_tm;
|
||||
snvs_hp_rtc_datetime_t rtcDate;
|
||||
|
||||
p_tm = localtime(×tamp);
|
||||
|
||||
rtcDate.second = p_tm->tm_sec ;
|
||||
rtcDate.minute = p_tm->tm_min ;
|
||||
rtcDate.hour = p_tm->tm_hour;
|
||||
|
||||
rtcDate.day = p_tm->tm_mday;
|
||||
rtcDate.month = p_tm->tm_mon + 1;
|
||||
rtcDate.year = p_tm->tm_year + 1900;
|
||||
|
||||
SNVS_HP_RTC_SetDatetime(SNVS, &rtcDate);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/* Çý¶¯½Ó¿Ú */
|
||||
static rt_err_t rt1052_hp_rtc_init(rt_device_t dev)
|
||||
{
|
||||
snvs_hp_rtc_config_t snvsRtcConfig;
|
||||
|
||||
SNVS_HP_RTC_GetDefaultConfig(&snvsRtcConfig);
|
||||
SNVS_HP_RTC_Init(SNVS, &snvsRtcConfig);
|
||||
|
||||
SNVS_HP_RTC_StartTimer(SNVS);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt1052_hp_rtc_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt1052_hp_rtc_close(rt_device_t dev)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_size_t rt1052_hp_rtc_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_size_t rt1052_hp_rtc_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_err_t rt1052_hp_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIME:
|
||||
{
|
||||
*(uint32_t *)args = get_timestamp();
|
||||
}
|
||||
break;
|
||||
|
||||
case RT_DEVICE_CTRL_RTC_SET_TIME:
|
||||
{
|
||||
set_timestamp(*(time_t *)args);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ÎÞЧ²ÎÊý */
|
||||
default:
|
||||
return RT_EINVAL;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static struct rt_device device =
|
||||
{
|
||||
.type = RT_Device_Class_RTC,
|
||||
.init = rt1052_hp_rtc_init,
|
||||
.open = rt1052_hp_rtc_open,
|
||||
.close = rt1052_hp_rtc_close,
|
||||
.read = rt1052_hp_rtc_read,
|
||||
.write = rt1052_hp_rtc_write,
|
||||
.control = rt1052_hp_rtc_control,
|
||||
};
|
||||
|
||||
int rt_hw_hp_rtc_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
|
||||
ret = rt_device_register(&device, "rtc", RT_DEVICE_FLAG_RDWR);
|
||||
if(ret != RT_EOK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
rt_device_open(&device, RT_DEVICE_OFLAG_RDWR);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_hp_rtc_init);
|
||||
|
||||
#endif /*RT_USING_RTC */
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* File : drv_hp_rtc.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006-2013, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-03-15 Liuguang the first version.
|
||||
*/
|
||||
|
||||
#ifndef __DRV_RTC_H__
|
||||
#define __DRV_RTC_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
int rt_hw_hp_rtc_init(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-03-13 Liuguang the first version.
|
||||
* 2018-03-19 Liuguang add GPIO interrupt mode support.
|
||||
*/
|
||||
|
||||
#ifndef __DRV_PIN_H__
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* File : usart.h
|
||||
* File : drv_uart.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2009, RT-Thread Development Team
|
||||
*
|
||||
@@ -9,11 +9,11 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2013-11-15 bright the first version
|
||||
* 2017-10-10 Tanek the first version
|
||||
*/
|
||||
|
||||
#ifndef __USART_H__
|
||||
#define __USART_H__
|
||||
#ifndef __DRV_USART_H__
|
||||
#define __DRV_USART_H__
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
+2450
-2649
File diff suppressed because it is too large
Load Diff
@@ -333,7 +333,7 @@
|
||||
<MiscControls>--library_interface=armcc --library_type=standardlib --diag_suppress=66,1296,186</MiscControls>
|
||||
<Define>SKIP_SYSCLK_INIT, CPU_MIMXRT1052DVL6A, FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1, EVK_MCIMXRM, FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE, RT_USING_ARM_LIBC</Define>
|
||||
<Undefine />
|
||||
<IncludePath>applications;.;drivers;Libraries;Libraries\drivers;Libraries\utilities;Libraries\CMSIS\Include;..\..\include;..\..\libcpu\arm\cortex-m7;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\net\lwip-2.0.2\src;..\..\components\net\lwip-2.0.2\src\include;..\..\components\net\lwip-2.0.2\src\include\ipv4;..\..\components\net\lwip-2.0.2\src\arch\include;..\..\components\net\lwip-2.0.2\src\include\netif;..\..\components\net\lwip-2.0.2\src\include\posix</IncludePath>
|
||||
<IncludePath>applications;.;drivers;Libraries;Libraries\drivers;Libraries\utilities;Libraries\CMSIS\Include;..\..\include;..\..\libcpu\arm\cortex-m7;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\net\lwip-2.0.2\src;..\..\components\net\lwip-2.0.2\src\include;..\..\components\net\lwip-2.0.2\src\include\ipv4;..\..\components\net\lwip-2.0.2\src\arch\include;..\..\components\net\lwip-2.0.2\src\include\netif;..\..\components\net\lwip-2.0.2\src\include\posix</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -416,9 +416,9 @@
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>usart.c</FileName>
|
||||
<FileName>drv_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>drivers\usart.c</FilePath>
|
||||
<FilePath>drivers\drv_uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
@@ -442,6 +442,13 @@
|
||||
<FilePath>drivers\drv_pin.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>drv_hp_rtc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>drivers\drv_hp_rtc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>drv_eth.c</FileName>
|
||||
@@ -1115,6 +1122,13 @@
|
||||
<FilePath>..\..\components\drivers\misc\pin.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>rtc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\components\drivers\rtc\rtc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>block_dev.c</FileName>
|
||||
|
||||
@@ -121,7 +121,9 @@
|
||||
#define RT_USING_PIN
|
||||
/* RT_USING_MTD_NOR is not set */
|
||||
/* RT_USING_MTD_NAND is not set */
|
||||
/* RT_USING_RTC is not set */
|
||||
#define RT_USING_RTC
|
||||
/* RT_USING_SOFT_RTC is not set */
|
||||
/* RTC_SYNC_USING_NTP is not set */
|
||||
#define RT_USING_SDIO
|
||||
/* RT_USING_SPI is not set */
|
||||
/* RT_USING_WDT is not set */
|
||||
@@ -277,7 +279,7 @@
|
||||
/* PKG_USING_HELLO is not set */
|
||||
/* PKG_USING_MULTIBUTTON is not set */
|
||||
#define SOC_IMXRT1052
|
||||
#define RT_USING_UART
|
||||
#define RT_USING_UART1
|
||||
#define RT_USING_HP_RTC
|
||||
|
||||
#endif
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
// </c>
|
||||
// <c1>Using Mutex
|
||||
// <i>Using Mutex
|
||||
//#define RT_USING_MUTEX
|
||||
#define RT_USING_MUTEX
|
||||
// </c>
|
||||
// <c1>Using Event
|
||||
// <i>Using Event
|
||||
|
||||
@@ -18,12 +18,6 @@ elif rtconfig.CROSS_TOOL == 'iar':
|
||||
CPPPATH = [cwd, cwd + '/inc', cwd + '/driverlib']
|
||||
|
||||
CPPDEFINES = [rtconfig.PART_TYPE]
|
||||
if rtconfig.CROSS_TOOL == 'gcc':
|
||||
CPPDEFINES += ['gcc'];
|
||||
CPPDEFINES += ['uint_fast8_t=uint32_t'];
|
||||
CPPDEFINES += ['uint_fast32_t=uint32_t'];
|
||||
CPPDEFINES += ['int_fast8_t=int32_t'];
|
||||
CPPDEFINES += ['uint_fast16_t=uint32_t'];
|
||||
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -214,7 +214,8 @@ int dfs_elm_mkfs(rt_device_t dev_id)
|
||||
int flag;
|
||||
FRESULT result;
|
||||
int index;
|
||||
|
||||
char logic_nbr[2] = {'0',':'};
|
||||
|
||||
work = rt_malloc(_MAX_SS);
|
||||
if(RT_NULL == work) {
|
||||
return -ENOMEM;
|
||||
@@ -264,7 +265,8 @@ int dfs_elm_mkfs(rt_device_t dev_id)
|
||||
* on the disk, you will get a failure. so we need f_mount here,
|
||||
* just fill the FatFS[index] in elm fatfs to make mkfs work.
|
||||
*/
|
||||
f_mount(fat, "", (BYTE)index);
|
||||
logic_nbr[0] = '0' + index;
|
||||
f_mount(fat, logic_nbr, (BYTE)index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,14 +275,14 @@ int dfs_elm_mkfs(rt_device_t dev_id)
|
||||
/* [IN] Size of the allocation unit */
|
||||
/* [-] Working buffer */
|
||||
/* [IN] Size of working buffer */
|
||||
result = f_mkfs("", FM_ANY, 0, work, _MAX_SS);
|
||||
result = f_mkfs(logic_nbr, FM_ANY, 0, work, _MAX_SS);
|
||||
rt_free(work); work = RT_NULL;
|
||||
|
||||
/* check flag status, we need clear the temp driver stored in disk[] */
|
||||
if (flag == FSM_STATUS_USE_TEMP_DRIVER)
|
||||
{
|
||||
rt_free(fat);
|
||||
f_mount(RT_NULL, "",(BYTE)index);
|
||||
f_mount(RT_NULL, logic_nbr,(BYTE)index);
|
||||
disk[index] = RT_NULL;
|
||||
/* close device */
|
||||
rt_device_close(dev_id);
|
||||
|
||||
@@ -140,6 +140,7 @@ struct udcd
|
||||
struct uendpoint ep0;
|
||||
uep0_stage_t stage;
|
||||
struct ep_id* ep_pool;
|
||||
rt_uint8_t device_is_hs;
|
||||
};
|
||||
typedef struct udcd* udcd_t;
|
||||
|
||||
|
||||
@@ -114,15 +114,17 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_CDC,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_CDC, //bDeviceClass
|
||||
0x00, //bDeviceSubClass
|
||||
0x00, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@@ -566,7 +568,8 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
|
||||
|
||||
/* create a cdc function */
|
||||
func = rt_usbd_function_new(device, &dev_desc, &ops);
|
||||
rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||
//not support HS
|
||||
//rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||
|
||||
/* allocate memory for cdc vcom data */
|
||||
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
|
||||
|
||||
@@ -41,7 +41,7 @@ struct rt_ecm_eth
|
||||
rt_uint8_t dev_addr[MAX_ADDR_LEN];
|
||||
|
||||
ALIGN(4)
|
||||
rt_uint8_t rx_pool[64];
|
||||
rt_uint8_t rx_pool[512];
|
||||
ALIGN(4)
|
||||
rt_size_t rx_size;
|
||||
ALIGN(4)
|
||||
@@ -147,14 +147,14 @@ const static struct ucdc_data_descriptor _data_desc =
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DIR_OUT | USB_DYNAMIC,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
/* endpoint, bulk in */
|
||||
USB_DESC_LENGTH_ENDPOINT,
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DYNAMIC | USB_DIR_IN,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
};
|
||||
|
||||
@@ -170,17 +170,20 @@ const static char* _ustring[] =
|
||||
};
|
||||
|
||||
ALIGN(4)
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_CDC,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_CDC, //bDeviceClass
|
||||
USB_CDC_SUBCLASS_ETH, //bDeviceSubClass
|
||||
USB_CDC_PROTOCOL_NONE, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
static rt_err_t _cdc_send_notifi(ufunction_t func,ucdc_notification_code_t notifi,rt_uint16_t wValue,rt_uint16_t wLength)
|
||||
{
|
||||
static struct ucdc_management_element_notifications _notifi;
|
||||
@@ -472,7 +475,7 @@ static struct ufunction_ops ops =
|
||||
*
|
||||
* @return RT_EOK on successful.
|
||||
*/
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr)
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
comm->call_mgmt_desc.data_interface = dintf_nr;
|
||||
comm->union_desc.master_interface = cintf_nr;
|
||||
@@ -480,7 +483,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
comm->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
|
||||
data->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
data->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -532,7 +536,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
|
||||
(rt_off_t)&((ucdc_eth_desc_t)0)->intf_desc);
|
||||
rt_usbd_altsetting_config_descriptor(data_setting, &_data_desc, 0);
|
||||
/* configure the cdc interface descriptor */
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num);
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create a command endpoint */
|
||||
comm_desc = (ucdc_eth_desc_t)comm_setting->desc;
|
||||
|
||||
@@ -227,18 +227,21 @@ static struct udevice_descriptor _dev_desc =
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
static struct usb_qualifier_descriptor _dev_qualifier =
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(_dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_HID,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_MASS_STORAGE, //bDeviceClass
|
||||
0x06, //bDeviceSubClass
|
||||
0x50, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
/* hid interface descriptor */
|
||||
const static struct uhid_comm_descriptor _hid_comm_desc =
|
||||
{
|
||||
@@ -631,7 +634,8 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
|
||||
|
||||
/* create a cdc function */
|
||||
func = rt_usbd_function_new(device, &_dev_desc, &ops);
|
||||
rt_usbd_device_set_qualifier(device, &_dev_qualifier);
|
||||
//not support hs
|
||||
//rt_usbd_device_set_qualifier(device, &_dev_qualifier);
|
||||
|
||||
/* allocate memory for cdc vcom data */
|
||||
data = (struct hid_s*)rt_malloc(sizeof(struct hid_s));
|
||||
|
||||
@@ -88,8 +88,8 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_DESC_TYPE_DEVICE, //type;
|
||||
USB_BCD_VERSION, //bcdUSB;
|
||||
USB_CLASS_MASS_STORAGE, //bDeviceClass;
|
||||
0x00, //bDeviceSubClass;
|
||||
0x00, //bDeviceProtocol;
|
||||
0x06, //bDeviceSubClass;
|
||||
0x50, //bDeviceProtocol;
|
||||
0x40, //bMaxPacketSize0;
|
||||
_VENDOR_ID, //idVendor;
|
||||
_PRODUCT_ID, //idProduct;
|
||||
@@ -100,15 +100,17 @@ static struct udevice_descriptor dev_desc =
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_MASS_STORAGE,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_MASS_STORAGE, //bDeviceClass
|
||||
0x06, //bDeviceSubClass
|
||||
0x50, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@@ -141,14 +143,14 @@ const static struct umass_descriptor _mass_desc =
|
||||
USB_DESC_TYPE_ENDPOINT, //type;
|
||||
USB_DYNAMIC | USB_DIR_OUT, //bEndpointAddress;
|
||||
USB_EP_ATTR_BULK, //bmAttributes;
|
||||
0x40, //wMaxPacketSize;
|
||||
USB_DYNAMIC, //wMaxPacketSize;
|
||||
0x00, //bInterval;
|
||||
|
||||
USB_DESC_LENGTH_ENDPOINT, //bLength;
|
||||
USB_DESC_TYPE_ENDPOINT, //type;
|
||||
USB_DYNAMIC | USB_DIR_IN, //bEndpointAddress;
|
||||
USB_EP_ATTR_BULK, //bmAttributes;
|
||||
0x40, //wMaxPacketSize;
|
||||
USB_DYNAMIC, //wMaxPacketSize;
|
||||
0x00, //bInterval;
|
||||
};
|
||||
|
||||
@@ -1043,11 +1045,13 @@ static struct ufunction_ops ops =
|
||||
_function_disable,
|
||||
RT_NULL,
|
||||
};
|
||||
static rt_err_t _mstorage_descriptor_config(umass_desc_t desc, rt_uint8_t cintf_nr)
|
||||
static rt_err_t _mstorage_descriptor_config(umass_desc_t desc, rt_uint8_t cintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
desc->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
desc->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
desc->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
return RT_EOK;
|
||||
}
|
||||
/**
|
||||
@@ -1090,7 +1094,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
|
||||
rt_usbd_altsetting_config_descriptor(setting, &_mass_desc, (rt_off_t)&((umass_desc_t)0)->intf_desc);
|
||||
|
||||
/* configure the msc interface descriptor */
|
||||
_mstorage_descriptor_config(setting->desc, intf->intf_num);
|
||||
_mstorage_descriptor_config(setting->desc, intf->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create a bulk out and a bulk in endpoint */
|
||||
mass_desc = (umass_desc_t)setting->desc;
|
||||
|
||||
@@ -58,9 +58,9 @@ struct rt_rndis_eth
|
||||
#endif /* RNDIS_DELAY_LINK_UP */
|
||||
|
||||
ALIGN(4)
|
||||
rt_uint8_t rx_pool[64];
|
||||
rt_uint8_t rx_pool[512];
|
||||
ALIGN(4)
|
||||
rt_uint8_t tx_pool[64];
|
||||
rt_uint8_t tx_pool[512];
|
||||
|
||||
rt_uint32_t cmd_pool[2];
|
||||
ALIGN(4)
|
||||
@@ -175,14 +175,14 @@ const static struct ucdc_data_descriptor _data_desc =
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DIR_OUT | USB_DYNAMIC,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
/* endpoint, bulk in */
|
||||
USB_DESC_LENGTH_ENDPOINT,
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DYNAMIC | USB_DIR_IN,
|
||||
USB_EP_ATTR_BULK,
|
||||
USB_CDC_BUFSIZE,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
};
|
||||
|
||||
@@ -206,16 +206,17 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
|
||||
.subCompatibleID = {'5', '1', '6', '2', '0', '0', '1', 0x00},
|
||||
.reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
ALIGN(4)
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
USB_CLASS_CDC,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_CDC, //bDeviceClass
|
||||
USB_CDC_SUBCLASS_ACM, //bDeviceSubClass
|
||||
USB_CDC_PROTOCOL_VENDOR, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@@ -401,7 +402,7 @@ static rt_err_t _rndis_query_response(ufunction_t func,rndis_query_msg_t msg)
|
||||
case OID_GEN_LINK_SPEED:
|
||||
resp = _create_resp(4);
|
||||
if(resp == RT_NULL) break;
|
||||
_set_resp(resp, (10UL * 1000 * 1000) / 100);
|
||||
_set_resp(resp, func->device->dcd->device_is_hs ? (480UL * 1000 *1000) : (12UL * 1000 * 1000) / 100);
|
||||
break;
|
||||
|
||||
case OID_GEN_MEDIA_CONNECT_STATUS:
|
||||
@@ -1008,7 +1009,7 @@ static struct ufunction_ops ops =
|
||||
*
|
||||
* @return RT_EOK on successful.
|
||||
*/
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr)
|
||||
static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
comm->call_mgmt_desc.data_interface = dintf_nr;
|
||||
comm->union_desc.master_interface = cintf_nr;
|
||||
@@ -1016,7 +1017,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
comm->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
|
||||
data->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
data->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -1237,7 +1239,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
|
||||
(rt_off_t)&((ucdc_comm_desc_t)0)->intf_desc);
|
||||
rt_usbd_altsetting_config_descriptor(data_setting, &_data_desc, 0);
|
||||
/* configure the cdc interface descriptor */
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num);
|
||||
_cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create a command endpoint */
|
||||
comm_desc = (ucdc_comm_desc_t)comm_setting->desc;
|
||||
|
||||
@@ -43,13 +43,14 @@ static struct udevice_descriptor dev_desc =
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier),
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER,
|
||||
0x0200,
|
||||
0x00,
|
||||
0x00,
|
||||
64,
|
||||
0x01,
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
0xFF, //bDeviceClass
|
||||
0x00, //bDeviceSubClass
|
||||
0x00, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
|
||||
@@ -81,14 +82,14 @@ struct winusb_descriptor _winusb_desc =
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DYNAMIC | USB_DIR_OUT,
|
||||
USB_EP_ATTR_BULK,
|
||||
0x40,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
/*endpoint descriptor*/
|
||||
USB_DESC_LENGTH_ENDPOINT,
|
||||
USB_DESC_TYPE_ENDPOINT,
|
||||
USB_DYNAMIC | USB_DIR_IN,
|
||||
USB_EP_ATTR_BULK,
|
||||
0x40,
|
||||
USB_DYNAMIC,
|
||||
0x00,
|
||||
};
|
||||
|
||||
@@ -197,11 +198,13 @@ static struct ufunction_ops ops =
|
||||
RT_NULL,
|
||||
};
|
||||
|
||||
static rt_err_t _winusb_descriptor_config(winusb_desc_t winusb, rt_uint8_t cintf_nr)
|
||||
static rt_err_t _winusb_descriptor_config(winusb_desc_t winusb, rt_uint8_t cintf_nr, rt_uint8_t device_is_hs)
|
||||
{
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
winusb->iad_desc.bFirstInterface = cintf_nr;
|
||||
#endif
|
||||
winusb->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
winusb->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64;
|
||||
winusb_func_comp_id_desc.bFirstInterfaceNumber = cintf_nr;
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -293,7 +296,7 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device)
|
||||
rt_usbd_altsetting_config_descriptor(winusb_setting, &_winusb_desc, (rt_off_t)&((winusb_desc_t)0)->intf_desc);
|
||||
|
||||
/* configure the hid interface descriptor */
|
||||
_winusb_descriptor_config(winusb_setting->desc, winusb_intf->intf_num);
|
||||
_winusb_descriptor_config(winusb_setting->desc, winusb_intf->intf_num, device->dcd->device_is_hs);
|
||||
|
||||
/* create endpoint */
|
||||
winusb_desc = (winusb_desc_t)winusb_setting->desc;
|
||||
|
||||
@@ -166,7 +166,7 @@ static rt_err_t _get_qualifier_descriptor(struct udevice* device, ureq_t setup)
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(setup != RT_NULL);
|
||||
|
||||
if(device->dev_qualifier)
|
||||
if(device->dev_qualifier && device->dcd->device_is_hs)
|
||||
{
|
||||
/* send device qualifier descriptor to endpoint 0 */
|
||||
rt_usbd_ep0_write(device, (rt_uint8_t*)device->dev_qualifier,
|
||||
@@ -210,6 +210,9 @@ static rt_err_t _get_descriptor(struct udevice* device, ureq_t setup)
|
||||
case USB_DESC_TYPE_DEVICEQUALIFIER:
|
||||
_get_qualifier_descriptor(device, setup);
|
||||
break;
|
||||
case USB_DESC_TYPE_OTHERSPEED:
|
||||
_get_config_descriptor(device, setup);
|
||||
break;
|
||||
default:
|
||||
rt_kprintf("unsupported descriptor request\n");
|
||||
rt_usbd_ep0_set_stall(device);
|
||||
|
||||
@@ -59,6 +59,20 @@ static struct udevice_descriptor compsit_desc =
|
||||
USB_STRING_SERIAL_INDEX, //iSerialNumber;
|
||||
USB_DYNAMIC, //bNumConfigurations;
|
||||
};
|
||||
|
||||
//FS and HS needed
|
||||
static struct usb_qualifier_descriptor dev_qualifier =
|
||||
{
|
||||
sizeof(dev_qualifier), //bLength
|
||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||
0x0200, //bcdUSB
|
||||
USB_CLASS_MISC, //bDeviceClass
|
||||
0x02, //bDeviceSubClass
|
||||
0x01, //bDeviceProtocol
|
||||
64, //bMaxPacketSize0
|
||||
0x01, //bNumConfigurations
|
||||
0,
|
||||
};
|
||||
#endif
|
||||
|
||||
struct usb_os_comp_id_descriptor usb_comp_id_desc =
|
||||
@@ -169,6 +183,7 @@ rt_err_t rt_usb_device_init(void)
|
||||
#ifdef RT_USB_DEVICE_COMPOSITE
|
||||
rt_usbd_device_set_descriptor(udevice, &compsit_desc);
|
||||
rt_usbd_device_set_string(udevice, ustring);
|
||||
rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||
#else
|
||||
rt_usbd_device_set_descriptor(udevice, func->dev_desc);
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
#define _SYS_UNISTD_H
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
|
||||
#define STDIN_FILENO 0 /* standard input file descriptor */
|
||||
#define STDOUT_FILENO 1 /* standard output file descriptor */
|
||||
#define STDERR_FILENO 2 /* standard error file descriptor */
|
||||
|
||||
#include <dfs_posix.h>
|
||||
#else
|
||||
#define _FREAD 0x0001 /* read enabled */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -77,11 +77,23 @@
|
||||
|
||||
struct stat
|
||||
{
|
||||
struct rt_device* st_dev;
|
||||
uint16_t st_mode;
|
||||
uint32_t st_size;
|
||||
time_t st_mtime;
|
||||
uint32_t st_blksize;
|
||||
struct rt_device *st_dev;
|
||||
uint16_t st_ino;
|
||||
uint16_t st_mode;
|
||||
uint16_t st_nlink;
|
||||
uint16_t st_uid;
|
||||
uint16_t st_gid;
|
||||
struct rt_device *st_rdev;
|
||||
uint32_t st_size;
|
||||
time_t st_atime;
|
||||
long st_spare1;
|
||||
time_t st_mtime;
|
||||
long st_spare2;
|
||||
time_t st_ctime;
|
||||
long st_spare3;
|
||||
uint32_t st_blksize;
|
||||
uint32_t st_blocks;
|
||||
long st_spare4[2];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user