1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

PIOS_COM and PIOS_USART now non-application specific.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@243 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2010-03-04 07:07:27 +00:00 committed by gussy
parent bffe79703a
commit 09645920ee
7 changed files with 41 additions and 38 deletions

View File

@ -99,6 +99,7 @@
//-------------------------
// PIOS_USART2 (GPS)
//-------------------------
#define PIOS_USART1_NAME GPS
#define PIOS_USART2_ENABLED 1
#define PIOS_USART2_USART USART3
#define PIOS_USART2_GPIO_PORT GPIOC
@ -132,7 +133,7 @@
#define PIOS_USART_NUM 3
#define PIOS_USART_RX_BUFFER_SIZE 1024
#define PIOS_USART_TX_BUFFER_SIZE 256
#define PIOS_COM_DEBUG_PORT GPS
#define PIOS_COM_DEBUG_PORT USART_1
//-------------------------
// SPI

View File

@ -74,12 +74,12 @@ int32_t PIOS_COM_SendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uin
switch(port) {
case COM_DEBUG_USART:
return PIOS_USART_TxBufferPutMoreNonBlocking(PIOS_COM_DEBUG_PORT, buffer, len);
case COM_GPS_USART:
return PIOS_USART_TxBufferPutMoreNonBlocking(GPS, buffer, len);
case COM_TELEM_USART:
return PIOS_USART_TxBufferPutMoreNonBlocking(TELEM, buffer, len);
case COM_AUX_USART:
return PIOS_USART_TxBufferPutMoreNonBlocking(AUX, buffer, len);
case COM_USART1:
return PIOS_USART_TxBufferPutMoreNonBlocking(USART_1, buffer, len);
case COM_USART2:
return PIOS_USART_TxBufferPutMoreNonBlocking(USART_2, buffer, len);
case COM_USART3:
return PIOS_USART_TxBufferPutMoreNonBlocking(USART_3, buffer, len);
case COM_USB_HID:
return PIOS_USB_HID_TxBufferPutMoreNonBlocking(buffer, len);
default:
@ -103,12 +103,12 @@ int32_t PIOS_COM_SendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len)
switch(port) {
case COM_DEBUG_USART:
return PIOS_USART_TxBufferPutMore(PIOS_COM_DEBUG_PORT, buffer, len);
case COM_GPS_USART:
return PIOS_USART_TxBufferPutMore(GPS, buffer, len);
case COM_TELEM_USART:
return PIOS_USART_TxBufferPutMore(TELEM, buffer, len);
case COM_AUX_USART:
return PIOS_USART_TxBufferPutMore(AUX, buffer, len);
case COM_USART1:
return PIOS_USART_TxBufferPutMore(USART_1, buffer, len);
case COM_USART2:
return PIOS_USART_TxBufferPutMore(USART_2, buffer, len);
case COM_USART3:
return PIOS_USART_TxBufferPutMore(USART_3, buffer, len);
case COM_USB_HID:
return PIOS_USB_HID_TxBufferPutMore(buffer, len);
default:
@ -245,17 +245,17 @@ int32_t PIOS_COM_ReceiveHandler(void)
status = PIOS_USART_RxBufferGet(PIOS_COM_DEBUG_PORT);
port = COM_DEBUG_USART;
break;
case COM_GPS_USART:
status = PIOS_USART_RxBufferGet(GPS);
port = COM_GPS_USART;
case COM_USART1:
status = PIOS_USART_RxBufferGet(USART_1);
port = COM_USART1;
break;
case COM_TELEM_USART:
status = PIOS_USART_RxBufferGet(TELEM);
port = COM_TELEM_USART;
case COM_USART2:
status = PIOS_USART_RxBufferGet(USART_2);
port = COM_USART2;
break;
case COM_AUX_USART:
status = PIOS_USART_RxBufferGet(AUX);
port = COM_AUX_USART;
case COM_USART3:
status = PIOS_USART_RxBufferGet(USART_3);
port = COM_USART3;
break;
case COM_USB_HID:
status = PIOS_USB_HID_RxBufferGet();

View File

@ -73,8 +73,10 @@ void PIOS_SYS_Init(void)
/* Initialise Basic NVIC */
NVIC_Configuration();
#if !defined(PIOS_DONT_USE_LED)
/* Initialise LEDs */
PIOS_LED_Init();
#endif
}
/**

View File

@ -525,15 +525,15 @@ PIOS_USART1_IRQHANDLER_FUNC
if(PIOS_USART1_USART->SR & (1 << 5)) {
uint8_t b = PIOS_USART1_USART->DR;
if(PIOS_USART_RxBufferPut(GPS, b) < 0) {
if(PIOS_USART_RxBufferPut(USART_1, b) < 0) {
/* Here we could add some error handling */
}
}
/* Check if TXE flag is set */
if(PIOS_USART1_USART->SR & (1 << 7)) {
if(PIOS_USART_TxBufferUsed(GPS) > 0) {
int b = PIOS_USART_TxBufferGet(GPS);
if(PIOS_USART_TxBufferUsed(USART_1) > 0) {
int b = PIOS_USART_TxBufferGet(USART_1);
if( b < 0 ) {
/* Here we could add some error handling */
PIOS_USART1_USART->DR = 0xff;
@ -554,15 +554,15 @@ PIOS_USART2_IRQHANDLER_FUNC
if(PIOS_USART2_USART->SR & (1 << 5)) {
uint8_t b = PIOS_USART2_USART->DR;
if(PIOS_USART_RxBufferPut(TELEM, b) < 0) {
if(PIOS_USART_RxBufferPut(USART_2, b) < 0) {
/* Here we could add some error handling */
}
}
/* Check if TXE flag is set */
if(PIOS_USART2_USART->SR & (1 << 7)) {
if(PIOS_USART_TxBufferUsed(TELEM) > 0) {
int b = PIOS_USART_TxBufferGet(TELEM);
if(PIOS_USART_TxBufferUsed(USART_2) > 0) {
int b = PIOS_USART_TxBufferGet(USART_2);
if(b < 0) {
/* Here we could add some error handling */
PIOS_USART2_USART->DR = 0xff;
@ -583,14 +583,14 @@ PIOS_USART3_IRQHANDLER_FUNC
if(PIOS_USART3_USART->SR & (1 << 5)) {
uint8_t b = PIOS_USART3_USART->DR;
if(PIOS_USART_RxBufferPut(AUX, b) < 0) {
if(PIOS_USART_RxBufferPut(USART_3, b) < 0) {
/* Here we could add some error handling */
}
}
if(PIOS_USART3_USART->SR & (1 << 7)) { // check if TXE flag is set
if(PIOS_USART_TxBufferUsed(AUX) > 0) {
int b = PIOS_USART_TxBufferGet(AUX);
if(PIOS_USART_TxBufferUsed(USART_3) > 0) {
int b = PIOS_USART_TxBufferGet(USART_3);
if(b < 0) {
/* Here we could add some error handling */
PIOS_USART3_USART->DR = 0xff;

View File

@ -120,7 +120,7 @@ int32_t PIOS_USB_HID_ChangeConnectionState(uint32_t Connected)
}
/**
* This function returns the connection status of the USB COM interface
* This function returns the connection status of the USB HID 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

View File

@ -30,9 +30,9 @@
/* Global Types */
typedef enum {
COM_DEBUG_USART = 0,
COM_GPS_USART = 1,
COM_TELEM_USART = 2,
COM_AUX_USART = 3,
COM_USART1 = 1,
COM_USART2 = 2,
COM_USART3 = 3,
COM_USB_HID = 4
} COMPortTypeDef;

View File

@ -29,7 +29,7 @@
/* Global Types */
typedef enum {GPS = 0, TELEM = 1, AUX = 2} USARTNumTypeDef; //TODO: Make this non-application specific
typedef enum {USART_1 = 0, USART_2 = 1, USART_3 = 2} USARTNumTypeDef; //TODO: Make this non-application specific
/* Public Functions */