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

Moved pios_settings.c to /PiOS/Common since it is not platform specific.

Started to add some FreeRTOS stuff into pios.c

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@47 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2009-12-02 06:44:53 +00:00 committed by gussy
parent fb9f7c5d4f
commit 42591b0edf
3 changed files with 64 additions and 35 deletions

View File

@ -60,7 +60,7 @@ void LoadSettings(void)
/** /**
* Dump Settings struct contents to UART * Dump Settings struct contents to UART
* \param[in] USARTx UART name (GPS, TELEM, AUX) * \param[in] USARTx USART name (GPS, TELEM, AUX)
*/ */
void DumpSettings(USART_TypeDef* USARTx) void DumpSettings(USART_TypeDef* USARTx)
{ {

View File

@ -16,7 +16,7 @@
#define configUSE_PREEMPTION 1 #define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0 #define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0 #define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 )

View File

@ -34,43 +34,41 @@
#include <task.h> #include <task.h>
#include <queue.h> #include <queue.h>
/* Local Variables */
static unsigned long ulIdleCycleCount = 0UL;
/* FreeRTOS Prototypes */ /* Function Prototypes */
void PiosMainTask( void *pvParameters ); void PiosMainTask(void *pvParameters);
void SensorTask( void *pvParameters ); void SensorTask(void *pvParameters);
void ServosTask(void *pvParameters);
void vApplicationIdleHook(void);
/**
* Main function
*/
int main() int main()
{ {
/* Setup Hardware */
SysInit();
/* Setup Hardware */ /* Start Main tasks. */
SysInit(); xTaskCreate(PiosMainTask, (signed portCHAR *) "PiosMain", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
xTaskCreate(SensorTask, (signed portCHAR *) "Sensor", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
xTaskCreate(ServosTask, (signed portCHAR *) "Servos", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
/* Start Main tasks. */ /* Start the scheduler. */
xTaskCreate( PiosMainTask, ( signed portCHAR * ) "PiosMain", configMINIMAL_STACK_SIZE, NULL, 2, NULL ); vTaskStartScheduler();
xTaskCreate( SensorTask, ( signed portCHAR * ) "Sensor", configMINIMAL_STACK_SIZE, NULL, 2, NULL );
/* If all is well we will never reach here as the scheduler will now be running. */
/* Start the scheduler. */ /* If we do get here, it will most likley be because we ran out of heap space. */
vTaskStartScheduler(); return 0;
}
/* If all is well we will never reach here as the scheduler will now be
running. */
return 0;
}
/** /**
* Function Name : PiosMainTask * PiosMainTask
* Description : PIOS
* Input : None
* Output : None
* Return : None
*/ */
void PiosMainTask( void *pvParameters ) void PiosMainTask(void *pvParameters)
{ {
while(1) while(1)
@ -79,18 +77,49 @@ void PiosMainTask( void *pvParameters )
} }
/** /**
* Function Name : SensorTask * SensorTask
* Description : PIOS
* Input : None
* Output : None
* Return : None
*/ */
void SensorTask( void *pvParameters ) void SensorTask(void *pvParameters)
{ {
while(1) while(1)
{ {
} }
} }
/**
* Task to update servo positions at 50Hz
*/
void ServosTask(void *pvParameters)
{
portTickType xLastWakeTime;
/* The xLastWakeTime variable needs to be initialized with the current tick count. */
xLastWakeTime = xTaskGetTickCount();
for(;;)
{
/* Update Servo positions */
/* This task should execute exactly every 20 milliseconds or 50Hz
There is no need to update the servos any faster than this */
vTaskDelayUntil(&xLastWakeTime, (20 / portTICK_RATE_MS));
}
}
/**
* Idle hook function
*/
void vApplicationIdleHook(void)
{
uint32_t IdleTimePercent = 0;
/* Called when the scheduler has no tasks to run */
/* In here we could implement stats for FreeRTOS */
/* This can give a basic indication of how much time the system spends in idle */
/* IdleTimePercent is the percentage of time spent in idle since the scheduler started */
ulIdleCycleCount++;
IdleTimePercent = ((ulIdleCycleCount / xTaskGetTickCount()) * 100);
}