diff --git a/flight/PiOS/STM32F10x/pios_usb_com.c b/flight/PiOS/STM32F10x/pios_usb_com.c deleted file mode 100644 index cf3ffa90c..000000000 --- a/flight/PiOS/STM32F10x/pios_usb_com.c +++ /dev/null @@ -1,510 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_SYS System Functions - * @brief PIOS USB communication code - * @{ - * - * @file pios_usb_com.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009. - * @brief Sets up STM32 USB communications - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -/* Project Includes */ -#include "pios.h" -#include - -#if defined(PIOS_INCLUDE_USB_COM) - - -///////////////////////////////////////////////////////////////////////////// -// Local Defines -///////////////////////////////////////////////////////////////////////////// -#define SEND_ENCAPSULATED_COMMAND 0x00 -#define GET_ENCAPSULATED_RESPONSE 0x01 -#define SET_COMM_FEATURE 0x02 -#define GET_COMM_FEATURE 0x03 -#define CLEAR_COMM_FEATURE 0x04 -#define SET_LINE_CODING 0x20 -#define GET_LINE_CODING 0x21 -#define SET_CONTROL_LINE_STATE 0x22 -#define SEND_BREAK 0x23 - - -///////////////////////////////////////////////////////////////////////////// -// Local Types -///////////////////////////////////////////////////////////////////////////// -typedef struct -{ - u32 bitrate; - u8 format; - u8 paritytype; - u8 datatype; -} LINE_CODING; - - -///////////////////////////////////////////////////////////////////////////// -// Local prototypes -///////////////////////////////////////////////////////////////////////////// -void PIOS_USB_COM_TxBufferHandler(void); -void PIOS_USB_COM_RxBufferHandler(void); - - -///////////////////////////////////////////////////////////////////////////// -// Local Variables -///////////////////////////////////////////////////////////////////////////// -// rx/tx status -static volatile u8 rx_buffer_new_data_ctr; -static volatile u8 rx_buffer_ix; - -static volatile u8 tx_buffer_busy; - -// transfer possible? -static u8 transfer_possible = 0; - -// COM Requests -u8 Request = 0; - -// Default linecoding -LINE_CODING linecoding = { - 115200, /* baud rate*/ - 0x00, /* stop bits-1*/ - 0x00, /* parity - none*/ - 0x08 /* no. of bits 8*/ -}; - - - -///////////////////////////////////////////////////////////////////////////// -//! Initializes USB COM layer -//! \param[in] mode currently only mode 0 supported -//! \return < 0 if initialisation failed -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_Init(u32 mode) -{ - // currently only mode 0 supported - if( mode != 0 ) - return -1; // unsupported mode - - return 0; // no error -} - - -///////////////////////////////////////////////////////////////////////////// -//! This function is called by the USB driver on cable connection/disconnection -//! \param[in] connected connection status (1 if connected) -//! \return < 0 on errors -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_ChangeConnectionState(u8 connected) -{ - // in all cases: re-initialize USB COM driver - - if( connected ) { - transfer_possible = 1; - rx_buffer_new_data_ctr = 0; - SetEPRxValid(ENDP3); - tx_buffer_busy = 0; // buffer not busy anymore - } else { - // cable disconnected: disable transfers - transfer_possible = 0; - rx_buffer_new_data_ctr = 0; - tx_buffer_busy = 1; // buffer busy - } - - return 0; // no error -} - - -///////////////////////////////////////////////////////////////////////////// -//! This function returns the connection status of the USB COM interface -//! \return 1: interface available -//! \return 0: interface not available -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_CheckAvailable(void) -{ - return transfer_possible ? 1 : 0; -} - - -///////////////////////////////////////////////////////////////////////////// -//! Returns number of free bytes in receive buffer -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \return number of free bytes -//! \return 0 if usb_com not available -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_RxBufferFree(u8 usb_com) -{ -#if PIOS_USB_COM_NUM == 0 - return 0; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return 0; - else - return PIOS_USB_COM_DATA_OUT_SIZE-rx_buffer_new_data_ctr; -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! Returns number of used bytes in receive buffer -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \return number of used bytes -//! \return 0 if usb_com not available -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_RxBufferUsed(u8 usb_com) -{ -#if PIOS_USB_COM_NUM == 0 - return 0; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return 0; - else - return rx_buffer_new_data_ctr; -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! Gets a byte from the receive buffer -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \return -1 if USB_COM not available -//! \return -2 if no new byte available -//! \return >= 0: received byte -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_RxBufferGet(u8 usb_com) -{ -#if PIOS_USB_COM_NUM == 0 - return -1; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return -1; // USB_COM not available - - if( !rx_buffer_new_data_ctr ) - return -2; // nothing new in buffer - - // get byte - this operation should be atomic! - // PIOS_IRQ_Disable(); - - // TODO: access buffer directly, so that we don't need to copy into temporary buffer - u8 buffer_out[PIOS_USB_COM_DATA_OUT_SIZE]; - PMAToUserBufferCopy(buffer_out, PIOS_USB_ENDP3_RXADDR, GetEPRxCount(ENDP3)); - u8 b = buffer_out[rx_buffer_ix++]; - if( !--rx_buffer_new_data_ctr ) - SetEPRxValid(ENDP3); - // PIOS_IRQ_Enable(); - - return b; // return received byte -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! Returns the next byte of the receive buffer without taking it -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \return -1 if USB_COM not available -//! \return -2 if no new byte available -//! \return >= 0: received byte -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_RxBufferPeek(u8 usb_com) -{ -#if PIOS_USB_COM_NUM == 0 - return -1; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return -1; // USB_COM not available - - if( !rx_buffer_new_data_ctr ) - return -2; // nothing new in buffer - - // get byte - this operation should be atomic! - // PIOS_IRQ_Disable(); - // TODO: access buffer directly, so that we don't need to copy into temporary buffer - u8 buffer_out[PIOS_USB_COM_DATA_OUT_SIZE]; - PMAToUserBufferCopy(buffer_out, PIOS_USB_ENDP3_RXADDR, GetEPRxCount(ENDP3)); - u8 b = buffer_out[rx_buffer_ix]; - // PIOS_IRQ_Enable(); - - return b; // return received byte -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! returns number of free bytes in transmit buffer -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \return number of free bytes -//! \return 0 if usb_com not available -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_TxBufferFree(u8 usb_com) -{ -#if PIOS_USB_COM_NUM == 0 - return 0; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return 0; - else - return tx_buffer_busy ? 0 : PIOS_USB_COM_DATA_IN_SIZE; -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! Returns number of used bytes in transmit buffer -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \return number of used bytes -//! \return 0 if usb_com not available -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_TxBufferUsed(u8 usb_com) -{ -#if PIOS_USB_COM_NUM == 0 - return 0; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return 0; - else - return tx_buffer_busy ? PIOS_USB_COM_DATA_IN_SIZE : 0; -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! puts more than one byte onto the transmit buffer (used for atomic sends) -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \param[in] *buffer pointer to buffer which should be transmitted -//! \param[in] len number of bytes which should be transmitted -//! \return 0 if no error -//! \return -1 if USB_COM not available -//! \return -2 if buffer full or cannot get all requested bytes (retry) -//! \return -3 if USB_COM not supported by PIOS_USB_COM_TxBufferPut Routine -//! \return -4 if too many bytes should be sent -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_TxBufferPutMoreNonBlocking(u8 usb_com, u8 *buffer, u16 len) -{ -#if PIOS_USB_COM_NUM == 0 - return -1; // no USB_COM available -#else - - if( usb_com >= PIOS_USB_COM_NUM ) - return -1; // USB_COM not available - - if( len > PIOS_USB_COM_DATA_IN_SIZE ) - return -4; // cannot get all requested bytes - - if( tx_buffer_busy ) - return -2; // buffer full (retry) - - // copy bytes to be transmitted into transmit buffer - UserToPMABufferCopy(buffer, PIOS_USB_ENDP4_TXADDR, len); - - // send buffer - tx_buffer_busy = 1; - SetEPTxCount(ENDP4, len); - SetEPTxValid(ENDP4); - - return 0; // no error -#endif - -} - - -///////////////////////////////////////////////////////////////////////////// -//! puts more than one byte onto the transmit buffer (used for atomic sends)
-//! (blocking function) -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \param[in] *buffer pointer to buffer which should be transmitted -//! \param[in] len number of bytes which should be transmitted -//! \return 0 if no error -//! \return -1 if USB_COM not available -//! \return -3 if USB_COM not supported by PIOS_USB_COM_TxBufferPut Routine -//! \return -4 if too many bytes should be sent -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_TxBufferPutMore(u8 usb_com, u8 *buffer, u16 len) -{ - s32 error; - - while( (error=PIOS_USB_COM_TxBufferPutMoreNonBlocking(usb_com, buffer, len)) == -2 ); - - return error; -} - - -///////////////////////////////////////////////////////////////////////////// -//! puts a byte onto the transmit buffer -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \param[in] b byte which should be put into Tx buffer -//! \return 0 if no error -//! \return -1 if USB_COM not available -//! \return -2 if buffer full (retry) -//! \return -3 if USB_COM not supported by PIOS_USB_COM_TxBufferPut Routine -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_TxBufferPut_NonBlocking(u8 usb_com, u8 b) -{ - // for more comfortable usage... - // -> just forward to PIOS_USB_COM_TxBufferPutMore - return PIOS_USB_COM_TxBufferPutMoreNonBlocking(usb_com, &b, 1); -} - - -///////////////////////////////////////////////////////////////////////////// -//! puts a byte onto the transmit buffer
-//! (blocking function) -//! \param[in] usb_com USB_COM number (not supported yet, should always be 0) -//! \param[in] b byte which should be put into Tx buffer -//! \return 0 if no error -//! \return -1 if USB_COM not available -//! \return -3 if USB_COM not supported by PIOS_USB_COM_TxBufferPut Routine -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -s32 PIOS_USB_COM_TxBufferPut(u8 usb_com, u8 b) -{ - s32 error; - - while( (error=PIOS_USB_COM_TxBufferPutMoreNonBlocking(usb_com, &b, 1)) == -2 ); - - return error; -} - - -///////////////////////////////////////////////////////////////////////////// -//! Called by STM32 USB driver to check for IN streams -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -void PIOS_USB_COM_EP4_IN_Callback(void) -{ - // package has been sent - tx_buffer_busy = 0; -} - -///////////////////////////////////////////////////////////////////////////// -//! Called by STM32 USB driver to check for OUT streams -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -void PIOS_USB_COM_EP3_OUT_Callback(void) -{ - // new data has been received - notify this - rx_buffer_new_data_ctr = GetEPRxCount(ENDP3); - rx_buffer_ix = 0; -} - - -///////////////////////////////////////////////////////////////////////////// -//! PIOS_USB callback functions (forwarded from STM32 USB driver) -//! \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions -///////////////////////////////////////////////////////////////////////////// -void PIOS_USB_COM_CB_StatusIn(void) -{ - if( Request == SET_LINE_CODING ) { - // configure UART here... - Request = 0; - } -} - - -// handles the data class specific requests -static u8 *Virtual_Com_Port_GetLineCoding(u16 Length) { - if( Length == 0 ) { - pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding); - return NULL; - } - - return(u8 *)&linecoding; -} - -u8 *Virtual_Com_Port_SetLineCoding(u16 Length) -{ - if( Length == 0 ) { - pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding); - return NULL; - } - - return(u8 *)&linecoding; -} - -s32 PIOS_USB_COM_CB_Data_Setup(u8 RequestNo) -{ - u8 *(*CopyRoutine)(u16) = NULL; - - if( RequestNo == GET_LINE_CODING ) { - if( Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT) ) { - CopyRoutine = Virtual_Com_Port_GetLineCoding; - } - } else if( RequestNo == SET_LINE_CODING ) { - if( Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT) ) { - CopyRoutine = Virtual_Com_Port_SetLineCoding; - } - Request = SET_LINE_CODING; - } - - if( CopyRoutine == NULL ) { - return USB_UNSUPPORT; - } - - pInformation->Ctrl_Info.CopyData = CopyRoutine; - pInformation->Ctrl_Info.Usb_wOffset = 0; - (*CopyRoutine)(0); - - return USB_SUCCESS; -} - -s32 PIOS_USB_COM_CB_NoData_Setup(u8 RequestNo) -{ - if( Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT) ) { - if( RequestNo == SET_COMM_FEATURE ) { - return USB_SUCCESS; - } else if( RequestNo == SET_CONTROL_LINE_STATE ) { - return USB_SUCCESS; - } - } - - return USB_UNSUPPORT; -} - -#endif - -/** - * @} - * @} - */ \ No newline at end of file diff --git a/flight/PiOS/STM32F10x/pios_usb_hid.c b/flight/PiOS/STM32F10x/pios_usb_hid.c index 790e3f691..723af0402 100644 --- a/flight/PiOS/STM32F10x/pios_usb_hid.c +++ b/flight/PiOS/STM32F10x/pios_usb_hid.c @@ -138,7 +138,7 @@ int32_t PIOS_USB_HID_ChangeConnectionState(uint32_t Connected) */ int32_t PIOS_USB_HID_CheckAvailable(uint8_t id) { - return transfer_possible ? 1 : 0; + return (PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) != 0 && transfer_possible ? 1 : 0; } /** diff --git a/flight/PiOS/STM32F10x/pios_usb_hid_desc.c b/flight/PiOS/STM32F10x/pios_usb_hid_desc.c index 8f08587ed..a83bc0883 100644 --- a/flight/PiOS/STM32F10x/pios_usb_hid_desc.c +++ b/flight/PiOS/STM32F10x/pios_usb_hid_desc.c @@ -52,7 +52,7 @@ const uint8_t PIOS_HID_DeviceDescriptor[PIOS_HID_SIZ_DEVICE_DESC] = device serial number */ 0x01 /*bNumConfigurations*/ } - ; /* CustomHID_DeviceDescriptor */ + ; /* PIOS_HID_DeviceDescriptor */ /* USB Configuration Descriptor */ @@ -116,7 +116,7 @@ const uint8_t PIOS_HID_ConfigDescriptor[PIOS_HID_SIZ_CONFIG_DESC] = 0x08, /* bInterval: Polling Interval (20 ms) */ /* 41 */ } - ; /* CustomHID_ConfigDescriptor */ + ; /* PIOS_HID_ConfigDescriptor */ const uint8_t PIOS_HID_ReportDescriptor[PIOS_HID_SIZ_REPORT_DESC] = { 0x06, 0x9c, 0xff, /* USAGE_PAGE (Vendor Page: 0xFF00) */ @@ -145,7 +145,7 @@ const uint8_t PIOS_HID_ReportDescriptor[PIOS_HID_SIZ_REPORT_DESC] = /* 34 */ 0xc0 /* END_COLLECTION */ - }; /* CustomHID_ReportDescriptor */ + }; /* PIOS_HID_ReportDescriptor */ /* USB String Descriptors (optional) */ const uint8_t PIOS_HID_StringLangID[PIOS_HID_SIZ_STRING_LANGID] = diff --git a/flight/PiOS/STM32F10x/pios_usb_hid_prop.c b/flight/PiOS/STM32F10x/pios_usb_hid_prop.c index c9c6f6cf8..588ee639e 100644 --- a/flight/PiOS/STM32F10x/pios_usb_hid_prop.c +++ b/flight/PiOS/STM32F10x/pios_usb_hid_prop.c @@ -42,30 +42,30 @@ DEVICE Device_Table = DEVICE_PROP Device_Property = { - CustomHID_init, - CustomHID_Reset, - CustomHID_Status_In, - CustomHID_Status_Out, - CustomHID_Data_Setup, - CustomHID_NoData_Setup, - CustomHID_Get_Interface_Setting, - CustomHID_GetDeviceDescriptor, - CustomHID_GetConfigDescriptor, - CustomHID_GetStringDescriptor, + PIOS_HID_init, + PIOS_HID_Reset, + PIOS_HID_Status_In, + PIOS_HID_Status_Out, + PIOS_HID_Data_Setup, + PIOS_HID_NoData_Setup, + PIOS_HID_Get_Interface_Setting, + PIOS_HID_GetDeviceDescriptor, + PIOS_HID_GetConfigDescriptor, + PIOS_HID_GetStringDescriptor, 0, 0x40 /*MAX PACKET SIZE*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { - CustomHID_GetConfiguration, - CustomHID_SetConfiguration, - CustomHID_GetInterface, - CustomHID_SetInterface, - CustomHID_GetStatus, - CustomHID_ClearFeature, - CustomHID_SetEndPointFeature, - CustomHID_SetDeviceFeature, - CustomHID_SetDeviceAddress + PIOS_HID_GetConfiguration, + PIOS_HID_SetConfiguration, + PIOS_HID_GetInterface, + PIOS_HID_SetInterface, + PIOS_HID_GetStatus, + PIOS_HID_ClearFeature, + PIOS_HID_SetEndPointFeature, + PIOS_HID_SetDeviceFeature, + PIOS_HID_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = @@ -106,13 +106,13 @@ ONE_DESCRIPTOR String_Descriptor[4] = /* Private functions ---------------------------------------------------------*/ /******************************************************************************* -* Function Name : CustomHID_init. +* Function Name : PIOS_HID_init. * Description : Custom HID init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ -void CustomHID_init(void) +void PIOS_HID_init(void) { /* Update the serial number string descriptor with the data from the unique ID*/ @@ -129,13 +129,13 @@ void CustomHID_init(void) } /******************************************************************************* -* Function Name : CustomHID_Reset. +* Function Name : PIOS_HID_Reset. * Description : Custom HID reset routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ -void CustomHID_Reset(void) +void PIOS_HID_Reset(void) { /* Set Joystick_DEVICE as not configured */ pInformation->Current_Configuration = 0; @@ -180,65 +180,65 @@ void CustomHID_Reset(void) bDeviceState = ATTACHED; } /******************************************************************************* -* Function Name : CustomHID_SetConfiguration. +* Function Name : PIOS_HID_SetConfiguration. * Description : Udpade the device state to configured and command the ADC * conversion. * Input : None. * Output : None. * Return : None. *******************************************************************************/ -void CustomHID_SetConfiguration(void) +void PIOS_HID_SetConfiguration(void) { if (pInformation->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; - - /* Start ADC1 Software Conversion */ - ADC_SoftwareStartConvCmd(ADC1, ENABLE); } + + /* Enable transfers */ + PIOS_USB_HID_ChangeConnectionState(pInformation->Current_Configuration != 0); } /******************************************************************************* -* Function Name : CustomHID_SetConfiguration. +* Function Name : PIOS_HID_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ -void CustomHID_SetDeviceAddress (void) +void PIOS_HID_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* -* Function Name : CustomHID_Status_In. +* Function Name : PIOS_HID_Status_In. * Description : Joystick status IN routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ -void CustomHID_Status_In(void) +void PIOS_HID_Status_In(void) { } /******************************************************************************* -* Function Name : CustomHID_Status_Out +* Function Name : PIOS_HID_Status_Out * Description : Joystick status OUT routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ -void CustomHID_Status_Out (void) +void PIOS_HID_Status_Out (void) { } /******************************************************************************* -* Function Name : CustomHID_Data_Setup +* Function Name : PIOS_HID_Data_Setup * Description : Handle the data class specific requests. * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ -RESULT CustomHID_Data_Setup(uint8_t RequestNo) +RESULT PIOS_HID_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); @@ -251,11 +251,11 @@ RESULT CustomHID_Data_Setup(uint8_t RequestNo) if (pInformation->USBwValue1 == REPORT_DESCRIPTOR) { - CopyRoutine = CustomHID_GetReportDescriptor; + CopyRoutine = PIOS_HID_GetReportDescriptor; } else if (pInformation->USBwValue1 == HID_DESCRIPTOR_TYPE) { - CopyRoutine = CustomHID_GetHIDDescriptor; + CopyRoutine = PIOS_HID_GetHIDDescriptor; } } /* End of GET_DESCRIPTOR */ @@ -264,7 +264,7 @@ RESULT CustomHID_Data_Setup(uint8_t RequestNo) else if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && RequestNo == GET_PROTOCOL) { - CopyRoutine = CustomHID_GetProtocolValue; + CopyRoutine = PIOS_HID_GetProtocolValue; } if (CopyRoutine == NULL) @@ -279,18 +279,18 @@ RESULT CustomHID_Data_Setup(uint8_t RequestNo) } /******************************************************************************* -* Function Name : CustomHID_NoData_Setup +* Function Name : PIOS_HID_NoData_Setup * Description : handle the no data class specific requests * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ -RESULT CustomHID_NoData_Setup(uint8_t RequestNo) +RESULT PIOS_HID_NoData_Setup(uint8_t RequestNo) { if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && (RequestNo == SET_PROTOCOL)) { - return CustomHID_SetProtocol(); + return PIOS_HID_SetProtocol(); } else @@ -300,37 +300,37 @@ RESULT CustomHID_NoData_Setup(uint8_t RequestNo) } /******************************************************************************* -* Function Name : CustomHID_GetDeviceDescriptor. +* Function Name : PIOS_HID_GetDeviceDescriptor. * Description : Gets the device descriptor. * Input : Length * Output : None. * Return : The address of the device descriptor. *******************************************************************************/ -uint8_t *CustomHID_GetDeviceDescriptor(uint16_t Length) +uint8_t *PIOS_HID_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor); } /******************************************************************************* -* Function Name : CustomHID_GetConfigDescriptor. +* Function Name : PIOS_HID_GetConfigDescriptor. * Description : Gets the configuration descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ -uint8_t *CustomHID_GetConfigDescriptor(uint16_t Length) +uint8_t *PIOS_HID_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Config_Descriptor); } /******************************************************************************* -* Function Name : CustomHID_GetStringDescriptor +* Function Name : PIOS_HID_GetStringDescriptor * Description : Gets the string descriptors according to the needed index * Input : Length * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ -uint8_t *CustomHID_GetStringDescriptor(uint16_t Length) +uint8_t *PIOS_HID_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 4) @@ -344,31 +344,31 @@ uint8_t *CustomHID_GetStringDescriptor(uint16_t Length) } /******************************************************************************* -* Function Name : CustomHID_GetReportDescriptor. +* Function Name : PIOS_HID_GetReportDescriptor. * Description : Gets the HID report descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ -uint8_t *CustomHID_GetReportDescriptor(uint16_t Length) +uint8_t *PIOS_HID_GetReportDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &PIOS_HID_Report_Descriptor); } /******************************************************************************* -* Function Name : CustomHID_GetHIDDescriptor. +* Function Name : PIOS_HID_GetHIDDescriptor. * Description : Gets the HID descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ -uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length) +uint8_t *PIOS_HID_GetHIDDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &PIOS_HID_Hid_Descriptor); } /******************************************************************************* -* Function Name : CustomHID_Get_Interface_Setting. +* Function Name : PIOS_HID_Get_Interface_Setting. * Description : tests the interface and the alternate setting according to the * supported one. * Input : - Interface : interface number. @@ -376,7 +376,7 @@ uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length) * Output : None. * Return : USB_SUCCESS or USB_UNSUPPORT. *******************************************************************************/ -RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) +RESULT PIOS_HID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) { if (AlternateSetting > 0) { @@ -390,13 +390,13 @@ RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetti } /******************************************************************************* -* Function Name : CustomHID_SetProtocol +* Function Name : PIOS_HID_SetProtocol * Description : Joystick Set Protocol request routine. * Input : None. * Output : None. * Return : USB SUCCESS. *******************************************************************************/ -RESULT CustomHID_SetProtocol(void) +RESULT PIOS_HID_SetProtocol(void) { uint8_t wValue0 = pInformation->USBwValue0; ProtocolValue = wValue0; @@ -404,13 +404,13 @@ RESULT CustomHID_SetProtocol(void) } /******************************************************************************* -* Function Name : CustomHID_GetProtocolValue +* Function Name : PIOS_HID_GetProtocolValue * Description : get the protocol value * Input : Length. * Output : None. * Return : address of the protcol value. *******************************************************************************/ -uint8_t *CustomHID_GetProtocolValue(uint16_t Length) +uint8_t *PIOS_HID_GetProtocolValue(uint16_t Length) { if (Length == 0) { diff --git a/flight/PiOS/STM32F10x/pios_usb_hid_pwr.c b/flight/PiOS/STM32F10x/pios_usb_hid_pwr.c index 4d3af29ad..880ec8900 100755 --- a/flight/PiOS/STM32F10x/pios_usb_hid_pwr.c +++ b/flight/PiOS/STM32F10x/pios_usb_hid_pwr.c @@ -47,7 +47,6 @@ struct *******************************************************************************/ void USB_Cable_Config (FunctionalState NewState) { - PIOS_USB_HID_ChangeConnectionState(NewState); } /******************************************************************************* diff --git a/flight/PiOS/inc/pios_usb_hid_prop.h b/flight/PiOS/inc/pios_usb_hid_prop.h index ae277363b..726f9d6a3 100644 --- a/flight/PiOS/inc/pios_usb_hid_prop.h +++ b/flight/PiOS/inc/pios_usb_hid_prop.h @@ -33,35 +33,35 @@ typedef enum _HID_REQUESTS /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ -void CustomHID_init(void); -void CustomHID_Reset(void); -void CustomHID_SetConfiguration(void); -void CustomHID_SetDeviceAddress (void); -void CustomHID_Status_In (void); -void CustomHID_Status_Out (void); -RESULT CustomHID_Data_Setup(uint8_t); -RESULT CustomHID_NoData_Setup(uint8_t); -RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); -uint8_t *CustomHID_GetDeviceDescriptor(uint16_t ); -uint8_t *CustomHID_GetConfigDescriptor(uint16_t); -uint8_t *CustomHID_GetStringDescriptor(uint16_t); -RESULT CustomHID_SetProtocol(void); -uint8_t *CustomHID_GetProtocolValue(uint16_t Length); -RESULT CustomHID_SetProtocol(void); -uint8_t *CustomHID_GetReportDescriptor(uint16_t Length); -uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length); +void PIOS_HID_init(void); +void PIOS_HID_Reset(void); +void PIOS_HID_SetConfiguration(void); +void PIOS_HID_SetDeviceAddress (void); +void PIOS_HID_Status_In (void); +void PIOS_HID_Status_Out (void); +RESULT PIOS_HID_Data_Setup(uint8_t); +RESULT PIOS_HID_NoData_Setup(uint8_t); +RESULT PIOS_HID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); +uint8_t *PIOS_HID_GetDeviceDescriptor(uint16_t ); +uint8_t *PIOS_HID_GetConfigDescriptor(uint16_t); +uint8_t *PIOS_HID_GetStringDescriptor(uint16_t); +RESULT PIOS_HID_SetProtocol(void); +uint8_t *PIOS_HID_GetProtocolValue(uint16_t Length); +RESULT PIOS_HID_SetProtocol(void); +uint8_t *PIOS_HID_GetReportDescriptor(uint16_t Length); +uint8_t *PIOS_HID_GetHIDDescriptor(uint16_t Length); /* Exported define -----------------------------------------------------------*/ -#define CustomHID_GetConfiguration NOP_Process -//#define CustomHID_SetConfiguration NOP_Process -#define CustomHID_GetInterface NOP_Process -#define CustomHID_SetInterface NOP_Process -#define CustomHID_GetStatus NOP_Process -#define CustomHID_ClearFeature NOP_Process -#define CustomHID_SetEndPointFeature NOP_Process -#define CustomHID_SetDeviceFeature NOP_Process -//#define CustomHID_SetDeviceAddress NOP_Process +#define PIOS_HID_GetConfiguration NOP_Process +//#define PIOS_HID_SetConfiguration NOP_Process +#define PIOS_HID_GetInterface NOP_Process +#define PIOS_HID_SetInterface NOP_Process +#define PIOS_HID_GetStatus NOP_Process +#define PIOS_HID_ClearFeature NOP_Process +#define PIOS_HID_SetEndPointFeature NOP_Process +#define PIOS_HID_SetDeviceFeature NOP_Process +//#define PIOS_HID_SetDeviceAddress NOP_Process #define REPORT_DESCRIPTOR 0x22 diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index e2d130e15..752092abe 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -7,6 +7,15 @@ objects = { /* Begin PBXFileReference section */ + 651CF9E5120B5D8300EEFD70 /* pios_usb_hid_desc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_desc.c; sourceTree = ""; }; + 651CF9E6120B5D8300EEFD70 /* pios_usb_hid_istr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_istr.c; sourceTree = ""; }; + 651CF9E7120B5D8300EEFD70 /* pios_usb_hid_prop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_prop.c; sourceTree = ""; }; + 651CF9E8120B5D8300EEFD70 /* pios_usb_hid_pwr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_pwr.c; sourceTree = ""; }; + 651CF9EF120B700D00EEFD70 /* pios_usb_hid_desc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_desc.h; sourceTree = ""; }; + 651CF9F0120B700D00EEFD70 /* pios_usb_hid_istr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_istr.h; sourceTree = ""; }; + 651CF9F1120B700D00EEFD70 /* pios_usb_hid_prop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_prop.h; sourceTree = ""; }; + 651CF9F2120B700D00EEFD70 /* pios_usb_hid_pwr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_pwr.h; sourceTree = ""; }; + 651CF9F3120B700D00EEFD70 /* usb_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = usb_conf.h; sourceTree = ""; }; 65A2C7EF11E2A33D00D0391E /* FreeRTOSConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FreeRTOSConfig.h; path = ../../PiOS.posix/inc/FreeRTOSConfig.h; sourceTree = SOURCE_ROOT; }; 65A2C7F011E2A33D00D0391E /* pios_com.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_com.h; path = ../../PiOS.posix/inc/pios_com.h; sourceTree = SOURCE_ROOT; }; 65A2C7F111E2A33D00D0391E /* pios_com_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_com_priv.h; path = ../../PiOS.posix/inc/pios_com_priv.h; sourceTree = SOURCE_ROOT; }; @@ -187,7 +196,6 @@ 65E8F05111EFF25C00BBF654 /* pios_usart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_usart.h; path = ../../PiOS/inc/pios_usart.h; sourceTree = SOURCE_ROOT; }; 65E8F05211EFF25C00BBF654 /* pios_usart_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_usart_priv.h; path = ../../PiOS/inc/pios_usart_priv.h; sourceTree = SOURCE_ROOT; }; 65E8F05311EFF25C00BBF654 /* pios_usb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_usb.h; path = ../../PiOS/inc/pios_usb.h; sourceTree = SOURCE_ROOT; }; - 65E8F05411EFF25C00BBF654 /* pios_usb_com.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_usb_com.h; path = ../../PiOS/inc/pios_usb_com.h; sourceTree = SOURCE_ROOT; }; 65E8F05511EFF25C00BBF654 /* pios_usb_hid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios_usb_hid.h; path = ../../PiOS/inc/pios_usb_hid.h; sourceTree = SOURCE_ROOT; }; 65E8F05611EFF25C00BBF654 /* stm32f10x_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stm32f10x_conf.h; path = ../../PiOS/inc/stm32f10x_conf.h; sourceTree = SOURCE_ROOT; }; 65E8F05711EFF25C00BBF654 /* pios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pios.h; path = ../../PiOS/pios.h; sourceTree = SOURCE_ROOT; }; @@ -315,8 +323,6 @@ 65E8F0E811EFF25C00BBF654 /* pios_spi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_spi.c; path = ../../PiOS/STM32F10x/pios_spi.c; sourceTree = SOURCE_ROOT; }; 65E8F0E911EFF25C00BBF654 /* pios_sys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_sys.c; path = ../../PiOS/STM32F10x/pios_sys.c; sourceTree = SOURCE_ROOT; }; 65E8F0EA11EFF25C00BBF654 /* pios_usart.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_usart.c; path = ../../PiOS/STM32F10x/pios_usart.c; sourceTree = SOURCE_ROOT; }; - 65E8F0EB11EFF25C00BBF654 /* pios_usb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_usb.c; path = ../../PiOS/STM32F10x/pios_usb.c; sourceTree = SOURCE_ROOT; }; - 65E8F0EC11EFF25C00BBF654 /* pios_usb_com.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_usb_com.c; path = ../../PiOS/STM32F10x/pios_usb_com.c; sourceTree = SOURCE_ROOT; }; 65E8F0ED11EFF25C00BBF654 /* pios_usb_hid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_usb_hid.c; path = ../../PiOS/STM32F10x/pios_usb_hid.c; sourceTree = SOURCE_ROOT; }; 65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_HD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_HD.S; sourceTree = SOURCE_ROOT; }; 65E8F0EF11EFF25C00BBF654 /* startup_stm32f10x_HD_BL.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_HD_BL.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_HD_BL.S; sourceTree = SOURCE_ROOT; }; @@ -941,6 +947,11 @@ 65E8F03811EFF25C00BBF654 /* inc */ = { isa = PBXGroup; children = ( + 651CF9EF120B700D00EEFD70 /* pios_usb_hid_desc.h */, + 651CF9F0120B700D00EEFD70 /* pios_usb_hid_istr.h */, + 651CF9F1120B700D00EEFD70 /* pios_usb_hid_prop.h */, + 651CF9F2120B700D00EEFD70 /* pios_usb_hid_pwr.h */, + 651CF9F3120B700D00EEFD70 /* usb_conf.h */, 65E8F03911EFF25C00BBF654 /* FreeRTOSConfig.h */, 65E8F03A11EFF25C00BBF654 /* pios_adc.h */, 65E8F03B11EFF25C00BBF654 /* pios_bmp085.h */, @@ -968,7 +979,6 @@ 65E8F05111EFF25C00BBF654 /* pios_usart.h */, 65E8F05211EFF25C00BBF654 /* pios_usart_priv.h */, 65E8F05311EFF25C00BBF654 /* pios_usb.h */, - 65E8F05411EFF25C00BBF654 /* pios_usb_com.h */, 65E8F05511EFF25C00BBF654 /* pios_usb_hid.h */, 65E8F05611EFF25C00BBF654 /* stm32f10x_conf.h */, ); @@ -999,9 +1009,11 @@ 65E8F0E811EFF25C00BBF654 /* pios_spi.c */, 65E8F0E911EFF25C00BBF654 /* pios_sys.c */, 65E8F0EA11EFF25C00BBF654 /* pios_usart.c */, - 65E8F0EB11EFF25C00BBF654 /* pios_usb.c */, - 65E8F0EC11EFF25C00BBF654 /* pios_usb_com.c */, 65E8F0ED11EFF25C00BBF654 /* pios_usb_hid.c */, + 651CF9E5120B5D8300EEFD70 /* pios_usb_hid_desc.c */, + 651CF9E6120B5D8300EEFD70 /* pios_usb_hid_istr.c */, + 651CF9E7120B5D8300EEFD70 /* pios_usb_hid_prop.c */, + 651CF9E8120B5D8300EEFD70 /* pios_usb_hid_pwr.c */, 65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */, 65E8F0EF11EFF25C00BBF654 /* startup_stm32f10x_HD_BL.S */, 65E8F0F011EFF25C00BBF654 /* startup_stm32f10x_HD_NB.S */,