/*
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "usb_host_config.h"
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U))
#include "usb_host.h"
#include "usb_host_hci.h"
#include "usb_host_devices.h"
#include "fsl_device_registers.h"
#include "usb_host_ehci.h"
#include "usb_phy.h"
#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
#include "usb_host.h"
#endif
/*******************************************************************************
* Definitions
******************************************************************************/
#if defined(USB_STACK_USE_DEDICATED_RAM) && (USB_STACK_USE_DEDICATED_RAM > 0U)
#error The SOC does not suppoort dedicated RAM case.
#endif
#define USB_HOST_EHCI_BANDWIDTH_DELAY (3500U)
#define USB_HOST_EHCI_BANDWIDTH_HUB_LS_SETUP (333U)
#define USB_HOST_EHCI_BANDWIDTH_FRAME_TOTOAL_TIME (900U)
#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
#define USB_HOST_EHCI_TEST_DESCRIPTOR_LENGTH (18U)
#define USB_HOST_EHCI_PORTSC_PTC_J_STATE (0x01U)
#define USB_HOST_EHCI_PORTSC_PTC_K_STATE (0x02U)
#define USB_HOST_EHCI_PORTSC_PTC_SE0_NAK (0x03U)
#define USB_HOST_EHCI_PORTSC_PTC_PACKET (0x04U)
#define USB_HOST_EHCI_PORTSC_PTC_FORCE_ENABLE_HS (0x05U)
#define USB_HOST_EHCI_PORTSC_PTC_FORCE_ENABLE_FS (0x06U)
#define USB_HOST_EHCI_PORTSC_PTC_FORCE_ENABLE_LS (0x07U)
#endif
/*******************************************************************************
* Prototypes
******************************************************************************/
/*!
* @brief compute data bandwidth time.
*
* @param speed data speed.
* @param pipeType data type.
* @param direction data direction.
* @param dataLength data length.
*
*@return time value.
*/
static uint32_t USB_HostBandwidthComputeTime(uint8_t speed, uint8_t pipeType, uint8_t direction, uint32_t dataLength);
/*!
* @brief compute current allocated bandwidth when ehci work as full-speed or low-speed host.
*
* @param ehciInstance ehci instance pointer.
* @param frameIndex frame index.
* @param frameBandwidths return frame bandwidth data.
*/
static void USB_HostBandwidthFslsHostComputeCurrent(usb_host_ehci_instance_t *ehciInstance,
uint16_t frameIndex,
uint16_t *frameBandwidth);
/*!
* @brief compute current hub's allocated FS/LS bandwidth when ehci work as hi-speed host.
*
* @param ehciInstance ehci instance pointer.
* @param hubNumber hub address.
* @param frameIndex frame index.
* @param frameBandwidths return frame bandwidth data.
*/
static void USB_HostBandwidthHsHostComputeCurrentFsls(usb_host_ehci_instance_t *ehciInstance,
uint32_t hubNumber,
uint16_t frameIndex,
uint8_t frameBandwidths[8]);
/*!
* @brief compute current allocated HS bandwidth when ehci work as hi-speed host.
*
* @param ehciInstance ehci instance pointer.
* @param frameIndex frame index.
* @param frameBandwidths return frame bandwidth data.
*/
static void USB_HostBandwidthHsHostComputeCurrentHsAll(usb_host_ehci_instance_t *ehciInstance,
uint16_t frameIndex,
uint8_t frameBandwidths[8]);
/*!
* @brief allocate HS bandwidth when host work as high-speed host.
*
* @param ehciInstance ehci instance pointer.
* @param uframeInterval micro-frame interval.
* @param timeData time for allocating.
* @param uframe_index_out return start uframe index.
*
* @return kStatus_USB_Success or error codes.
*/
static usb_status_t USB_HostBandwidthHsHostAllocateHsCommon(usb_host_ehci_instance_t *ehciInstance,
uint16_t uframeInterval,
uint16_t timeData,
uint16_t *uframeIndexOut);
/*!
* @brief allocate HS interrupt bandwidth when host work as high-speed host.
*
* @param ehciInstance ehci instance pointer.
* @param ehciPipePointer ehci pipe pointer.
*
* @return kStatus_USB_Success or error codes.
*/
static usb_status_t USB_HostBandwidthHsHostAllocateInterrupt(usb_host_ehci_instance_t *ehciInstance,
usb_host_ehci_pipe_t *ehciPipePointer);
/*!
* @brief allocate bandwidth when host work as full-speed or low-speed host.
*
* @param ehciInstance ehci instance pointer.
* @param ehciPipePointer ehci pipe pointer.
*
* @return kStatus_USB_Success or error codes.
*/
static usb_status_t USB_HostBandwidthFslsHostAllocate(usb_host_ehci_instance_t *ehciInstance,
usb_host_ehci_pipe_t *ehciPipePointer);
/*!
* @brief get the 2 power value of uint8_t.
*
* @param value input uint8_t value.
*/
static uint8_t USB_HostEhciGet2PowerValue(uint8_t value);
/*!
* @brief memory zero.
*
* @param buffer buffer pointer.
* @param length buffer length.
*/
static void USB_HostEhciZeroMem(uint32_t *buffer, uint32_t length);
/*!
* @brief host ehci delay.
*
* @param ehciIpBase ehci ip base address.
* @param ms millisecond.
*/
static void USB_HostEhciDelay(USBHS_Type *ehciIpBase, uint32_t ms);
/*!
* @brief host ehci start async schedule.
*
* @param ehciInstance ehci instance pointer.
*/
static void USB_HostEhciStartAsync(usb_host_ehci_instance_t *ehciInstance);
/*!
* @brief host ehci stop async schedule.
*
* @param ehciInstance ehci instance pointer.
*/
static void USB_HostEhciStopAsync(usb_host_ehci_instance_t *ehciInstance);
/*!
* @brief host ehci start periodic schedule.
*
* @param ehciInstance ehci instance pointer.
*/
static void USB_HostEhciStartPeriodic(usb_host_ehci_instance_t *ehciInstance);
/*!
* @brief host ehci stop periodic schedule.
*
* @param ehciInstance ehci instance pointer.
*/
static void USB_HostEhciStopPeriodic(usb_host_ehci_instance_t *ehciInstance);
/*!
* @brief initialize the qtd for one transfer.
*
* @param ehciInstance ehci instance pointer.
* @param ehciPipePointer ehci pipe pointer.
* @param transfer transfer information.
*
*@return kStatus_USB_Success or error codes.
*/
static usb_status_t USB_HostEhciQhQtdListInit(usb_host_ehci_instance_t *ehciInstance,
usb_host_ehci_pipe_t *ehciPipePointer,
usb_host_transfer_t *transfer);
/*!
* @brief release the qtd list.
*
* @param ehciInstance ehci instance pointer.
* @param ehciQtdStart qtd list start pointer.
* @param ehciQtdEnd qtd list end pointer.
*
*@return the transfer's length.
*/
static uint32_t USB_HostEhciQtdListRelease(usb_host_ehci_instance_t *ehciInstance,
usb_host_ehci_qtd_t *ehciQtdStart,
usb_host_ehci_qtd_t *ehciQtdEnd);
/*!
* @brief de-initialize qh's linking qtd list.
* 1. remove qtd from qh; 2. remove transfer from qh; 3. release qtd; 4. transfer callback.
*
* @param ehciInstance ehci instance pointer.
* @param ehciPipePointer ehci pipe.
*
*@return kStatus_USB_Success or error codes.
*/
static usb_status_t USB_HostEhciQhQtdListDeinit(usb_host_ehci_instance_t *ehciInstance,
智能车校赛摄像头循迹代码参考
需积分: 0 176 浏览量
更新于2023-10-11
25
收藏 143MB ZIP 举报
智能车校赛是一种深受学生喜爱的科技创新竞赛,它融合了机械、电子、计算机等多个领域的技术。在这样的比赛中,摄像头循迹是常见的技术挑战之一,它涉及到图像处理、控制理论以及实时系统等多个知识点。下面我们将详细探讨这些技术及其应用。
摄像头循迹的核心在于通过摄像头捕捉赛道的图像,然后对图像进行分析,提取出赛道边界,以此来指导车辆的行驶方向。这个过程主要包括以下几个步骤:
1. 图像采集:摄像头作为传感器,负责捕捉赛道的实时画面。选择合适的摄像头至关重要,它需要有良好的成像质量,能在不同光照条件下稳定工作。
2. 图像预处理:采集到的原始图像可能存在噪声、光照不均等问题,需要进行预处理,如灰度化、直方图均衡化、滤波等操作,以提高后续处理的效果。
3. 边缘检测:通过算法(如Canny、Sobel、Hough变换等)检测赛道的边缘。这些边缘将作为车辆行驶路径的依据。
4. 轨迹识别:根据边缘检测的结果,识别出赛道的轨迹。可能需要运用形态学操作、连通成分分析等手段,确保轨迹的连续性和稳定性。
5. 轨迹跟踪:将识别出的轨迹转化为车辆可以理解的控制信号。这通常需要将图像坐标系转换为车辆坐标系,并结合PID控制或其他控制算法,调整车辆的速度和转向角度。
6. 控制反馈:车辆在行驶过程中,需要不断根据实际位置与目标轨迹的偏差进行调整,这就需要用到控制理论。PID控制器是最常见的选择,但也可以考虑更复杂的控制策略,如自适应控制、滑模控制等。
7. 实时性:由于比赛环境的动态性,摄像头循迹系统必须具备快速响应的能力。这要求代码优化,减少计算延迟,确保在限定时间内完成处理并给出控制指令。
在"Code"这个文件中,很可能包含了实现上述功能的源代码。参赛者可能使用了Python、C++或MATLAB等语言,结合OpenCV等图像处理库来实现摄像头循迹。通过对代码的阅读和学习,可以深入了解每个步骤的具体实现,提升自己的技能水平。
在实际比赛中,除了技术实现,还需要考虑硬件平台的选择、系统的稳定性和可靠性、调试技巧等多方面因素。智能车摄像头循迹是一项综合性的技术挑战,既考验参赛者的编程能力,也锻炼他们的创新思维和团队协作能力。
星柯&
- 粉丝: 140
- 资源: 1
最新资源
- Golang_Puzzlers-春节主题资源
- 创创猫java单商户商城-品牌自营如三只松鼠-c/c++源码资源
- llvm-ocaml-doc-3.4.2-8.el7.x64-86.rpm.tar.gz
- 活动发布管理-活动资源
- llvm-private-7.0.1-1.el7.x64-86.rpm.tar.gz
- llvm-private-devel-7.0.1-1.el7.x64-86.rpm.tar.gz
- awesome-Geosciences-机器学习开发资源
- Simulation-matlab仿真资源
- llvm-static-3.4.2-8.el7.x64-86.rpm.tar.gz
- oops-game-kit-cocos资源
- HeartRateSPO2-硬件开发资源
- lm-sensors-3.4.0-8.20160601gitf9185e5.el7-9.1.x64-86.rpm.tar.gz
- Command on Scratch-scratch资源
- arlog-golang资源
- Golang_Puzzlers-春节主题资源
- lm-sensors-devel-3.4.0-8.20160601gitf9185e5.el7-9.1.x64-86.rpm.tar.gz