add cardinality_of function to return number of set bits
refractor tests in ehci
This commit is contained in:
@@ -44,16 +44,17 @@
|
||||
#include "binary.h"
|
||||
|
||||
#include "hal.h"
|
||||
#include "mock_osal.h"
|
||||
#include "hcd.h"
|
||||
#include "mock_usbh_hcd.h"
|
||||
#include "ehci.h"
|
||||
|
||||
#include "ehci_controller_fake.h"
|
||||
#include "mock_osal.h"
|
||||
#include "mock_usbh_hcd.h"
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Setup/Teardown + helper declare
|
||||
|
||||
@@ -36,31 +36,32 @@
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unity.h"
|
||||
#include "tusb_option.h"
|
||||
#include "errors.h"
|
||||
#include "binary.h"
|
||||
|
||||
#include "hal.h"
|
||||
#include "mock_osal.h"
|
||||
#include "hcd.h"
|
||||
#include "mock_usbh_hcd.h"
|
||||
#include "ehci.h"
|
||||
|
||||
#include "ehci_controller_fake.h"
|
||||
#include "mock_osal.h"
|
||||
#include "mock_usbh_hcd.h"
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t hostid;
|
||||
ehci_registers_t * regs;
|
||||
static uint8_t hostid;
|
||||
static ehci_registers_t * regs;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
ehci_controller_init();
|
||||
TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, hcd_init());
|
||||
|
||||
hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX;
|
||||
regs = get_operational_register(hostid);
|
||||
|
||||
hcd_init();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
|
||||
@@ -36,17 +36,19 @@
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unity.h"
|
||||
#include "tusb_option.h"
|
||||
#include "errors.h"
|
||||
#include "binary.h"
|
||||
|
||||
#include "hal.h"
|
||||
#include "mock_osal.h"
|
||||
#include "hcd.h"
|
||||
#include "mock_usbh_hcd.h"
|
||||
#include "ehci.h"
|
||||
|
||||
#include "ehci_controller_fake.h"
|
||||
#include "mock_osal.h"
|
||||
#include "mock_usbh_hcd.h"
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
@@ -318,7 +320,7 @@ void test_ehci_data(void)
|
||||
TEST_ASSERT_BITS_LOW(4096-1, (uint32_t)get_period_frame_list(hostid) );
|
||||
}
|
||||
|
||||
TEST_IGNORE();
|
||||
// TODO more tests on ehci_data
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unity.h"
|
||||
#include "tusb_option.h"
|
||||
#include "errors.h"
|
||||
@@ -51,16 +52,15 @@
|
||||
#include "ehci.h"
|
||||
#include "ehci_controller_fake.h"
|
||||
|
||||
#define _TINY_USB_SOURCE_FILE_
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
uint8_t const control_max_packet_size = 64;
|
||||
uint8_t hub_addr;
|
||||
uint8_t hub_port;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
ehci_registers_t * regs;
|
||||
ehci_qhd_t *async_head;
|
||||
ehci_qhd_t *period_head_arr;
|
||||
static uint8_t const control_max_packet_size = 64;
|
||||
static uint8_t hub_addr;
|
||||
static uint8_t hub_port;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
static ehci_registers_t * regs;
|
||||
static ehci_qhd_t *async_head;
|
||||
static ehci_qhd_t *period_head_arr;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
|
||||
@@ -50,12 +50,12 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
|
||||
ehci_qhd_t *async_head;
|
||||
static ehci_qhd_t *async_head;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Setup/Teardown + helper declare
|
||||
|
||||
@@ -50,16 +50,16 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
uint8_t xfer_data [18000]; // 18K to test buffer pointer list
|
||||
uint8_t data2[100];
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
static uint8_t xfer_data [18000]; // 18K to test buffer pointer list
|
||||
static uint8_t data2[100];
|
||||
|
||||
ehci_qhd_t *async_head;
|
||||
ehci_qhd_t *p_qhd_bulk;
|
||||
pipe_handle_t pipe_hdl_bulk;
|
||||
static ehci_qhd_t *async_head;
|
||||
static ehci_qhd_t *p_qhd_bulk;
|
||||
static pipe_handle_t pipe_hdl_bulk;
|
||||
|
||||
tusb_descriptor_endpoint_t const desc_ept_bulk_in =
|
||||
{
|
||||
|
||||
@@ -50,14 +50,14 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const control_max_packet_size = 64;
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
static uint8_t const control_max_packet_size = 64;
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
|
||||
ehci_qhd_t *async_head;
|
||||
ehci_qhd_t *p_control_qhd;
|
||||
static ehci_qhd_t *async_head;
|
||||
static ehci_qhd_t *p_control_qhd;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Setup/Teardown + helper declare
|
||||
|
||||
@@ -50,19 +50,19 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const control_max_packet_size = 64;
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
uint8_t xfer_data [100];
|
||||
static uint8_t const control_max_packet_size = 64;
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
static uint8_t xfer_data [100];
|
||||
|
||||
ehci_qhd_t *async_head;
|
||||
ehci_qhd_t *p_control_qhd;
|
||||
static ehci_qhd_t *async_head;
|
||||
static ehci_qhd_t *p_control_qhd;
|
||||
|
||||
ehci_qtd_t *p_setup;
|
||||
ehci_qtd_t *p_data;
|
||||
ehci_qtd_t *p_status;
|
||||
static ehci_qtd_t *p_setup;
|
||||
static ehci_qtd_t *p_data;
|
||||
static ehci_qtd_t *p_status;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Setup/Teardown + helper declare
|
||||
|
||||
@@ -50,15 +50,15 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
|
||||
ehci_qhd_t *period_head_arr;
|
||||
static ehci_qhd_t *period_head_arr;
|
||||
|
||||
ehci_qhd_t *p_int_qhd;
|
||||
pipe_handle_t pipe_hdl;
|
||||
static ehci_qhd_t *p_int_qhd;
|
||||
static pipe_handle_t pipe_hdl;
|
||||
|
||||
uint8_t count_set_bits(uint8_t x);
|
||||
|
||||
|
||||
@@ -50,18 +50,18 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
uint8_t xfer_data [100];
|
||||
uint8_t data2[100];
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
static uint8_t xfer_data [100];
|
||||
static uint8_t data2[100];
|
||||
|
||||
ehci_qhd_t *period_head_arr;
|
||||
ehci_qhd_t *p_qhd_interrupt;
|
||||
pipe_handle_t pipe_hdl_interrupt;
|
||||
static ehci_qhd_t *period_head_arr;
|
||||
static ehci_qhd_t *p_qhd_interrupt;
|
||||
static pipe_handle_t pipe_hdl_interrupt;
|
||||
|
||||
tusb_descriptor_endpoint_t const desc_ept_interrupt_in =
|
||||
static tusb_descriptor_endpoint_t const desc_ept_interrupt_in =
|
||||
{
|
||||
.bLength = sizeof(tusb_descriptor_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
@@ -71,7 +71,7 @@ tusb_descriptor_endpoint_t const desc_ept_interrupt_in =
|
||||
.bInterval = 2
|
||||
};
|
||||
|
||||
tusb_descriptor_endpoint_t const desc_ept_interupt_out =
|
||||
static tusb_descriptor_endpoint_t const desc_ept_interupt_out =
|
||||
{
|
||||
.bLength = sizeof(tusb_descriptor_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
|
||||
@@ -50,12 +50,12 @@
|
||||
|
||||
usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
|
||||
|
||||
uint8_t const hub_addr = 2;
|
||||
uint8_t const hub_port = 2;
|
||||
uint8_t dev_addr;
|
||||
uint8_t hostid;
|
||||
static uint8_t const hub_addr = 2;
|
||||
static uint8_t const hub_port = 2;
|
||||
static uint8_t dev_addr;
|
||||
static uint8_t hostid;
|
||||
|
||||
ehci_qhd_t *period_head_arr;
|
||||
static ehci_qhd_t *period_head_arr;
|
||||
//--------------------------------------------------------------------+
|
||||
// Setup/Teardown + helper declare
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user