update usbh_init and test
This commit is contained in:
parent
06f923c7bb
commit
6db8af2023
127
.cproject
127
.cproject
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<?fileVersion 4.0.0?>
|
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
|
||||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
<cconfiguration id="com.crt.advproject.toolchain.exe.debug.1281391870">
|
<cconfiguration id="com.crt.advproject.toolchain.exe.debug.1281391870">
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.toolchain.exe.debug.1281391870" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.toolchain.exe.debug.1281391870" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||||
|
@ -47,6 +45,56 @@
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<project id="tinyusb.null.492346701" name="tinyusb"/>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="com.crt.config">
|
||||||
|
<projectStorage><?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<TargetConfig>
|
||||||
|
<Properties property_0="" property_3="NXP" property_4="LPC1343" property_count="5" version="1"/>
|
||||||
|
<infoList vendor="NXP"><info chip="LPC1343" match_id="0x3d00002b" name="LPC1343" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1343</name>
|
||||||
|
<family>LPC13xx</family>
|
||||||
|
<vendor>NXP (formerly Philips)</vendor>
|
||||||
|
<reset board="None" core="Real" sys="Real"/>
|
||||||
|
<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
|
||||||
|
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
|
||||||
|
<memory id="RAM" type="RAM"/>
|
||||||
|
<memory id="Periph" is_volatile="true" type="Peripheral"/>
|
||||||
|
<memoryInstance derived_from="Flash" id="MFlash32" location="0x0" size="0x8000"/>
|
||||||
|
<memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/>
|
||||||
|
<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x8000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_I2C" determined="infoFile" id="I2C0" location="0x40000000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_WDT" determined="infoFile" id="WDT" location="0x40004000"/>
|
||||||
|
<peripheralInstance derived_from="LPC1xxx_UART_MODEM" determined="infoFile" id="UART0" location="0x40008000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_ADC" determined="infoFile" id="ADC" location="0x4001c000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_TIMER16" determined="infoFile" id="TMR160" location="0x4000c000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_TIMER16" determined="infoFile" id="TMR161" location="0x40010000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_TIMER32" determined="infoFile" id="TIMER0" location="0x40014000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_TIMER32" determined="infoFile" id="TIMER1" location="0x40018000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_USBDEV" determined="infoFile" id="USB" location="0x40020000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_PMU" determined="infoFile" id="PMU" location="0x40038000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_SSP" determined="infoFile" id="SSP0" location="0x40040000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_IOCON" determined="infoFile" id="IOCON" location="0x40044000"/>
|
||||||
|
<peripheralInstance derived_from="LPC13_SYSCTL" determined="infoFile" id="SYSCTL" location="0x40048000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO0" location="0x50000000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO1" location="0x50010000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO2" location="0x50020000"/>
|
||||||
|
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO3" location="0x50030000"/>
|
||||||
|
<peripheralInstance derived_from="LPC17_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/>
|
||||||
|
<peripheralInstance derived_from="CM3_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/>
|
||||||
|
<peripheralInstance derived_from="LPC11U_FMC" determined="infoFile" id="FMC" location="0x4003c000"/>
|
||||||
|
</chip>
|
||||||
|
<processor><name gcc_name="cortex-m3">Cortex-M3</name>
|
||||||
|
<family>Cortex-M</family>
|
||||||
|
</processor>
|
||||||
|
<link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/>
|
||||||
|
</info>
|
||||||
|
</infoList>
|
||||||
|
</TargetConfig></projectStorage>
|
||||||
|
</storageModule>
|
||||||
<storageModule moduleId="scannerConfiguration">
|
<storageModule moduleId="scannerConfiguration">
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
<profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP">
|
<profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP">
|
||||||
|
@ -612,27 +660,11 @@
|
||||||
</profile>
|
</profile>
|
||||||
</scannerConfigBuildInfo>
|
</scannerConfigBuildInfo>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||||
<buildTargets>
|
<buildTargets>
|
||||||
<target name="all" path="demos/device/keyboard" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>all</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
<target name="clean" path="demos/device/keyboard" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>clean</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
<target name="clean" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="clean" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -640,6 +672,7 @@
|
||||||
</target>
|
</target>
|
||||||
<target name="release" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="release" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
<buildTarget>release</buildTarget>
|
<buildTarget>release</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -647,7 +680,6 @@
|
||||||
</target>
|
</target>
|
||||||
<target name="test" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="test" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>test:all</buildTarget>
|
<buildTarget>test:all</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -655,7 +687,6 @@
|
||||||
</target>
|
</target>
|
||||||
<target name="test delta" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="test delta" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>test:delta</buildTarget>
|
<buildTarget>test:delta</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -663,7 +694,6 @@
|
||||||
</target>
|
</target>
|
||||||
<target name="clobber" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="clobber" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>clobber</buildTarget>
|
<buildTarget>clobber</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -671,7 +701,6 @@
|
||||||
</target>
|
</target>
|
||||||
<target name="test verbose" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="test verbose" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>verbosity[4] test:all</buildTarget>
|
<buildTarget>verbosity[4] test:all</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -679,7 +708,6 @@
|
||||||
</target>
|
</target>
|
||||||
<target name="test verbose delta" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="test verbose delta" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>rake.bat</buildCommand>
|
<buildCommand>rake.bat</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>verbosity[4] test:delta</buildTarget>
|
<buildTarget>verbosity[4] test:delta</buildTarget>
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
@ -687,53 +715,4 @@
|
||||||
</target>
|
</target>
|
||||||
</buildTargets>
|
</buildTargets>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
</cconfiguration>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
|
||||||
<project id="tinyusb.null.492346701" name="tinyusb"/>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="com.crt.config">
|
|
||||||
<projectStorage><?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<TargetConfig>
|
|
||||||
<Properties property_0="" property_3="NXP" property_4="LPC1343" property_count="5" version="1"/>
|
|
||||||
<infoList vendor="NXP"><info chip="LPC1343" match_id="0x3d00002b" name="LPC1343" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1343</name>
|
|
||||||
<family>LPC13xx</family>
|
|
||||||
<vendor>NXP (formerly Philips)</vendor>
|
|
||||||
<reset board="None" core="Real" sys="Real"/>
|
|
||||||
<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
|
|
||||||
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
|
|
||||||
<memory id="RAM" type="RAM"/>
|
|
||||||
<memory id="Periph" is_volatile="true" type="Peripheral"/>
|
|
||||||
<memoryInstance derived_from="Flash" id="MFlash32" location="0x0" size="0x8000"/>
|
|
||||||
<memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/>
|
|
||||||
<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x8000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_I2C" determined="infoFile" id="I2C0" location="0x40000000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_WDT" determined="infoFile" id="WDT" location="0x40004000"/>
|
|
||||||
<peripheralInstance derived_from="LPC1xxx_UART_MODEM" determined="infoFile" id="UART0" location="0x40008000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_ADC" determined="infoFile" id="ADC" location="0x4001c000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_TIMER16" determined="infoFile" id="TMR160" location="0x4000c000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_TIMER16" determined="infoFile" id="TMR161" location="0x40010000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_TIMER32" determined="infoFile" id="TIMER0" location="0x40014000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_TIMER32" determined="infoFile" id="TIMER1" location="0x40018000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_USBDEV" determined="infoFile" id="USB" location="0x40020000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_PMU" determined="infoFile" id="PMU" location="0x40038000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_SSP" determined="infoFile" id="SSP0" location="0x40040000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_IOCON" determined="infoFile" id="IOCON" location="0x40044000"/>
|
|
||||||
<peripheralInstance derived_from="LPC13_SYSCTL" determined="infoFile" id="SYSCTL" location="0x40048000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO0" location="0x50000000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO1" location="0x50010000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO2" location="0x50020000"/>
|
|
||||||
<peripheralInstance derived_from="LPC11_13_GPIO" determined="infoFile" id="GPIO3" location="0x50030000"/>
|
|
||||||
<peripheralInstance derived_from="LPC17_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/>
|
|
||||||
<peripheralInstance derived_from="CM3_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/>
|
|
||||||
<peripheralInstance derived_from="LPC11U_FMC" determined="infoFile" id="FMC" location="0x4003c000"/>
|
|
||||||
</chip>
|
|
||||||
<processor><name gcc_name="cortex-m3">Cortex-M3</name>
|
|
||||||
<family>Cortex-M</family>
|
|
||||||
</processor>
|
|
||||||
<link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/>
|
|
||||||
</info>
|
|
||||||
</infoList>
|
|
||||||
</TargetConfig></projectStorage>
|
|
||||||
</storageModule>
|
|
||||||
</cproject>
|
</cproject>
|
||||||
|
|
|
@ -190,34 +190,3 @@ void test_keyboard_get_ok()
|
||||||
TEST_ASSERT_EQUAL_MEMORY(&sample_key[1], &report, sizeof(tusb_keyboard_report_t));
|
TEST_ASSERT_EQUAL_MEMORY(&sample_key[1], &report, sizeof(tusb_keyboard_report_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
void test_keyboard_open_invalid_para()
|
|
||||||
{
|
|
||||||
tusb_handle_keyboard_t keyboard_handle;
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(TUSB_CFG_HOST_DEVICE_MAX, 1, &keyboard_handle) );
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 0, &keyboard_handle) );
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, TUSB_CFG_CONFIGURATION_MAX+1, &keyboard_handle) );
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 1, NULL) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_keyboard_open_succeed()
|
|
||||||
{
|
|
||||||
tusb_handle_keyboard_t keyboard_handle = 0;
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_open(0, 1, &keyboard_handle));
|
|
||||||
TEST_ASSERT_TRUE( 0 != keyboard_handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_keyboard_callback__()
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
tusb_handle_device_t device_handle = __LINE__;
|
|
||||||
tusb_handle_configure_t configure_handle = __LINE__;
|
|
||||||
tusb_handle_interface_t interface_handle = __LINE__;
|
|
||||||
uint32_t configure_flags = BIT_(TUSB_CLASS_HID);
|
|
||||||
tusbh_usbd_device_mounted_cb_ExpectWithArray(TUSB_ERROR_NONE, device_handle, &configure_flags, 1, 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "usbd_host.h"
|
#include "usbd_host.h"
|
||||||
|
#include "mock_osal.h"
|
||||||
|
|
||||||
extern usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
|
extern usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
|
||||||
tusb_handle_device_t dev_hdl;
|
tusb_handle_device_t dev_hdl;
|
||||||
|
@ -50,16 +51,26 @@ void tearDown(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_usbh_init(void)
|
//--------------------------------------------------------------------+
|
||||||
|
// init, get_status
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
void test_usbh_init_checkmem(void)
|
||||||
{
|
{
|
||||||
usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX];
|
usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX];
|
||||||
memset(device_info_zero, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
memset(device_info_zero, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||||
|
|
||||||
usbh_init();
|
osal_queue_create_IgnoreAndReturn(TUSB_ERROR_NONE);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, usbh_init());
|
||||||
TEST_ASSERT_EQUAL_MEMORY(device_info_zero, device_info_pool, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
TEST_ASSERT_EQUAL_MEMORY(device_info_zero, device_info_pool, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_usbh_init_queue_create_fail(void)
|
||||||
|
{
|
||||||
|
osal_queue_create_IgnoreAndReturn(TUSB_ERROR_OSAL_QUEUE_FAILED);
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init());
|
||||||
|
}
|
||||||
|
|
||||||
void test_usbh_status_get_fail(void)
|
void test_usbh_status_get_fail(void)
|
||||||
{
|
{
|
||||||
usbh_init();
|
usbh_init();
|
||||||
|
@ -73,3 +84,43 @@ void test_usbh_status_get_succeed(void)
|
||||||
TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_READY, tusbh_device_status_get(dev_hdl) );
|
TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_READY, tusbh_device_status_get(dev_hdl) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// enum task
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
void test_enum_task(void)
|
||||||
|
{
|
||||||
|
// osal_queue_
|
||||||
|
TEST_IGNORE();
|
||||||
|
usbh_enumerate_task();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void test_keyboard_open_invalid_para()
|
||||||
|
{
|
||||||
|
tusb_handle_keyboard_t keyboard_handle;
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(TUSB_CFG_HOST_DEVICE_MAX, 1, &keyboard_handle) );
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 0, &keyboard_handle) );
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, TUSB_CFG_CONFIGURATION_MAX+1, &keyboard_handle) );
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 1, NULL) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_keyboard_open_succeed()
|
||||||
|
{
|
||||||
|
tusb_handle_keyboard_t keyboard_handle = 0;
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_open(0, 1, &keyboard_handle));
|
||||||
|
TEST_ASSERT_TRUE( 0 != keyboard_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_keyboard_callback__()
|
||||||
|
{
|
||||||
|
TEST_IGNORE();
|
||||||
|
tusb_handle_device_t device_handle = __LINE__;
|
||||||
|
tusb_handle_configure_t configure_handle = __LINE__;
|
||||||
|
tusb_handle_interface_t interface_handle = __LINE__;
|
||||||
|
uint32_t configure_flags = BIT_(TUSB_CLASS_HID);
|
||||||
|
tusbh_usbd_device_mounted_cb_ExpectWithArray(TUSB_ERROR_NONE, device_handle, &configure_flags, 1, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\
|
ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\
|
||||||
ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\
|
ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\
|
||||||
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
|
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
|
||||||
|
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
|
||||||
ENTRY(TUSB_ERROR_FAILED)\
|
ENTRY(TUSB_ERROR_FAILED)\
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "usbd_host.h"
|
#include "usbd_host.h"
|
||||||
|
#include "osal/osal.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
|
@ -57,6 +58,10 @@
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
STATIC_ usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
|
STATIC_ usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
|
||||||
|
|
||||||
|
#define ENUM_DEPTH 2
|
||||||
|
STATIC_ osal_queue_t queue_enumerate;
|
||||||
|
STATIC_ uint8_t queue_enumerate_buffer[ENUM_DEPTH*sizeof(usbh_enumerate_t)];
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// PUBLIC API (Parameter Verification is required)
|
// PUBLIC API (Parameter Verification is required)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -69,21 +74,16 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CLASS-USBD API (don't require to verify parameters)
|
// CLASS-USBD API (don't require to verify parameters)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void usbh_init(void)
|
tusb_error_t usbh_init(void)
|
||||||
{
|
{
|
||||||
memset(device_info_pool, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
memset(device_info_pool, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||||
}
|
// ASSERT_STATUS(osal_queue_create());
|
||||||
|
|
||||||
#if 0
|
|
||||||
tusb_error_t tusbh_keyboard_open(tusb_handle_device_t device_hdl, uint8_t configure_num, tusb_handle_keyboard_t *keyboard_hdl)
|
|
||||||
{
|
|
||||||
ASSERT(device_hdl < TUSB_CFG_HOST_DEVICE_MAX, TUSB_ERROR_INVALID_PARA);
|
|
||||||
ASSERT_INT_WITHIN(1, TUSB_CFG_CONFIGURATION_MAX, configure_num, TUSB_ERROR_INVALID_PARA);
|
|
||||||
ASSERT_PTR(keyboard_hdl, TUSB_ERROR_INVALID_PARA);
|
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
void usbh_enumerate_task(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -135,6 +135,13 @@ typedef enum {
|
||||||
} pipe_status_t;
|
} pipe_status_t;
|
||||||
|
|
||||||
typedef uint32_t tusb_handle_device_t;
|
typedef uint32_t tusb_handle_device_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t core_id;
|
||||||
|
uint8_t hub_address;
|
||||||
|
uint8_t hub_port;
|
||||||
|
} usbh_enumerate_t;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -153,8 +160,9 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#ifdef _TINY_USB_SOURCE_FILE_
|
#ifdef _TINY_USB_SOURCE_FILE_
|
||||||
|
|
||||||
void usbh_init(void);
|
tusb_error_t usbh_init(void);
|
||||||
pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT;
|
pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
void usbh_enum_task(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,8 @@ enum
|
||||||
// QUEUE API
|
// QUEUE API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
typedef uint32_t osal_queue_id_t;
|
typedef uint32_t osal_queue_id_t;
|
||||||
|
//osal_queue_id_t osal_queue_create(osal_queue_t *queue, uint8_t *buffer);
|
||||||
tusb_error_t osal_queue_create(osal_queue_id_t qid, uint8_t *buffer);
|
osal_queue_id_t osal_queue_create(osal_queue_id_t *queue, uint8_t *buffer);
|
||||||
tusb_error_t osal_queue_put(osal_queue_id_t qid, uint32_t data, osal_timeout_t msec);
|
tusb_error_t osal_queue_put(osal_queue_id_t qid, uint32_t data, osal_timeout_t msec);
|
||||||
tusb_error_t osal_queue_get(osal_queue_id_t qid, uint32_t *data, osal_timeout_t msec);
|
tusb_error_t osal_queue_get(osal_queue_id_t qid, uint32_t *data, osal_timeout_t msec);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@ typedef struct{
|
||||||
volatile uint16_t rd_ptr ; ///< read pointer
|
volatile uint16_t rd_ptr ; ///< read pointer
|
||||||
} osal_queue_t;
|
} osal_queue_t;
|
||||||
|
|
||||||
|
//typedef osal_queue_t osal_queue_id_t*;
|
||||||
|
|
||||||
#define OSAL_DEF_QUEUE(name, size)\
|
#define OSAL_DEF_QUEUE(name, size)\
|
||||||
osal_queue_t name;\
|
osal_queue_t name;\
|
||||||
uint8_t buffer_##name[size]
|
uint8_t buffer_##name[size]
|
||||||
|
|
Loading…
Reference in New Issue