添加GD32H7的CMake工程
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
\file usbh_hid_core.h
|
||||
\brief header file for the usbh_hid_core.c
|
||||
|
||||
\version 2025-01-24, V1.4.0, firmware for GD32H7xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2025, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USBH_HID_CORE_H
|
||||
#define USBH_HID_CORE_H
|
||||
|
||||
#include "usb_hid.h"
|
||||
#include "usbh_enum.h"
|
||||
#include "usbh_transc.h"
|
||||
|
||||
#define HID_MIN_POLL 10U /*!< HID minimum polling */
|
||||
#define HID_REPORT_SIZE 16U /*!< HID report size */
|
||||
#define HID_QUEUE_SIZE 10U /*!< HID queue size */
|
||||
|
||||
#define USB_HID_DESC_SIZE 9U /*!< HID descriptor size */
|
||||
|
||||
/* states for HID state machine */
|
||||
typedef enum {
|
||||
HID_INIT = 0U, /*!< HID init state */
|
||||
HID_IDLE, /*!< HID idle state */
|
||||
HID_SEND_DATA, /*!< HID send data state */
|
||||
HID_BUSY, /*!< HID busy state */
|
||||
HID_GET_DATA, /*!< HID get data state */
|
||||
HID_SYNC, /*!< HID synchronous state */
|
||||
HID_POLL, /*!< HID polling state */
|
||||
HID_ERROR /*!< HID error state */
|
||||
} hid_state;
|
||||
|
||||
/* state types of HID control request */
|
||||
typedef enum {
|
||||
HID_REQ_INIT = 0U, /*!< HID init request */
|
||||
HID_REQ_IDLE, /*!< HID idle request */
|
||||
HID_REQ_GET_REPORT_DESC, /*!< get report descriptor request */
|
||||
HID_REQ_GET_HID_DESC, /*!< get HID descriptor request */
|
||||
HID_REQ_SET_IDLE, /*!< set idle request */
|
||||
HID_REQ_SET_PROTOCOL, /*!< set protocol request */
|
||||
HID_REQ_SET_REPORT /*!< set report request */
|
||||
} hid_ctlstate;
|
||||
|
||||
/* HID types */
|
||||
typedef enum {
|
||||
HID_MOUSE = 0x01U, /*!< HID mouse type */
|
||||
HID_KEYBOARD = 0x02U, /*!< HID keyboard type */
|
||||
HID_UNKNOWN = 0xFFU /*!< unknown type */
|
||||
} hid_type;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *buf; /*!< data FIFO buff pointer */
|
||||
uint16_t head; /*!< data FIFO header */
|
||||
uint16_t tail; /*!< data FIFO tail */
|
||||
uint16_t size; /*!< data FIFO size */
|
||||
uint8_t lock; /*!< data FIFO lock */
|
||||
} data_fifo;
|
||||
|
||||
/* structure for HID process */
|
||||
typedef struct _hid_process {
|
||||
uint8_t pipe_in; /*!< pipe IN */
|
||||
uint8_t pipe_out; /*!< pipe OUT */
|
||||
uint8_t ep_addr; /*!< endpoint address */
|
||||
uint8_t ep_in; /*!< endpoint IN */
|
||||
uint8_t ep_out; /*!< endpoint OUT */
|
||||
uint8_t *pdata; /*!< HID data pointer */
|
||||
__IO uint8_t data_ready; /*!< HID data ready */
|
||||
uint16_t len; /*!< HID data length */
|
||||
uint16_t poll; /*!< HID polling */
|
||||
__IO uint32_t timer; /*!< HID timer */
|
||||
usb_desc_hid hid_desc; /*!< HID descriptor */
|
||||
hid_state state; /*!< HID state structure */
|
||||
hid_ctlstate ctl_state; /*!< control request state structure */
|
||||
usbh_status (*init)(usb_core_driver *udev, usbh_host *uhost);
|
||||
usbh_status (*decode)(uint8_t *data);
|
||||
} usbh_hid_handler;
|
||||
|
||||
extern usbh_class usbh_hid;
|
||||
|
||||
/* function declarations */
|
||||
/* set HID report */
|
||||
usbh_status usbh_set_report(usb_core_driver *udev, \
|
||||
usbh_host *uhost, \
|
||||
uint8_t report_type, \
|
||||
uint8_t report_ID, \
|
||||
uint8_t report_len, \
|
||||
uint8_t *report_buf);
|
||||
|
||||
#endif /* USBH_HID_CORE_H */
|
||||
@@ -0,0 +1,96 @@
|
||||
/*!
|
||||
\file usbh_standard_hid.h
|
||||
\brief header file for usbh_standard_hid.c
|
||||
|
||||
\version 2025-01-24, V1.4.0, firmware for GD32H7xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2025, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USBH_STANDARD_HID_H
|
||||
#define USBH_STANDARD_HID_H
|
||||
|
||||
#include "usbh_hid_core.h"
|
||||
|
||||
//#define AZERTY_KEYBOARD
|
||||
#define QWERTY_KEYBOARD
|
||||
|
||||
#define MOUSE_BUTTON_1 0x01U /*!< mouse button 1 */
|
||||
#define MOUSE_BUTTON_2 0x02U /*!< mouse button 2 */
|
||||
#define MOUSE_BUTTON_3 0x04U /*!< mouse button 3 */
|
||||
|
||||
#define KBD_LEFT_CTRL 0x01U /*!< keyboard left ctrl key */
|
||||
#define KBD_LEFT_SHIFT 0x02U /*!< keyboard left shift key */
|
||||
#define KBD_LEFT_ALT 0x04U /*!< keyboard left alt key */
|
||||
#define KBD_LEFT_GUI 0x08U /*!< keyboard left gui key */
|
||||
#define KBD_RIGHT_CTRL 0x10U /*!< keyboard right ctrl key */
|
||||
#define KBD_RIGHT_SHIFT 0x20U /*!< keyboard right shift key */
|
||||
#define KBD_RIGHT_ALT 0x40U /*!< keyboard right alt key */
|
||||
#define KBD_RIGHT_GUI 0x80U /*!< keyboard right gui key */
|
||||
|
||||
#define KBD_PRESSED_MAX_NUM 6U /*!< keyboard pressed maximum number */
|
||||
|
||||
typedef struct _mouse_report_data {
|
||||
uint8_t x; /*!< X coordinate value */
|
||||
uint8_t y; /*!< Y coordinate value */
|
||||
uint8_t buttons[3]; /*!< button buff */
|
||||
} mouse_report_data;
|
||||
|
||||
typedef struct {
|
||||
uint8_t state; /*!< keyboard state */
|
||||
uint8_t lctrl; /*!< keyboard left control key */
|
||||
uint8_t lshift; /*!< keyboard left shift */
|
||||
uint8_t lalt; /*!< keyboard left alt */
|
||||
uint8_t lgui; /*!< keyboard left GUI */
|
||||
uint8_t rctrl; /*!< keyboard right control key */
|
||||
uint8_t rshift; /*!< keyboard right shift */
|
||||
uint8_t ralt; /*!< keyboard right alt */
|
||||
uint8_t rgui; /*!< keyboard right GUI */
|
||||
uint8_t keys[6]; /*!< keyboard keys buff */
|
||||
} hid_keybd_info;
|
||||
|
||||
/* function declarations */
|
||||
/* initialize mouse */
|
||||
void usr_mouse_init(void);
|
||||
/* process mouse data */
|
||||
void usr_mouse_process_data(mouse_report_data *data);
|
||||
/* initialize mouse function */
|
||||
usbh_status usbh_hid_mouse_init(usb_core_driver *udev, usbh_host *uhost);
|
||||
/* decode mouse information */
|
||||
usbh_status usbh_hid_mouse_decode(uint8_t *data);
|
||||
|
||||
/* initialize keyboard */
|
||||
void usr_keybrd_init(void);
|
||||
/* process keyboard data */
|
||||
void usr_keybrd_process_data(uint8_t pbuf);
|
||||
/* initialize the keyboard function */
|
||||
usbh_status usbh_hid_keybrd_init(usb_core_driver *udev, usbh_host *uhost);
|
||||
/* decode keyboard information */
|
||||
usbh_status usbh_hid_keybrd_decode(uint8_t *data);
|
||||
|
||||
#endif /* USBH_STANDARD_HID_H */
|
||||
Reference in New Issue
Block a user