clang format

input_events
NepEgor 3 years ago
parent b5ab8e525b
commit 6403ac5ac5

@ -0,0 +1,29 @@
UseTab: false
IndentWidth: 4
#AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: true
ColumnLimit: 0
PointerAlignment: Left
#AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
#AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignAfterOpenBracket: true
BreakBeforeBraces: Custom
SortIncludes: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

@ -4,25 +4,25 @@
#include <stdint.h> #include <stdint.h>
#define USB_HID_CUSTOM_CONFIG_DESC_SIZ 34U #define USB_HID_CUSTOM_CONFIG_DESC_SIZ 34U
#define USB_HID_CUSTOM_DESC_SIZ 9U #define USB_HID_CUSTOM_DESC_SIZ 9U
#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU #define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
#define HID_CUSTOM_REPORT_DESC_SIZE 34U #define HID_CUSTOM_REPORT_DESC_SIZE 34U
//#define HID_KEYBOARD_REPORT_DESC_SIZE 45U //#define HID_KEYBOARD_REPORT_DESC_SIZE 45U
#define HID_DESCRIPTOR_TYPE 0x21 #define HID_DESCRIPTOR_TYPE 0x21
#ifndef HID_HS_BINTERVAL #ifndef HID_HS_BINTERVAL
#define HID_HS_BINTERVAL 0x07U #define HID_HS_BINTERVAL 0x07U
#endif #endif
#ifndef HID_FS_BINTERVAL #ifndef HID_FS_BINTERVAL
#define HID_FS_BINTERVAL 0x0AU #define HID_FS_BINTERVAL 0x0AU
#endif #endif
#define HID_CUSTOM_INTERFACE 0x00U #define HID_CUSTOM_INTERFACE 0x00U
#define HID_CUSTOM_EPIN_ADDR 0x81U #define HID_CUSTOM_EPIN_ADDR 0x81U
#define HID_CUSTOM_EPIN_SIZE 0x08U #define HID_CUSTOM_EPIN_SIZE 0x08U
//#define HID_KEYBOARD_INTERFACE 0x01U //#define HID_KEYBOARD_INTERFACE 0x01U
//#define HID_KEYBOARD_EPIN_ADDR 0x82U //#define HID_KEYBOARD_EPIN_ADDR 0x82U

@ -4,16 +4,16 @@
#include "usbd_ioreq.h" #include "usbd_ioreq.h"
#include "usbd_ep_conf.h" #include "usbd_ep_conf.h"
#define HID_REPORT_DESC 0x22 #define HID_REPORT_DESC 0x22
#define HID_REQ_SET_PROTOCOL 0x0BU #define HID_REQ_SET_PROTOCOL 0x0BU
#define HID_REQ_GET_PROTOCOL 0x03U #define HID_REQ_GET_PROTOCOL 0x03U
#define HID_REQ_SET_IDLE 0x0AU #define HID_REQ_SET_IDLE 0x0AU
#define HID_REQ_GET_IDLE 0x02U #define HID_REQ_GET_IDLE 0x02U
#define HID_REQ_SET_REPORT 0x09U #define HID_REQ_SET_REPORT 0x09U
#define HID_REQ_GET_REPORT 0x01U #define HID_REQ_GET_REPORT 0x01U
typedef enum typedef enum
{ {
@ -24,9 +24,9 @@ HID_StateTypeDef;
typedef struct typedef struct
{ {
uint32_t Protocol; uint32_t Protocol;
uint32_t IdleState; uint32_t IdleState;
uint32_t AltSetting; uint32_t AltSetting;
HID_StateTypeDef Mousestate; HID_StateTypeDef Mousestate;
} }
USBD_HID_HandleTypeDef; USBD_HID_HandleTypeDef;
@ -34,8 +34,8 @@ USBD_HID_HandleTypeDef;
extern USBD_ClassTypeDef USBD_CUSTOM_HID; extern USBD_ClassTypeDef USBD_CUSTOM_HID;
#define USBD_CUSTOM_HID_CLASS &USBD_CUSTOM_HID #define USBD_CUSTOM_HID_CLASS &USBD_CUSTOM_HID
uint8_t USBD_HID_CUSTOM_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len); uint8_t USBD_HID_CUSTOM_SendReport(USBD_HandleTypeDef* pdev, uint8_t* report, uint16_t len);
uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev); uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef* pdev);
#endif #endif

@ -4,6 +4,6 @@
void HID_Custom_Init(); void HID_Custom_Init();
void HID_Custom_DeInit(); void HID_Custom_DeInit();
void HID_Custom_sendReport(uint8_t *report, uint16_t len); void HID_Custom_sendReport(uint8_t* report, uint16_t len);
#endif #endif

@ -3,28 +3,28 @@
#include "usbd_descriptors.h" #include "usbd_descriptors.h"
static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx); static uint8_t USBD_HID_Init(USBD_HandleTypeDef* pdev, uint8_t cfgidx);
static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx); static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef* pdev, uint8_t cfgidx);
static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req);
static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req);
static uint8_t *USBD_HID_GetFSCfgDesc(uint16_t *length); static uint8_t* USBD_HID_GetFSCfgDesc(uint16_t* length);
static uint8_t *USBD_HID_GetHSCfgDesc(uint16_t *length); static uint8_t* USBD_HID_GetHSCfgDesc(uint16_t* length);
static uint8_t *USBD_HID_GetOtherSpeedCfgDesc(uint16_t *length); static uint8_t* USBD_HID_GetOtherSpeedCfgDesc(uint16_t* length);
static uint8_t *USBD_HID_GetDeviceQualifierDesc(uint16_t *length); static uint8_t* USBD_HID_GetDeviceQualifierDesc(uint16_t* length);
static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum); static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef* pdev, uint8_t epnum);
USBD_ClassTypeDef USBD_CUSTOM_HID = { USBD_ClassTypeDef USBD_CUSTOM_HID = {
USBD_HID_Init, USBD_HID_Init,
USBD_HID_DeInit, USBD_HID_DeInit,
USBD_CUSTOM_HID_Setup, USBD_CUSTOM_HID_Setup,
NULL, //EP0_TxSent NULL, //EP0_TxSent
NULL, //EP0_RxReady NULL, //EP0_RxReady
USBD_HID_DataIn, //DataIn USBD_HID_DataIn, //DataIn
NULL, //DataOut NULL, //DataOut
NULL, //SOF NULL, //SOF
NULL, NULL,
NULL, NULL,
USBD_HID_GetHSCfgDesc, USBD_HID_GetHSCfgDesc,
@ -33,7 +33,7 @@ USBD_ClassTypeDef USBD_CUSTOM_HID = {
USBD_HID_GetDeviceQualifierDesc, USBD_HID_GetDeviceQualifierDesc,
}; };
static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) static uint8_t USBD_HID_Init(USBD_HandleTypeDef* pdev, uint8_t cfgidx)
{ {
UNUSED(cfgidx); UNUSED(cfgidx);
uint8_t ret = USBD_OK; uint8_t ret = USBD_OK;
@ -57,14 +57,14 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
} }
else else
{ {
((USBD_HID_HandleTypeDef *)pdev->pClassData)->Mousestate = HID_IDLE; ((USBD_HID_HandleTypeDef*)pdev->pClassData)->Mousestate = HID_IDLE;
//((USBD_HID_HandleTypeDef *)pdev->pClassData)->Keyboardstate = HID_IDLE; //((USBD_HID_HandleTypeDef *)pdev->pClassData)->Keyboardstate = HID_IDLE;
} }
return ret; return ret;
} }
static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx) static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef* pdev, uint8_t cfgidx)
{ {
UNUSED(cfgidx); UNUSED(cfgidx);
/* Close HID EPs */ /* Close HID EPs */
@ -84,7 +84,7 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
return USBD_OK; return USBD_OK;
} }
static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req)
{ {
/* Check which interface is targetted by this request */ /* Check which interface is targetted by this request */
//if ((req->wIndex & 0x00FF) == HID_KEYBOARD_INTERFACE) //if ((req->wIndex & 0x00FF) == HID_KEYBOARD_INTERFACE)
@ -93,15 +93,15 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqType
//} //}
//else //else
//{ //{
return USBD_HID_MOUSE_Setup(pdev, req); return USBD_HID_MOUSE_Setup(pdev, req);
//} //}
} }
static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req)
{ {
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef*)pdev->pClassData; USBD_HID_HandleTypeDef* hhid = (USBD_HID_HandleTypeDef*)pdev->pClassData;
uint16_t len = 0U; uint16_t len = 0U;
uint8_t *pbuf = NULL; uint8_t* pbuf = NULL;
uint16_t status_info = 0U; uint16_t status_info = 0U;
USBD_StatusTypeDef ret = USBD_OK; USBD_StatusTypeDef ret = USBD_OK;
@ -115,7 +115,7 @@ static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTyped
break; break;
case HID_REQ_GET_PROTOCOL: case HID_REQ_GET_PROTOCOL:
USBD_CtlSendData(pdev, (uint8_t *)&hhid->Protocol, 1U); USBD_CtlSendData(pdev, (uint8_t*)&hhid->Protocol, 1U);
break; break;
case HID_REQ_SET_IDLE: case HID_REQ_SET_IDLE:
@ -123,7 +123,7 @@ static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTyped
break; break;
case HID_REQ_GET_IDLE: case HID_REQ_GET_IDLE:
USBD_CtlSendData(pdev, (uint8_t *)&hhid->IdleState, 1U); USBD_CtlSendData(pdev, (uint8_t*)&hhid->IdleState, 1U);
break; break;
default: default:
@ -139,7 +139,7 @@ static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTyped
case USB_REQ_GET_STATUS: case USB_REQ_GET_STATUS:
if (pdev->dev_state == USBD_STATE_CONFIGURED) if (pdev->dev_state == USBD_STATE_CONFIGURED)
{ {
USBD_CtlSendData(pdev, (uint8_t *)(void *)&status_info, 2U); USBD_CtlSendData(pdev, (uint8_t*)(void*)&status_info, 2U);
} }
else else
{ {
@ -168,10 +168,10 @@ static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTyped
USBD_CtlSendData(pdev, pbuf, len); USBD_CtlSendData(pdev, pbuf, len);
break; break;
case USB_REQ_GET_INTERFACE : case USB_REQ_GET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED) if (pdev->dev_state == USBD_STATE_CONFIGURED)
{ {
USBD_CtlSendData(pdev, (uint8_t *)&hhid->AltSetting, 1U); USBD_CtlSendData(pdev, (uint8_t*)&hhid->AltSetting, 1U);
} }
else else
{ {
@ -180,7 +180,7 @@ static uint8_t USBD_HID_MOUSE_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTyped
} }
break; break;
case USB_REQ_SET_INTERFACE : case USB_REQ_SET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED) if (pdev->dev_state == USBD_STATE_CONFIGURED)
{ {
hhid->AltSetting = (uint8_t)(req->wValue); hhid->AltSetting = (uint8_t)(req->wValue);
@ -223,7 +223,7 @@ uint8_t USBD_HID_CUSTOM_SendReport(USBD_HandleTypeDef* pdev, uint8_t* report, ui
return USBD_OK; return USBD_OK;
} }
uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev) uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef* pdev)
{ {
uint32_t polling_interval = 0U; uint32_t polling_interval = 0U;
@ -239,47 +239,46 @@ uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev)
{ /* LOW and FULL-speed endpoints */ { /* LOW and FULL-speed endpoints */
/* Sets the data transfer polling interval for low and full /* Sets the data transfer polling interval for low and full
speed transfers */ speed transfers */
polling_interval = HID_FS_BINTERVAL; polling_interval = HID_FS_BINTERVAL;
} }
return ((uint32_t)(polling_interval)); return ((uint32_t)(polling_interval));
} }
static uint8_t *USBD_HID_GetFSCfgDesc(uint16_t *length) static uint8_t* USBD_HID_GetFSCfgDesc(uint16_t* length)
{ {
*length = sizeof(USBD_HID_CUSTOM_CfgFSDesc); *length = sizeof(USBD_HID_CUSTOM_CfgFSDesc);
return USBD_HID_CUSTOM_CfgFSDesc; return USBD_HID_CUSTOM_CfgFSDesc;
} }
static uint8_t *USBD_HID_GetHSCfgDesc(uint16_t *length) static uint8_t* USBD_HID_GetHSCfgDesc(uint16_t* length)
{ {
*length = sizeof(USBD_HID_CUSTOM_CfgHSDesc); *length = sizeof(USBD_HID_CUSTOM_CfgHSDesc);
return USBD_HID_CUSTOM_CfgHSDesc; return USBD_HID_CUSTOM_CfgHSDesc;
} }
static uint8_t *USBD_HID_GetOtherSpeedCfgDesc(uint16_t *length) static uint8_t* USBD_HID_GetOtherSpeedCfgDesc(uint16_t* length)
{ {
*length = sizeof(USBD_HID_CUSTOM_OtherSpeedCfgDesc); *length = sizeof(USBD_HID_CUSTOM_OtherSpeedCfgDesc);
return USBD_HID_CUSTOM_OtherSpeedCfgDesc; return USBD_HID_CUSTOM_OtherSpeedCfgDesc;
} }
static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum) static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef* pdev, uint8_t epnum)
{ {
/* Ensure that the FIFO is empty before a new transfer, this condition could /* Ensure that the FIFO is empty before a new transfer, this condition could
be caused by a new transfer before the end of the previous transfer */ be caused by a new transfer before the end of the previous transfer */
//if (epnum == (HID_KEYBOARD_EPIN_ADDR & 0x7F)) //if (epnum == (HID_KEYBOARD_EPIN_ADDR & 0x7F))
//{ //{
//((USBD_HID_HandleTypeDef *)pdev->pClassData)->Keyboardstate = HID_IDLE; //((USBD_HID_HandleTypeDef *)pdev->pClassData)->Keyboardstate = HID_IDLE;
//} //}
//else if (epnum == (HID_CUSTOM_EPIN_ADDR & 0x7F)) //else if (epnum == (HID_CUSTOM_EPIN_ADDR & 0x7F))
//{ //{
((USBD_HID_HandleTypeDef*)pdev->pClassData)->Mousestate = HID_IDLE; ((USBD_HID_HandleTypeDef*)pdev->pClassData)->Mousestate = HID_IDLE;
//} //}
return USBD_OK; return USBD_OK;
} }
static uint8_t* USBD_HID_GetDeviceQualifierDesc(uint16_t* length)
static uint8_t *USBD_HID_GetDeviceQualifierDesc(uint16_t *length)
{ {
*length = sizeof(USBD_HID_DeviceQualifierDesc); *length = sizeof(USBD_HID_DeviceQualifierDesc);
return USBD_HID_DeviceQualifierDesc; return USBD_HID_DeviceQualifierDesc;

@ -29,7 +29,7 @@ void HID_Custom_DeInit()
} }
} }
void HID_Custom_sendReport(uint8_t *report, uint16_t len) void HID_Custom_sendReport(uint8_t* report, uint16_t len)
{ {
USBD_HID_CUSTOM_SendReport(&hUSBD_Device_HID, report, len); USBD_HID_CUSTOM_SendReport(&hUSBD_Device_HID, report, len);
} }

Loading…
Cancel
Save