summaryrefslogtreecommitdiff
path: root/tests/test/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-02-27 17:14:59 +0700
committerhathach <[email protected]>2013-02-27 17:14:59 +0700
commit8869d17d98cd484f6bfee3977365203d8ef76e7b (patch)
tree3eac5dd7dd6a5298f776d2e98b6cf1e5140f3801 /tests/test/host
parentb73e6c7a35e6075127f60df1f462801f57ea280f (diff)
add test for EHCI register offset
add test for EHCI usbcmd register structure
Diffstat (limited to 'tests/test/host')
-rw-r--r--tests/test/host/ehci/test_ehci.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/tests/test/host/ehci/test_ehci.c b/tests/test/host/ehci/test_ehci.c
index b8b7b65a3..84407d0d6 100644
--- a/tests/test/host/ehci/test_ehci.c
+++ b/tests/test/host/ehci/test_ehci.c
@@ -51,9 +51,9 @@ uint8_t number_of_high_bits(uint32_t value);
({\
uint32_t value=0;\
struct_type str;\
- memclr_(&str, sizeof(struct_type));\
+ memclr_((void*)&str, sizeof(struct_type));\
str.member.bitfield_member = 1;\
- memcpy(&value, &str.member, sizeof(str.member));\
+ memcpy(&value, (void*)&str.member, sizeof(str.member));\
first_pos_of_high_bit( value );\
})
@@ -73,7 +73,9 @@ void tearDown(void)
{
}
-
+//--------------------------------------------------------------------+
+//
+//--------------------------------------------------------------------+
void test_struct_alignment(void)
{
TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qhd_t) );
@@ -95,6 +97,9 @@ void test_struct_size(void)
TEST_ASSERT_EQUAL( 4, sizeof(ehci_link_t) );
}
+//--------------------------------------------------------------------+
+// EHCI Data Structure
+//--------------------------------------------------------------------+
void test_qtd_structure(void)
{
TEST_ASSERT_EQUAL( 0, offsetof(ehci_qtd_t, next));
@@ -198,6 +203,38 @@ void test_sitd_structure(void)
}
//--------------------------------------------------------------------+
+// EHCI Register Interface
+//--------------------------------------------------------------------+
+void test_register_offset(void)
+{
+ TEST_ASSERT_EQUAL( 0x00, offsetof(ehci_registers_t, usb_cmd));
+ TEST_ASSERT_EQUAL( 0x04, offsetof(ehci_registers_t, usb_sts));
+ TEST_ASSERT_EQUAL( 0x08, offsetof(ehci_registers_t, usb_int_enable));
+ TEST_ASSERT_EQUAL( 0x0C, offsetof(ehci_registers_t, frame_index));
+ TEST_ASSERT_EQUAL( 0x10, offsetof(ehci_registers_t, ctrl_ds_seg));
+ TEST_ASSERT_EQUAL( 0x14, offsetof(ehci_registers_t, periodic_list_base));
+ TEST_ASSERT_EQUAL( 0x18, offsetof(ehci_registers_t, async_list_base));
+ TEST_ASSERT_EQUAL( 0x1C, offsetof(ehci_registers_t, tt_control)); // NXP specific
+ TEST_ASSERT_EQUAL( 0x40, offsetof(ehci_registers_t, config_flag)); // NXP not used
+ TEST_ASSERT_EQUAL( 0x44, offsetof(ehci_registers_t, portsc));
+}
+
+void test_register_usbcmd(void)
+{
+ TEST_ASSERT_EQUAL( 0 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, run_stop) );
+ TEST_ASSERT_EQUAL( 1 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, reset) );
+ TEST_ASSERT_EQUAL( 2 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, framelist_size) );
+ TEST_ASSERT_EQUAL( 4 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, periodic_enable) );
+ TEST_ASSERT_EQUAL( 5 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, async_enable) );
+ TEST_ASSERT_EQUAL( 6 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, int_advacne_async) );
+ TEST_ASSERT_EQUAL( 7 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, light_reset) );
+ TEST_ASSERT_EQUAL( 8 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, async_park) );
+ TEST_ASSERT_EQUAL( 11 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, async_park_enable) );
+ TEST_ASSERT_EQUAL( 15 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, nxp_framelist_size_msb) );
+ TEST_ASSERT_EQUAL( 16 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, int_threshold) );
+}
+
+//--------------------------------------------------------------------+
// Helper
//--------------------------------------------------------------------+
int8_t first_pos_of_high_bit(uint32_t value)