diff --git a/Documentation/Doxygen/src/introduction.txt b/Documentation/Doxygen/src/introduction.txt index 6b41c70..bf9705e 100644 --- a/Documentation/Doxygen/src/introduction.txt +++ b/Documentation/Doxygen/src/introduction.txt @@ -202,14 +202,14 @@ It is configured via define values in the USBH_EHCI_Config.h configuratio - USB Host Controller 0: - Export control block Driver_USBH#: Specifies the exported driver control block number. - EHCI Registers base address: Specifies the absolute address at which EHCI controller registers are located. - - Relocate EHCI Communication Area: Specifies if the communication area is located at a specific address (via the linker script): - - Section name: Specifies the section name of the EHCI communication area (for positioning via the linker script). + - Locate EHCI Communication Area: Specifies if the communication area is located in a specific memory (via the linker script): + - Section name: Specifies the section name for the EHCI communication area (for positioning via the linker script). - USB Host Controller 1 (can be enabled/disabled): - Export control block Driver_USBH#: Specifies the exported driver control block number. - EHCI Registers base address: Specifies the absolute address at which EHCI controller registers are located. - - Relocate EHCI Communication Area: Specifies if the communication area is located at a specific address (via the linker script): - - Section name: Specifies the section name of the EHCI communication area (for positioning via the linker script). + - Locate EHCI Communication Area: Specifies if the communication area is located in a specific memory (via the linker script): + - Section name: Specifies the section name for the EHCI communication area (for positioning via the linker script). - Maximum number of Pipes (per controller): Specifies the maximum number of pipes that the driver will support (per controller). @@ -228,14 +228,14 @@ It is configured via define values in the USBH_OHCI_Config.h configuratio - USB Host Controller 0: - Export control block Driver_USBH#: Specifies the exported driver control block number. - OHCI Registers base address: Specifies the absolute address at which OHCI controller registers are located. - - Relocate OHCI Communication Area (HCCA): Specifies if the communication area is located at a specific address (via the linker script): - - Section name: Specifies the section name of the OHCI communication area (for positioning via the linker script). + - Locate OHCI Communication Area (HCCA): Specifies if the communication area is located in a specific memory (via the linker script): + - Section name: Specifies the section name for the OHCI communication area (for positioning via the linker script). - USB Host Controller 1 (can be enabled/disabled): - Export control block Driver_USBH#: Specifies the exported driver control block number. - OHCI Registers base address: Specifies the absolute address at which OHCI controller registers are located. - - Relocate OHCI Communication Area (HCCA): Specifies if the communication area is located at a specific address (via the linker script): - - Section name: Specifies the section name of the OHCI communication area (for positioning via the linker script). + - Locate OHCI Communication Area (HCCA): Specifies if the communication area is located in a specific memory (via the linker script): + - Section name: Specifies the section name for the OHCI communication area (for positioning via the linker script). - Maximum number of Pipes (per controller): Specifies the maximum number of pipes that the driver will support (per controller). */ @@ -289,7 +289,7 @@ The \ref driver_pack_content provides implementations of Setup - Serial Port - Configure/Open: \image html ISM43362_set_COM_port_conf.png - - Check the follwoing settings (Serial Port being the one added just now): + - Check the following settings (Serial Port being the one added just now): \image html ISM43362_set_COM_port.png - Go to Menu - Firmware - Update: \image html ISM43362_update_firmware.png diff --git a/USB/EHCI/Config/USBH_EHCI_Config.h b/USB/EHCI/Config/USBH_EHCI_Config.h index 9d2a501..01ff710 100644 --- a/USB/EHCI/Config/USBH_EHCI_Config.h +++ b/USB/EHCI/Config/USBH_EHCI_Config.h @@ -17,7 +17,7 @@ * * ----------------------------------------------------------------------------- * - * $Date: 27. May 2024 + * $Date: 4. July 2024 * $Revision: V1.0 * * Project: USB Host EHCI Controller Driver Configuration definitions @@ -40,13 +40,13 @@ // Specifies the absolute address at which EHCI controller registers are located #define USBH0_EHCI_BASE_ADDR 0x402E0100 -// Relocate EHCI Communication Area -// Specifies if the communication area is located at a specific address +// Locate EHCI Communication Area +// Specifies if the communication area is located in a specific memory // (via the linker script) -#define USBH0_EHCI_COM_AREA_RELOC 0 +#define USBH0_EHCI_COM_AREA_LOCATE 0 // Section name -// Specifies the section name of the EHCI communication area +// Specifies the section name for the EHCI communication area // (for positioning via the linker script) #define USBH0_EHCI_COM_AREA_SECTION_NAME ".driver.usbh0.ehci_com_area" // @@ -65,13 +65,13 @@ // Specifies the absolute address at which EHCI controller registers are located #define USBH1_EHCI_BASE_ADDR 0x402E0300 -// Relocate EHCI Communication Area -// Specifies if the communication area is located at a specific address +// Locate EHCI Communication Area +// Specifies if the communication area is located in a specific memory // (via the linker script) -#define USBH1_EHCI_COM_AREA_RELOC 0 +#define USBH1_EHCI_COM_AREA_LOCATE 0 // Section name -// Specifies the section name of the EHCI communication area +// Specifies the section name for the EHCI communication area // (for positioning via the linker script) #define USBH1_EHCI_COM_AREA_SECTION_NAME ".driver.usbh1.ehci_com_area" // diff --git a/USB/EHCI/Interface/USBH_EHCI_HW.h b/USB/EHCI/Interface/USBH_EHCI_HW.h index 363d219..31c3cb7 100644 --- a/USB/EHCI/Interface/USBH_EHCI_HW.h +++ b/USB/EHCI/Interface/USBH_EHCI_HW.h @@ -1,70 +1,70 @@ /* * Copyright (c) 2024 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * ----------------------------------------------------------------------------- - * - * $Date: 28. May 2024 - * $Revision: V1.0 * - * Project: USB Host EHCI Controller Driver Hardware-specific header + * $Date: 28. May 2024 + * $Revision: V1.0 * - * ----------------------------------------------------------------------------- - */ - -#ifndef USBH_EHCI_HW_H_ -#define USBH_EHCI_HW_H_ - -#include + * Project: USB Host EHCI Controller Driver Hardware-specific header + * + * ----------------------------------------------------------------------------- + */ + +#ifndef USBH_EHCI_HW_H_ +#define USBH_EHCI_HW_H_ + +#include #ifdef __cplusplus extern "C" { #endif - -typedef void (*USBH_EHCI_Interrupt_t) (void); ///< Pointer to EHCI Interrupt Handler Routine. - -/** - \fn int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler) - \brief Initialize USB Host EHCI Interface. - \param[in] ctrl Index of USB Host controller - \param[in] interrupt_handler Pointer to Interrupt Handler Routine - \return 0 on success, -1 on error. -*/ -extern int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler); - -/** - \fn int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl) - \brief De-initialize USB Host EHCI Interface. - \param[in] ctrl Index of USB Host controller - \return 0 on success, -1 on error. -*/ -extern int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl); - -/** - \fn int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) - \brief Control USB Host EHCI Interface Power. - \param[in] ctrl Index of USB Host controller - \param[in] state Power state (0 = power off, 1 = power on) - \return 0 on success, -1 on error. -*/ -extern int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state); - -#ifdef __cplusplus -} -#endif - -#endif /* USBH_EHCI_HW_H_ */ + +typedef void (*USBH_EHCI_Interrupt_t) (void); ///< Pointer to EHCI Interrupt Handler Routine. + +/** + \fn int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler) + \brief Initialize USB Host EHCI Interface. + \param[in] ctrl Index of USB Host controller + \param[in] interrupt_handler Pointer to Interrupt Handler Routine + \return 0 on success, -1 on error. +*/ +extern int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler); + +/** + \fn int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl) + \brief De-initialize USB Host EHCI Interface. + \param[in] ctrl Index of USB Host controller + \return 0 on success, -1 on error. +*/ +extern int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl); + +/** + \fn int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) + \brief Control USB Host EHCI Interface Power. + \param[in] ctrl Index of USB Host controller + \param[in] state Power state (0 = power off, 1 = power on) + \return 0 on success, -1 on error. +*/ +extern int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state); + +#ifdef __cplusplus +} +#endif + +#endif /* USBH_EHCI_HW_H_ */ diff --git a/USB/EHCI/Source/USBH_EHCI_TT.c b/USB/EHCI/Source/USBH_EHCI_TT.c index 73f7a7a..dcd5a6d 100644 --- a/USB/EHCI/Source/USBH_EHCI_TT.c +++ b/USB/EHCI/Source/USBH_EHCI_TT.c @@ -17,15 +17,15 @@ * * ----------------------------------------------------------------------------- * - * $Date: 28. May 2024 - * $Revision: V1.0 + * $Date: 4. July 2024 + * $Revision: V1.0 * * Project: USB Host EHCI Controller Driver * for customized EHCI with internal Transaction Translator (TT) * (with full/low speed support) - * - * ----------------------------------------------------------------------------- - */ + * + * ----------------------------------------------------------------------------- + */ /* History: * Version 1.0 @@ -85,21 +85,21 @@ static ARM_USBH_CAPABILITIES usbh_driver_capabilities[USBH_EHCI_TT_INSTANCES] = // Macros -#define USBHn_EHCI_COM_AREA_SECTION_(x) __attribute__((section(x))) - -#if (USBH0_EHCI_COM_AREA_RELOC == 1) -#define USBH0_EHCI_COM_AREA_SECTION(x) USBHn_EHCI_COM_AREA_SECTION_(x) -#else -#define USBH0_EHCI_COM_AREA_SECTION(x) -#endif - -#if (USBH1_EHCI_ENABLED == 1) -#if (USBH1_EHCI_COM_AREA_RELOC == 1) -#define USBH1_EHCI_COM_AREA_SECTION(x) USBHn_EHCI_COM_AREA_SECTION_(x) -#else -#define USBH1_EHCI_COM_AREA_SECTION(x) -#endif -#endif +#define USBHn_EHCI_COM_AREA_SECTION_(x) __attribute__((section(x))) + +#if (USBH0_EHCI_COM_AREA_LOCATE == 1) +#define USBH0_EHCI_COM_AREA_SECTION(x) USBHn_EHCI_COM_AREA_SECTION_(x) +#else +#define USBH0_EHCI_COM_AREA_SECTION(x) +#endif + +#if (USBH1_EHCI_ENABLED == 1) +#if (USBH1_EHCI_COM_AREA_LOCATE == 1) +#define USBH1_EHCI_COM_AREA_SECTION(x) USBHn_EHCI_COM_AREA_SECTION_(x) +#else +#define USBH1_EHCI_COM_AREA_SECTION(x) +#endif +#endif #ifndef USBH_EHCI_MEM_PFL_SIZE #define USBH_EHCI_MEM_PFL_SIZE (4096U) @@ -192,7 +192,7 @@ static const USBH_EHCI_t usbh0_ehci = { USBH0_EHCI_DRV_NUM, &usbh0_ehci_com_area.sitd[0], NULL, &usbh0_transfer_info[0], - &usbh0_pipe_evt_info, + &usbh0_pipe_evt_info, Driver_USBH0_IRQ_Handler }; @@ -292,26 +292,26 @@ static void USBH_EHCI_IOC (uint32_t *ptr_pfl_entry) { ptr_curr = (USBH_EHCI_COMMON *)(*ptr_pfl_entry & (~0x1FU)); // Process all isochronous (siTDs) first - while ((ptr_curr->DW0.LinkPtr != 0U) && - (ptr_curr->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_siTD) && + while ((ptr_curr->DW0.LinkPtr != 0U) && + (ptr_curr->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_siTD) && (ptr_curr->DW0.T == 0U)) { ((USBH_EHCI_siTD *)ptr_curr)->DW3.IOC = 0U; // Clear IOC (for current siTD) ptr_curr = (USBH_EHCI_COMMON *)(ptr_curr->DW0.LinkPtr << 5); } - if ((ptr_curr->DW0.LinkPtr != 0U) && - (ptr_curr->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_qH) && + if ((ptr_curr->DW0.LinkPtr != 0U) && + (ptr_curr->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_qH) && (ptr_curr->DW0.T == 0U)) { // Process all interrupt (qH) do { ptr_int_td = ptr_curr; - while ((ptr_int_td->DW0.LinkPtr != 0U) && + while ((ptr_int_td->DW0.LinkPtr != 0U) && (ptr_int_td->DW0.T == 0U)) { ((USBH_EHCI_qTD *)ptr_int_td)->DW2.IOC = 0U; // Clear IOC (for current qTD) ptr_int_td = (USBH_EHCI_COMMON *)(ptr_int_td->DW0.LinkPtr << 5); } - } while ((ptr_curr->DW0.LinkPtr != 0U) && - (ptr_curr->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_qH) && + } while ((ptr_curr->DW0.LinkPtr != 0U) && + (ptr_curr->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_qH) && (ptr_curr->DW0.T == 0U)); ((USBH_EHCI_siTD *)ptr_int_td)->DW3.IOC = 1U; // Set IOC (for last qTD) } else { @@ -342,7 +342,7 @@ static bool USBH_EHCI_StartStop (uint8_t ctrl, uint8_t type, bool start) { } else { // Periodic type msk = (1UL << 4); } - + // Wait for status = command (max 1 second) for (tout = 10100U; ; tout-- ){ usbcmd = usbh_ehci_reg_ptr[ctrl]->USBCMD; @@ -519,7 +519,7 @@ static USBH_EHCI_qTD *USBH_EHCI_qTD_GetNext_qH (const USBH_EHCI_qH *ptr_qH) { */ static bool USBH_EHCI_qTD_IsLinkedIn_qH (const USBH_EHCI_qH *ptr_qH, const USBH_EHCI_qTD *ptr_qTD) { USBH_EHCI_qTD *ptr_curr_qTD; - + if (ptr_qH == NULL) { return NULL; } if (ptr_qTD == NULL) { return NULL; } @@ -772,14 +772,14 @@ static bool USBH_EHCI_IsoTransferActivate (uint8_t ctrl, USBH_TransferInfo_t *pt ptr_TI->iso_last_frame_index = pfl_index; ptr_TI->iso_frame_index[ti_index] = pfl_index; - // Insert siTD into PFL, if entry already exists append this new transfer to + // Insert siTD into PFL, if entry already exists append this new transfer to // last existing isochronous transfer if (((*ptr_uint32_t & 0x1FU) == 4U) && // If T bit is 0 and Type is siTD, meaning it is valid entry ((*ptr_uint32_t & (~0x1FU)) != 0U)) { // and if NextLinkPointer is != 0 // Find last iso entry and add new one behind it ptr_curr_siTD = (USBH_EHCI_siTD *)(*ptr_uint32_t & ~0x1FU); - while ((ptr_curr_siTD->DW0.NextLinkPtr != 0U) && - (ptr_curr_siTD->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_siTD) && + while ((ptr_curr_siTD->DW0.NextLinkPtr != 0U) && + (ptr_curr_siTD->DW0.Typ == USBH_EHCI_ELEMENT_TYPE_siTD) && (ptr_curr_siTD->DW0.T == 0U)) { ptr_curr_siTD = (USBH_EHCI_siTD *)(ptr_curr_siTD->DW0.NextLinkPtr << 5); } @@ -2661,7 +2661,7 @@ static void USBH_HW_IRQ_Handler (uint8_t ctrl) { status = ptr_qTD->DW2.Status; transferred = ptr_TI->num_to_transfer - ptr_qTD->DW2.TBT; ptr_TI->num_transferred_total += transferred; - if (((status & (1UL << 7)) == 0U) && + if (((status & (1UL << 7)) == 0U) && ((status & (1UL << 6)) == 0U)) { // No Error if (ptr_TI->num == ptr_TI->num_transferred_total) { // All data was transferred ep_event = ARM_USBH_EVENT_TRANSFER_COMPLETE; diff --git a/USB/EHCI/Source/USBH_EHCI_TT.h b/USB/EHCI/Source/USBH_EHCI_TT.h index c60f080..ed3e39e 100644 --- a/USB/EHCI/Source/USBH_EHCI_TT.h +++ b/USB/EHCI/Source/USBH_EHCI_TT.h @@ -17,8 +17,8 @@ * * ----------------------------------------------------------------------------- * - * $Date: 28. May 2024 - * $Revision: V1.0 + * $Date: 28. May 2024 + * $Revision: V1.0 * * Project: USB Host EHCI Controller Driver header * for customized EHCI with internal Transaction Translator (TT) diff --git a/USB/EHCI/Source/USBH_EHCI_TT_Regs.h b/USB/EHCI/Source/USBH_EHCI_TT_Regs.h index a87d006..278448e 100644 --- a/USB/EHCI/Source/USBH_EHCI_TT_Regs.h +++ b/USB/EHCI/Source/USBH_EHCI_TT_Regs.h @@ -17,8 +17,8 @@ * * ----------------------------------------------------------------------------- * - * $Date: 28. May 2024 - * $Revision: V1.0 + * $Date: 28. May 2024 + * $Revision: V1.0 * * Project: USB Host EHCI Controller Driver Registers header * for customized EHCI with internal Transaction Translator (TT) diff --git a/USB/EHCI/Template/USBH_EHCI_HW.c b/USB/EHCI/Template/USBH_EHCI_HW.c index 42c15d5..431d0bf 100644 --- a/USB/EHCI/Template/USBH_EHCI_HW.c +++ b/USB/EHCI/Template/USBH_EHCI_HW.c @@ -1,85 +1,85 @@ /* * Copyright (c) 2024 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * ----------------------------------------------------------------------------- - * - * $Date: 28. May 2024 - * $Revision: V1.0 - * - * Project: USB Host EHCI Controller Driver Hardware-specific template - * - * ----------------------------------------------------------------------------- - */ - -#include "USBH_EHCI_HW.h" - -static USBH_EHCI_Interrupt_t EHCI_IRQ_Handler; - -/** - \fn int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler) - \brief Initialize USB Host EHCI Interface. - \param[in] ctrl Index of USB Host controller - \param[in] interrupt_handler Pointer to Interrupt Handler Routine - \return 0 on success, -1 on error. -*/ -int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler) { - - // Add hardware-specific initialization code - - EHCI_IRQ_Handler = interrupt_handler; // Register EHCI interrupt handler - - return 0; -} - -/** - \fn int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl) - \brief De-initialize USB Host EHCI Interface. - \param[in] ctrl Index of USB Host controller - \return 0 on success, -1 on error. -*/ -int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl) { - - // Add hardware-specific uninitialization code - - return 0; -} - -/** - \fn int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) - \brief Control USB Host EHCI Interface Power. - \param[in] ctrl Index of USB Host controller - \param[in] state Power state (0 = power off, 1 = power on) - \return 0 on success, -1 on error. -*/ -int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) { - - if (state == 0U) { // If power off requested - // Add hardware-specific code to power off the Host interface - } else { // If power on requested - // Add hardware-specific code to power on the Host interface - } - - return 0; -} - -/** - \fn void USBH0_IRQ (void) - \brief USB0 Host Interrupt Routine (IRQ). -*/ -void USBH0_IRQ (void) { - EHCI_IRQ_Handler(); // Call registered EHCI interrupt handler from hardware USB interrupt handler -} + * + * $Date: 28. May 2024 + * $Revision: V1.0 + * + * Project: USB Host EHCI Controller Driver Hardware-specific template + * + * ----------------------------------------------------------------------------- + */ + +#include "USBH_EHCI_HW.h" + +static USBH_EHCI_Interrupt_t EHCI_IRQ_Handler; + +/** + \fn int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler) + \brief Initialize USB Host EHCI Interface. + \param[in] ctrl Index of USB Host controller + \param[in] interrupt_handler Pointer to Interrupt Handler Routine + \return 0 on success, -1 on error. +*/ +int32_t USBH_EHCI_HW_Initialize (uint8_t ctrl, USBH_EHCI_Interrupt_t interrupt_handler) { + + // Add hardware-specific initialization code + + EHCI_IRQ_Handler = interrupt_handler; // Register EHCI interrupt handler + + return 0; +} + +/** + \fn int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl) + \brief De-initialize USB Host EHCI Interface. + \param[in] ctrl Index of USB Host controller + \return 0 on success, -1 on error. +*/ +int32_t USBH_EHCI_HW_Uninitialize (uint8_t ctrl) { + + // Add hardware-specific uninitialization code + + return 0; +} + +/** + \fn int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) + \brief Control USB Host EHCI Interface Power. + \param[in] ctrl Index of USB Host controller + \param[in] state Power state (0 = power off, 1 = power on) + \return 0 on success, -1 on error. +*/ +int32_t USBH_EHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) { + + if (state == 0U) { // If power off requested + // Add hardware-specific code to power off the Host interface + } else { // If power on requested + // Add hardware-specific code to power on the Host interface + } + + return 0; +} + +/** + \fn void USBH0_IRQ (void) + \brief USB0 Host Interrupt Routine (IRQ). +*/ +void USBH0_IRQ (void) { + EHCI_IRQ_Handler(); // Call registered EHCI interrupt handler from hardware USB interrupt handler +} diff --git a/USB/OHCI/Config/USBH_OHCI_Config.h b/USB/OHCI/Config/USBH_OHCI_Config.h index 5779e22..1c1bc6b 100644 --- a/USB/OHCI/Config/USBH_OHCI_Config.h +++ b/USB/OHCI/Config/USBH_OHCI_Config.h @@ -17,7 +17,7 @@ * * ----------------------------------------------------------------------------- * - * $Date: 27. May 2024 + * $Date: 4. July 2024 * $Revision: V1.0 * * Project: USB Host OHCI Controller Driver Configuration definitions @@ -40,13 +40,13 @@ // Specifies the absolute address at which OHCI controller registers are located #define USBH0_OHCI_BASE_ADDR 0x5000C000 -// Relocate OHCI Communication Area (HCCA) -// Specifies if the communication area is located at a specific address +// Locate OHCI Communication Area (HCCA) +// Specifies if the communication area is located in a specific memory // (via the linker script) -#define USBH0_OHCI_HCCA_RELOC 0 +#define USBH0_OHCI_HCCA_LOCATE 0 // Section name -// Specifies the section name of the OHCI communication area +// Specifies the section name for the OHCI communication area // (for positioning via the linker script) #define USBH0_OHCI_HCCA_SECTION_NAME ".driver.usbh0.ohci_hcca" // @@ -65,13 +65,13 @@ // Specifies the absolute address at which OHCI controller registers are located #define USBH1_OHCI_BASE_ADDR 0x00000000 -// Relocate OHCI Communication Area (HCCA) -// Specifies if the communication area is located at a specific address +// Locate OHCI Communication Area (HCCA) +// Specifies if the communication area is located in a specific memory // (via the linker script) -#define USBH1_OHCI_HCCA_RELOC 0 +#define USBH1_OHCI_HCCA_LOCATE 0 // Section name -// Specifies the section name of the OHCI communication area +// Specifies the section name for the OHCI communication area // (for positioning via the linker script) #define USBH1_OHCI_HCCA_SECTION_NAME ".driver.usbh1.ohci_hcca" // diff --git a/USB/OHCI/Interface/USBH_OHCI_HW.h b/USB/OHCI/Interface/USBH_OHCI_HW.h index 0fab081..7879bb2 100644 --- a/USB/OHCI/Interface/USBH_OHCI_HW.h +++ b/USB/OHCI/Interface/USBH_OHCI_HW.h @@ -1,70 +1,70 @@ /* * Copyright (c) 2024 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * ----------------------------------------------------------------------------- - * - * $Date: 28. May 2024 - * $Revision: V1.0 - * - * Project: USB Host OHCI Controller Driver Hardware-specific header - * - * ----------------------------------------------------------------------------- - */ - -#ifndef USBH_OHCI_HW_H_ -#define USBH_OHCI_HW_H_ - -#include + * + * $Date: 28. May 2024 + * $Revision: V1.0 + * + * Project: USB Host OHCI Controller Driver Hardware-specific header + * + * ----------------------------------------------------------------------------- + */ + +#ifndef USBH_OHCI_HW_H_ +#define USBH_OHCI_HW_H_ + +#include #ifdef __cplusplus extern "C" { #endif - -typedef void (*USBH_OHCI_Interrupt_t) (void); ///< Pointer to OHCI Interrupt Handler Routine. - -/** - \fn int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler) - \brief Initialize USB Host OHCI Interface. - \param[in] ctrl Index of USB Host controller - \param[in] interrupt_handler Pointer to Interrupt Handler Routine - \return 0 on success, -1 on error. -*/ -extern int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler); - -/** - \fn int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl) - \brief De-initialize USB Host OHCI Interface. - \param[in] ctrl Index of USB Host controller - \return 0 on success, -1 on error. -*/ -extern int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl); - -/** - \fn int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) - \brief Control USB Host OHCI Interface Power. - \param[in] ctrl Index of USB Host controller - \param[in] state Power state (0 = power off, 1 = power on) - \return 0 on success, -1 on error. -*/ -extern int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state); - -#ifdef __cplusplus -} -#endif - -#endif /* USBH_OHCI_HW_H_ */ + +typedef void (*USBH_OHCI_Interrupt_t) (void); ///< Pointer to OHCI Interrupt Handler Routine. + +/** + \fn int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler) + \brief Initialize USB Host OHCI Interface. + \param[in] ctrl Index of USB Host controller + \param[in] interrupt_handler Pointer to Interrupt Handler Routine + \return 0 on success, -1 on error. +*/ +extern int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler); + +/** + \fn int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl) + \brief De-initialize USB Host OHCI Interface. + \param[in] ctrl Index of USB Host controller + \return 0 on success, -1 on error. +*/ +extern int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl); + +/** + \fn int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) + \brief Control USB Host OHCI Interface Power. + \param[in] ctrl Index of USB Host controller + \param[in] state Power state (0 = power off, 1 = power on) + \return 0 on success, -1 on error. +*/ +extern int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state); + +#ifdef __cplusplus +} +#endif + +#endif /* USBH_OHCI_HW_H_ */ diff --git a/USB/OHCI/Source/USBH_OHCI.c b/USB/OHCI/Source/USBH_OHCI.c index da2fa1f..03f3e02 100644 --- a/USB/OHCI/Source/USBH_OHCI.c +++ b/USB/OHCI/Source/USBH_OHCI.c @@ -17,13 +17,13 @@ * * ----------------------------------------------------------------------------- * - * $Date: 28. May 2024 - * $Revision: V1.0 + * $Date: 4. July 2024 + * $Revision: V1.0 * * Project: USB Host OHCI Controller Driver - * - * ----------------------------------------------------------------------------- - */ + * + * ----------------------------------------------------------------------------- + */ /* History: * Version 1.0 @@ -83,22 +83,22 @@ static ARM_USBH_CAPABILITIES usbh_driver_capabilities[USBH_OHCI_INSTANCES] = { // Macros -#define USBHn_OHCI_HCCA_SECTION_(x) __attribute__((section(x))) - -#if (USBH0_OHCI_HCCA_RELOC == 1) -#define USBH0_OHCI_HCCA_SECTION(x) USBHn_OHCI_HCCA_SECTION_(x) -#else -#define USBH0_OHCI_HCCA_SECTION(x) -#endif - -#if (USBH1_OHCI_ENABLED == 1) -#if (USBH1_OHCI_HCCA_RELOC == 1) -#define USBH1_OHCI_HCCA_SECTION(x) USBHn_OHCI_HCCA_SECTION_(x) -#else -#define USBH1_OHCI_HCCA_SECTION(x) -#endif -#endif - +#define USBHn_OHCI_HCCA_SECTION_(x) __attribute__((section(x))) + +#if (USBH0_OHCI_HCCA_LOCATE == 1) +#define USBH0_OHCI_HCCA_SECTION(x) USBHn_OHCI_HCCA_SECTION_(x) +#else +#define USBH0_OHCI_HCCA_SECTION(x) +#endif + +#if (USBH1_OHCI_ENABLED == 1) +#if (USBH1_OHCI_HCCA_LOCATE == 1) +#define USBH1_OHCI_HCCA_SECTION(x) USBHn_OHCI_HCCA_SECTION_(x) +#else +#define USBH1_OHCI_HCCA_SECTION(x) +#endif +#endif + #ifndef USBH_OHCI_MEM_HCCA_SIZE #define USBH_OHCI_MEM_HCCA_SIZE (256U) #endif @@ -152,7 +152,7 @@ static void Driver_USBH1_IRQ_Handler (void); // USB Host 0 information static USBH_TransferInfo_t usbh0_transfer_info [USBH_OHCI_MAX_PIPES]; -static USBH_OHCI_HCCA_t usbh0_ohci_hcca USBH0_OHCI_HCCA_SECTION(USBH0_OHCI_HCCA_SECTION_NAME) __ALIGNED(USBH_OHCI_MEM_HCCA_SIZE); +static USBH_OHCI_HCCA_t usbh0_ohci_hcca USBH0_OHCI_HCCA_SECTION(USBH0_OHCI_HCCA_SECTION_NAME) __ALIGNED(USBH_OHCI_MEM_HCCA_SIZE); static const USBH_OHCI_t usbh0_ohci = { USBH0_OHCI_DRV_NUM, (uint32_t *)USBH0_OHCI_BASE_ADDR, USBH_OHCI_MAX_PIPES, @@ -170,7 +170,7 @@ static const USBH_OHCI_t usbh0_ohci = { USBH0_OHCI_DRV_NUM, // USB Host 1 information #if (USBH1_OHCI_ENABLED == 1) static USBH_TransferInfo_t usbh1_transfer_info [USBH_OHCI_MAX_PIPES]; -static USBH_OHCI_HCCA_t usbh1_ohci_hcca USBH1_OHCI_HCCA_SECTION(USBH1_OHCI_HCCA_SECTION_NAME) __ALIGNED(USBH_OHCI_MEM_HCCA_SIZE); +static USBH_OHCI_HCCA_t usbh1_ohci_hcca USBH1_OHCI_HCCA_SECTION(USBH1_OHCI_HCCA_SECTION_NAME) __ALIGNED(USBH_OHCI_MEM_HCCA_SIZE); static const USBH_OHCI_t usbh1_ohci = { USBH1_OHCI_DRV_NUM, (uint32_t *)USBH1_OHCI_BASE_ADDR, USBH_OHCI_MAX_PIPES, @@ -731,8 +731,8 @@ static USBH_OHCI_ED *USBH_OHCI_ED_GetLast (USBH_OHCI_ED *ptr_ED) { return pointer to beginning of the linked list Endpoint Descriptor \param[in] ptr_first_ED Pointer to first Endpoint Descriptor in linked list \param[in] ptr_ED Pointer to Endpoint Descriptor - \return Pointer to beginning ot the linked list, Endpoint Descriptor not found or function failed - value > 0: pointer to beginning ot the linked list + \return Pointer to beginning of the linked list, Endpoint Descriptor not found or function failed + value > 0: pointer to beginning of the linked list value = 0: Endpoint Descriptor not found or function failed */ static USBH_OHCI_ED *USBH_OHCI_ED_Unlink (USBH_OHCI_ED *ptr_first_ED, USBH_OHCI_ED *ptr_ED) { @@ -1181,8 +1181,8 @@ static int32_t USBH_HW_PowerControl (uint8_t ctrl, ARM_POWER_STATE state) { usbh_ohci_reg_ptr[ctrl]->HcBulkHeadED = 0; // Initialize Bulk list head usbh_ohci_reg_ptr[ctrl]->HcCommandStatus = USBH_OHCI_HcCommandStatus_HCR; // Host Ctrl Reset - usbh_ohci_reg_ptr[ctrl]->HcFmInterval = USBH_OHCI_HcFmInterval_FSMPS(0x2778)|// Max Pckt Sz - USBH_OHCI_HcFmInterval_FI(0x2EDF); // Frm Intrvl + usbh_ohci_reg_ptr[ctrl]->HcFmInterval = USBH_OHCI_HcFmInterval_FSMPS(0x2778)|// Max Packet Size + USBH_OHCI_HcFmInterval_FI(0x2EDF); // Frame Interval usbh_ohci_reg_ptr[ctrl]->HcPeriodicStart = 0x2A2F; // 10% before end of HcFmInterval usbh_ohci_reg_ptr[ctrl]->HcHCCA = (uint32_t)((usbh_ohci_ptr[ctrl])->ptr_HCCA); // HCCA @@ -1705,7 +1705,7 @@ static int32_t USBH1_HW_PipeTransfer (ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t p \brief Get result of USB Pipe transfer. \param[in] ctrl Index of USB Host controller \param[in] pipe_hndl Pipe Handle - \return number of successfully transfered data bytes + \return number of successfully transferred data bytes */ static uint32_t USBH_HW_PipeTransferGetResult (uint8_t ctrl, ARM_USBH_PIPE_HANDLE pipe_hndl) { const USBH_TransferInfo_t *ptr_TI; diff --git a/USB/OHCI/Source/USBH_OHCI.h b/USB/OHCI/Source/USBH_OHCI.h index b663a46..83b148d 100644 --- a/USB/OHCI/Source/USBH_OHCI.h +++ b/USB/OHCI/Source/USBH_OHCI.h @@ -17,8 +17,8 @@ * * ----------------------------------------------------------------------------- * - * $Date: 28. May 2024 - * $Revision: V1.0 + * $Date: 28. May 2024 + * $Revision: V1.0 * * Project: USB Host OHCI Controller Driver header * diff --git a/USB/OHCI/Source/USBH_OHCI_Regs.h b/USB/OHCI/Source/USBH_OHCI_Regs.h index 67690fe..eba65e8 100644 --- a/USB/OHCI/Source/USBH_OHCI_Regs.h +++ b/USB/OHCI/Source/USBH_OHCI_Regs.h @@ -17,8 +17,8 @@ * * ----------------------------------------------------------------------------- * - * $Date: 28. May 2024 - * $Revision: V1.0 + * $Date: 28. May 2024 + * $Revision: V1.0 * * Project: USB Host OHCI Controller Driver Registers header * diff --git a/USB/OHCI/Template/USBH_OHCI_HW.c b/USB/OHCI/Template/USBH_OHCI_HW.c index c2b25c4..af1a92d 100644 --- a/USB/OHCI/Template/USBH_OHCI_HW.c +++ b/USB/OHCI/Template/USBH_OHCI_HW.c @@ -1,85 +1,85 @@ /* * Copyright (c) 2024 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * * ----------------------------------------------------------------------------- - * - * $Date: 28. May 2024 - * $Revision: V1.0 - * - * Project: USB Host OHCI Controller Driver Hardware-specific template + * + * $Date: 28. May 2024 + * $Revision: V1.0 + * + * Project: USB Host OHCI Controller Driver Hardware-specific template * * ----------------------------------------------------------------------------- */ - -#include "USBH_OHCI_HW.h" - -static USBH_OHCI_Interrupt_t OHCI_IRQ_Handler; - -/** - \fn int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler) - \brief Initialize USB Host OHCI Interface. - \param[in] ctrl Index of USB Host controller - \param[in] interrupt_handler Pointer to Interrupt Handler Routine - \return 0 on success, -1 on error. -*/ -int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler) { - - // Add hardware-specific initialization code - - OHCI_IRQ_Handler = interrupt_handler; // Register OHCI interrupt handler - - return 0; -} - -/** - \fn int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl) - \brief De-initialize USB Host OHCI Interface. - \param[in] ctrl Index of USB Host controller - \return 0 on success, -1 on error. -*/ -int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl) { - - // Add hardware-specific uninitialization code - - return 0; -} - -/** - \fn int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) - \brief Control USB Host OHCI Interface Power. - \param[in] ctrl Index of USB Host controller - \param[in] state Power state (0 = power off, 1 = power on) - \return 0 on success, -1 on error. -*/ -int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) { - - if (state == 0U) { // If power off requested - // Add hardware-specific code to power off the Host interface - } else { // If power on requested - // Add hardware-specific code to power on the Host interface - } - - return 0; -} - -/** - \fn void USBH0_IRQ (void) - \brief USB0 Host Interrupt Routine (IRQ). -*/ -void USBH0_IRQ (void) { - OHCI_IRQ_Handler(); // Call registered OHCI interrupt handler from hardware USB interrupt handler -} + +#include "USBH_OHCI_HW.h" + +static USBH_OHCI_Interrupt_t OHCI_IRQ_Handler; + +/** + \fn int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler) + \brief Initialize USB Host OHCI Interface. + \param[in] ctrl Index of USB Host controller + \param[in] interrupt_handler Pointer to Interrupt Handler Routine + \return 0 on success, -1 on error. +*/ +int32_t USBH_OHCI_HW_Initialize (uint8_t ctrl, USBH_OHCI_Interrupt_t interrupt_handler) { + + // Add hardware-specific initialization code + + OHCI_IRQ_Handler = interrupt_handler; // Register OHCI interrupt handler + + return 0; +} + +/** + \fn int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl) + \brief De-initialize USB Host OHCI Interface. + \param[in] ctrl Index of USB Host controller + \return 0 on success, -1 on error. +*/ +int32_t USBH_OHCI_HW_Uninitialize (uint8_t ctrl) { + + // Add hardware-specific uninitialization code + + return 0; +} + +/** + \fn int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) + \brief Control USB Host OHCI Interface Power. + \param[in] ctrl Index of USB Host controller + \param[in] state Power state (0 = power off, 1 = power on) + \return 0 on success, -1 on error. +*/ +int32_t USBH_OHCI_HW_PowerControl (uint8_t ctrl, uint32_t state) { + + if (state == 0U) { // If power off requested + // Add hardware-specific code to power off the Host interface + } else { // If power on requested + // Add hardware-specific code to power on the Host interface + } + + return 0; +} + +/** + \fn void USBH0_IRQ (void) + \brief USB0 Host Interrupt Routine (IRQ). +*/ +void USBH0_IRQ (void) { + OHCI_IRQ_Handler(); // Call registered OHCI interrupt handler from hardware USB interrupt handler +}