update version to v2.0.4

This commit is contained in:
Artery-MCU
2022-04-11 19:32:28 +08:00
parent 07d7347ba4
commit ccd0f1e108
1470 changed files with 213761 additions and 13939 deletions

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_hid_class.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host hid class type
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -29,27 +29,27 @@
#include "usbh_ctrl.h"
#include "usbh_hid_mouse.h"
#include "usbh_hid_keyboard.h"
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @defgroup USBH_hid_class
* @brief usb host class hid demo
* @{
*/
*/
/** @defgroup USBH_hid_class_private_functions
* @{
*/
static usb_sts_type uhost_init_handler(void *uhost);
static usb_sts_type uhost_reset_handler(void *uhost);
static usb_sts_type uhost_request_handler(void *uhost);
static usb_sts_type uhost_process_handler(void *uhost);
usbh_hid_type usbh_hid;
usbh_class_handler_type uhost_hid_class_handler =
usbh_class_handler_type uhost_hid_class_handler =
{
uhost_init_handler,
uhost_reset_handler,
@@ -69,9 +69,9 @@ static usb_sts_type uhost_init_handler(void *uhost)
usb_sts_type status = USB_OK;
uint8_t hidx, eptidx = 0;
usbh_hid_type *phid = &usbh_hid;
puhost->class_handler->pdata = &usbh_hid;
/* get hid interface */
hidx = usbh_find_interface(puhost, USB_CLASS_CODE_HID, 0x01, 0xFF);
if(hidx == 0xFF)
@@ -79,10 +79,10 @@ static usb_sts_type uhost_init_handler(void *uhost)
USBH_DEBUG("Unsupport Device!");
return USB_NOT_SUPPORT;
}
/* get hid protocol */
phid->protocol = puhost->dev.cfg_desc.interface[hidx].interface.bInterfaceProtocol;
if(phid->protocol == USB_HID_MOUSE_PROTOCOL_CODE)
{
USBH_DEBUG("Mouse Device!");
@@ -91,7 +91,7 @@ static usb_sts_type uhost_init_handler(void *uhost)
{
USBH_DEBUG("Keyboard Device!");
}
for(eptidx = 0; eptidx < puhost->dev.cfg_desc.interface[hidx].interface.bNumEndpoints; eptidx ++)
{
if(puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].bEndpointAddress & 0x80)
@@ -100,12 +100,12 @@ static usb_sts_type uhost_init_handler(void *uhost)
phid->eptin = puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].bEndpointAddress;
phid->in_maxpacket = puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].wMaxPacketSize;
phid->in_poll = puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].bInterval;
phid->chin = usbh_alloc_channel(puhost, phid->eptin);
/* enable channel */
usbh_hc_open(puhost, phid->chin,phid->eptin,
puhost->dev.address, EPT_INT_TYPE,
phid->in_maxpacket,
phid->in_maxpacket,
puhost->dev.speed);
usbh_set_toggle(puhost, phid->chin, 0);
}
@@ -115,12 +115,12 @@ static usb_sts_type uhost_init_handler(void *uhost)
phid->eptout = puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].bEndpointAddress;
phid->out_maxpacket = puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].wMaxPacketSize;
phid->out_poll = puhost->dev.cfg_desc.interface[hidx].endpoint[eptidx].bInterval;
phid->chout = usbh_alloc_channel(puhost, usbh_hid.eptout);
/* enable channel */
usbh_hc_open(puhost, phid->chout, phid->eptout,
puhost->dev.address, EPT_INT_TYPE,
phid->out_maxpacket,
phid->out_maxpacket,
puhost->dev.speed);
usbh_set_toggle(puhost, phid->chout, 0);
}
@@ -143,7 +143,7 @@ static usb_sts_type uhost_reset_handler(void *uhost)
{
return status;
}
if(phid->chin != 0)
{
/* free in channel */
@@ -151,7 +151,7 @@ static usb_sts_type uhost_reset_handler(void *uhost)
usbh_ch_disable(puhost, phid->chin);
phid->chin = 0;
}
if(phid->chout != 0)
{
/* free out channel */
@@ -180,8 +180,8 @@ usb_sts_type usbh_hid_get_desc(void *uhost, uint16_t length)
{
bm_req = USB_REQ_RECIPIENT_INTERFACE | USB_REQ_TYPE_STANDARD;
wvalue = (0x21 << 8) & 0xFF00;
usbh_get_descriptor(puhost, length, bm_req,
usbh_get_descriptor(puhost, length, bm_req,
wvalue, puhost->rx_buffer);
}
else
@@ -218,14 +218,14 @@ usb_sts_type usbh_hid_get_report(void *uhost, uint16_t length)
{
bm_req = USB_REQ_RECIPIENT_INTERFACE | USB_REQ_TYPE_STANDARD;
wvalue = (0x22 << 8) & 0xFF00;
usbh_get_descriptor(puhost, length, bm_req,
usbh_get_descriptor(puhost, length, bm_req,
wvalue, puhost->rx_buffer);
}
else
{
if(usbh_ctrl_result_check(puhost, CONTROL_IDLE, ENUM_IDLE) == USB_OK)
{
{
status = USB_OK;
}
}
@@ -340,7 +340,7 @@ static usb_sts_type uhost_request_handler(void *uhost)
usb_sts_type status = USB_WAIT;
usbh_core_type *puhost = (usbh_core_type *)uhost;
usbh_hid_type *phid = (usbh_hid_type *)puhost->class_handler->pdata;
switch(phid->ctrl_state)
{
case USB_HID_STATE_IDLE:
@@ -375,9 +375,9 @@ static usb_sts_type uhost_request_handler(void *uhost)
status = USB_OK;
break;
default:
break;
break;
}
return status;
}
@@ -396,13 +396,13 @@ static usb_sts_type uhost_process_handler(void *uhost)
case USB_HID_INIT:
phid->state = USB_HID_GET;
break;
case USB_HID_GET:
usbh_interrupt_recv(puhost, phid->chin, (uint8_t *)phid->buffer, phid->in_maxpacket);
phid->state = USB_HID_POLL;
phid->poll_timer = usbh_get_frame(puhost->usb_reg);
break;
case USB_HID_POLL:
if((usbh_get_frame(puhost->usb_reg) - phid->poll_timer) >= phid->in_poll )
{
@@ -422,7 +422,7 @@ static usb_sts_type uhost_process_handler(void *uhost)
{
usbh_hid_keyboard_decode((uint8_t *)phid->buffer);
}
}
else if(urb_status == URB_STALL)
{
@@ -433,7 +433,7 @@ static usb_sts_type uhost_process_handler(void *uhost)
}
}
break;
default:
break;
}
@@ -442,7 +442,7 @@ static usb_sts_type uhost_process_handler(void *uhost)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_hid_class.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host hid class header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -30,19 +30,19 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usbh_core.h"
#include "usb_conf.h"
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @addtogroup USBH_hid_class
* @{
*/
/** @defgroup USBH_hid_class_definition
/** @defgroup USBH_hid_class_definition
* @{
*/
@@ -112,13 +112,13 @@ typedef struct
uint8_t eptin;
uint16_t in_maxpacket;
uint8_t in_poll;
uint8_t chout;
uint8_t eptout;
uint16_t out_maxpacket;
uint8_t out_poll;
uint8_t protocol;
usb_hid_desc_type hid_desc;
usb_hid_ctrl_state_type ctrl_state;
@@ -137,7 +137,7 @@ extern usbh_class_handler_type uhost_hid_class_handler;
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_hid_keyboard.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host hid keyboard type
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -24,21 +24,21 @@
**************************************************************************
*/
#include "usbh_hid_keyboard.h"
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @defgroup USBH_hid_class_keyboard
* @brief usb host class hid keyboard
* @{
*/
*/
/** @defgroup USBH_hid_class_keyboard_private_functions
* @{
*/
static const uint8_t hid_keyboard_codes[] =
static const uint8_t hid_keyboard_codes[] =
{
0, 0, 0, 0, 31, 50, 48, 33,
19, 34, 35, 36, 24, 37, 38, 39,
@@ -67,7 +67,7 @@ static const uint8_t hid_keyboard_codes[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
58, 44, 60, 127, 64, 57, 62, 128,
};
@@ -76,33 +76,33 @@ static const uint8_t hid_keyboard_codes[] =
static const int8_t hid_keyboard_key[] = {
'\0', '`', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '0', '-', '=', '\0', '\r',
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u',
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u',
'i', 'o', 'p', '[', ']', '\\',
'\0', 'a', 's', 'd', 'f', 'g', 'h', 'j',
'\0', 'a', 's', 'd', 'f', 'g', 'h', 'j',
'k', 'l', ';', '\'', '\0', '\n',
'\0', '\0', 'z', 'x', 'c', 'v', 'b', 'n',
'\0', '\0', 'z', 'x', 'c', 'v', 'b', 'n',
'm', ',', '.', '/', '\0', '\0',
'\0', '\0', '\0', ' ', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', ' ', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '7', '4', '1',
'\0', '/', '8', '5', '2',
'0', '*', '9', '6', '3',
'.', '-', '+', '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0'
};
static const int8_t hid_keyboard_key_shift[] = {
'\0', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'_', '+', '\0', '\0', '\0', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
'I', 'O', 'P', '{', '}', '|', '\0', 'A', 'S', 'D', 'F', 'G',
'H', 'J', 'K', 'L', ':', '"', '\0', '\n', '\0', '\0', 'Z', 'X',
'_', '+', '\0', '\0', '\0', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
'I', 'O', 'P', '{', '}', '|', '\0', 'A', 'S', 'D', 'F', 'G',
'H', 'J', 'K', 'L', ':', '"', '\0', '\n', '\0', '\0', 'Z', 'X',
'C', 'V', 'B', 'N', 'M', '<', '>', '?', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
@@ -111,14 +111,14 @@ static const int8_t hid_keyboard_key_shift[] = {
#else
static const int8_t hid_keyboard_key[] = {
'\0', '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'-', '=', '\0', '\r', '\t', 'a', 'z', 'e', 'r', 't', 'y', 'u',
'i', 'o', 'p', '[', ']', '\\', '\0', 'q', 's', 'd', 'f', 'g',
'h', 'j', 'k', 'l', 'm', '\0', '\0', '\n', '\0', '\0', 'w', 'x',
'c', 'v', 'b', 'n', ',', ';', ':', '!', '\0', '\0', '\0', '\0',
'\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '4', '1','\0', '/',
'8', '5', '2', '0', '*', '9', '6', '3', '.', '-', '+', '\0',
'-', '=', '\0', '\r', '\t', 'a', 'z', 'e', 'r', 't', 'y', 'u',
'i', 'o', 'p', '[', ']', '\\', '\0', 'q', 's', 'd', 'f', 'g',
'h', 'j', 'k', 'l', 'm', '\0', '\0', '\n', '\0', '\0', 'w', 'x',
'c', 'v', 'b', 'n', ',', ';', ':', '!', '\0', '\0', '\0', '\0',
'\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '4', '1','\0', '/',
'8', '5', '2', '0', '*', '9', '6', '3', '.', '-', '+', '\0',
'\n', '\0', '\0', '\0', '\0', '\0', '\0','\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
};
@@ -126,13 +126,13 @@ static const int8_t hid_keyboard_key[] = {
static const int8_t hid_keyboard_key_shift[] = {
'\0', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_',
'+', '\0', '\0', '\0', 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O',
'P', '{', '}', '*', '\0', 'Q', 'S', 'D', 'F', 'G', 'H', 'J', 'K',
'P', '{', '}', '*', '\0', 'Q', 'S', 'D', 'F', 'G', 'H', 'J', 'K',
'L', 'M', '%', '\0', '\n', '\0', '\0', 'W', 'X', 'C', 'V', 'B', 'N',
'?', '.', '/', '\0', '\0', '\0','\0', '\0', '\0', '\0', '\0', '\0', '\0',
'?', '.', '/', '\0', '\0', '\0','\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
};
#endif
@@ -152,17 +152,17 @@ void usbh_hid_keyboard_decode(uint8_t *data)
static uint8_t nb_keys;
static uint8_t nb_keys_n;
static uint8_t nb_keys_l;
uint8_t idx;
uint8_t idy;
uint8_t err;
uint8_t out;
nb_keys = 0;
nb_keys_n = 0;
nb_keys_l = 0;
key_newest = 0;
if(data[0] == KEYBOARD_LEFT_SHIFT || data[0] == KEYBOARD_RIGHT_SHIFT)
{
shift = TRUE;
@@ -172,7 +172,7 @@ void usbh_hid_keyboard_decode(uint8_t *data)
shift = FALSE;
}
err = FALSE;
for(idx = 2; idx < 2 + KEYBOARD_MAX_NB_PRESSED; idx ++)
{
if((data[idx] == 0x01) ||
@@ -182,12 +182,12 @@ void usbh_hid_keyboard_decode(uint8_t *data)
err = TRUE;
}
}
if(err == TRUE)
{
return;
}
nb_keys = 0;
nb_keys_n = 0;
for(idx = 2; idx < 2 + KEYBOARD_MAX_NB_PRESSED; idx ++)
@@ -203,20 +203,20 @@ void usbh_hid_keyboard_decode(uint8_t *data)
break;
}
}
if(idy == nb_keys_l)
{
keys_n[nb_keys_n] = data[idx];
nb_keys_n ++;
}
}
}
if(nb_keys_n == 1)
{
key_newest = keys_n[0];
if(shift == TRUE)
{
out = hid_keyboard_key_shift[hid_keyboard_codes[key_newest]];
@@ -232,7 +232,7 @@ void usbh_hid_keyboard_decode(uint8_t *data)
{
key_newest = 0;
}
nb_keys_l = nb_keys;
for(idx = 0; idx < KEYBOARD_MAX_NB_PRESSED; idx ++)
{
@@ -243,7 +243,7 @@ void usbh_hid_keyboard_decode(uint8_t *data)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_hid_keyboard.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host hid keyboard header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -30,18 +30,18 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usb_conf.h"
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @addtogroup USBH_hid_class_keyboard
* @{
*/
/** @defgroup USBH_hid_class_keyboard_definition
/** @defgroup USBH_hid_class_keyboard_definition
* @{
*/
@@ -73,7 +73,7 @@ void usbh_hid_keyboard_decode(uint8_t *data);
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_hid_mouse.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host hid mouse type
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -28,11 +28,11 @@
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @defgroup USBH_hid_class_mouse
* @brief usb host class hid mouse
* @{
*/
*/
/** @defgroup USBH_hid_class_mouse_private_functions
* @{
@@ -53,7 +53,7 @@ void usbh_hid_mouse_position(uint8_t x, uint8_t y)
{
x_pos += x / 2;
y_pos += y / 2;
if(x_pos > MOUSE_WINDOW_WIDTH - 12)
{
x_pos = MOUSE_WINDOW_WIDTH - 12;
@@ -62,7 +62,7 @@ void usbh_hid_mouse_position(uint8_t x, uint8_t y)
{
y_pos = MOUSE_WINDOW_HEIGHT - 12;
}
if(x_pos < 2)
{
x_pos = 2;
@@ -73,7 +73,7 @@ void usbh_hid_mouse_position(uint8_t x, uint8_t y)
}
USBH_DEBUG("Moving Mouse");
}
}
/**
@@ -137,7 +137,7 @@ void usbh_hid_mouse_process(usb_hid_mouse_type *mouse)
{
usbh_hid_mouse_position(mouse->x, mouse->y);
}
for(idx = 0; idx < 3; idx ++)
{
if(mouse->button & 1 << idx)
@@ -170,7 +170,7 @@ void usbh_hid_mouse_decode(uint8_t *mouse_data)
hid_mouse.x = mouse_data[1];
hid_mouse.y = mouse_data[2];
hid_mouse.z = mouse_data[3];
usbh_hid_mouse_process(&hid_mouse);
}
@@ -181,7 +181,7 @@ void usbh_hid_mouse_decode(uint8_t *mouse_data)
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_hid_mouse.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host hid mouse header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -30,18 +30,18 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usb_conf.h"
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @addtogroup USBH_hid_class_mouse
* @{
*/
/** @defgroup USBH_hid_class_mouse_definition
/** @defgroup USBH_hid_class_mouse_definition
* @{
*/
@@ -63,12 +63,12 @@ extern "C" {
/**
* @brief usb hid mouse type
*/
typedef struct
typedef struct
{
uint8_t button;
uint8_t button;
uint8_t x;
uint8_t y;
uint8_t z;
uint8_t z;
}usb_hid_mouse_type;
void usbh_hid_mouse_decode(uint8_t *mouse_data);
@@ -81,7 +81,7 @@ void usbh_hid_mouse_decode(uint8_t *mouse_data);
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_msc_bot_scsi.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host msc bulk-only transfer and scsi type
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -32,11 +32,11 @@
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @defgroup USBH_msc_bot_scsi_class
* @brief usb host class msc bot scsi
* @{
*/
*/
/** @defgroup USBH_msc_bot_scsi_class_private_functions
* @{
@@ -47,9 +47,9 @@ static usb_sts_type usbh_cmd_inquiry(msc_bot_trans_type *bot_trans, uint8_t *cmd
static usb_sts_type usbh_cmd_capacity10(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun);
static usb_sts_type usbh_cmd_test_unit_ready(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun);
static usb_sts_type usbh_cmd_requset_sense(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun);
static usb_sts_type usbh_cmd_write(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
static usb_sts_type usbh_cmd_write(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
uint32_t data_len, uint32_t address, uint8_t *buffer);
static usb_sts_type usbh_cmd_read(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
static usb_sts_type usbh_cmd_read(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
uint32_t data_len, uint32_t address, uint8_t *buffer);
/**
@@ -74,7 +74,7 @@ static usb_sts_type usbh_bot_cbw(msc_bot_cbw_type *cbw, uint32_t data_length, ui
}
return USB_OK;
}
/**
* @brief usb host msc command inquiry
* @param bot_trans: to the structure of msc_bot_trans_type
@@ -88,7 +88,7 @@ static usb_sts_type usbh_cmd_inquiry(msc_bot_trans_type *bot_trans, uint8_t *cmd
cmd[0] = MSC_OPCODE_INQUIRY;
cmd[1] = lun << 5;
cmd[4] = MSC_INQUIRY_DATA_LEN;
bot_trans->data = (uint8_t *)&msc_struct->l_unit_n[lun].inquiry;
return USB_OK;
}
@@ -105,7 +105,7 @@ static usb_sts_type usbh_cmd_capacity10(msc_bot_trans_type *bot_trans, uint8_t *
usbh_msc_type *msc_struct = (usbh_msc_type *)bot_trans->msc_struct;
cmd[0] = MSC_OPCODE_CAPACITY;
cmd[1] = lun << 5;
msc_struct->bot_trans.data = (uint8_t *)bot_trans->buffer;
return USB_OK;
}
@@ -121,7 +121,7 @@ static usb_sts_type usbh_cmd_test_unit_ready(msc_bot_trans_type *bot_trans, uint
{
cmd[0] = MSC_OPCODE_TEST_UNIT_READY;
cmd[1] = lun << 5;
return USB_OK;
}
@@ -137,7 +137,7 @@ static usb_sts_type usbh_cmd_requset_sense(msc_bot_trans_type *bot_trans, uint8_
cmd[0] = MSC_OPCODE_REQUEST_SENSE;
cmd[1] = lun << 5;
cmd[4] = MSC_REQUEST_SENSE_DATA_LEN;
bot_trans->data = bot_trans->buffer;
return USB_OK;
}
@@ -152,7 +152,7 @@ static usb_sts_type usbh_cmd_requset_sense(msc_bot_trans_type *bot_trans, uint8_
* @param buffer: transfer data buffer
* @retval status: usb_sts_type status
*/
static usb_sts_type usbh_cmd_write(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
static usb_sts_type usbh_cmd_write(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
uint32_t data_len, uint32_t address, uint8_t *buffer)
{
cmd[0] = MSC_OPCODE_WRITE10;
@@ -161,10 +161,10 @@ static usb_sts_type usbh_cmd_write(msc_bot_trans_type *bot_trans, uint8_t *cmd,
cmd[3] = (uint8_t)(address >> 16);
cmd[4] = (uint8_t)(address >> 8);
cmd[5] = (uint8_t)(address & 0xFF);
cmd[7] = data_len >> 8;
cmd[8] = data_len;
bot_trans->data = buffer;
return USB_OK;
}
@@ -179,7 +179,7 @@ static usb_sts_type usbh_cmd_write(msc_bot_trans_type *bot_trans, uint8_t *cmd,
* @param buffer: transfer data buffer
* @retval status: usb_sts_type status
*/
static usb_sts_type usbh_cmd_read(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
static usb_sts_type usbh_cmd_read(msc_bot_trans_type *bot_trans, uint8_t *cmd, uint8_t lun,
uint32_t data_len, uint32_t address, uint8_t *buffer)
{
cmd[0] = MSC_OPCODE_READ10;
@@ -188,10 +188,10 @@ static usb_sts_type usbh_cmd_read(msc_bot_trans_type *bot_trans, uint8_t *cmd, u
cmd[3] = (uint8_t)(address >> 16);
cmd[4] = (uint8_t)(address >> 8);
cmd[5] = (uint8_t)(address & 0xFF);
cmd[7] = data_len >> 8;
cmd[8] = data_len;
bot_trans->data = buffer;
return USB_OK;
}
@@ -237,7 +237,7 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
usbh_bulk_send(puhost, msc_struct->chout, (uint8_t *)(&bot_trans->cbw), MSC_CBW_LEN);
bot_trans->bot_state = BOT_STATE_SEND_CBW_WAIT;
break;
case BOT_STATE_SEND_CBW_WAIT:
urb_status = usbh_get_urb_status(puhost, msc_struct->chout);
if(urb_status == URB_DONE)
@@ -267,13 +267,13 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
bot_trans->bot_state = BOT_STATE_ERROR_OUT;
}
break;
case BOT_STATE_DATA_IN:
usbh_bulk_recv(puhost, msc_struct->chin, bot_trans->data,
usbh_bulk_recv(puhost, msc_struct->chin, bot_trans->data,
msc_struct->in_maxpacket);
bot_trans->bot_state = BOT_STATE_DATA_IN_WAIT;
break;
case BOT_STATE_DATA_IN_WAIT:
urb_status = usbh_get_urb_status(puhost, msc_struct->chin);
if(urb_status == URB_DONE)
@@ -289,11 +289,11 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
}
if(bot_trans->cbw.dCBWDataTransferLength > 0)
{
usbh_bulk_recv(puhost, msc_struct->chin, bot_trans->data,
usbh_bulk_recv(puhost, msc_struct->chin, bot_trans->data,
msc_struct->in_maxpacket);
}
else
{
{
bot_trans->bot_state = BOT_STATE_RECV_CSW;
}
}
@@ -301,14 +301,14 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
{
bot_trans->bot_state = BOT_STATE_ERROR_IN;
}
break;
case BOT_STATE_DATA_OUT:
usbh_bulk_send(puhost, msc_struct->chout, bot_trans->data, msc_struct->out_maxpacket);
bot_trans->bot_state = BOT_STATE_DATA_OUT_WAIT;
break;
case BOT_STATE_DATA_OUT_WAIT:
urb_status = usbh_get_urb_status(puhost, msc_struct->chout);
if(urb_status == URB_DONE)
@@ -340,12 +340,12 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
bot_trans->bot_state = BOT_STATE_ERROR_OUT;
}
break;
case BOT_STATE_RECV_CSW:
usbh_bulk_recv(puhost, msc_struct->chin, (uint8_t *)&bot_trans->csw,
usbh_bulk_recv(puhost, msc_struct->chin, (uint8_t *)&bot_trans->csw,
MSC_CSW_LEN);
bot_trans->bot_state = BOT_STATE_RECV_CSW_WAIT;
break;
case BOT_STATE_RECV_CSW_WAIT:
urb_status = usbh_get_urb_status(puhost, msc_struct->chin);
@@ -359,7 +359,7 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
{
bot_trans->bot_state = BOT_STATE_ERROR_IN;
}
break;
case BOT_STATE_ERROR_IN:
clr_status = usbh_clear_ept_feature(puhost, msc_struct->eptin, msc_struct->chin);
@@ -368,7 +368,7 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
bot_trans->bot_state = BOT_STATE_RECV_CSW;
usbh_set_toggle(puhost, msc_struct->chin, 0);
}
break;
case BOT_STATE_ERROR_OUT:
clr_status = usbh_clear_ept_feature(puhost, msc_struct->eptout, msc_struct->chout);
@@ -381,11 +381,11 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
break;
case BOT_STATE_COMPLETE:
break;
default:
break;
}
return status;
}
@@ -397,7 +397,7 @@ usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans)
* @param inquiry: to the structure of msc_scsi_data_inquiry
* @retval status: usb_sts_type status
*/
usb_sts_type usbh_msc_bot_scsi_get_inquiry(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_get_inquiry(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun, msc_scsi_data_inquiry *inquiry)
{
usb_sts_type status = USB_WAIT;
@@ -409,7 +409,7 @@ usb_sts_type usbh_msc_bot_scsi_get_inquiry(void *uhost, msc_bot_trans_type *bot
bot_trans->cmd_state = CMD_STATE_WAIT;
bot_trans->bot_state = BOT_STATE_SEND_CBW;
break;
case CMD_STATE_WAIT:
status = usb_bot_request(uhost, bot_trans);
if(status == USB_OK)
@@ -435,7 +435,7 @@ usb_sts_type usbh_msc_bot_scsi_get_inquiry(void *uhost, msc_bot_trans_type *bot
* @param capacity: to the structure of msc_scsi_data_capacity
* @retval status: usb_sts_type status
*/
usb_sts_type usbh_msc_bot_scsi_capacity(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_capacity(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun, msc_scsi_data_capacity *capacity)
{
usb_sts_type status = USB_WAIT;
@@ -447,7 +447,7 @@ usb_sts_type usbh_msc_bot_scsi_capacity(void *uhost, msc_bot_trans_type *bot_tra
bot_trans->cmd_state = CMD_STATE_WAIT;
bot_trans->bot_state = BOT_STATE_SEND_CBW;
break;
case CMD_STATE_WAIT:
status = usb_bot_request(uhost, bot_trans);
if(status == USB_OK)
@@ -475,20 +475,20 @@ usb_sts_type usbh_msc_bot_scsi_capacity(void *uhost, msc_bot_trans_type *bot_tra
* @param lun: logical unit number
* @retval status: usb_sts_type status
*/
usb_sts_type usbh_msc_bot_scsi_test_unit_ready(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_test_unit_ready(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun)
{
usb_sts_type status = USB_WAIT;
switch(bot_trans->cmd_state)
{
case CMD_STATE_SEND:
usbh_bot_cbw(&bot_trans->cbw, MSC_TEST_UNIT_READY_DATA_LEN,
usbh_bot_cbw(&bot_trans->cbw, MSC_TEST_UNIT_READY_DATA_LEN,
MSC_TEST_UNIT_READY_CMD_LEN, MSC_CBW_FLAG_OUT);
usbh_cmd_test_unit_ready(bot_trans, bot_trans->cbw.CBWCB, lun);
bot_trans->cmd_state = CMD_STATE_WAIT;
bot_trans->bot_state = BOT_STATE_SEND_CBW;
break;
case CMD_STATE_WAIT:
status = usb_bot_request(uhost, bot_trans);
if(status == USB_OK)
@@ -513,20 +513,20 @@ usb_sts_type usbh_msc_bot_scsi_test_unit_ready(void *uhost, msc_bot_trans_type *
* @param lun: logical unit number
* @retval status: usb_sts_type status
*/
usb_sts_type usbh_msc_bot_scsi_request_sense(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_request_sense(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun)
{
usb_sts_type status = USB_WAIT;
switch(bot_trans->cmd_state)
{
case CMD_STATE_SEND:
usbh_bot_cbw(&bot_trans->cbw, MSC_REQUEST_SENSE_DATA_LEN,
usbh_bot_cbw(&bot_trans->cbw, MSC_REQUEST_SENSE_DATA_LEN,
MSC_REQUEST_SENSE_CMD_LEN, MSC_CBW_FLAG_IN);
usbh_cmd_requset_sense(bot_trans, bot_trans->cbw.CBWCB, lun);
bot_trans->cmd_state = CMD_STATE_WAIT;
bot_trans->bot_state = BOT_STATE_SEND_CBW;
break;
case CMD_STATE_WAIT:
status = usb_bot_request(uhost, bot_trans);
if(status == USB_OK)
@@ -562,13 +562,13 @@ usb_sts_type usbh_msc_bot_scsi_write(void *uhost, msc_bot_trans_type *bot_trans,
switch(bot_trans->cmd_state)
{
case CMD_STATE_SEND:
usbh_bot_cbw(&bot_trans->cbw, write_len * 512,
usbh_bot_cbw(&bot_trans->cbw, write_len * 512,
MSC_WRITE_CMD_LEN, MSC_CBW_FLAG_OUT);
usbh_cmd_write(bot_trans, bot_trans->cbw.CBWCB, lun, write_len, address, write_data);
bot_trans->cmd_state = CMD_STATE_WAIT;
bot_trans->bot_state = BOT_STATE_SEND_CBW;
break;
case CMD_STATE_WAIT:
status = usb_bot_request(uhost, bot_trans);
if(status == USB_OK)
@@ -604,13 +604,13 @@ usb_sts_type usbh_msc_bot_scsi_read(void *uhost, msc_bot_trans_type *bot_trans,
switch(bot_trans->cmd_state)
{
case CMD_STATE_SEND:
usbh_bot_cbw(&bot_trans->cbw, read_len * 512,
usbh_bot_cbw(&bot_trans->cbw, read_len * 512,
MSC_READ_CMD_LEN, MSC_CBW_FLAG_IN);
usbh_cmd_read(bot_trans, bot_trans->cbw.CBWCB, lun, read_len, address, read_data);
bot_trans->cmd_state = CMD_STATE_WAIT;
bot_trans->bot_state = BOT_STATE_SEND_CBW;
break;
case CMD_STATE_WAIT:
status = usb_bot_request(uhost, bot_trans);
if(status == USB_OK)
@@ -650,7 +650,7 @@ usb_sts_type msc_bot_scsi_init(usbh_msc_type *msc_struct)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_msc_bot_scsi.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host msc bulk-only transfer and scsi header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -30,19 +30,19 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usbh_core.h"
#include "usb_conf.h"
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @addtogroup USBH_msc_bot_scsi_class
* @{
*/
/** @defgroup USBH_msc_bot_scsi_class_definition
/** @defgroup USBH_msc_bot_scsi_class_definition
* @{
*/
@@ -201,16 +201,16 @@ typedef struct
usb_sts_type usb_bot_request(void *uhost, msc_bot_trans_type *bot_trans);
usb_sts_type usbh_msc_bot_scsi_get_inquiry(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_get_inquiry(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun, msc_scsi_data_inquiry *inquiry);
usb_sts_type usbh_msc_bot_scsi_capacity(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_capacity(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun, msc_scsi_data_capacity *capacity);
usb_sts_type usbh_msc_bot_scsi_test_unit_ready(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_test_unit_ready(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun);
usb_sts_type usbh_msc_bot_scsi_request_sense(void *uhost, msc_bot_trans_type *bot_trans,
usb_sts_type usbh_msc_bot_scsi_request_sense(void *uhost, msc_bot_trans_type *bot_trans,
uint8_t lun);
usb_sts_type usbh_msc_bot_scsi_write(void *uhost, msc_bot_trans_type *bot_trans,
@@ -227,7 +227,7 @@ usb_sts_type usbh_msc_bot_scsi_read(void *uhost, msc_bot_trans_type *bot_trans,
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_msc_class.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host msc class type
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -31,11 +31,11 @@
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @defgroup USBH_msc_class
* @brief usb host class msc demo
* @{
*/
*/
/** @defgroup USBH_msc_class_private_functions
* @{
@@ -52,7 +52,7 @@ static usb_sts_type usbh_msc_clear_feature(void *uhost, uint8_t ept_num);
usbh_msc_type usbh_msc;
usbh_class_handler_type uhost_msc_class_handler =
usbh_class_handler_type uhost_msc_class_handler =
{
uhost_init_handler,
uhost_reset_handler,
@@ -75,7 +75,7 @@ static usb_sts_type uhost_init_handler(void *uhost)
uint8_t if_x, eptidx = 0;
usbh_msc_type *pmsc = &usbh_msc;
puhost->class_handler->pdata = &usbh_msc;
if_x = usbh_find_interface(puhost, USB_CLASS_CODE_MSC, MSC_SUBCLASS_SCSI_TRANS, MSC_PROTOCOL_BBB);
if(if_x == 0xFF)
{
@@ -83,7 +83,7 @@ static usb_sts_type uhost_init_handler(void *uhost)
return USB_NOT_SUPPORT;
}
pmsc->protocol = puhost->dev.cfg_desc.interface[if_x].interface.bInterfaceProtocol;
for(eptidx = 0; eptidx < puhost->dev.cfg_desc.interface[if_x].interface.bNumEndpoints; eptidx ++)
{
if(puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].bEndpointAddress & 0x80)
@@ -91,12 +91,12 @@ static usb_sts_type uhost_init_handler(void *uhost)
pmsc->eptin = puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].bEndpointAddress;
pmsc->in_maxpacket = puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].wMaxPacketSize;
pmsc->in_poll = puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].bInterval;
pmsc->chin = usbh_alloc_channel(puhost, pmsc->eptin);
/* enable channel */
usbh_hc_open(puhost, pmsc->chin, pmsc->eptin,
puhost->dev.address, EPT_BULK_TYPE,
pmsc->in_maxpacket,
pmsc->in_maxpacket,
puhost->dev.speed);
}
else
@@ -104,16 +104,16 @@ static usb_sts_type uhost_init_handler(void *uhost)
pmsc->eptout = puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].bEndpointAddress;
pmsc->out_maxpacket = puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].wMaxPacketSize;
pmsc->out_poll = puhost->dev.cfg_desc.interface[if_x].endpoint[eptidx].bInterval;
pmsc->chout = usbh_alloc_channel(puhost, pmsc->eptout);
/* enable channel */
usbh_hc_open(puhost, pmsc->chout,pmsc->eptout,
puhost->dev.address, EPT_BULK_TYPE,
pmsc->out_maxpacket,
pmsc->out_maxpacket,
puhost->dev.speed);
}
}
msc_bot_scsi_init(pmsc);
usbh_set_toggle(puhost, pmsc->chout, 0);
usbh_set_toggle(puhost, pmsc->chin, 0);
@@ -136,7 +136,7 @@ static usb_sts_type uhost_reset_handler(void *uhost)
{
return status;
}
for(i_index = 0; i_index < pmsc->max_lun ; i_index ++)
{
pmsc->l_unit_n[i_index].pre_state = USB_FAIL;
@@ -144,14 +144,14 @@ static usb_sts_type uhost_reset_handler(void *uhost)
pmsc->l_unit_n[i_index].state = USBH_MSC_INIT;
pmsc->l_unit_n[i_index].ready = MSC_NOT_READY;
}
if(pmsc->chin != 0 )
{
usbh_free_channel(puhost, pmsc->chin);
usbh_ch_disable(puhost, pmsc->chin);
pmsc->chin = 0;
}
if(pmsc->chout != 0 )
{
usbh_free_channel(puhost, pmsc->chout);
@@ -173,7 +173,7 @@ static usb_sts_type uhost_request_handler(void *uhost)
usbh_msc_type *pmsc = (usbh_msc_type *)puhost->class_handler->pdata;
usb_sts_type status = USB_WAIT;
uint8_t i_index = 0;
switch(pmsc->ctrl_state)
{
case USBH_MSC_STATE_IDLE:
@@ -201,7 +201,7 @@ static usb_sts_type uhost_request_handler(void *uhost)
default:
break;
}
return status;
}
@@ -251,7 +251,7 @@ static usb_sts_type uhost_process_handler(void *uhost)
pmsc->l_unit_n[pmsc->cur_lun].ready = MSC_NOT_READY;
}
break;
case USBH_MSC_READ_CAPACITY10:
status = usbh_msc_bot_scsi_capacity(uhost, &pmsc->bot_trans, pmsc->cur_lun, &pmsc->l_unit_n[pmsc->cur_lun].capacity);
if(status == USB_OK)
@@ -281,7 +281,7 @@ static usb_sts_type uhost_process_handler(void *uhost)
pmsc->l_unit_n[pmsc->cur_lun].state = USBH_MSC_ERROR;
}
break;
case USBH_MSC_BUSY:
break;
case USBH_MSC_ERROR:
@@ -456,9 +456,9 @@ usb_sts_type usbh_msc_read(void *uhost, uint32_t address, uint32_t len, uint8_t
pmsc->bot_trans.msc_struct = &usbh_msc;
pmsc->l_unit_n[lun].state = USBH_MSC_READ10;
pmsc->use_lun = lun;
timeout = puhost->timer;
while(usbh_msc_rw_handle(uhost, address, len, buffer, lun) == USB_WAIT)
{
if(puhost->conn_sts == 0 || (puhost->timer - timeout) > (len * 10000))
@@ -489,11 +489,11 @@ usb_sts_type usbh_msc_write(void *uhost, uint32_t address, uint32_t len, uint8_t
{
return USB_FAIL;
}
pmsc->bot_trans.msc_struct = &usbh_msc;
pmsc->l_unit_n[lun].state = USBH_MSC_WRITE;
pmsc->use_lun = lun;
timeout = puhost->timer;
while(usbh_msc_rw_handle(uhost, address, len, buffer, lun) == USB_WAIT)
{
@@ -508,7 +508,7 @@ usb_sts_type usbh_msc_write(void *uhost, uint32_t address, uint32_t len, uint8_t
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file usbh_msc_class.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb host msc class header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -30,7 +30,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usbh_core.h"
#include "usb_conf.h"
#include "usbh_msc_bot_scsi.h"
@@ -38,12 +38,12 @@ extern "C" {
/** @addtogroup AT32F415_middlewares_usbh_class
* @{
*/
/** @addtogroup USBH_msc_class
* @{
*/
/** @defgroup USBH_msc_class_definition
/** @defgroup USBH_msc_class_definition
* @{
*/
@@ -96,17 +96,17 @@ typedef struct
uint8_t eptin;
uint16_t in_maxpacket;
uint8_t in_poll;
uint8_t chout;
uint8_t eptout;
uint16_t out_maxpacket;
uint8_t out_poll;
uint8_t protocol;
uint32_t max_lun;
uint32_t cur_lun;
uint32_t use_lun;
usbh_msc_ctrl_state_type ctrl_state;
msc_state_type state;
@@ -132,7 +132,7 @@ usb_sts_type msc_bot_scsi_init(usbh_msc_type *msc_struct);
/**
* @}
*/
/**
* @}
*/