佚名通过本文主要向大家介绍了stm32f103zet6编译环境mdk517usb部分函数库函数求解释!头文件:rl_usbh等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: stm32f103zet6 编译环境mdk517 usb部分函数库函数求解释!头文件:rl_usbh
描述:
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Device
* Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved.
*------------------------------------------------------------------------------
* Name: HID.c
* Purpose: USB Device Human Interface Device example program
*----------------------------------------------------------------------------*/
#include "cmsis_os.h"
#include "rl_usb.h"
#include "Board_LED.h"
#include "Board_Joystick.h"
#include "Board_GLCD.h"
#include "GLCD_Config.h"
extern GLCD_FONT GLCD_Font_6x8;
extern GLCD_FONT GLCD_Font_16x24;
int main (void) {
uint8_t but;
uint8_t buf[1];
LED_Initialize ();
Joystick_Initialize();
GLCD_Initialize ();
GLCD_SetBackgroundColor (GLCD_COLOR_BLUE);
GLCD_SetForegroundColor (GLCD_COLOR_WHITE);
GLCD_ClearScreen ();
GLCD_SetFont (&GLCD_Font_16x24);
GLCD_DrawString (0, 0*24, " USB Device ");
GLCD_DrawString (0, 1*24, " HID Class ");
GLCD_DrawString (0, 2*24, " HID Example ");
GLCD_DrawString (0, 4*24, "USBFS: HID0 ");
GLCD_DrawString (0, 8*24, " Keil Tools by ARM ");
GLCD_DrawString (0, 9*24, " www.keil.com ");
USBD_Initialize (0); /* USB Device 0 Initialization */
USBD_Connect (0); /* USB Device 0 Connect */
while (1) { /* Loop forever */
but = (uint8_t)(Joystick_GetState ());
if (but ^ buf[0]) {
buf[0] = but;
USBD_HID_GetReportTrigger(0, 0, &buf[0], 1);
}
osDelay(100); /* 100 ms delay for sampling buttons */
}
}
观察发现rl_usb.h是一个st提供给用户的api文件,其中文件中的说明如下:
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB
* Copyright (c) 2004-2015 ARM Germany GmbH. All rights reserved.
*------------------------------------------------------------------------------
* Name: rl_usb.h
* Purpose: USB User API
* Rev.: V6.6.1
*----------------------------------------------------------------------------*/
那么也就是说,st官方已经开发了一套便于用户开发usb程序的api函数,其中观察到:
// ==== USB Device Functions ====
/// \brief Initialize USB Device stack and controller
/// \param[in] device index of USB Device.
/// \return status code that indicates the execution status of the function as defined with \ref usbStatus.
extern usbStatus USBD_Initialize (uint8_t device);
/// \brief De-initialize USB Device stack and controller
/// \param[in] device index of USB Device.
/// \return status code that indicates the execution status of the function as defined with \ref usbStatus.
extern usbStatus USBD_Uninitialize (uint8_t device);
/// \brief Activate pull-up on D+ or D- line to signal USB Device connection on USB Bus
/// \param[in] device index of USB Device.
/// \return status code that indicates the execution status of the function as defined with \ref usbStatus.
extern usbStatus USBD_Connect (uint8_t device);
/// \brief Disconnect USB Device from USB Bus
描述:
stm32usb开发st官方例程keil5mdk5
大家有谁用过keil提供的kit来开发usb吗?这两天一直在研究,发现网上现在非常多的例程都是说的是从usb的整体框架开始编写,非常细节的比如usb的基础配置,io配置,枚举过程细节等等,还有中断函数都是要自己编写,然而st官方在mdk517版本中已经添加了相关的usb框架,并且提供了例程,其中一个例程的main函数如下:/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Device
* Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved.
*------------------------------------------------------------------------------
* Name: HID.c
* Purpose: USB Device Human Interface Device example program
*----------------------------------------------------------------------------*/
#include "cmsis_os.h"
#include "rl_usb.h"
#include "Board_LED.h"
#include "Board_Joystick.h"
#include "Board_GLCD.h"
#include "GLCD_Config.h"
extern GLCD_FONT GLCD_Font_6x8;
extern GLCD_FONT GLCD_Font_16x24;
int main (void) {
uint8_t but;
uint8_t buf[1];
LED_Initialize ();
Joystick_Initialize();
GLCD_Initialize ();
GLCD_SetBackgroundColor (GLCD_COLOR_BLUE);
GLCD_SetForegroundColor (GLCD_COLOR_WHITE);
GLCD_ClearScreen ();
GLCD_SetFont (&GLCD_Font_16x24);
GLCD_DrawString (0, 0*24, " USB Device ");
GLCD_DrawString (0, 1*24, " HID Class ");
GLCD_DrawString (0, 2*24, " HID Example ");
GLCD_DrawString (0, 4*24, "USBFS: HID0 ");
GLCD_DrawString (0, 8*24, " Keil Tools by ARM ");
GLCD_DrawString (0, 9*24, " www.keil.com ");
USBD_Initialize (0); /* USB Device 0 Initialization */
USBD_Connect (0); /* USB Device 0 Connect */
while (1) { /* Loop forever */
but = (uint8_t)(Joystick_GetState ());
if (but ^ buf[0]) {
buf[0] = but;
USBD_HID_GetReportTrigger(0, 0, &buf[0], 1);
}
osDelay(100); /* 100 ms delay for sampling buttons */
}
}
观察发现rl_usb.h是一个st提供给用户的api文件,其中文件中的说明如下:
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB
* Copyright (c) 2004-2015 ARM Germany GmbH. All rights reserved.
*------------------------------------------------------------------------------
* Name: rl_usb.h
* Purpose: USB User API
* Rev.: V6.6.1
*----------------------------------------------------------------------------*/
那么也就是说,st官方已经开发了一套便于用户开发usb程序的api函数,其中观察到:
// ==== USB Device Functions ====
/// \brief Initialize USB Device stack and controller
/// \param[in] device index of USB Device.
/// \return status code that indicates the execution status of the function as defined with \ref usbStatus.
extern usbStatus USBD_Initialize (uint8_t device);
/// \brief De-initialize USB Device stack and controller
/// \param[in] device index of USB Device.
/// \return status code that indicates the execution status of the function as defined with \ref usbStatus.
extern usbStatus USBD_Uninitialize (uint8_t device);
/// \brief Activate pull-up on D+ or D- line to signal USB Device connection on USB Bus
/// \param[in] device index of USB Device.
/// \return status code that indicates the execution status of the function as defined with \ref usbStatus.
extern usbStatus USBD_Connect (uint8_t device);
/// \brief Disconnect USB Device from USB Bus