/**
******************************************************************************
* @file usb_lib.h
* @author MCD Application Team
* @version V4.0.0
* @date 28-August-2012
* @brief USB library include files
******************************************************************************
* @attention
*
*
© COPYRIGHT 2012 STMicroelectronics
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
// Define to prevent recursive inclusion
#ifndef __USB_LIB_H
#define __USB_LIB_H
#include "usb_conf.h"
#include "hw_config.h"
#include "usb_regs.h"
#include "usb_core.h"
// Public defines
// Definition of "USBbmRequestType"
#define REQUEST_TYPE 0x60 // Mask to get request type
#define STANDARD_REQUEST 0x00 // Standard request
#define CLASS_REQUEST 0x20 // Class request
#define VENDOR_REQUEST 0x40 // Vendor request
#define RECIPIENT 0x1F // Mask to get recipient
// Exported types
#ifndef NULL
#define NULL ((void *)0)
#endif
#ifndef BOOL
#define BOOL
typedef enum {
FALSE = 0,
TRUE = !FALSE
} bool;
#endif
typedef enum _RECIPIENT_TYPE {
DEVICE_RECIPIENT, // Recipient device
INTERFACE_RECIPIENT, // Recipient interface
ENDPOINT_RECIPIENT, // Recipient endpoint
OTHER_RECIPIENT
} RECIPIENT_TYPE;
typedef enum _STANDARD_REQUESTS {
GET_STATUS = 0,
CLEAR_FEATURE,
RESERVED1,
SET_FEATURE,
RESERVED2,
SET_ADDRESS,
GET_DESCRIPTOR,
SET_DESCRIPTOR,
GET_CONFIGURATION,
SET_CONFIGURATION,
GET_INTERFACE,
SET_INTERFACE,
TOTAL_sREQUEST, // Total number of Standard request
SYNCH_FRAME = 12
} STANDARD_REQUESTS;
// Definition of "USBwValue"
typedef enum _DESCRIPTOR_TYPE {
DEVICE_DESCRIPTOR = 1,
CONFIG_DESCRIPTOR,
STRING_DESCRIPTOR,
INTERFACE_DESCRIPTOR,
ENDPOINT_DESCRIPTOR
} DESCRIPTOR_TYPE;
// Feature selector of a SET_FEATURE or CLEAR_FEATURE
typedef enum _FEATURE_SELECTOR {
ENDPOINT_STALL,
DEVICE_REMOTE_WAKEUP
} FEATURE_SELECTOR;
// Public variables
// Points to the DEVICE_INFO structure of current device
// The purpose of this register is to speed up the execution
extern DEVICE_INFO *pInformation;
/* Points to the DEVICE_PROP structure of current device */
/* The purpose of this register is to speed up the execution */
extern DEVICE_PROP* pProperty;
extern void (*pEpInt_IN[ 7])(void); // Handles IN interrupts
extern void (*pEpInt_OUT[7])(void); // Handles OUT interrupts
extern uint8_t EPindex; // The number of current endpoint, it will be used to specify an endpoint
// Temporary save the state of Rx & Tx status.
// Whenever the Rx or Tx state is changed, its value is saved
// in this variable first and will be set to the EPRB or EPRA
// at the end of interrupt process
extern uint16_t SaveState;
extern uint16_t wInterrupt_Mask; // Contains interrupt mask
extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; //
// Function prototypes
void USB_Init(void);
void CTR_LP(void);
void CTR_HP(void);
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
uint32_t USB_SIL_Init(void);
uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize);
uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer);
#endif // __USB_LIB_H