1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Updated all PIOS function names to new standard.

New standard to be used is PIOS_Module_Function().
Likewise with OpenPilot, OP_Module_Function() is to be used.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@59 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2009-12-08 02:13:21 +00:00 committed by gussy
parent 21d62c0c36
commit f52a719c1d
17 changed files with 150 additions and 148 deletions

View File

@ -56,6 +56,7 @@ void OpenPilotInit(void)
- Supervisor should have highest possibly priority (Idle + 14?)
- Supervisor should also act as the warnings system, low batter etc)
- Supervisor should handle all telemetry inputs (not outputs), and act accordingly
- ARC and HARC tasks should be split into two parts, gathering sensor data and acting on sensor data.
- Sub tasks of the supervisor should have a priority just lower than the supervisor (Idle + 12?)
- Sub tasks of the supervisor shoud ONLY be pre-empted by system interrupts such as UART, I2C etc
- Gatekeepers should sit in a blocked state while there is nothing on the que, with a low priority

View File

@ -42,7 +42,7 @@ static int32_t (*receive_callback_func)(COMPortTypeDef port, char c);
* \param[in] mode currently only mode 0 supported
* \return < 0 if initialisation failed
*/
int32_t COMInit(void)
int32_t PIOS_COM_Init(void)
{
int32_t ret = 0;
@ -50,7 +50,7 @@ int32_t COMInit(void)
receive_callback_func = NULL;
/* If any COM assignment: */
USARTInit();
PIOS_USART_Init();
return -ret;
}
@ -65,18 +65,18 @@ int32_t COMInit(void)
* caller should retry until buffer is free again
* \return 0 on success
*/
int32_t COMSendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uint16_t len)
int32_t PIOS_COM_SendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uint16_t len)
{
/* Branch depending on selected port */
switch(port) {
case 0:
return USARTTxBufferPutMoreNonBlocking(COM_DEBUG_PORT, buffer, len);
return PIOS_USART_TxBufferPutMoreNonBlocking(COM_DEBUG_PORT, buffer, len);
case 1:
return USARTTxBufferPutMoreNonBlocking(GPS, buffer, len);
return PIOS_USART_TxBufferPutMoreNonBlocking(GPS, buffer, len);
case 2:
return USARTTxBufferPutMoreNonBlocking(TELEM, buffer, len);
return PIOS_USART_TxBufferPutMoreNonBlocking(TELEM, buffer, len);
case 3:
return USARTTxBufferPutMoreNonBlocking(AUX, buffer, len);
return PIOS_USART_TxBufferPutMoreNonBlocking(AUX, buffer, len);
default:
/* Invalid port */
return -1;
@ -94,18 +94,18 @@ int32_t COMSendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uint16_t
* \return -1 if port not available
* \return 0 on success
*/
int32_t COMSendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len)
int32_t PIOS_COM_SendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len)
{
/* Branch depending on selected port */
switch(port) {
case 0:
return USARTTxBufferPutMore(COM_DEBUG_PORT, buffer, len);
return PIOS_USART_TxBufferPutMore(COM_DEBUG_PORT, buffer, len);
case 1:
return USARTTxBufferPutMore(GPS, buffer, len);
return PIOS_USART_TxBufferPutMore(GPS, buffer, len);
case 2:
return USARTTxBufferPutMore(TELEM, buffer, len);
return PIOS_USART_TxBufferPutMore(TELEM, buffer, len);
case 3:
return USARTTxBufferPutMore(AUX, buffer, len);
return PIOS_USART_TxBufferPutMore(AUX, buffer, len);
default:
/* Invalid port */
return -1;
@ -122,9 +122,9 @@ int32_t COMSendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len)
* caller should retry until buffer is free again
* \return 0 on success
*/
int32_t COMSendCharNonBlocking(COMPortTypeDef port, char c)
int32_t PIOS_COM_SendCharNonBlocking(COMPortTypeDef port, char c)
{
return COMSendBufferNonBlocking(port, (uint8_t *)&c, 1);
return PIOS_COM_SendBufferNonBlocking(port, (uint8_t *)&c, 1);
}
@ -136,9 +136,9 @@ int32_t COMSendCharNonBlocking(COMPortTypeDef port, char c)
* \return -1 if port not available
* \return 0 on success
*/
int32_t COMSendChar(COMPortTypeDef port, char c)
int32_t PIOS_COM_SendChar(COMPortTypeDef port, char c)
{
return COMSendBuffer(port, (uint8_t *)&c, 1);
return PIOS_COM_SendBuffer(port, (uint8_t *)&c, 1);
}
@ -151,9 +151,9 @@ int32_t COMSendChar(COMPortTypeDef port, char c)
* caller should retry until buffer is free again
* \return 0 on success
*/
int32_t COMSendStringNonBlocking(COMPortTypeDef port, char *str)
int32_t PIOS_COM_SendStringNonBlocking(COMPortTypeDef port, char *str)
{
return COMSendBufferNonBlocking(port, (uint8_t *)str, (uint16_t)strlen(str));
return PIOS_COM_SendBufferNonBlocking(port, (uint8_t *)str, (uint16_t)strlen(str));
}
@ -165,9 +165,9 @@ int32_t COMSendStringNonBlocking(COMPortTypeDef port, char *str)
* \return -1 if port not available
* \return 0 on success
*/
int32_t COMSendString(COMPortTypeDef port, char *str)
int32_t PIOS_COM_SendString(COMPortTypeDef port, char *str)
{
return COMSendBuffer(port, (uint8_t *)str, strlen(str));
return PIOS_COM_SendBuffer(port, (uint8_t *)str, strlen(str));
}
@ -181,7 +181,7 @@ int32_t COMSendString(COMPortTypeDef port, char *str)
* caller should retry until buffer is free again
* \return 0 on success
*/
int32_t COMSendFormattedStringNonBlocking(COMPortTypeDef port, char *format, ...)
int32_t PIOS_COM_SendFormattedStringNonBlocking(COMPortTypeDef port, char *format, ...)
{
uint8_t buffer[128]; // TODO: tmp!!! Provide a streamed COM method later!
@ -189,7 +189,7 @@ int32_t COMSendFormattedStringNonBlocking(COMPortTypeDef port, char *format, ...
va_start(args, format);
vsprintf((char *)buffer, format, args);
return COMSendBufferNonBlocking(port, buffer, (uint16_t)strlen((char *)buffer));
return PIOS_COM_SendBufferNonBlocking(port, buffer, (uint16_t)strlen((char *)buffer));
}
@ -202,14 +202,14 @@ int32_t COMSendFormattedStringNonBlocking(COMPortTypeDef port, char *format, ...
* \return -1 if port not available
* \return 0 on success
*/
int32_t COMSendFormattedString(COMPortTypeDef port, char *format, ...)
int32_t PIOS_COM_SendFormattedString(COMPortTypeDef port, char *format, ...)
{
uint8_t buffer[128]; // TODO: tmp!!! Provide a streamed COM method later!
va_list args;
va_start(args, format);
vsprintf((char *)buffer, format, args);
return COMSendBuffer(port, buffer, (uint16_t)strlen((char *)buffer));
return PIOS_COM_SendBuffer(port, buffer, (uint16_t)strlen((char *)buffer));
}
@ -223,7 +223,7 @@ int32_t COMSendFormattedString(COMPortTypeDef port, char *format, ...)
*
* \return < 0 on errors
*/
int32_t COMReceiveHandler(void)
int32_t PIOS_COM_ReceiveHandler(void)
{
uint8_t port;
@ -244,10 +244,10 @@ int32_t COMReceiveHandler(void)
// it would also improve this spagetthi code ;)
int32_t status = -1;
switch( intf++ ) {
case 0: status = USARTRxBufferGet(COM_DEBUG_PORT); port = COM_DEBUG_UART; break;
case 1: status = USARTRxBufferGet(GPS); port = COM_GPS_UART; break;
case 2: status = USARTRxBufferGet(TELEM); port = COM_TELEM_UART; break;
case 3: status = USARTRxBufferGet(AUX); port = COM_AUX_UART; break;
case 0: status = PIOS_USART_RxBufferGet(COM_DEBUG_PORT); port = COM_DEBUG_UART; break;
case 1: status = PIOS_USART_RxBufferGet(GPS); port = COM_GPS_UART; break;
case 2: status = PIOS_USART_RxBufferGet(TELEM); port = COM_TELEM_UART; break;
case 3: status = PIOS_USART_RxBufferGet(AUX); port = COM_AUX_UART; break;
default:
// allow 64 forwards maximum to yield some CPU time for other tasks
if(bytes_forwarded && total_bytes_forwarded < 64) {
@ -291,12 +291,12 @@ int32_t COMReceiveHandler(void)
*
* The callback function has been installed in an Init() function with:
* \code
* COMReceiveCallbackInit(CONSOLE_Parse);
* PIOS_COM_ReceiveCallbackInit(CONSOLE_Parse);
* \endcode
* \param[in] callback_debug_command the callback function (NULL disables the callback)
* \return < 0 on errors
*/
int32_t COMReceiveCallbackInit(void *callback_receive)
int32_t PIOS_COM_ReceiveCallbackInit(void *callback_receive)
{
receive_callback_func = callback_receive;

View File

@ -42,7 +42,7 @@ SettingsTypeDef Settings;
*/
/* Value Reading: ini_getl("Section", "Key", (DefaultValue), IniFile); */
/* String Reading: ini_gets("Section", "Key", "DefaultValue", StrBuffer, sizearray(StrBuffer), IniFile); */
void LoadSettings(void)
void PIOS_Settings_Load(void)
{
/* Unused yet, until we load strings
char StrBuffer[100];
@ -69,7 +69,7 @@ void LoadSettings(void)
* Dump Settings struct contents to UART
* \param[in] USARTx USART name (GPS, TELEM, AUX)
*/
void DumpSettings(USART_TypeDef* USARTx)
void PIOS_Settings_Dump(USART_TypeDef* USARTx)
{
/* Implement once UART is fully implemented */
}
@ -79,7 +79,7 @@ void DumpSettings(USART_TypeDef* USARTx)
* \return 0 All files found
* \return >0 Number of files missing
*/
int CheckForSettingsFiles(void)
int PIOS_Settings_CheckForFiles(void)
{
FILINFO DummyVar;
int MissingCount = 0;

View File

@ -45,7 +45,7 @@ static void printchar(char **str, int c)
++(*str);
}
else COMSendChar(COM_DEBUG_UART, c); // (void)putchar(c);
else PIOS_COM_SendChar(COM_DEBUG_UART, c); // (void)putchar(c);
}

View File

@ -41,7 +41,7 @@ static uint16_t adc_pin_values[NUM_ADC_PINS];
/**
* Initialise the ADC Peripheral
*/
void ADCInit(void)
void PIOS_ADC_Init(void)
{
int32_t i;
@ -153,7 +153,7 @@ void ADCInit(void)
* \return ADC pin value - resolution depends on the selected oversampling rate Set in Settings.ini
* \return -1 if pin doesn't exist
*/
int32_t ADCPinGet(uint32_t pin)
int32_t PIOS_ADC_PinGet(uint32_t pin)
{
/* Check if pin exists */
if(pin >= NUM_ADC_PINS) {
@ -173,7 +173,7 @@ int32_t ADCPinGet(uint32_t pin)
* \param[in] _callback pointer to callback function
* \return < 0 on errors
*/
int32_t ADCHandler(void *_callback)
int32_t PIOS_ADC_Handler(void *_callback)
{
/* No callback function? */
if(_callback == NULL) {
@ -185,9 +185,9 @@ int32_t ADCHandler(void *_callback)
/* Check for changed ADC conversion values */
for(pin = 0; pin < NUM_ADC_PINS; pin++) {
IRQDisable();
PIOS_IRQ_Disable();
uint32_t pin_value = adc_pin_values[pin];
IRQEnable();
PIOS_IRQ_Enable();
/* Call application hook */
/* Note that due to dual conversion approach, we have to convert the pin number */

View File

@ -45,22 +45,22 @@ static unsigned int prev_primask;
* Disables all interrupts (nested)
* \return < 0 On errors
*/
int IRQDisable(void)
int PIOS_IRQ_Disable(void)
{
/* Get current priority if nested level == 0 */
if(!nested_ctr) {
__asm volatile ( \
" mrs %0, primask\n" \
: "=r" (prev_primask) \
);
__asm volatile ( \
" mrs %0, primask\n" \
: "=r" (prev_primask) \
);
}
/* disable interrupts */
__asm volatile ( \
" mov r0, #1 \n" \
" msr primask, r0\n" \
:::"r0" \
);
__asm volatile ( \
" mov r0, #1 \n" \
" msr primask, r0\n" \
:::"r0" \
);
++nested_ctr;
@ -72,9 +72,9 @@ int IRQDisable(void)
/**
* Enables all interrupts (nested)
* \return < 0 on errors
* \return -1 on nesting errors (IRQDisable() hasn't been called before)
* \return -1 on nesting errors (PIOS_IRQ_Disable() hasn't been called before)
*/
int IRQEnable(void)
int PIOS_IRQ_Enable(void)
{
/* Check for nesting error */
if(nested_ctr == 0) {

View File

@ -42,7 +42,7 @@ static const uint32_t LED_GPIO_CLK[NUM_LED] = {LED1_GPIO_CLK, LED2_GPIO_CLK};
/**
* Initialises all the LED's
*/
void LED_INIT(void)
void PIOS_LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
@ -60,7 +60,7 @@ void LED_INIT(void)
* Turn on LED
* \param[in] LED LED Name (LED1, LED2)
*/
void LED_ON(LedTypeDef LED)
void PIOS_LED_On(LedTypeDef LED)
{
LED_GPIO_PORT[LED]->BSRR = LED_GPIO_PIN[LED];
}
@ -70,7 +70,7 @@ void LED_ON(LedTypeDef LED)
* Turn off LED
* \param[in] LED LED Name (LED1, LED2)
*/
void LED_OFF(LedTypeDef LED)
void PIOS_LED_Off(LedTypeDef LED)
{
LED_GPIO_PORT[LED]->BRR = LED_GPIO_PIN[LED];
}
@ -80,7 +80,7 @@ void LED_OFF(LedTypeDef LED)
* Toggle LED on/off
* \param[in] LED LED Name (LED1, LED2)
*/
void LED_TOGGLE(LedTypeDef LED)
void PIOS_LED_Toggle(LedTypeDef LED)
{
LED_GPIO_PORT[LED]->ODR ^= LED_GPIO_PIN[LED];
}

View File

@ -42,7 +42,7 @@ static FATFS Fatfs[_DRIVES];
/**
* Initializes all system peripherals
*/
void SysInit(void)
void PIOS_SYS_Init(void)
{
/* Setup STM32 system (RCC, clock, PLL and Flash configuration) - CMSIS Function */
SystemInit();
@ -51,20 +51,20 @@ void SysInit(void)
NVIC_Configuration();
/* Initialize LEDs */
LED_INIT();
PIOS_LED_Init();
/* Initialize FatFS disk */
if(f_mount(0, &Fatfs[0]) != FR_OK) {
/* Failed to mount MicroSD filesystem, flash LED1 forever */
while(1) {
for(int i = 0; i < 1000; i++);
LED_TOGGLE(LED1);
PIOS_LED_Toggle(LED1);
}
}
/* Call LoadSettings which populates System Vars */
/* Settings can not be loaded before this point */
LoadSettings();
PIOS_Settings_Load();
}
@ -107,16 +107,16 @@ void assert_failed(uint8_t* file, uint32_t line)
/* printf("Wrong parameters value: file %s on line %d\r\n", file, line); */
/* Setup the LEDs to Alternate */
LED_ON(LED1);
LED_OFF(LED2);
PIOS_LED_On(LED1);
PIOS_LED_Off(LED2);
/* Infinite loop */
while (1)
{
for(int i = 0; i < 1000; i++);
LED_TOGGLE(LED1);
PIOS_LED_Toggle(LED1);
for(int i = 0; i < 1000; i++);
LED_TOGGLE(LED2);
PIOS_LED_Toggle(LED2);
}
}
#endif

View File

@ -48,7 +48,7 @@ static volatile uint8_t tx_buffer_size[USART_NUM];
/**
* Initialise the GPS and TELEM onboard USARTs
*/
void USARTInit(void)
void PIOS_USART_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
@ -137,7 +137,7 @@ void USARTInit(void)
/**
* Enables AUX USART at the expense of servo inputs
*/
void USARTEnableAux(void)
void PIOS_USART_EnableAux(void)
{
//Implement after servo inputs are implemented
}
@ -146,7 +146,7 @@ void USARTEnableAux(void)
/**
* Disables AUX USART reclaims two servo inputs
*/
void USARTDisableAux(void)
void PIOS_USART_DisableAux(void)
{
//Implement after servo inputs are implemented
}
@ -157,7 +157,7 @@ void USARTDisableAux(void)
* \param[in] USARTx USART name (GPS, TELEM, AUX)
* \param[in] Baud Requested baud rate
*/
void USARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud)
void PIOS_USART_ChangeBaud(USART_TypeDef* USARTx, uint32_t Baud)
{
/* USART BRR Configuration */
/* Configure the USART Baud Rate */
@ -195,7 +195,7 @@ void USARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud)
* \return 1: USART available
* \return 0: USART not available
*/
int USARTRxBufferFree(USARTNumTypeDef usart)
int PIOS_USART_RxBufferFree(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
return 0;
@ -211,7 +211,7 @@ int USARTRxBufferFree(USARTNumTypeDef usart)
* \return 0 if USART not available
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTRxBufferUsed(USARTNumTypeDef usart)
int PIOS_USART_RxBufferUsed(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
return 0;
@ -228,7 +228,7 @@ int USARTRxBufferUsed(USARTNumTypeDef usart)
* \return >= 0: number of received bytes
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTRxBufferGet(USARTNumTypeDef usart)
int PIOS_USART_RxBufferGet(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
/* USART not available */
@ -240,13 +240,13 @@ int USARTRxBufferGet(USARTNumTypeDef usart)
}
/* get byte - this operation should be atomic! */
IRQDisable();
PIOS_IRQ_Disable();
uint8_t b = rx_buffer[usart][rx_buffer_tail[usart]];
if(++rx_buffer_tail[usart] >= USART_RX_BUFFER_SIZE) {
rx_buffer_tail[usart] = 0;
}
--rx_buffer_size[usart];
IRQEnable();
PIOS_IRQ_Enable();
/* Return received byte */
return b;
@ -260,7 +260,7 @@ int USARTRxBufferGet(USARTNumTypeDef usart)
* \return >= 0: number of received bytes
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTRxBufferPeek(USARTNumTypeDef usart)
int PIOS_USART_RxBufferPeek(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
/* USART not available */
@ -273,9 +273,9 @@ int USARTRxBufferPeek(USARTNumTypeDef usart)
}
/* Get byte - this operation should be atomic! */
IRQDisable();
PIOS_IRQ_Disable();
uint8_t b = rx_buffer[usart][rx_buffer_tail[usart]];
IRQEnable();
PIOS_IRQ_Enable();
/* Return received byte */
return b;
@ -290,7 +290,7 @@ int USARTRxBufferPeek(USARTNumTypeDef usart)
* \return -2 if buffer full (retry)
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTRxBufferPut(USARTNumTypeDef usart, uint8_t b)
int PIOS_USART_RxBufferPut(USARTNumTypeDef usart, uint8_t b)
{
if(usart >= USART_NUM) {
/* USART not available */
@ -304,13 +304,13 @@ int USARTRxBufferPut(USARTNumTypeDef usart, uint8_t b)
/* Copy received byte into receive buffer */
/* This operation should be atomic! */
IRQDisable();
PIOS_IRQ_Disable();
rx_buffer[usart][rx_buffer_head[usart]] = b;
if(++rx_buffer_head[usart] >= USART_RX_BUFFER_SIZE) {
rx_buffer_head[usart] = 0;
}
++rx_buffer_size[usart];
IRQEnable();
PIOS_IRQ_Enable();
/* No error */
return 0;
@ -324,7 +324,7 @@ int USARTRxBufferPut(USARTNumTypeDef usart, uint8_t b)
* \return 0 if USART not available
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferFree(USARTNumTypeDef usart)
int PIOS_USART_TxBufferFree(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
return 0;
@ -340,7 +340,7 @@ int USARTTxBufferFree(USARTNumTypeDef usart)
* \return 0 if USART not available
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferUsed(USARTNumTypeDef usart)
int PIOS_USART_TxBufferUsed(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
return 0;
@ -357,7 +357,7 @@ int USARTTxBufferUsed(USARTNumTypeDef usart)
* \return >= 0: transmitted byte
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferGet(USARTNumTypeDef usart)
int PIOS_USART_TxBufferGet(USARTNumTypeDef usart)
{
if(usart >= USART_NUM) {
/* USART not available */
@ -370,13 +370,13 @@ int USARTTxBufferGet(USARTNumTypeDef usart)
}
/* Get byte - this operation should be atomic! */
IRQDisable();
PIOS_IRQ_Disable();
uint8_t b = tx_buffer[usart][tx_buffer_tail[usart]];
if(++tx_buffer_tail[usart] >= USART_TX_BUFFER_SIZE) {
tx_buffer_tail[usart] = 0;
}
--tx_buffer_size[usart];
IRQEnable();
PIOS_IRQ_Enable();
/* Return transmitted byte */
return b;
@ -393,7 +393,7 @@ int USARTTxBufferGet(USARTNumTypeDef usart)
* \return -3 if USART not supported by USARTTxBufferPut Routine
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferPutMoreNonBlocking(USARTNumTypeDef usart, uint8_t *buffer, uint16_t len)
int PIOS_USART_TxBufferPutMoreNonBlocking(USARTNumTypeDef usart, uint8_t *buffer, uint16_t len)
{
if(usart >= USART_NUM) {
/* USART not available */
@ -407,7 +407,7 @@ int USARTTxBufferPutMoreNonBlocking(USARTNumTypeDef usart, uint8_t *buffer, uint
/* Copy bytes to be transmitted into transmit buffer */
/* This operation should be atomic! */
IRQDisable();
PIOS_IRQ_Disable();
uint16_t i;
for(i = 0; i < len; ++i) {
@ -427,12 +427,12 @@ int USARTTxBufferPutMoreNonBlocking(USARTNumTypeDef usart, uint8_t *buffer, uint
/* Enable TXE interrupt (TXEIE=1) */
case 2: AUX_USART_USART->CR1 |= (1 << 7); break;
/* USART not supported by routine (yet) */
default: IRQEnable(); return -3;
default: PIOS_IRQ_Enable(); return -3;
}
}
}
IRQEnable();
PIOS_IRQ_Enable();
/* No error */
return 0;
@ -449,11 +449,11 @@ int USARTTxBufferPutMoreNonBlocking(USARTNumTypeDef usart, uint8_t *buffer, uint
* \return -3 if USART not supported by USARTTxBufferPut Routine
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferPutMore(USARTNumTypeDef usart, uint8_t *buffer, uint16_t len)
int PIOS_USART_TxBufferPutMore(USARTNumTypeDef usart, uint8_t *buffer, uint16_t len)
{
int error;
while((error = USARTTxBufferPutMoreNonBlocking(usart, buffer, len)) == -2);
while((error = PIOS_USART_TxBufferPutMoreNonBlocking(usart, buffer, len)) == -2);
return error;
}
@ -468,11 +468,11 @@ int USARTTxBufferPutMore(USARTNumTypeDef usart, uint8_t *buffer, uint16_t len)
* \return -3 if USART not supported by USARTTxBufferPut Routine
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferPut_NonBlocking(USARTNumTypeDef usart, uint8_t b)
int PIOS_USART_TxBufferPut_NonBlocking(USARTNumTypeDef usart, uint8_t b)
{
/* For more comfortable usage... */
/* -> Just forward to USARTTxBufferPutMore */
return USARTTxBufferPutMore(usart, &b, 1);
return PIOS_USART_TxBufferPutMore(usart, &b, 1);
}
/**
@ -485,11 +485,11 @@ int USARTTxBufferPut_NonBlocking(USARTNumTypeDef usart, uint8_t b)
* \return -3 if USART not supported by USARTTxBufferPut Routine
* \note Applications shouldn't call these functions directly, instead please use \ref PIOS_COM layer functions
*/
int USARTTxBufferPut(USARTNumTypeDef usart, uint8_t b)
int PIOS_USART_TxBufferPut(USARTNumTypeDef usart, uint8_t b)
{
int error;
while((error = USARTTxBufferPutMore(usart, &b, 1)) == -2);
while((error = PIOS_USART_TxBufferPutMore(usart, &b, 1)) == -2);
return error;
}
@ -501,15 +501,15 @@ GPS_IRQHANDLER_FUNC
if(GPS_USART->SR & (1 << 5)) {
uint8_t b = GPS_USART->DR;
if(USARTRxBufferPut(0, b) < 0) {
if(PIOS_USART_RxBufferPut(GPS, b) < 0) {
/* Here we could add some error handling */
}
}
/* Check if TXE flag is set */
if(GPS_USART->SR & (1 << 7)) {
if(USARTTxBufferUsed(0) > 0) {
int b = USARTTxBufferGet(0);
if(PIOS_USART_TxBufferUsed(GPS) > 0) {
int b = PIOS_USART_TxBufferGet(GPS);
if( b < 0 ) {
/* Here we could add some error handling */
GPS_USART->DR = 0xff;
@ -530,14 +530,15 @@ TELEM_IRQHANDLER_FUNC
if(TELEM_USART->SR & (1 << 5)) {
uint8_t b = TELEM_USART->DR;
if(USARTRxBufferPut(1, b) < 0) {
if(PIOS_USART_RxBufferPut(TELEM, b) < 0) {
/* Here we could add some error handling */
}
}
if(TELEM_USART->SR & (1 << 7)) { // check if TXE flag is set
if(USARTTxBufferUsed(1) > 0) {
int b = USARTTxBufferGet(1);
/* Check if TXE flag is set */
if(TELEM_USART->SR & (1 << 7)) {
if(PIOS_USART_TxBufferUsed(TELEM) > 0) {
int b = PIOS_USART_TxBufferGet(TELEM);
if(b < 0) {
/* Here we could add some error handling */
TELEM_USART->DR = 0xff;
@ -558,14 +559,14 @@ AUX_USART_IRQHANDLER_FUNC
if(AUX_USART_USART->SR & (1 << 5)) {
uint8_t b = AUX_USART_USART->DR;
if(USARTRxBufferPut(1, b) < 0) {
if(PIOS_USART_RxBufferPut(AUX, b) < 0) {
/* Here we could add some error handling */
}
}
if(AUX_USART_USART->SR & (1 << 7)) { // check if TXE flag is set
if(USARTTxBufferUsed(1) > 0) {
int b = USARTTxBufferGet(1);
if(PIOS_USART_TxBufferUsed(AUX) > 0) {
int b = PIOS_USART_TxBufferGet(AUX);
if(b < 0) {
/* Here we could add some error handling */
AUX_USART_USART->DR = 0xff;

View File

@ -27,8 +27,8 @@
#define PIOS_ADC_H
/* Public Functions */
extern void ADCInit(void);
extern int32_t ADCPinGet(uint32_t pin);
extern int32_t ADCHandler(void *_callback);
extern void PIOS_ADC_Init(void);
extern int32_t PIOS_ADC_PinGet(uint32_t pin);
extern int32_t PIOS_ADC_Handler(void *_callback);
#endif /* PIOS_ADC_H */

View File

@ -35,18 +35,18 @@ typedef enum {
} COMPortTypeDef;
/* Public Functions */
extern int32_t COMInit(void);
extern int32_t PIOS_COM_Init(void);
extern int32_t COMSendCharNonBlocking(COMPortTypeDef port, char c);
extern int32_t COMSendChar(COMPortTypeDef port, char c);
extern int32_t COMSendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uint16_t len);
extern int32_t COMSendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len);
extern int32_t COMSendStringNonBlocking(COMPortTypeDef port, char *str);
extern int32_t COMSendString(COMPortTypeDef port, char *str);
extern int32_t COMSendFormattedStringNonBlocking(COMPortTypeDef port, char *format, ...);
extern int32_t COMSendFormattedString(COMPortTypeDef port, char *format, ...);
extern int32_t PIOS_COM_SendCharNonBlocking(COMPortTypeDef port, char c);
extern int32_t PIOS_COM_SendChar(COMPortTypeDef port, char c);
extern int32_t PIOS_COM_SendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uint16_t len);
extern int32_t PIOS_COM_SendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len);
extern int32_t PIOS_COM_SendStringNonBlocking(COMPortTypeDef port, char *str);
extern int32_t PIOS_COM_SendString(COMPortTypeDef port, char *str);
extern int32_t PIOS_COM_SendFormattedStringNonBlocking(COMPortTypeDef port, char *format, ...);
extern int32_t PIOS_COM_SendFormattedString(COMPortTypeDef port, char *format, ...);
extern int32_t COMReceiveHandler(void);
extern int32_t COMReceiveCallbackInit(void *callback_receive);
extern int32_t PIOS_COM_ReceiveHandler(void);
extern int32_t PIOS_COM_ReceiveCallbackInit(void *callback_receive);
#endif /* PIOS_COM_H */

View File

@ -27,7 +27,7 @@
#define PIOS_IRQ_H
/* Public Functions */
extern int IRQDisable(void);
extern int IRQEnable(void);
extern int PIOS_IRQ_Disable(void);
extern int PIOS_IRQ_Enable(void);
#endif /* PIOS_IRQ_H */

View File

@ -30,9 +30,9 @@
typedef enum {LED1 = 0, LED2 = 1} LedTypeDef;
/* Public Functions */
extern void LED_INIT(void);
extern void LED_ON(LedTypeDef LED);
extern void LED_OFF(LedTypeDef LED);
extern void LED_TOGGLE(LedTypeDef LED);
extern void PIOS_LED_Init(void);
extern void PIOS_LED_On(LedTypeDef LED);
extern void PIOS_LED_Off(LedTypeDef LED);
extern void PIOS_LED_Toggle(LedTypeDef LED);
#endif /* PIOS_LED_H */

View File

@ -67,8 +67,8 @@ typedef struct {
extern SettingsTypeDef Settings;
/* Public Functions */
extern void LoadSettings(void);
extern void DumpSettings(USART_TypeDef* USARTx);
extern int CheckForSettingsFiles(void);
extern void PIOS_Settings_Load(void);
extern void PIOS_Settings_Dump(USART_TypeDef* USARTx);
extern int PIOS_Settings_CheckForFiles(void);
#endif /* PIOS_SETTINGS_H */

View File

@ -27,6 +27,6 @@
#define PIOS_SYS_H
/* Public Functions */
extern void SysInit(void);
extern void PIOS_SYS_Init(void);
#endif /* PIOS_SYS_H */

View File

@ -32,22 +32,22 @@ typedef enum {GPS = 0, TELEM = 1, AUX = 2} USARTNumTypeDef;
/* Public Functions */
extern void USARTInit(void);
extern void USARTEnableAux(void);
extern void USARTDisableAux(void);
extern void USARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud);
extern void PIOS_USART_Init(void);
extern void PIOS_USART_EnableAux(void);
extern void PIOS_USART_DisableAux(void);
extern void PIOS_USART_ChangeBaud(USART_TypeDef* USARTx, uint32_t Baud);
extern int USARTRxBufferFree(USARTNumTypeDef uart);
extern int USARTRxBufferUsed(USARTNumTypeDef uart);
extern int USARTRxBufferGet(USARTNumTypeDef uart);
extern int USARTRxBufferPeek(USARTNumTypeDef uart);
extern int USARTRxBufferPut(USARTNumTypeDef uart, uint8_t b);
extern int PIOS_USART_RxBufferFree(USARTNumTypeDef uart);
extern int PIOS_USART_RxBufferUsed(USARTNumTypeDef uart);
extern int PIOS_USART_RxBufferGet(USARTNumTypeDef uart);
extern int PIOS_USART_RxBufferPeek(USARTNumTypeDef uart);
extern int PIOS_USART_RxBufferPut(USARTNumTypeDef uart, uint8_t b);
extern int USARTTxBufferFree(USARTNumTypeDef uart);
extern int USARTTxBufferGet(USARTNumTypeDef uart);
extern int USARTTxBufferPutMoreNonBlocking(USARTNumTypeDef uart, uint8_t *buffer, uint16_t len);
extern int USARTTxBufferPutMore(USARTNumTypeDef uart, uint8_t *buffer, uint16_t len);
extern int USARTTxBufferPutNonBlocking(uint8_t uart, uint8_t b);
extern int USARTTxBufferPut(USARTNumTypeDef uart, uint8_t b);
extern int PIOS_USART_TxBufferFree(USARTNumTypeDef uart);
extern int PIOS_USART_TxBufferGet(USARTNumTypeDef uart);
extern int PIOS_USART_TxBufferPutMoreNonBlocking(USARTNumTypeDef uart, uint8_t *buffer, uint16_t len);
extern int PIOS_USART_TxBufferPutMore(USARTNumTypeDef uart, uint8_t *buffer, uint16_t len);
extern int PIOS_USART_TxBufferPutNonBlocking(uint8_t uart, uint8_t b);
extern int PIOS_USART_TxBufferPut(USARTNumTypeDef uart, uint8_t b);
#endif /* PIOS_USART_H */

View File

@ -52,9 +52,9 @@ static void HooksTask(void *pvParameters);
int main()
{
/* Setup Hardware */
SysInit();
COMInit();
ADCInit();
PIOS_SYS_Init();
PIOS_COM_Init();
PIOS_ADC_Init();
/* Initialise OpenPilot */
OpenPilotInit();
@ -91,7 +91,7 @@ static void HooksTask(void *pvParameters)
//ADCHandler(ADCNotifyChange);
/* Check for incoming COM messages */
COMReceiveHandler();
PIOS_COM_ReceiveHandler();
}
}