STM32 usb_core.c分析
usb_core.c這個(gè)c文件是個(gè)龐大的文件,主要是定義了usb2.0的標(biāo)注協(xié)議處理函數(shù)。
下面是這個(gè)文件的所有函數(shù):
/*******************************************************************************
* Function Name : Standard_GetConfiguration.
* Description : 返回當(dāng)前配置變量的地址
* Input : Length -需要的字節(jié) How many bytes are needed.
* Output : None.
* Return : 如果'Length'值為0時(shí),請(qǐng)求無效,返回1。長度不為0時(shí),返回配置變量的地址
* Readme : 當(dāng)配置值與摸個(gè)配置描述符中的配置編號(hào)一致時(shí),表示選中該配置
*******************************************************************************/
uint8_t *Standard_GetConfiguration(uint16_t Length);
/*******************************************************************************
* Function Name : Standard_SetConfiguration.
* Description : 該函數(shù)用于設(shè)置配置值,主機(jī)發(fā)送該請(qǐng)求后,usb設(shè)備要配置自己的設(shè)備值
* Input : None.
* Output : None.
* Return : 當(dāng)該請(qǐng)求被執(zhí)行了,返回USB_SUCCESS
* 當(dāng)請(qǐng)求無效時(shí),然會(huì)USB_UNSUPPORT
*******************************************************************************/
RESULT Standard_SetConfiguration(void);
/*******************************************************************************
* Function Name : Standard_GetInterface.
* Description : 返回當(dāng)前接口的備用接口
* Input : Length -需要的字節(jié)數(shù)
* Output : None.
* Return : 當(dāng)'Length'的值為0,請(qǐng)求無效,返回0,當(dāng)長度不為0,返回備用接口的地址
*******************************************************************************/
uint8_t *Standard_GetInterface(uint16_t Length);
/*******************************************************************************
* Function Name : Standard_GetStatus.
* Description : 拷貝設(shè)備請(qǐng)求數(shù)據(jù)到"StatusInfo buffer".
* Input : - Length -需要的字節(jié)數(shù)
* Output : None.
* Return : 如果請(qǐng)求在數(shù)據(jù)塊的末端,或則當(dāng)'Length'為0是,請(qǐng)求無效,則返回0
*******************************************************************************/
uint8_t *Standard_GetStatus(uint16_t Length);
/*******************************************************************************
* Function Name : Standard_ClearFeature.
* Description : 清除或禁止某個(gè)指定的特性
* Input : None.
* Output : None.
* Return : 當(dāng)請(qǐng)求被執(zhí)行,返回Return USB_SUCCESS,如果請(qǐng)求無效,返回USB_UNSUPPORT
*******************************************************************************/
RESULT Standard_ClearFeature(void);
/*******************************************************************************
* Function Name : Standard_SetEndPointFeature
* Description : 設(shè)置或使能端點(diǎn)的指定的特性
* Input : None.
* Output : None.
* Return : 如果請(qǐng)求被執(zhí)行,返回USB_SUCCESS,如果請(qǐng)求無效,則返回USB_UNSUPPORT
*******************************************************************************/
RESULT Standard_SetEndPointFeature(void);
/*******************************************************************************
* Function Name : Standard_SetDeviceFeature.
* Description : 設(shè)置或使能設(shè)備指定的特性
* Input : None.
* Output : None.
* Return : 如果請(qǐng)求被執(zhí)行,返回USB_SUCCESS,如果請(qǐng)求無效,則返回USB_UNSUPPORT
*******************************************************************************/
RESULT Standard_SetDeviceFeature(void);
/*******************************************************************************
* Function Name : Standard_GetDescriptorData.
* Description : Standard_GetDescriptorData用于描述符的傳輸.
* : 這個(gè)函數(shù)用于駐留在flash或RAM里的描述符pDesc可以自相Flash或RAM
* 這個(gè)函數(shù)的目的是具有不同的方式去響應(yīng)描述符請(qǐng)求。
* 它允許用戶通過軟件生成的某些描述符或則讀取外部存儲(chǔ)設(shè)備的描述符部分.
* Input : Length - 這次傳輸?shù)牡臄?shù)據(jù)長度
* pDesc - 指向描述符結(jié)構(gòu)體的指針
* Output : None.
* Return : 返回usb_wOffset指向的描述符部分的地址。這個(gè)地址指向的緩沖包含最起碼Length個(gè)字節(jié)
*******************************************************************************/
uint8_t *Standard_GetDescriptorData(uint16_t Length, ONE_DESCRIPTOR *pDesc);
/*******************************************************************************
* Function Name : DataStageOut.
* Description : 數(shù)據(jù)階段的控制寫傳輸
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void DataStageOut(void);
/*******************************************************************************
* Function Name : DataStageIn.
* Description : 數(shù)據(jù)階段的控制讀傳輸
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void DataStageIn(void);
/*******************************************************************************
* Function Name : NoData_Setup0.
* Description : 處理沒有數(shù)據(jù)階段的建立請(qǐng)求
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void NoData_Setup0(void);
/*******************************************************************************
* Function Name : Data_Setup0.
* Description : 處理有數(shù)據(jù)階段的建立請(qǐng)求
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Data_Setup0(void);
/*******************************************************************************
* Function Name : Setup0_Process
* Description : 建立階段的數(shù)據(jù)處理Get the device request data and dispatch to individual process.
* Input : None.
* Output : None.
* Return : Post0_Process.
*******************************************************************************/
uint8_t Setup0_Process(void);
/*******************************************************************************
* Function Name : In0_Process
* Description : 處理默認(rèn)端點(diǎn)的所有IN令牌包
* Input : None.
* Output : None.
* Return : Post0_Process.
*******************************************************************************/
uint8_t In0_Process(void);
/*******************************************************************************
* Function Name : Out0_Process
* Description : 處理默認(rèn)端點(diǎn)上的所有OUT令牌包
* Input : None.
* Output : None.
* Return : Post0_Process.
*******************************************************************************/
uint8_t Out0_Process(void);
/*******************************************************************************
* Function Name : Post0_Process
* Description : 為防止錯(cuò)誤,停止端點(diǎn)0Stall the Endpoint 0 in case of error.
* Input : None.
* Output : None.
* Return : 如果控制狀態(tài)是PAUSE,返回0;如果不是返回1
*******************************************************************************/
uint8_t Post0_Process(void);
/*******************************************************************************
* Function Name : SetDeviceAddress.
* Description : 設(shè)置設(shè)備和所有使用過的端點(diǎn)地址
* Input : Val:設(shè)備地址
* Output : None.
* Return : None.
*******************************************************************************/
void SetDeviceAddress(uint8_t Val);
/*******************************************************************************
* Function Name : NOP_Process
* Description : 沒有處理函數(shù)
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void NOP_Process(void);
這里簡單地介紹幾類函數(shù)。
首先要將的是關(guān)于USB特性(Feature)和狀態(tài)的函數(shù),這些函數(shù)包括:St