1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Added ability to enable and disable PiOS modules.

Added PIOS_USB_COM.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@202 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2010-02-28 06:47:49 +00:00 committed by gussy
parent 7f31e3a9ff
commit adcd47a31b
19 changed files with 651 additions and 2 deletions

View File

@ -29,7 +29,25 @@
#define PIOS_CONFIG_H
/* Compile Time Macros */
/* Enable/Disable PiOS Modules */
//#define PIOS_DONT_USE_ADC
//#define PIOS_DONT_USE_DELAY
//#define PIOS_DONT_USE_I2C
//#define PIOS_DONT_USE_IRQ
//#define PIOS_DONT_USE_LED
//#define PIOS_DONT_USE_PWM
//#define PIOS_DONT_USE_SERVO
//#define PIOS_DONT_USE_SPI
//#define PIOS_DONT_USE_SYS
//#define PIOS_DONT_USE_USART
#define PIOS_DONT_USE_USB_COM
//#define PIOS_DONT_USE_USB_HID
//#define PIOS_DONT_USE_USB
//#define PIOS_DONT_USE_BMP085
//#define PIOS_DONT_USE_COM
//#define PIOS_DONT_USE_SDCARD
//#define PIOS_DONT_USE_SETTINGS
/* Defaults for Logging */
#define LOG_FILENAME "PIOS.LOG"

View File

@ -42,6 +42,8 @@ Example of how to use this module:
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_BMP085)
/* Glocal Variables */
ConversionTypeTypeDef CurrentRead;
@ -293,3 +295,5 @@ void EXTI15_10_IRQHandler(void)
PIOS_IRQ_Enable();
}
}
#endif

View File

@ -30,6 +30,7 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_COM)
/* Private Function Prototypes */
@ -314,3 +315,5 @@ int32_t PIOS_COM_ReceiveCallbackInit(void *callback_receive)
/* No error */
return 0;
}
#endif

View File

@ -30,6 +30,9 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_SDCARD)
/* Global Variables */
VOLINFO PIOS_SDCARD_VolInfo;
uint8_t PIOS_SDCARD_Sector[SECTOR_SIZE];
@ -989,3 +992,4 @@ int32_t PIOS_SDCARD_FileDelete(char *Filename)
return 0;
}
#endif

View File

@ -29,6 +29,8 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_SETTINGS)
/* Private Function Prototypes */
@ -110,3 +112,5 @@ int32_t PIOS_Settings_CheckForFiles(void)
/* All files found */
return 0;
}
#endif

View File

@ -30,6 +30,7 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_ADC)
/* Local Variables */
/* following two arrays are word aligned, so that DMA can transfer two hwords at once */
@ -259,3 +260,5 @@ void DMA1_Channel1_IRQHandler(void)
/* Request next conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
#endif

View File

@ -31,6 +31,7 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_DELAY)
/**
* Initialises the Timer used by PIOS_DELAY functions<BR>
@ -106,3 +107,5 @@ int32_t PIOS_DELAY_WaitmS(uint16_t mS)
/* No error */
return 0;
}
#endif

View File

@ -30,6 +30,8 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_I2C)
/* Global Variables */
volatile uint32_t PIOS_I2C_UnexpectedEvent;
@ -572,3 +574,5 @@ void I2C2_ER_IRQHandler(void)
{
ER_IRQHandler((I2CRecTypeDef *)&I2CRec);
}
#endif

View File

@ -30,6 +30,8 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_IRQ)
/* Private Function Prototypes */
@ -97,3 +99,5 @@ int32_t PIOS_IRQ_Enable(void)
/* No error */
return 0;
}
#endif

View File

@ -29,6 +29,7 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_LED)
/* Private Function Prototypes */
@ -84,3 +85,5 @@ void PIOS_LED_Toggle(LedTypeDef LED)
{
LED_GPIO_PORT[LED]->ODR ^= LED_GPIO_PIN[LED];
}
#endif

View File

@ -29,6 +29,7 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_PWM)
/* Local Variables */
volatile uint16_t IC3Value = 0;
@ -116,3 +117,5 @@ void TIM3_IRQHandler(void)
}
#endif
}
#endif

View File

@ -29,6 +29,8 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_SERVO)
/* Private Function Prototypes */
@ -161,3 +163,4 @@ void PIOS_Servo_Set(uint8_t Servo, uint16_t Position)
}
}
#endif

View File

@ -39,6 +39,8 @@
#include <pios.h>
#if !defined(PIOS_DONT_USE_SPI)
/* Local variables */
static void (*spi_callback[2])(void);
@ -593,3 +595,4 @@ PIOS_SPI1_DMA_IRQHANDLER_FUNC
}
}
#endif

View File

@ -30,6 +30,9 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_SYS)
/* Private Function Prototypes */
void NVIC_Configuration(void);
void SysTick_Handler(void);
@ -138,3 +141,5 @@ void assert_failed(uint8_t* file, uint32_t line)
}
}
#endif
#endif

View File

@ -30,6 +30,8 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_USART)
/* Global Variables */
extern SettingsTypeDef Settings;
@ -580,3 +582,5 @@ AUX_USART_IRQHANDLER_FUNC
}
}
}
#endif

View File

@ -28,7 +28,8 @@
/* Project Includes */
#include "pios.h"
//#include <string.h>
#if !defined(PIOS_DONT_USE_USB)
/* Local definitions */
@ -576,3 +577,4 @@ static RESULT PIOS_USB_CB_Get_Interface_Setting(uint8_t Interface, uint8_t Alter
return USB_SUCCESS;
}
#endif

View File

@ -0,0 +1,502 @@
/**
******************************************************************************
*
* @file pios_sys.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009.
* @brief Sets up basic system hardware, functions are called from Main.
* @see The GNU Public License (GPL) Version 3
* @defgroup PIOS_SYS System Functions
* @{
*
*****************************************************************************/
/*
* 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 <usb_lib.h>
#if !defined(PIOS_DONT_USE_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)<BR>
//! (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<BR>
//! (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

View File

@ -31,6 +31,9 @@
/* Project Includes */
#include "pios.h"
#if !defined(PIOS_DONT_USE_HID)
/* Local types */
typedef enum _HID_REQUESTS {
GET_REPORT = 1,
@ -339,3 +342,4 @@ void PIOS_USB_HID_EP1_OUT_Callback(void)
#endif
}
#endif

View File

@ -0,0 +1,73 @@
/**
******************************************************************************
*
* @file pios_usb_com.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009.
* @brief USB_COM functions header.
* @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
*/
#ifndef PIOS_USB_COM_H
#define PIOS_USB_COM_H
/////////////////////////////////////////////////////////////////////////////
// Global definitions
/////////////////////////////////////////////////////////////////////////////
// number of USB_COM interfaces (0..1)
#ifndef PIOS_USB_COM_NUM
#define PIOS_USB_COM_NUM 1
#endif
// size of IN/OUT pipe
#ifndef PIOS_USB_COM_DATA_IN_SIZE
#define PIOS_USB_COM_DATA_IN_SIZE 64
#endif
#ifndef PIOS_USB_COM_DATA_OUT_SIZE
#define PIOS_USB_COM_DATA_OUT_SIZE 64
#endif
#ifndef PIOS_USB_COM_INT_IN_SIZE
#define PIOS_USB_COM_INT_IN_SIZE 64
#endif
/* Public Functions */
extern s32 PIOS_USB_COM_Init(u32 mode);
extern s32 PIOS_USB_COM_CheckAvailable(void);
extern s32 PIOS_USB_COM_ChangeConnectionState(u8 connected);
extern void PIOS_USB_COM_EP4_IN_Callback(void);
extern void PIOS_USB_COM_EP3_OUT_Callback(void);
extern void PIOS_USB_COM_CB_StatusIn(void);
extern s32 PIOS_USB_COM_CB_Data_Setup(u8 RequestNo);
extern s32 PIOS_USB_COM_CB_NoData_Setup(u8 RequestNo);
extern s32 PIOS_USB_COM_RxBufferFree(u8 usb_com);
extern s32 PIOS_USB_COM_RxBufferUsed(u8 usb_com);
extern s32 PIOS_USB_COM_RxBufferGet(u8 usb_com);
extern s32 PIOS_USB_COM_TxBufferFree(u8 usb_com);
extern s32 PIOS_USB_COM_TxBufferUsed(u8 usb_com);
extern s32 PIOS_USB_COM_TxBufferPut_NonBlocking(u8 usb_com, u8 b);
extern s32 PIOS_USB_COM_TxBufferPut(u8 usb_com, u8 b);
extern s32 PIOS_USB_COM_TxBufferPutMore_NonBlocking(u8 usb_com, u8 *buffer, u16 len);
extern s32 PIOS_USB_COM_TxBufferPutMore(u8 usb_com, u8 *buffer, u16 len);
#endif /* PIOS_USB_COM_H */