mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-07 18:02:15 +08:00
爲imxrt系列添加usb host驅動 (#4377)
* adding fsl_os_abstraction porting * port usbh to imxrt Co-authored-by: guo <guozhanxin@rt-thread.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_OS_ABSTRACTION_CONFIG_H_
|
||||
#define _FSL_OS_ABSTRACTION_CONFIG_H_
|
||||
|
||||
#ifndef gMainThreadStackSize_c
|
||||
#define gMainThreadStackSize_c 1024
|
||||
#endif
|
||||
|
||||
#ifndef gMainThreadPriority_c
|
||||
#define gMainThreadPriority_c 1
|
||||
#endif
|
||||
|
||||
#ifndef gTaskMultipleInstancesManagement_c
|
||||
#define gTaskMultipleInstancesManagement_c 0
|
||||
#endif
|
||||
|
||||
/*! @brief Definition to determine whether enable OSA's TASK module. */
|
||||
#ifndef OSA_USED
|
||||
#ifndef FSL_OSA_TASK_ENABLE
|
||||
#define FSL_OSA_TASK_ENABLE 0U
|
||||
#endif
|
||||
#else
|
||||
#if defined(FSL_OSA_TASK_ENABLE)
|
||||
#undef FSL_OSA_TASK_ENABLE
|
||||
#endif
|
||||
#define FSL_OSA_TASK_ENABLE 1U
|
||||
#endif /* OSA_USED */
|
||||
|
||||
#endif /* _FSL_OS_ABSTRACTION_CONFIG_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,130 @@
|
||||
/*! *********************************************************************************
|
||||
* Copyright (c) 2013-2014, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* ile
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
********************************************************************************** */
|
||||
#if !defined(__FSL_OS_ABSTRACTION_RTTHREAD_H__)
|
||||
#define __FSL_OS_ABSTRACTION_RTTHREAD_H__
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
/**
|
||||
* Workaround to disable MISRA C message suppress warnings for IAR compiler.
|
||||
*/
|
||||
// http://supp.iar.com/Support/?note=24725
|
||||
|
||||
#define MISRAC_DISABLE \
|
||||
_Pragma( \
|
||||
"diag_suppress= \
|
||||
Pm001,Pm002,Pm003,Pm004,Pm005,Pm006,Pm007,Pm008,Pm009,Pm010,Pm011,\
|
||||
Pm012,Pm013,Pm014,Pm015,Pm016,Pm017,Pm018,Pm019,Pm020,Pm021,Pm022,\
|
||||
Pm023,Pm024,Pm025,Pm026,Pm027,Pm028,Pm029,Pm030,Pm031,Pm032,Pm033,\
|
||||
Pm034,Pm035,Pm036,Pm037,Pm038,Pm039,Pm040,Pm041,Pm042,Pm043,Pm044,\
|
||||
Pm045,Pm046,Pm047,Pm048,Pm049,Pm050,Pm051,Pm052,Pm053,Pm054,Pm055,\
|
||||
Pm056,Pm057,Pm058,Pm059,Pm060,Pm061,Pm062,Pm063,Pm064,Pm065,Pm066,\
|
||||
Pm067,Pm068,Pm069,Pm070,Pm071,Pm072,Pm073,Pm074,Pm075,Pm076,Pm077,\
|
||||
Pm078,Pm079,Pm080,Pm081,Pm082,Pm083,Pm084,Pm085,Pm086,Pm087,Pm088,\
|
||||
Pm089,Pm090,Pm091,Pm092,Pm093,Pm094,Pm095,Pm096,Pm097,Pm098,Pm099,\
|
||||
Pm100,Pm101,Pm102,Pm103,Pm104,Pm105,Pm106,Pm107,Pm108,Pm109,Pm110,\
|
||||
Pm111,Pm112,Pm113,Pm114,Pm115,Pm116,Pm117,Pm118,Pm119,Pm120,Pm121,\
|
||||
Pm122,Pm123,Pm124,Pm125,Pm126,Pm127,Pm128,Pm129,Pm130,Pm131,Pm132,\
|
||||
Pm133,Pm134,Pm135,Pm136,Pm137,Pm138,Pm139,Pm140,Pm141,Pm142,Pm143,\
|
||||
Pm144,Pm145,Pm146,Pm147,Pm148,Pm149,Pm150,Pm151,Pm152,Pm153,Pm154,\
|
||||
Pm155")
|
||||
|
||||
#define MISRAC_ENABLE \
|
||||
_Pragma( \
|
||||
"diag_default= \
|
||||
Pm001,Pm002,Pm003,Pm004,Pm005,Pm006,Pm007,Pm008,Pm009,Pm010,Pm011,\
|
||||
Pm012,Pm013,Pm014,Pm015,Pm016,Pm017,Pm018,Pm019,Pm020,Pm021,Pm022,\
|
||||
Pm023,Pm024,Pm025,Pm026,Pm027,Pm028,Pm029,Pm030,Pm031,Pm032,Pm033,\
|
||||
Pm034,Pm035,Pm036,Pm037,Pm038,Pm039,Pm040,Pm041,Pm042,Pm043,Pm044,\
|
||||
Pm045,Pm046,Pm047,Pm048,Pm049,Pm050,Pm051,Pm052,Pm053,Pm054,Pm055,\
|
||||
Pm056,Pm057,Pm058,Pm059,Pm060,Pm061,Pm062,Pm063,Pm064,Pm065,Pm066,\
|
||||
Pm067,Pm068,Pm069,Pm070,Pm071,Pm072,Pm073,Pm074,Pm075,Pm076,Pm077,\
|
||||
Pm078,Pm079,Pm080,Pm081,Pm082,Pm083,Pm084,Pm085,Pm086,Pm087,Pm088,\
|
||||
Pm089,Pm090,Pm091,Pm092,Pm093,Pm094,Pm095,Pm096,Pm097,Pm098,Pm099,\
|
||||
Pm100,Pm101,Pm102,Pm103,Pm104,Pm105,Pm106,Pm107,Pm108,Pm109,Pm110,\
|
||||
Pm111,Pm112,Pm113,Pm114,Pm115,Pm116,Pm117,Pm118,Pm119,Pm120,Pm121,\
|
||||
Pm122,Pm123,Pm124,Pm125,Pm126,Pm127,Pm128,Pm129,Pm130,Pm131,Pm132,\
|
||||
Pm133,Pm134,Pm135,Pm136,Pm137,Pm138,Pm139,Pm140,Pm141,Pm142,Pm143,\
|
||||
Pm144,Pm145,Pm146,Pm147,Pm148,Pm149,Pm150,Pm151,Pm152,Pm153,Pm154,\
|
||||
Pm155")
|
||||
#else
|
||||
/* Empty MISRA C macros for other toolchains. */
|
||||
#define MISRAC_DISABLE
|
||||
#define MISRAC_ENABLE
|
||||
#endif
|
||||
|
||||
MISRAC_DISABLE
|
||||
#include <rtthread.h>
|
||||
MISRAC_ENABLE
|
||||
|
||||
/*!
|
||||
* @addtogroup os_abstraction_free_rtos
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Declarations
|
||||
******************************************************************************/
|
||||
/*! @brief Type for a task handler, returned by the OSA_TaskCreate function. */
|
||||
typedef rt_thread_t task_handler_t;
|
||||
|
||||
/*! @brief Type for a task stack.*/
|
||||
typedef rt_uint32_t task_stack_t;
|
||||
|
||||
/*! @brief Type for task parameter */
|
||||
typedef void *task_param_t;
|
||||
|
||||
/*! @brief Type for an event flags object.*/
|
||||
typedef rt_uint32_t event_flags_t;
|
||||
|
||||
/*! @brief Constant to pass as timeout value in order to wait indefinitely. */
|
||||
#define OSA_WAIT_FOREVER 0xFFFFFFFFU
|
||||
|
||||
/*! @brief OSA's time range in millisecond, OSA time wraps if exceeds this value. */
|
||||
#define FSL_OSA_TIME_RANGE 0xFFFFFFFFU
|
||||
|
||||
/*! @brief The default interrupt handler installed in vector table. */
|
||||
#define OSA_DEFAULT_INT_HANDLER ((osa_int_handler_t)(&DefaultISR))
|
||||
|
||||
extern void DefaultISR(void);
|
||||
|
||||
/*!
|
||||
* @name Thread management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief To provide unified task piority for upper layer, OSA layer makes conversion.
|
||||
*/
|
||||
#define PRIORITY_OSA_TO_RTOS(osa_prio) ((UBaseType_t)configMAX_PRIORITIES - (osa_prio)-2U)
|
||||
#define PRIORITY_RTOS_TO_OSA(rtos_prio) ((UBaseType_t)configMAX_PRIORITIES - (rtos_prio)-2U)
|
||||
|
||||
/* @}*/
|
||||
|
||||
/*!
|
||||
* @name Message queues
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief This macro statically reserves the memory required for the queue.
|
||||
*
|
||||
* @param name Identifier for the memory region.
|
||||
* @param number Number of elements in the queue.
|
||||
* @param size Size of every elements in words.
|
||||
*/
|
||||
#define MSG_QUEUE_DECLARE(name, number, size) msg_queue_t *name = NULL
|
||||
|
||||
/* @}*/
|
||||
|
||||
/*! @}*/
|
||||
/*! @}*/
|
||||
/*! @}*/
|
||||
|
||||
#endif // __FSL_OS_ABSTRACTION_RTTHREAD_H__
|
||||
475
bsp/imxrt/libraries/MIMXRT1050/MIMXRT1052/drivers/generic_list.c
Normal file
475
bsp/imxrt/libraries/MIMXRT1050/MIMXRT1052/drivers/generic_list.c
Normal file
@@ -0,0 +1,475 @@
|
||||
/*
|
||||
* Copyright 2018-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Include
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
#include "generic_list.h"
|
||||
|
||||
static list_status_t LIST_Error_Check(list_handle_t list, list_element_handle_t newElement)
|
||||
{
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
list_element_handle_t element = list->head;
|
||||
|
||||
if ((list->max != 0U) && (list->max == list->size))
|
||||
{
|
||||
listStatus = kLIST_Full; /*List is full*/
|
||||
}
|
||||
else
|
||||
{
|
||||
while (element != NULL) /*Scan list*/
|
||||
{
|
||||
/* Determine if element is duplicated */
|
||||
if (element == newElement)
|
||||
{
|
||||
listStatus = kLIST_DuplicateError;
|
||||
break;
|
||||
}
|
||||
element = element->next;
|
||||
}
|
||||
}
|
||||
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public functions
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
/*! *********************************************************************************
|
||||
* \brief Initialises the list descriptor.
|
||||
*
|
||||
* \param[in] list - LIST_ handle to init.
|
||||
* max - Maximum number of elements in list. 0 for unlimited.
|
||||
*
|
||||
* \return void.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
void LIST_Init(list_handle_t list, uint32_t max)
|
||||
{
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
list->max = (uint16_t)max;
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets the list that contains the given element.
|
||||
*
|
||||
* \param[in] element - Handle of the element.
|
||||
*
|
||||
* \return NULL if element is orphan.
|
||||
* Handle of the list the element is inserted into.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_handle_t LIST_GetList(list_element_handle_t element)
|
||||
{
|
||||
return element->list;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Links element to the tail of the list.
|
||||
*
|
||||
* \param[in] list - ID of list to insert into.
|
||||
* element - element to add
|
||||
*
|
||||
* \return kLIST_Full if list is full.
|
||||
* kLIST_Ok if insertion was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_AddTail(list_handle_t list, list_element_handle_t element)
|
||||
{
|
||||
uint32_t regPrimask = DisableGlobalIRQ();
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
|
||||
listStatus = LIST_Error_Check(list, element);
|
||||
if (listStatus == kLIST_Ok) /* Avoiding list status error */
|
||||
{
|
||||
if (list->size == 0U)
|
||||
{
|
||||
list->head = element;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->tail->next = element;
|
||||
}
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
#else
|
||||
element->prev = list->tail;
|
||||
#endif
|
||||
element->list = list;
|
||||
element->next = NULL;
|
||||
list->tail = element;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
EnableGlobalIRQ(regPrimask);
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Links element to the head of the list.
|
||||
*
|
||||
* \param[in] list - ID of list to insert into.
|
||||
* element - element to add
|
||||
*
|
||||
* \return kLIST_Full if list is full.
|
||||
* kLIST_Ok if insertion was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_AddHead(list_handle_t list, list_element_handle_t element)
|
||||
{
|
||||
uint32_t regPrimask = DisableGlobalIRQ();
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
|
||||
listStatus = LIST_Error_Check(list, element);
|
||||
if (listStatus == kLIST_Ok) /* Avoiding list status error */
|
||||
{
|
||||
/* Links element to the head of the list */
|
||||
if (list->size == 0U)
|
||||
{
|
||||
list->tail = element;
|
||||
}
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
#else
|
||||
else
|
||||
{
|
||||
list->head->prev = element;
|
||||
}
|
||||
element->prev = NULL;
|
||||
#endif
|
||||
element->list = list;
|
||||
element->next = list->head;
|
||||
list->head = element;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
EnableGlobalIRQ(regPrimask);
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Unlinks element from the head of the list.
|
||||
*
|
||||
* \param[in] list - ID of list to remove from.
|
||||
*
|
||||
* \return NULL if list is empty.
|
||||
* ID of removed element(pointer) if removal was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_RemoveHead(list_handle_t list)
|
||||
{
|
||||
list_element_handle_t element;
|
||||
|
||||
uint32_t regPrimask = DisableGlobalIRQ();
|
||||
|
||||
if ((NULL == list) || (list->size == 0U))
|
||||
{
|
||||
element = NULL; /*LIST_ is empty*/
|
||||
}
|
||||
else
|
||||
{
|
||||
element = list->head;
|
||||
list->size--;
|
||||
if (list->size == 0U)
|
||||
{
|
||||
list->tail = NULL;
|
||||
}
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
#else
|
||||
else
|
||||
{
|
||||
element->next->prev = NULL;
|
||||
}
|
||||
#endif
|
||||
element->list = NULL;
|
||||
list->head = element->next; /*Is NULL if element is head*/
|
||||
}
|
||||
|
||||
EnableGlobalIRQ(regPrimask);
|
||||
return element;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets head element ID.
|
||||
*
|
||||
* \param[in] list - ID of list.
|
||||
*
|
||||
* \return NULL if list is empty.
|
||||
* ID of head element if list is not empty.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_GetHead(list_handle_t list)
|
||||
{
|
||||
return list->head;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets next element ID.
|
||||
*
|
||||
* \param[in] element - ID of the element.
|
||||
*
|
||||
* \return NULL if element is tail.
|
||||
* ID of next element if exists.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_GetNext(list_element_handle_t element)
|
||||
{
|
||||
return element->next;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets previous element ID.
|
||||
*
|
||||
* \param[in] element - ID of the element.
|
||||
*
|
||||
* \return NULL if element is head.
|
||||
* ID of previous element if exists.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_element_handle_t LIST_GetPrev(list_element_handle_t element)
|
||||
{
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
return NULL;
|
||||
#else
|
||||
return element->prev;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Unlinks an element from its list.
|
||||
*
|
||||
* \param[in] element - ID of the element to remove.
|
||||
*
|
||||
* \return kLIST_OrphanElement if element is not part of any list.
|
||||
* kLIST_Ok if removal was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_RemoveElement(list_element_handle_t element)
|
||||
{
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
uint32_t regPrimask = DisableGlobalIRQ();
|
||||
|
||||
if (element->list == NULL)
|
||||
{
|
||||
listStatus = kLIST_OrphanElement; /*Element was previusly removed or never added*/
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
list_element_handle_t element_list = element->list->head;
|
||||
while (element_list)
|
||||
{
|
||||
if (element->list->head == element)
|
||||
{
|
||||
element->list->head = element_list->next;
|
||||
break;
|
||||
}
|
||||
if (element_list->next == element)
|
||||
{
|
||||
element_list->next = element->next;
|
||||
break;
|
||||
}
|
||||
element_list = element_list->next;
|
||||
}
|
||||
#else
|
||||
if (element->prev == NULL) /*Element is head or solo*/
|
||||
{
|
||||
element->list->head = element->next; /*is null if solo*/
|
||||
}
|
||||
if (element->next == NULL) /*Element is tail or solo*/
|
||||
{
|
||||
element->list->tail = element->prev; /*is null if solo*/
|
||||
}
|
||||
if (element->prev != NULL) /*Element is not head*/
|
||||
{
|
||||
element->prev->next = element->next;
|
||||
}
|
||||
if (element->next != NULL) /*Element is not tail*/
|
||||
{
|
||||
element->next->prev = element->prev;
|
||||
}
|
||||
#endif
|
||||
element->list->size--;
|
||||
element->list = NULL;
|
||||
}
|
||||
|
||||
EnableGlobalIRQ(regPrimask);
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Links an element in the previous position relative to a given member
|
||||
* of a list.
|
||||
*
|
||||
* \param[in] element - ID of a member of a list.
|
||||
* newElement - new element to insert before the given member.
|
||||
*
|
||||
* \return kLIST_OrphanElement if element is not part of any list.
|
||||
* kLIST_Full if list is full.
|
||||
* kLIST_Ok if insertion was successful.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
list_status_t LIST_AddPrevElement(list_element_handle_t element, list_element_handle_t newElement)
|
||||
{
|
||||
list_status_t listStatus = kLIST_Ok;
|
||||
uint32_t regPrimask = DisableGlobalIRQ();
|
||||
|
||||
if (element->list == NULL)
|
||||
{
|
||||
listStatus = kLIST_OrphanElement; /*Element was previusly removed or never added*/
|
||||
}
|
||||
else
|
||||
{
|
||||
listStatus = LIST_Error_Check(element->list, newElement);
|
||||
if (listStatus == kLIST_Ok)
|
||||
{
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
list_element_handle_t element_list = element->list->head;
|
||||
while (element_list)
|
||||
{
|
||||
if ((element_list->next == element) || (element_list == element))
|
||||
{
|
||||
if (element_list == element)
|
||||
{
|
||||
element->list->head = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
element_list->next = newElement;
|
||||
}
|
||||
newElement->list = element->list;
|
||||
newElement->next = element;
|
||||
element->list->size++;
|
||||
break;
|
||||
}
|
||||
element_list = element_list->next;
|
||||
}
|
||||
|
||||
#else
|
||||
if (element->prev == NULL) /*Element is list head*/
|
||||
{
|
||||
element->list->head = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
element->prev->next = newElement;
|
||||
}
|
||||
newElement->list = element->list;
|
||||
element->list->size++;
|
||||
newElement->next = element;
|
||||
newElement->prev = element->prev;
|
||||
element->prev = newElement;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
EnableGlobalIRQ(regPrimask);
|
||||
return listStatus;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets the current size of a list.
|
||||
*
|
||||
* \param[in] list - ID of the list.
|
||||
*
|
||||
* \return Current size of the list.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
uint32_t LIST_GetSize(list_handle_t list)
|
||||
{
|
||||
return list->size;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Gets the number of free places in the list.
|
||||
*
|
||||
* \param[in] list - ID of the list.
|
||||
*
|
||||
* \return Available size of the list.
|
||||
*
|
||||
* \pre
|
||||
*
|
||||
* \post
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
********************************************************************************** */
|
||||
uint32_t LIST_GetAvailableSize(list_handle_t list)
|
||||
{
|
||||
return ((uint32_t)list->max - (uint32_t)list->size); /*Gets the number of free places in the list*/
|
||||
}
|
||||
203
bsp/imxrt/libraries/MIMXRT1050/MIMXRT1052/drivers/generic_list.h
Normal file
203
bsp/imxrt/libraries/MIMXRT1050/MIMXRT1052/drivers/generic_list.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright 2018-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _GENERIC_LIST_H_
|
||||
#define _GENERIC_LIST_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
/*!
|
||||
* @addtogroup GenericList
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!*********************************************************************************
|
||||
*************************************************************************************
|
||||
* Include
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public macro definitions
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
#ifndef GENERIC_LIST_LIGHT
|
||||
#define GENERIC_LIST_LIGHT (0)
|
||||
#endif
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public type definitions
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
/*! @brief The list status */
|
||||
typedef enum _list_status
|
||||
{
|
||||
kLIST_Ok = kStatus_Success, /*!< Success */
|
||||
kLIST_DuplicateError = MAKE_STATUS(kStatusGroup_LIST, 1), /*!< Duplicate Error */
|
||||
kLIST_Full = MAKE_STATUS(kStatusGroup_LIST, 2), /*!< FULL */
|
||||
kLIST_Empty = MAKE_STATUS(kStatusGroup_LIST, 3), /*!< Empty */
|
||||
kLIST_OrphanElement = MAKE_STATUS(kStatusGroup_LIST, 4), /*!< Orphan Element */
|
||||
kLIST_NotSupport = MAKE_STATUS(kStatusGroup_LIST, 5), /*!< Not Support */
|
||||
} list_status_t;
|
||||
|
||||
/*! @brief The list structure*/
|
||||
typedef struct list_label
|
||||
{
|
||||
struct list_element_tag *head; /*!< list head */
|
||||
struct list_element_tag *tail; /*!< list tail */
|
||||
uint16_t size; /*!< list size */
|
||||
uint16_t max; /*!< list max number of elements */
|
||||
} list_label_t, *list_handle_t;
|
||||
#if (defined(GENERIC_LIST_LIGHT) && (GENERIC_LIST_LIGHT > 0U))
|
||||
/*! @brief The list element*/
|
||||
typedef struct list_element_tag
|
||||
{
|
||||
struct list_element_tag *next; /*!< next list element */
|
||||
struct list_label *list; /*!< pointer to the list */
|
||||
} list_element_t, *list_element_handle_t;
|
||||
#else
|
||||
/*! @brief The list element*/
|
||||
typedef struct list_element_tag
|
||||
{
|
||||
struct list_element_tag *next; /*!< next list element */
|
||||
struct list_element_tag *prev; /*!< previous list element */
|
||||
struct list_label *list; /*!< pointer to the list */
|
||||
} list_element_t, *list_element_handle_t;
|
||||
#endif
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public prototypes
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* _cplusplus */
|
||||
/*!
|
||||
* @brief Initialize the list.
|
||||
*
|
||||
* This function initialize the list.
|
||||
*
|
||||
* @param list - List handle to initialize.
|
||||
* @param max - Maximum number of elements in list. 0 for unlimited.
|
||||
*/
|
||||
void LIST_Init(list_handle_t list, uint32_t max);
|
||||
|
||||
/*!
|
||||
* @brief Gets the list that contains the given element.
|
||||
*
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
* @retval NULL if element is orphan, Handle of the list the element is inserted into.
|
||||
*/
|
||||
list_handle_t LIST_GetList(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Links element to the head of the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
* @param element - Handle of the element.
|
||||
* @retval kLIST_Full if list is full, kLIST_Ok if insertion was successful.
|
||||
*/
|
||||
list_status_t LIST_AddHead(list_handle_t list, list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Links element to the tail of the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
* @param element - Handle of the element.
|
||||
* @retval kLIST_Full if list is full, kLIST_Ok if insertion was successful.
|
||||
*/
|
||||
list_status_t LIST_AddTail(list_handle_t list, list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Unlinks element from the head of the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_RemoveHead(list_handle_t list);
|
||||
|
||||
/*!
|
||||
* @brief Gets head element handle.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_GetHead(list_handle_t list);
|
||||
|
||||
/*!
|
||||
* @brief Gets next element handle for given element handle.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_GetNext(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Gets previous element handle for given element handle.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
*
|
||||
* @retval NULL if list is empty, handle of removed element(pointer) if removal was successful.
|
||||
*/
|
||||
list_element_handle_t LIST_GetPrev(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Unlinks an element from its list.
|
||||
*
|
||||
* @param element - Handle of the element.
|
||||
*
|
||||
* @retval kLIST_OrphanElement if element is not part of any list.
|
||||
* @retval kLIST_Ok if removal was successful.
|
||||
*/
|
||||
list_status_t LIST_RemoveElement(list_element_handle_t element);
|
||||
|
||||
/*!
|
||||
* @brief Links an element in the previous position relative to a given member of a list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
* @param element - Handle of the element.
|
||||
* @param newElement - New element to insert before the given member.
|
||||
*
|
||||
* @retval kLIST_OrphanElement if element is not part of any list.
|
||||
* @retval kLIST_Ok if removal was successful.
|
||||
*/
|
||||
list_status_t LIST_AddPrevElement(list_element_handle_t element, list_element_handle_t newElement);
|
||||
|
||||
/*!
|
||||
* @brief Gets the current size of a list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval Current size of the list.
|
||||
*/
|
||||
uint32_t LIST_GetSize(list_handle_t list);
|
||||
|
||||
/*!
|
||||
* @brief Gets the number of free places in the list.
|
||||
*
|
||||
* @param list - Handle of the list.
|
||||
*
|
||||
* @retval Available size of the list.
|
||||
*/
|
||||
uint32_t LIST_GetAvailableSize(list_handle_t list);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*! @}*/
|
||||
#endif /*_GENERIC_LIST_H_*/
|
||||
@@ -83,6 +83,10 @@ if GetDepend(['BSP_USING_PULSE_ENCODER']):
|
||||
src += ['MIMXRT1052/drivers/fsl_xbara.c']
|
||||
src += ['MIMXRT1052/drivers/fsl_xbarb.c']
|
||||
|
||||
#fsl os abstract files
|
||||
src += ['MIMXRT1052/drivers/fsl_os_abstraction_rtthread.c']
|
||||
src += ['MIMXRT1052/drivers/generic_list.c']
|
||||
|
||||
if rtconfig.CROSS_TOOL == 'gcc':
|
||||
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, ASFLAGS = '$ASFLAGS -D __STARTUP_CLEAR_BSS')
|
||||
else:
|
||||
|
||||
@@ -59,10 +59,14 @@ if GetDepend('BSP_USING_USB_DEVICE'):
|
||||
src += ['drv_usbd.c']
|
||||
src += Glob('usb/device/*.c')
|
||||
|
||||
if GetDepend('BSP_USING_USB_DEVICE'):
|
||||
if GetDepend('BSP_USING_USB_DEVICE') or GetDepend('RT_USING_USB_HOST'):
|
||||
src += Glob('usb/phy/*.c')
|
||||
CPPDEFINES += ['ENDIANNESS']
|
||||
CPPDEFINES += ['ENDIANNESS','USE_RTOS']
|
||||
|
||||
if GetDepend('RT_USING_USB_HOST'):
|
||||
src += ['drv_usbh.c']
|
||||
src += Glob('usb/host/*.c')
|
||||
|
||||
if GetDepend('BSP_USING_PULSE_ENCODER'):
|
||||
src += ['drv_pulse_encoder.c']
|
||||
|
||||
|
||||
730
bsp/imxrt/libraries/drivers/drv_usbh.c
Normal file
730
bsp/imxrt/libraries/drivers/drv_usbh.c
Normal file
File diff suppressed because it is too large
Load Diff
22
bsp/imxrt/libraries/drivers/drv_usbh.h
Normal file
22
bsp/imxrt/libraries/drivers/drv_usbh.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-12-12 ZYH the first version
|
||||
* 2019-12-19 tyustli port to stm32 series
|
||||
* 2021-01-19 Leslie Lee port to imxrt series
|
||||
*/
|
||||
#ifndef __DRV_USBH_H__
|
||||
#define __DRV_USBH_H__
|
||||
#include <rtthread.h>
|
||||
|
||||
#define OTG_PORT 1
|
||||
|
||||
int imxrt_usbh_register(void);
|
||||
|
||||
#endif
|
||||
|
||||
/************* end of file ************/
|
||||
@@ -1,31 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* Copyright 2016 - 2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_H_
|
||||
@@ -68,6 +46,16 @@ typedef enum _usb_host_event
|
||||
kUSB_HostEventDetach, /*!< Device is detached */
|
||||
kUSB_HostEventEnumerationDone, /*!< Device's enumeration is done and the device is supported */
|
||||
kUSB_HostEventNotSupported, /*!< Device's enumeration is done and the device is not supported */
|
||||
/*! Device's enumeration failed due to errors
|
||||
* fail reason is put in the high 2 bytes of callback event code.
|
||||
* kStatus_USB_TransferFailed - the transfer failed.
|
||||
* kStatus_USB_TransferCancel - transfer is canceled by application.
|
||||
* kStatus_USB_Error - parsing descriptor failed, the power cannot satisfy device's requirement,
|
||||
* device addresss allocation failed, transfer is not enough
|
||||
* or the transfer API failed.
|
||||
* kStatus_USB_AllocFail - malloc failed.
|
||||
*/
|
||||
kUSB_HostEventEnumerationFail,
|
||||
#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
|
||||
kUSB_HostEventNotSuspended, /*!< Suspend failed */
|
||||
kUSB_HostEventSuspended, /*!< Suspend successful */
|
||||
@@ -103,7 +91,60 @@ typedef enum _usb_host_dev_info
|
||||
kUSB_HostGetConfigurationDes, /*!< Device's configuration descriptor pointer */
|
||||
kUSB_HostGetConfigurationLength, /*!< Device's configuration descriptor pointer */
|
||||
} usb_host_dev_info_t;
|
||||
/*! @brief Request type */
|
||||
typedef enum _usb_host_request_type
|
||||
{
|
||||
kRequestDevice = 1U, /*!< Control request object is device */
|
||||
kRequestInterface, /*!< Control request object is interface */
|
||||
kRequestEndpoint, /*!< Control request object is endpoint */
|
||||
} usb_host_request_type_t;
|
||||
/*! @brief For USB_REQUEST_STANDARD_GET_DESCRIPTOR and USB_REQUEST_STANDARD_SET_DESCRIPTOR */
|
||||
typedef struct _usb_host_process_descriptor_param
|
||||
{
|
||||
uint8_t descriptorType; /*!< See the usb_spec.h, such as the USB_DESCRIPTOR_TYPE_DEVICE */
|
||||
uint8_t descriptorIndex; /*!< The descriptor index is used to select a specific descriptor (only for configuration
|
||||
and string descriptors) when several descriptors of the same type are implemented in a
|
||||
device */
|
||||
uint8_t languageId; /*!< It specifies the language ID for string descriptors or is reset to zero for other
|
||||
descriptors */
|
||||
uint8_t *descriptorBuffer; /*!< Buffer pointer */
|
||||
uint16_t descriptorLength; /*!< Buffer data length */
|
||||
} usb_host_process_descriptor_param_t;
|
||||
/*! @brief For USB_REQUEST_STANDARD_CLEAR_FEATURE and USB_REQUEST_STANDARD_SET_FEATURE */
|
||||
typedef struct _usb_host_process_feature_param
|
||||
{
|
||||
uint8_t requestType; /*!< See the #usb_host_request_type_t */
|
||||
uint8_t featureSelector; /*!< Set/cleared feature */
|
||||
uint8_t interfaceOrEndpoint; /*!< Interface or end pointer */
|
||||
} usb_host_process_feature_param_t;
|
||||
/*! @brief For USB_REQUEST_STANDARD_GET_INTERFACE */
|
||||
typedef struct _usb_host_get_interface_param
|
||||
{
|
||||
uint8_t interface; /*!< Interface number */
|
||||
uint8_t *alternateInterfaceBuffer; /*!< Save the transfer result */
|
||||
} usb_host_get_interface_param_t;
|
||||
|
||||
/*! @brief For USB_REQUEST_STANDARD_GET_STATUS */
|
||||
typedef struct _usb_host_get_status_param
|
||||
{
|
||||
uint16_t statusSelector; /*!< Interface number, the end pointer number or OTG status selector */
|
||||
uint8_t requestType; /*!< See the #usb_host_request_type_t */
|
||||
uint8_t *statusBuffer; /*!< Save the transfer result */
|
||||
} usb_host_get_status_param_t;
|
||||
|
||||
/*! @brief For USB_REQUEST_STANDARD_SET_INTERFACE */
|
||||
typedef struct _usb_host_set_interface_param
|
||||
{
|
||||
uint8_t alternateSetting; /*!< Alternate setting value */
|
||||
uint8_t interface; /*!< Interface number */
|
||||
} usb_host_set_interface_param_t;
|
||||
|
||||
/*! @brief For USB_REQUEST_STANDARD_SYNCH_FRAME */
|
||||
typedef struct _usb_host_synch_frame_param
|
||||
{
|
||||
uint8_t endpoint; /*!< Endpoint number */
|
||||
uint8_t *frameNumberBuffer; /*!< Frame number data buffer */
|
||||
} usb_host_synch_frame_param_t;
|
||||
/*!
|
||||
* @brief Host callback function typedef.
|
||||
*
|
||||
@@ -243,8 +284,8 @@ typedef struct _usb_host_pipe_init
|
||||
/*! @brief Cancel transfer parameter structure */
|
||||
typedef struct _usb_host_cancel_param
|
||||
{
|
||||
usb_host_pipe_handle pipeHandle; /*!< Cancelling pipe handle*/
|
||||
usb_host_transfer_t *transfer; /*!< Cancelling transfer*/
|
||||
usb_host_pipe_handle pipeHandle; /*!< Canceling pipe handle*/
|
||||
usb_host_transfer_t *transfer; /*!< Canceling transfer*/
|
||||
} usb_host_cancel_param_t;
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -342,7 +383,7 @@ extern usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handl
|
||||
* @retval kStatus_USB_InvalidParameter The deviceHandle instance don't belong to hostHandle instance.
|
||||
*/
|
||||
extern usb_status_t USB_HostRemoveDevice(usb_host_handle hostHandle, usb_device_handle deviceHandle);
|
||||
|
||||
#if (defined(USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI > 0U))
|
||||
/*!
|
||||
* @brief KHCI task function.
|
||||
*
|
||||
@@ -353,7 +394,8 @@ extern usb_status_t USB_HostRemoveDevice(usb_host_handle hostHandle, usb_device_
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostKhciTaskFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U))
|
||||
/*!
|
||||
* @brief EHCI task function.
|
||||
*
|
||||
@@ -364,7 +406,8 @@ extern void USB_HostKhciTaskFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostEhciTaskFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
|
||||
/*!
|
||||
* @brief OHCI task function.
|
||||
*
|
||||
@@ -375,7 +418,8 @@ extern void USB_HostEhciTaskFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostOhciTaskFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
|
||||
/*!
|
||||
* @brief IP3516HS task function.
|
||||
*
|
||||
@@ -386,7 +430,8 @@ extern void USB_HostOhciTaskFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostIp3516HsTaskFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI > 0U))
|
||||
/*!
|
||||
* @brief Device KHCI ISR function.
|
||||
*
|
||||
@@ -395,7 +440,8 @@ extern void USB_HostIp3516HsTaskFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostKhciIsrFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U))
|
||||
/*!
|
||||
* @brief Device EHCI ISR function.
|
||||
*
|
||||
@@ -404,7 +450,8 @@ extern void USB_HostKhciIsrFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostEhciIsrFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
|
||||
/*!
|
||||
* @brief Device OHCI ISR function.
|
||||
*
|
||||
@@ -413,7 +460,8 @@ extern void USB_HostEhciIsrFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostOhciIsrFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
#if (defined(USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
|
||||
/*!
|
||||
* @brief Device IP3516HS ISR function.
|
||||
*
|
||||
@@ -422,7 +470,7 @@ extern void USB_HostOhciIsrFunction(void *hostHandle);
|
||||
* @param[in] hostHandle The host handle.
|
||||
*/
|
||||
extern void USB_HostIp3516HsIsrFunction(void *hostHandle);
|
||||
|
||||
#endif
|
||||
/*! @}*/
|
||||
|
||||
/*!
|
||||
@@ -566,7 +614,7 @@ extern usb_status_t USB_HostFreeTransfer(usb_host_handle hostHandle, usb_host_tr
|
||||
* This function sends the USB standard request packet.
|
||||
*
|
||||
* @param[in] deviceHandle The device handle for control transfer.
|
||||
* @param[in] usbRequest A USB standard request code. Se the usb_spec.h.
|
||||
* @param[in] usbRequest A USB standard request code. See the usb_spec.h.
|
||||
* @param[in] transfer The used transfer.
|
||||
* @param[in] param The parameter structure is different for different request, see
|
||||
* usb_host_framework.h.
|
||||
@@ -694,10 +742,10 @@ extern usb_status_t USB_HostL1ResumeDeviceResquest(usb_host_handle hostHandle,
|
||||
/*!
|
||||
* @brief Update the lpm param.
|
||||
*
|
||||
* The function is used to configuure the lpm token.
|
||||
* The function is used to configure the lpm token.
|
||||
*
|
||||
* @param[in] hostHandle The host handle.
|
||||
* @param[in] lpmParam HIRD vaule and whether enable remotewakeup.
|
||||
* @param[in] lpmParam HIRD value and whether enable remotewakeup.
|
||||
*
|
||||
*/
|
||||
extern usb_status_t USB_HostL1SleepDeviceResquestConfig(usb_host_handle hostHandle, uint8_t *lpmParam);
|
||||
@@ -715,6 +763,19 @@ extern usb_status_t USB_HostUpdateHwTick(usb_host_handle hostHandle, uint64_t ti
|
||||
|
||||
#endif
|
||||
|
||||
#if ((defined(USB_HOST_CONFIG_BATTERY_CHARGER)) && (USB_HOST_CONFIG_BATTERY_CHARGER > 0U))
|
||||
/*!
|
||||
* @brief Set the charger type. It is only supported on RT600 currently.
|
||||
*
|
||||
* The set charger type becomes valid in next attach.
|
||||
*
|
||||
* @param[in] hostHandle The host handle.
|
||||
* @param[in] type.
|
||||
*
|
||||
*/
|
||||
extern usb_status_t USB_HostSetChargerType(usb_host_handle hostHandle, uint8_t type);
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -723,4 +784,4 @@ extern usb_status_t USB_HostUpdateHwTick(usb_host_handle hostHandle, uint64_t ti
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _USB_HOST_H_ */
|
||||
#endif /* _USB_HOST_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_DEV_MNG_H_
|
||||
@@ -79,11 +57,11 @@ typedef struct _usb_host_device_instance
|
||||
usb_descriptor_device_t *deviceDescriptor; /*!< Standard device descriptor */
|
||||
usb_host_pipe_handle controlPipe; /*!< Device's control pipe */
|
||||
uint8_t *configurationDesc; /*!< Configuration descriptor pointer */
|
||||
uint8_t *enumBuffer; /*!< Buffer for enumeration */
|
||||
uint16_t configurationLen; /*!< Configuration descriptor length */
|
||||
uint16_t configurationValue; /*!< Configuration index */
|
||||
uint8_t interfaceStatus[USB_HOST_CONFIG_CONFIGURATION_MAX_INTERFACE]; /*!< Interfaces' status, please reference to
|
||||
#usb_host_interface_state_t */
|
||||
uint8_t *enumBuffer; /*!< Buffer for enumeration */
|
||||
uint8_t configurationValue; /*!< Configuration index */
|
||||
uint8_t state; /*!< Device state for enumeration */
|
||||
uint8_t enumRetries; /*!< Re-enumeration when error in control transfer */
|
||||
uint8_t stallRetries; /*!< Re-transfer when stall */
|
||||
@@ -104,11 +82,10 @@ typedef struct _usb_host_device_instance
|
||||
|
||||
typedef struct _usb_host_enum_process_entry
|
||||
{
|
||||
uint8_t successState; /*!< When the last step is successful, the next state value */
|
||||
uint8_t retryState; /*!< When the last step need retry, the next state value */
|
||||
usb_status_t (*process)(usb_host_device_instance_t *deviceInstance); /*!< When the last step transfer is done, the
|
||||
function is used to process the transfer
|
||||
data */
|
||||
usb_host_device_enumeration_status_t successState; /*!< When the last step is successful, the next state value */
|
||||
usb_host_device_enumeration_status_t retryState; /*!< When the last step need retry, the next state value */
|
||||
/*! When the last step transfer is done, the function is used to process the transfer data */
|
||||
usb_status_t (*process)(usb_host_device_instance_t *deviceInstance, uint32_t dataLength);
|
||||
} usb_host_enum_process_entry_t;
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -175,4 +152,4 @@ extern uint8_t USB_HostGetDeviceAttachState(usb_device_handle deviceHandle);
|
||||
extern usb_status_t USB_HostValidateDevice(usb_host_handle hostHandle, usb_device_handle deviceHandle);
|
||||
|
||||
/*! @}*/
|
||||
#endif /* _USB_HOST_DEV_MNG_H_ */
|
||||
#endif /* _USB_HOST_DEV_MNG_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* Copyright 2016,2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_CONTROLLER_EHCI_H_
|
||||
@@ -39,95 +17,95 @@
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/* EHCI host macros */
|
||||
#define EHCI_HOST_T_INVALID_VALUE (1U)
|
||||
#define EHCI_HOST_POINTER_TYPE_ITD (0x00U)
|
||||
#define EHCI_HOST_POINTER_TYPE_QH (0x00000002U)
|
||||
#define EHCI_HOST_POINTER_TYPE_SITD (0x00000004U)
|
||||
#define EHCI_HOST_POINTER_TYPE_FSTN (0x00000006U)
|
||||
#define EHCI_HOST_POINTER_TYPE_MASK (0x00000006U)
|
||||
#define EHCI_HOST_T_INVALID_VALUE (1U)
|
||||
#define EHCI_HOST_POINTER_TYPE_ITD (0x00U)
|
||||
#define EHCI_HOST_POINTER_TYPE_QH (0x00000002U)
|
||||
#define EHCI_HOST_POINTER_TYPE_SITD (0x00000004U)
|
||||
#define EHCI_HOST_POINTER_TYPE_FSTN (0x00000006U)
|
||||
#define EHCI_HOST_POINTER_TYPE_MASK (0x00000006U)
|
||||
#define EHCI_HOST_POINTER_ADDRESS_MASK (0xFFFFFFE0U)
|
||||
#define EHCI_HOST_PID_OUT (0U)
|
||||
#define EHCI_HOST_PID_IN (1U)
|
||||
#define EHCI_HOST_PID_SETUP (2U)
|
||||
#define EHCI_HOST_PID_OUT (0UL)
|
||||
#define EHCI_HOST_PID_IN (1UL)
|
||||
#define EHCI_HOST_PID_SETUP (2UL)
|
||||
|
||||
#define EHCI_HOST_QH_RL_SHIFT (28U)
|
||||
#define EHCI_HOST_QH_RL_MASK (0xF0000000U)
|
||||
#define EHCI_HOST_QH_C_SHIFT (27U)
|
||||
#define EHCI_HOST_QH_MAX_PACKET_LENGTH_SHIFT (16U)
|
||||
#define EHCI_HOST_QH_MAX_PACKET_LENGTH_MASK (0x07FF0000U)
|
||||
#define EHCI_HOST_QH_H_SHIFT (15U)
|
||||
#define EHCI_HOST_QH_DTC_SHIFT (14U)
|
||||
#define EHCI_HOST_QH_EPS_SHIFT (12U)
|
||||
#define EHCI_HOST_QH_ENDPT_SHIFT (8U)
|
||||
#define EHCI_HOST_QH_I_SHIFT (7U)
|
||||
#define EHCI_HOST_QH_DEVICE_ADDRESS_SHIFT (0U)
|
||||
#define EHCI_HOST_QH_MULT_SHIFT (30U)
|
||||
#define EHCI_HOST_QH_PORT_NUMBER_SHIFT (23U)
|
||||
#define EHCI_HOST_QH_HUB_ADDR_SHIFT (16U)
|
||||
#define EHCI_HOST_QH_UFRAME_CMASK_SHIFT (8U)
|
||||
#define EHCI_HOST_QH_UFRAME_SMASK_SHIFT (0U)
|
||||
#define EHCI_HOST_QH_STATUS_ERROR_MASK (0x0000007EU)
|
||||
#define EHCI_HOST_QH_RL_SHIFT (28U)
|
||||
#define EHCI_HOST_QH_RL_MASK (0xF0000000U)
|
||||
#define EHCI_HOST_QH_C_SHIFT (27U)
|
||||
#define EHCI_HOST_QH_MAX_PACKET_LENGTH_SHIFT (16U)
|
||||
#define EHCI_HOST_QH_MAX_PACKET_LENGTH_MASK (0x07FF0000U)
|
||||
#define EHCI_HOST_QH_H_SHIFT (15U)
|
||||
#define EHCI_HOST_QH_DTC_SHIFT (14U)
|
||||
#define EHCI_HOST_QH_EPS_SHIFT (12U)
|
||||
#define EHCI_HOST_QH_ENDPT_SHIFT (8U)
|
||||
#define EHCI_HOST_QH_I_SHIFT (7U)
|
||||
#define EHCI_HOST_QH_DEVICE_ADDRESS_SHIFT (0U)
|
||||
#define EHCI_HOST_QH_MULT_SHIFT (30U)
|
||||
#define EHCI_HOST_QH_PORT_NUMBER_SHIFT (23U)
|
||||
#define EHCI_HOST_QH_HUB_ADDR_SHIFT (16U)
|
||||
#define EHCI_HOST_QH_UFRAME_CMASK_SHIFT (8U)
|
||||
#define EHCI_HOST_QH_UFRAME_SMASK_SHIFT (0U)
|
||||
#define EHCI_HOST_QH_STATUS_ERROR_MASK (0x0000007EU)
|
||||
#define EHCI_HOST_QH_STATUS_NOSTALL_ERROR_MASK (0x0000003EU)
|
||||
|
||||
#define EHCI_HOST_QTD_DT_SHIFT (31U)
|
||||
#define EHCI_HOST_QTD_DT_MASK (0x80000000U)
|
||||
#define EHCI_HOST_QTD_TOTAL_BYTES_SHIFT (16U)
|
||||
#define EHCI_HOST_QTD_TOTAL_BYTES_MASK (0x7FFF0000U)
|
||||
#define EHCI_HOST_QTD_IOC_MASK (0x00008000U)
|
||||
#define EHCI_HOST_QTD_C_PAGE_SHIFT (12U)
|
||||
#define EHCI_HOST_QTD_CERR_SHIFT (10U)
|
||||
#define EHCI_HOST_QTD_CERR_MAX_VALUE (0x00000003U)
|
||||
#define EHCI_HOST_QTD_PID_CODE_SHIFT (8U)
|
||||
#define EHCI_HOST_QTD_STATUS_SHIFT (0U)
|
||||
#define EHCI_HOST_QTD_CURRENT_OFFSET_MASK (0x00000FFFU)
|
||||
#define EHCI_HOST_QTD_BUFFER_POINTER_SHIFT (12U)
|
||||
#define EHCI_HOST_QTD_STATUS_ACTIVE_MASK (0x00000080U)
|
||||
#define EHCI_HOST_QTD_STATUS_MASK (0x000000ffU)
|
||||
#define EHCI_HOST_QTD_STATUS_ERROR_MASK (0x0000007EU)
|
||||
#define EHCI_HOST_QTD_DT_SHIFT (31U)
|
||||
#define EHCI_HOST_QTD_DT_MASK (0x80000000U)
|
||||
#define EHCI_HOST_QTD_TOTAL_BYTES_SHIFT (16U)
|
||||
#define EHCI_HOST_QTD_TOTAL_BYTES_MASK (0x7FFF0000U)
|
||||
#define EHCI_HOST_QTD_IOC_MASK (0x00008000U)
|
||||
#define EHCI_HOST_QTD_C_PAGE_SHIFT (12U)
|
||||
#define EHCI_HOST_QTD_CERR_SHIFT (10U)
|
||||
#define EHCI_HOST_QTD_CERR_MAX_VALUE (0x00000003UL)
|
||||
#define EHCI_HOST_QTD_PID_CODE_SHIFT (8U)
|
||||
#define EHCI_HOST_QTD_STATUS_SHIFT (0U)
|
||||
#define EHCI_HOST_QTD_CURRENT_OFFSET_MASK (0x00000FFFU)
|
||||
#define EHCI_HOST_QTD_BUFFER_POINTER_SHIFT (12U)
|
||||
#define EHCI_HOST_QTD_STATUS_ACTIVE_MASK (0x00000080U)
|
||||
#define EHCI_HOST_QTD_STATUS_MASK (0x000000ffU)
|
||||
#define EHCI_HOST_QTD_STATUS_ERROR_MASK (0x0000007EU)
|
||||
#define EHCI_HOST_QTD_STATUS_STALL_ERROR_MASK (0x00000040U)
|
||||
|
||||
#define EHCI_HOST_ITD_STATUS_ACTIVE_MASK (0x80000000U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_LEN_SHIFT (16U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_LEN_MASK (0x0FFF0000U)
|
||||
#define EHCI_HOST_ITD_IOC_SHIFT (15U)
|
||||
#define EHCI_HOST_ITD_PG_SHIFT (12U)
|
||||
#define EHCI_HOST_ITD_STATUS_ACTIVE_MASK (0x80000000U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_LEN_SHIFT (16U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_LEN_MASK (0x0FFF0000U)
|
||||
#define EHCI_HOST_ITD_IOC_SHIFT (15U)
|
||||
#define EHCI_HOST_ITD_PG_SHIFT (12U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_OFFSET_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_OFFSET_MASK (0x00000FFFU)
|
||||
#define EHCI_HOST_ITD_BUFFER_POINTER_SHIFT (12U)
|
||||
#define EHCI_HOST_ITD_ENDPT_SHIFT (8U)
|
||||
#define EHCI_HOST_ITD_DEVICE_ADDRESS_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_MAX_PACKET_SIZE_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_MULT_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_DIRECTION_SHIFT (11U)
|
||||
#define EHCI_HOST_ITD_TRANSACTION_OFFSET_MASK (0x00000FFFU)
|
||||
#define EHCI_HOST_ITD_BUFFER_POINTER_SHIFT (12U)
|
||||
#define EHCI_HOST_ITD_ENDPT_SHIFT (8U)
|
||||
#define EHCI_HOST_ITD_DEVICE_ADDRESS_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_MAX_PACKET_SIZE_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_MULT_SHIFT (0U)
|
||||
#define EHCI_HOST_ITD_DIRECTION_SHIFT (11U)
|
||||
|
||||
#define EHCI_HOST_SITD_STATUS_ACTIVE_MASK (0x00000080U)
|
||||
#define EHCI_HOST_SITD_DIRECTION_SHIFT (31U)
|
||||
#define EHCI_HOST_SITD_PORT_NUMBER_SHIFT (24U)
|
||||
#define EHCI_HOST_SITD_HUB_ADDR_SHIFT (16U)
|
||||
#define EHCI_HOST_SITD_ENDPT_SHIFT (8U)
|
||||
#define EHCI_HOST_SITD_STATUS_ACTIVE_MASK (0x00000080U)
|
||||
#define EHCI_HOST_SITD_DIRECTION_SHIFT (31U)
|
||||
#define EHCI_HOST_SITD_PORT_NUMBER_SHIFT (24U)
|
||||
#define EHCI_HOST_SITD_HUB_ADDR_SHIFT (16U)
|
||||
#define EHCI_HOST_SITD_ENDPT_SHIFT (8U)
|
||||
#define EHCI_HOST_SITD_DEVICE_ADDRESS_SHIFT (0U)
|
||||
#define EHCI_HOST_SITD_CMASK_SHIFT (8U)
|
||||
#define EHCI_HOST_SITD_SMASK_SHIFT (0U)
|
||||
#define EHCI_HOST_SITD_TOTAL_BYTES_SHIFT (16U)
|
||||
#define EHCI_HOST_SITD_TOTAL_BYTES_MASK (0x03FF0000U)
|
||||
#define EHCI_HOST_SITD_TP_SHIFT (3U)
|
||||
#define EHCI_HOST_SITD_TCOUNT_SHIFT (0U)
|
||||
#define EHCI_HOST_SITD_IOC_SHIFT (31U)
|
||||
#define EHCI_HOST_SITD_CMASK_SHIFT (8U)
|
||||
#define EHCI_HOST_SITD_SMASK_SHIFT (0U)
|
||||
#define EHCI_HOST_SITD_TOTAL_BYTES_SHIFT (16U)
|
||||
#define EHCI_HOST_SITD_TOTAL_BYTES_MASK (0x03FF0000U)
|
||||
#define EHCI_HOST_SITD_TP_SHIFT (3U)
|
||||
#define EHCI_HOST_SITD_TCOUNT_SHIFT (0U)
|
||||
#define EHCI_HOST_SITD_IOC_SHIFT (31U)
|
||||
|
||||
/* register related MACROs */
|
||||
#define EHCI_PORTSC1_W1_BITS (0x0000002AU)
|
||||
#define EHCI_PORTSC1_W1_BITS (0x0000002AU)
|
||||
#define EHCI_MAX_UFRAME_VALUE (0x00003FFFU)
|
||||
|
||||
/* task event */
|
||||
#define EHCI_TASK_EVENT_DEVICE_ATTACH (0x01U)
|
||||
#define EHCI_TASK_EVENT_DEVICE_ATTACH (0x01U)
|
||||
#define EHCI_TASK_EVENT_TRANSACTION_DONE (0x02U)
|
||||
#define EHCI_TASK_EVENT_DEVICE_DETACH (0x04U)
|
||||
#define EHCI_TASK_EVENT_PORT_CHANGE (0x08U)
|
||||
#define EHCI_TASK_EVENT_TIMER0 (0x10U)
|
||||
#define EHCI_TASK_EVENT_TIMER1 (0x20U)
|
||||
#define EHCI_TASK_EVENT_DEVICE_DETACH (0x04U)
|
||||
#define EHCI_TASK_EVENT_PORT_CHANGE (0x08U)
|
||||
#define EHCI_TASK_EVENT_TIMER0 (0x10U)
|
||||
#define EHCI_TASK_EVENT_TIMER1 (0x20U)
|
||||
|
||||
#define USB_HostEhciLock() USB_OsaMutexLock(ehciInstance->ehciMutex)
|
||||
#define USB_HostEhciUnlock() USB_OsaMutexUnlock(ehciInstance->ehciMutex)
|
||||
#define USB_HostEhciLock() (void)OSA_MutexLock(ehciInstance->ehciMutex, USB_OSA_WAIT_TIMEOUT)
|
||||
#define USB_HostEhciUnlock() (void)OSA_MutexUnlock(ehciInstance->ehciMutex)
|
||||
|
||||
/*******************************************************************************
|
||||
* KHCI driver public structures, enumerations, macros, functions
|
||||
@@ -144,6 +122,8 @@
|
||||
#define USB_HOST_EHCI_PORT_CONNECT_DEBOUNCE_DELAY (101U)
|
||||
/*! @brief Delay for port reset */
|
||||
#define USB_HOST_EHCI_PORT_RESET_DELAY (11U)
|
||||
/*! @brief The MAX continuous transfers that application can send. */
|
||||
#define USB_HOST_EHCI_ISO_MAX_CONTINUOUS_TRANSFER (8U)
|
||||
/*! @brief The SITD inserts a frame interval for putting more SITD continuously.
|
||||
* There is an interval when an application sends two FS/LS ISO transfers.
|
||||
* When the interval is less than the macro, the two transfers are continuous in the frame list. Otherwise, the two
|
||||
@@ -171,7 +151,7 @@
|
||||
*/
|
||||
#define USB_HOST_EHCI_ISO_BOUNCE_UFRAME_NUMBER (16U)
|
||||
/*! @brief Control or bulk transaction timeout value (unit: 100 ms) */
|
||||
#define USB_HOST_EHCI_CONTROL_BULK_TIME_OUT_VALUE (20U)
|
||||
#define USB_HOST_EHCI_CONTROL_BULK_TIME_OUT_VALUE (50U)
|
||||
|
||||
#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
|
||||
typedef enum _bus_ehci_suspend_request_state
|
||||
@@ -323,8 +303,10 @@ typedef struct _usb_host_ehci_instance
|
||||
usb_host_ehci_pipe_t *ehciPipeIndexBase; /*!< Pipe buffer's start pointer*/
|
||||
usb_host_ehci_pipe_t *ehciPipeList; /*!< Idle pipe list pointer*/
|
||||
usb_host_ehci_pipe_t *ehciRunningPipeList; /*!< Running pipe list pointer*/
|
||||
usb_osa_mutex_handle ehciMutex; /*!< EHCI mutex*/
|
||||
usb_osa_event_handle taskEventHandle; /*!< EHCI task event*/
|
||||
osa_mutex_handle_t ehciMutex; /*!< EHCI mutex*/
|
||||
uint32_t mutexBuffer[(OSA_MUTEX_HANDLE_SIZE + 3) / 4]; /*!< The mutex buffer. */
|
||||
osa_event_handle_t taskEventHandle; /*!< EHCI task event*/
|
||||
uint32_t taskEventHandleBuffer[(OSA_EVENT_HANDLE_SIZE + 3) / 4]; /*!< EHCI task event handle buffer*/
|
||||
#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
|
||||
uint64_t matchTick;
|
||||
USBPHY_Type *registerPhyBase; /*!< The base address of the PHY register */
|
||||
@@ -355,6 +337,10 @@ typedef struct _usb_host_ehci_data
|
||||
#endif
|
||||
#if ((defined(USB_HOST_CONFIG_EHCI_MAX_ITD)) && (USB_HOST_CONFIG_EHCI_MAX_ITD > 0U))
|
||||
usb_host_ehci_itd_t ehciItd[USB_HOST_CONFIG_EHCI_MAX_ITD]; /*!< Idle ITD list array*/
|
||||
/* add additional 32bytes because the itd cannot cross over 4K boundary,
|
||||
* If one ITD cross over 4K boundary, the code will move 32 bytes for ITD.
|
||||
*/
|
||||
uint32_t reserved[8];
|
||||
#endif
|
||||
#if ((defined(USB_HOST_CONFIG_EHCI_MAX_SITD)) && (USB_HOST_CONFIG_EHCI_MAX_SITD > 0U))
|
||||
usb_host_ehci_sitd_t ehciSitd[USB_HOST_CONFIG_EHCI_MAX_SITD]; /*!< Idle SITD list array*/
|
||||
@@ -463,7 +449,6 @@ extern usb_status_t USB_HostEhciWritePipe(usb_host_controller_handle controllerH
|
||||
* @param[in] controllerHandle The controller handle.
|
||||
* @param[in] pipeHandle The receiving pipe handle.
|
||||
* @param[in] transfer The transfer information.
|
||||
|
||||
* @retval kStatus_USB_Success Send successfully.
|
||||
* @retval kStatus_USB_LackSwapBuffer There is no swap buffer for KHCI.
|
||||
* @retval kStatus_USB_Error There is no idle QTD/ITD/SITD for EHCI.
|
||||
@@ -488,6 +473,45 @@ extern usb_status_t USB_HostEhciIoctl(usb_host_controller_handle controllerHandl
|
||||
uint32_t ioctlEvent,
|
||||
void *ioctlParam);
|
||||
|
||||
/*!
|
||||
* @brief control ehci bus.
|
||||
*
|
||||
* @param ehciInstance ehci instance pointer.
|
||||
* @param bus_control control code.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
extern usb_status_t USB_HostEhciControlBus(usb_host_ehci_instance_t *ehciInstance, uint8_t busControl);
|
||||
|
||||
/*!
|
||||
* @brief ehci port change interrupt process function.
|
||||
*
|
||||
* @param ehciInstance ehci instance pointer.
|
||||
*/
|
||||
extern void USB_HostEhciPortChange(usb_host_ehci_instance_t *ehciInstance);
|
||||
|
||||
/*!
|
||||
* @brief ehci timer0 interrupt process function.
|
||||
* cancel control/bulk transfer that time out.
|
||||
*
|
||||
* @param ehciInstance ehci instance pointer.
|
||||
*/
|
||||
extern void USB_HostEhciTimer0(usb_host_ehci_instance_t *ehciInstance);
|
||||
|
||||
/*!
|
||||
* @brief host ehci start async schedule.
|
||||
*
|
||||
* @param ehciInstance ehci instance pointer.
|
||||
*/
|
||||
extern void USB_HostEhciStartAsync(usb_host_ehci_instance_t *ehciInstance);
|
||||
|
||||
/*!
|
||||
* @brief host ehci start periodic schedule.
|
||||
*
|
||||
* @param ehciInstance ehci instance pointer.
|
||||
*/
|
||||
extern void USB_HostEhciStartPeriodic(usb_host_ehci_instance_t *ehciInstance);
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -496,4 +520,4 @@ extern usb_status_t USB_HostEhciIoctl(usb_host_controller_handle controllerHandl
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _USB_HOST_CONTROLLER_EHCI_H_ */
|
||||
#endif /* _USB_HOST_CONTROLLER_EHCI_H_ */
|
||||
261
bsp/imxrt/libraries/drivers/usb/host/usb_host_framework.c
Normal file
261
bsp/imxrt/libraries/drivers/usb/host/usb_host_framework.c
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <usb/include/usb_host_config.h>
|
||||
#include "usb_host.h"
|
||||
#include "usb_host_hci.h"
|
||||
#include "usb_host_devices.h"
|
||||
#include "usb_host_framework.h"
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "middleware.usb.host.fatfs_usb_stack"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
usb_status_t USB_HostCh9RequestCommon(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
uint8_t *buffer,
|
||||
uint32_t bufferLen)
|
||||
{
|
||||
/* initialize transfer */
|
||||
transfer->setupPacket->wLength = USB_SHORT_TO_LITTLE_ENDIAN((uint16_t)bufferLen);
|
||||
transfer->transferBuffer = buffer;
|
||||
transfer->transferLength = bufferLen;
|
||||
|
||||
if (USB_HostSendSetup(deviceInstance->hostHandle, deviceInstance->controlPipe, transfer) !=
|
||||
kStatus_USB_Success) /* send setup transfer */
|
||||
{
|
||||
#ifdef HOST_ECHO
|
||||
usb_echo("failed for USB_HostSendSetup\r\n");
|
||||
#endif
|
||||
(void)USB_HostFreeTransfer(deviceInstance->hostHandle, transfer);
|
||||
return kStatus_USB_Error;
|
||||
}
|
||||
return kStatus_USB_Success;
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardGetStatus(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_get_status_param_t *statusParam;
|
||||
uint8_t length;
|
||||
|
||||
/* initialize transfer */
|
||||
statusParam = (usb_host_get_status_param_t *)param;
|
||||
transfer->setupPacket->bmRequestType = USB_REQUEST_TYPE_DIR_IN | USB_REQUEST_TYPE_TYPE_STANDARD;
|
||||
if (statusParam->requestType == (uint8_t)kRequestDevice)
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_DEVICE;
|
||||
}
|
||||
else if (statusParam->requestType == (uint8_t)kRequestInterface)
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_INTERFACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_ENDPOINT;
|
||||
}
|
||||
transfer->setupPacket->wIndex = USB_SHORT_TO_LITTLE_ENDIAN(statusParam->statusSelector);
|
||||
|
||||
length = 2;
|
||||
if (statusParam->statusSelector == USB_REQUEST_STANDARD_GET_STATUS_OTG_STATUS_SELECTOR)
|
||||
{
|
||||
length = 1;
|
||||
}
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, statusParam->statusBuffer, length);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardSetClearFeature(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_process_feature_param_t *featureParam;
|
||||
|
||||
/* initialize transfer */
|
||||
featureParam = (usb_host_process_feature_param_t *)param;
|
||||
if (featureParam->requestType == (uint8_t)kRequestDevice)
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_DEVICE;
|
||||
}
|
||||
else if (featureParam->requestType == (uint8_t)kRequestInterface)
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_INTERFACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_ENDPOINT;
|
||||
}
|
||||
transfer->setupPacket->wValue = USB_SHORT_TO_LITTLE_ENDIAN(featureParam->featureSelector);
|
||||
transfer->setupPacket->wIndex = USB_SHORT_TO_LITTLE_ENDIAN(featureParam->interfaceOrEndpoint);
|
||||
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, NULL, 0);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardSetAddress(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
uint8_t address;
|
||||
|
||||
/* initialize transfer */
|
||||
address = *(uint8_t *)param;
|
||||
transfer->setupPacket->wValue = USB_SHORT_TO_LITTLE_ENDIAN(address);
|
||||
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, NULL, 0);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardSetGetDescriptor(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_process_descriptor_param_t *descriptorParam;
|
||||
|
||||
/* initialize transfer */
|
||||
descriptorParam = (usb_host_process_descriptor_param_t *)param;
|
||||
transfer->setupPacket->wValue = USB_SHORT_TO_LITTLE_ENDIAN(
|
||||
(uint16_t)((uint16_t)descriptorParam->descriptorType << 8) | descriptorParam->descriptorIndex);
|
||||
transfer->setupPacket->wIndex = USB_SHORT_TO_LITTLE_ENDIAN(descriptorParam->languageId);
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, descriptorParam->descriptorBuffer,
|
||||
descriptorParam->descriptorLength);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardGetInterface(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_get_interface_param_t *interfaceParam;
|
||||
|
||||
/* initialize transfer */
|
||||
interfaceParam = (usb_host_get_interface_param_t *)param;
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_DIR_IN;
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_INTERFACE;
|
||||
transfer->setupPacket->wIndex = USB_SHORT_TO_LITTLE_ENDIAN(interfaceParam->interface);
|
||||
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, interfaceParam->alternateInterfaceBuffer, 1);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardSetInterface(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_set_interface_param_t *setParam;
|
||||
|
||||
/* initialize transfer */
|
||||
setParam = (usb_host_set_interface_param_t *)param;
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_INTERFACE;
|
||||
transfer->setupPacket->wIndex = USB_SHORT_TO_LITTLE_ENDIAN(setParam->interface);
|
||||
transfer->setupPacket->wValue = USB_SHORT_TO_LITTLE_ENDIAN(setParam->alternateSetting);
|
||||
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, NULL, 0);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostStandardSyncFrame(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_synch_frame_param_t *frameParam;
|
||||
|
||||
/* initialize transfer */
|
||||
frameParam = (usb_host_synch_frame_param_t *)param;
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_DIR_IN;
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_RECIPIENT_ENDPOINT;
|
||||
transfer->setupPacket->wIndex = USB_SHORT_TO_LITTLE_ENDIAN(frameParam->endpoint);
|
||||
|
||||
return USB_HostCh9RequestCommon(deviceInstance, transfer, frameParam->frameNumberBuffer, 2);
|
||||
}
|
||||
|
||||
usb_status_t USB_HostRequestControl(usb_device_handle deviceHandle,
|
||||
uint8_t usbRequest,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param)
|
||||
{
|
||||
usb_host_device_instance_t *deviceInstance = (usb_host_device_instance_t *)deviceHandle;
|
||||
usb_status_t status = kStatus_USB_Error;
|
||||
|
||||
if (deviceHandle == NULL)
|
||||
{
|
||||
return kStatus_USB_InvalidHandle;
|
||||
}
|
||||
|
||||
/* reset transfer fields */
|
||||
transfer->setupPacket->bmRequestType = 0x00;
|
||||
transfer->setupPacket->bRequest = usbRequest;
|
||||
transfer->setupPacket->wIndex = 0;
|
||||
transfer->setupPacket->wLength = 0;
|
||||
transfer->setupPacket->wValue = 0;
|
||||
|
||||
switch (usbRequest)
|
||||
{
|
||||
case USB_REQUEST_STANDARD_GET_STATUS: /* standard get status request */
|
||||
status = USB_HostStandardGetStatus(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_CLEAR_FEATURE: /* standard clear status request */
|
||||
case USB_REQUEST_STANDARD_SET_FEATURE: /* standard set feature request */
|
||||
status = USB_HostStandardSetClearFeature(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_SET_ADDRESS: /* standard set address request */
|
||||
status = USB_HostStandardSetAddress(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_GET_DESCRIPTOR: /* standard get descriptor request */
|
||||
case USB_REQUEST_STANDARD_SET_DESCRIPTOR: /* standard set descriptor request */
|
||||
if (usbRequest == USB_REQUEST_STANDARD_GET_DESCRIPTOR)
|
||||
{
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_DIR_IN;
|
||||
}
|
||||
status = USB_HostStandardSetGetDescriptor(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_GET_CONFIGURATION: /* standard get configuration descriptor request */
|
||||
transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_DIR_IN;
|
||||
status =
|
||||
USB_HostCh9RequestCommon((usb_host_device_instance_t *)deviceHandle, transfer, (uint8_t *)param, 1);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_SET_CONFIGURATION: /* standard set configuration request */
|
||||
transfer->setupPacket->wValue = USB_SHORT_TO_LITTLE_ENDIAN(*((uint8_t *)param));
|
||||
status = USB_HostCh9RequestCommon((usb_host_device_instance_t *)deviceHandle, transfer, NULL, 0);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_GET_INTERFACE: /* standard get interface request */
|
||||
status = USB_HostStandardGetInterface(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_SET_INTERFACE: /* standard set interface request */
|
||||
status = USB_HostStandardSetInterface(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
case USB_REQUEST_STANDARD_SYNCH_FRAME: /* standard synch frame request */
|
||||
status = USB_HostStandardSyncFrame(deviceInstance, transfer, param);
|
||||
break;
|
||||
|
||||
default:
|
||||
/*no action*/
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
131
bsp/imxrt/libraries/drivers/usb/host/usb_host_framework.h
Normal file
131
bsp/imxrt/libraries/drivers/usb/host/usb_host_framework.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_CH9_H_
|
||||
#define _USB_HOST_CH9_H_
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_host_drv
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @}*/
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @brief standard control transfer common code.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param buffer data buffer pointer.
|
||||
* @param bufferLen data length.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostCh9RequestCommon(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
uint8_t *buffer,
|
||||
uint32_t bufferLen);
|
||||
|
||||
/*!
|
||||
* @brief standard get status implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardGetStatus(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
|
||||
/*!
|
||||
* @brief standard set/clear feature implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardSetClearFeature(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
|
||||
/*!
|
||||
* @brief standard set address implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardSetAddress(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
|
||||
/*!
|
||||
* @brief standard set/get descriptor implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardSetGetDescriptor(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
|
||||
/*!
|
||||
* @brief standard get interface implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardGetInterface(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
|
||||
/*!
|
||||
* @brief standard set interface implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardSetInterface(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
|
||||
/*!
|
||||
* @brief standard sync frame implementation.
|
||||
*
|
||||
* @param deviceInstance device instance handle.
|
||||
* @param transfer transfer.
|
||||
* @param param parameter.
|
||||
*
|
||||
* @return kStatus_USB_Success or error codes.
|
||||
*/
|
||||
usb_status_t USB_HostStandardSyncFrame(usb_host_device_instance_t *deviceInstance,
|
||||
usb_host_transfer_t *transfer,
|
||||
void *param);
|
||||
#endif /* _USB_HOST_CH9_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* Copyright 2016 - 2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_HCI_H_
|
||||
@@ -36,9 +14,9 @@
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief USB host lock */
|
||||
#define USB_HostLock() USB_OsaMutexLock(hostInstance->hostMutex)
|
||||
#define USB_HostLock() OSA_MutexLock(hostInstance->hostMutex, USB_OSA_WAIT_TIMEOUT)
|
||||
/*! @brief USB host unlock */
|
||||
#define USB_HostUnlock() USB_OsaMutexUnlock(hostInstance->hostMutex)
|
||||
#define USB_HostUnlock() OSA_MutexUnlock(hostInstance->hostMutex)
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_host_controller_driver
|
||||
@@ -56,6 +34,10 @@ typedef enum _usb_host_controller_control
|
||||
kUSB_HostPortAttachDisable, /*!< Disable the port attach event */
|
||||
kUSB_HostPortAttachEnable, /*!< Enable the port attach event */
|
||||
kUSB_HostL1Config, /*!< L1 suspend Bus control code */
|
||||
kUSB_HostSetChargerType, /*!< set charger type */
|
||||
#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
|
||||
kUSB_HostTestModeInit, /*!< intialize charger type */
|
||||
#endif
|
||||
} usb_host_controller_control_t;
|
||||
|
||||
/*! @brief USB host controller bus control code */
|
||||
@@ -97,7 +79,9 @@ typedef struct _usb_host_controller_interface
|
||||
uint32_t ioctlEvent,
|
||||
void *ioctlParam); /*!< Control a controller function prototype*/
|
||||
} usb_host_controller_interface_t;
|
||||
|
||||
#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
|
||||
usb_status_t USB_HostTestModeInit(usb_device_handle deviceHandle);
|
||||
#endif
|
||||
/*! @}*/
|
||||
|
||||
/*!
|
||||
@@ -110,7 +94,8 @@ typedef struct _usb_host_instance
|
||||
{
|
||||
void *controllerHandle; /*!< The low level controller handle*/
|
||||
host_callback_t deviceCallback; /*!< Device attach/detach callback*/
|
||||
usb_osa_mutex_handle hostMutex; /*!< Host layer mutex*/
|
||||
osa_mutex_handle_t hostMutex; /*!< Host layer mutex*/
|
||||
uint32_t mutexBuffer[(OSA_MUTEX_HANDLE_SIZE + 3) / 4]; /*!< Host layer mutex*/
|
||||
usb_host_transfer_t transferList[USB_HOST_CONFIG_MAX_TRANSFERS]; /*!< Transfer resource*/
|
||||
usb_host_transfer_t *transferHead; /*!< Idle transfer head*/
|
||||
const usb_host_controller_interface_t *controllerTable; /*!< KHCI/EHCI interface*/
|
||||
@@ -126,6 +111,7 @@ typedef struct _usb_host_instance
|
||||
uint8_t controllerId; /*!< The controller ID*/
|
||||
} usb_host_instance_t;
|
||||
|
||||
extern usb_host_instance_t g_UsbHostInstance[USB_HOST_CONFIG_MAX_HOST];
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _USB_HOST_HCI_H_ */
|
||||
#endif /* _USB_HOST_HCI_H_ */
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <fsl_common.h>
|
||||
#include <fsl_os_abstraction.h>
|
||||
#include "usb_misc.h"
|
||||
#include "usb_spec.h"
|
||||
|
||||
@@ -137,4 +138,4 @@ typedef struct _usb_version
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif /* __USB_H__ */
|
||||
#endif /* __USB_H__ */
|
||||
247
bsp/imxrt/libraries/drivers/usb/include/usb_host_config.h
Normal file
247
bsp/imxrt/libraries/drivers/usb/include/usb_host_config.h
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 - 2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _USB_HOST_CONFIG_H_
|
||||
#define _USB_HOST_CONFIG_H_
|
||||
|
||||
/* Host Controller Enable */
|
||||
/*!
|
||||
* @brief host khci instance count, meantime it indicates khci enable or disable.
|
||||
* - if 0, host khci driver is disable.
|
||||
* - if greater than 0, host khci driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_KHCI (0U)
|
||||
|
||||
/*!
|
||||
* @brief host ehci instance count, meantime it indicates ehci enable or disable.
|
||||
* - if 0, host ehci driver is disable.
|
||||
* - if greater than 0, host ehci driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_EHCI (2U)
|
||||
|
||||
/*!
|
||||
* @brief host ohci instance count, meantime it indicates ohci enable or disable.
|
||||
* - if 0, host ohci driver is disable.
|
||||
* - if greater than 0, host ohci driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_OHCI (0U)
|
||||
|
||||
/*!
|
||||
* @brief host ip3516hs instance count, meantime it indicates ohci enable or disable.
|
||||
* - if 0, host ip3516hs driver is disable.
|
||||
* - if greater than 0, host ip3516hs driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_IP3516HS (0U)
|
||||
|
||||
/* Common configuration macros for all controllers */
|
||||
|
||||
/*!
|
||||
* @brief host driver instance max count.
|
||||
* for example: 2 - one for khci, one for ehci.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_MAX_HOST \
|
||||
(USB_HOST_CONFIG_KHCI + USB_HOST_CONFIG_EHCI + USB_HOST_CONFIG_OHCI + USB_HOST_CONFIG_IP3516HS)
|
||||
|
||||
/*!
|
||||
* @brief host pipe max count.
|
||||
* pipe is the host driver resource for device endpoint, one endpoint need one pipe.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_MAX_PIPES (16U)
|
||||
|
||||
/*!
|
||||
* @brief host transfer max count.
|
||||
* transfer is the host driver resource for data transmission mission, one transmission mission need one transfer.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_MAX_TRANSFERS (16U)
|
||||
|
||||
/*!
|
||||
* @brief the max endpoint for one interface.
|
||||
* the max endpoint descriptor number that one interface descriptor contain.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_INTERFACE_MAX_EP (4U)
|
||||
|
||||
/*!
|
||||
* @brief the max interface for one configuration.
|
||||
* the max interface descriptor number that one configuration descriptor can contain.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_CONFIGURATION_MAX_INTERFACE (5U)
|
||||
|
||||
/*!
|
||||
* @brief the max power for one device.
|
||||
* the max power the host can provide for one device.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_MAX_POWER (250U)
|
||||
|
||||
/*!
|
||||
* @brief the max retries for enumeration.
|
||||
* retry time when enumeration fail.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_ENUMERATION_MAX_RETRIES (3U)
|
||||
|
||||
/*!
|
||||
* @brief the max retries for enumeration setup stall.
|
||||
* the max times for one transfer can stall.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_ENUMERATION_MAX_STALL_RETRIES (1U)
|
||||
|
||||
/*!
|
||||
* @brief the max NAK count for one transaction.
|
||||
* when nak count reach to the value, the transaction fail.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_MAX_NAK (3000U)
|
||||
|
||||
/*! @brief Whether the transfer buffer is cache-enabled or not. */
|
||||
#ifndef USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE
|
||||
#define USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE (0U)
|
||||
#endif
|
||||
/*! @brief if 1, enable usb compliance test codes; if 0, disable usb compliance test codes. */
|
||||
#define USB_HOST_CONFIG_COMPLIANCE_TEST (0U)
|
||||
|
||||
/*! @brief if 1, class driver clear stall automatically; if 0, class driver don't clear stall. */
|
||||
#define USB_HOST_CONFIG_CLASS_AUTO_CLEAR_STALL (0U)
|
||||
|
||||
/* KHCI configuration */
|
||||
#if ((defined USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI))
|
||||
|
||||
/*!
|
||||
* @brief khci dma align fix buffer size.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_KHCI_DMA_ALIGN_BUFFER (64U)
|
||||
|
||||
#endif
|
||||
|
||||
/* EHCI configuration */
|
||||
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
|
||||
|
||||
/*!
|
||||
* @brief ehci periodic frame list size.
|
||||
* the value can be 1024, 512, 256, 128, 64, 32, 16 or 8.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_EHCI_FRAME_LIST_SIZE (1024U)
|
||||
|
||||
/*!
|
||||
* @brief ehci QH max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_EHCI_MAX_QH (8U)
|
||||
|
||||
/*!
|
||||
* @brief ehci QTD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_EHCI_MAX_QTD (8U)
|
||||
|
||||
/*!
|
||||
* @brief ehci ITD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_EHCI_MAX_ITD (0U)
|
||||
|
||||
/*!
|
||||
* @brief ehci SITD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_EHCI_MAX_SITD (0U)
|
||||
|
||||
#endif
|
||||
|
||||
/* OHCI configuration */
|
||||
#if ((defined USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI))
|
||||
|
||||
/*!
|
||||
* @brief ohci ED max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_OHCI_MAX_ED (8U)
|
||||
|
||||
/*!
|
||||
* @brief ohci GTD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_OHCI_MAX_GTD (8U)
|
||||
|
||||
/*!
|
||||
* @brief ohci ITD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_OHCI_MAX_ITD (8U)
|
||||
|
||||
#endif
|
||||
|
||||
/* OHCI configuration */
|
||||
#if ((defined USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS))
|
||||
|
||||
#define USB_HOST_CONFIG_IP3516HS_MAX_PIPE (32U)
|
||||
|
||||
/*!
|
||||
* @brief ohci ED max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_IP3516HS_MAX_ATL (32U)
|
||||
|
||||
/*!
|
||||
* @brief ohci GTD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_IP3516HS_MAX_INT (32U)
|
||||
|
||||
/*!
|
||||
* @brief ohci ITD max count.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_IP3516HS_MAX_ISO (0U)
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief host HUB class instance count, meantime it indicates HUB class enable or disable.
|
||||
* - if 0, host HUB class driver is disable.
|
||||
* - if greater than 0, host HUB class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_HUB (0U)
|
||||
|
||||
/*!
|
||||
* @brief host HID class instance count, meantime it indicates HID class enable or disable.
|
||||
* - if 0, host HID class driver is disable.
|
||||
* - if greater than 0, host HID class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_HID (0U)
|
||||
|
||||
/*!
|
||||
* @brief host MSD class instance count, meantime it indicates MSD class enable or disable.
|
||||
* - if 0, host MSD class driver is disable.
|
||||
* - if greater than 0, host MSD class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_MSD (0U)
|
||||
|
||||
/*!
|
||||
* @brief host CDC class instance count, meantime it indicates CDC class enable or disable.
|
||||
* - if 0, host CDC class driver is disable.
|
||||
* - if greater than 0, host CDC class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_CDC (0U)
|
||||
|
||||
/*!
|
||||
* @brief host AUDIO class instance count, meantime it indicates AUDIO class enable or disable.
|
||||
* - if 0, host AUDIO class driver is disable.
|
||||
* - if greater than 0, host AUDIO class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_AUDIO (0U)
|
||||
|
||||
/*!
|
||||
* @brief host PHDC class instance count, meantime it indicates PHDC class enable or disable.
|
||||
* - if 0, host PHDC class driver is disable.
|
||||
* - if greater than 0, host PHDC class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_PHDC (0U)
|
||||
|
||||
/*!
|
||||
* @brief host printer class instance count, meantime it indicates printer class enable or disable.
|
||||
* - if 0, host printer class driver is disable.
|
||||
* - if greater than 0, host printer class driver is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_PRINTER (0U)
|
||||
|
||||
/*!
|
||||
* @brief host charger detect enable or disable. It is only supported on RT600 currently.
|
||||
* - if 0, host charger detect is disable.
|
||||
* - if greater than 0, host charger detect is enable.
|
||||
*/
|
||||
#define USB_HOST_CONFIG_BATTERY_CHARGER (0U)
|
||||
|
||||
#endif /* _USB_HOST_CONFIG_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user