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

Added in ADC hooks to OpenPilot.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@52 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2009-12-02 21:49:31 +00:00 committed by gussy
parent dc830b7a96
commit 7a39f5f55c
4 changed files with 37 additions and 21 deletions

View File

@ -43,5 +43,7 @@
extern void OpenPilotInit(void);
extern void vApplicationIdleHook(void);
/* Hooks */
extern void ADCNotifyChange(uint32_t pin, uint32_t pin_value);
#endif /* OPENPILOT_H */

View File

@ -29,8 +29,7 @@
/* Local Variables */
static uint32_t ulIdleCycleCount = 0;
static uint32_t IdleTimePercent = 0;
static uint16_t adc_pin_values[4];
/* Local Functions */
static void ServosTask(void *pvParameters);
@ -67,23 +66,11 @@ static void ServosTask(void *pvParameters)
}
}
/**
* Idle hook function
* This hook is called every time the
*/
void vApplicationIdleHook(void)
void ADCNotifyChange(uint32_t pin, uint32_t pin_value)
{
/* Called when the scheduler has no tasks to run */
/* In here we could implement full stats for FreeRTOS
Although this would need us to enable stats in FreeRTOS
which is *very* costly. With the function below we can
either print it out or just watch the variable using JTAG */
/* 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 */
/* For example a value of 75 would mean we are spending 75% of FreeRTOS Cycles in idle */
ulIdleCycleCount++;
IdleTimePercent = ((ulIdleCycleCount / xTaskGetTickCount()) * 100);
/* All we really need to do here is store the values in a local array. */
adc_pin_values[pin] = (uint16_t) pin_value;
}

View File

@ -34,6 +34,10 @@
/* Task Priorities */
#define PRIORITY_TASK_HOOKS ( tskIDLE_PRIORITY + 3 )
/* Local Variables */
static uint32_t ulIdleCycleCount = 0;
static uint32_t IdleTimePercent = 0;
/* Function Prototypes */
static void HooksTask(void *pvParameters);
@ -45,6 +49,8 @@ int main()
{
/* Setup Hardware */
SysInit();
COMInit();
ADCInit();
/* Initialise OpenPilot */
OpenPilotInit();
@ -77,8 +83,29 @@ static void HooksTask(void *pvParameters)
xLastExecutionTime = xCurrentTickCount;
}
/* Check for ADC pin changes, call ADCNotifyChange on each pin change */
ADCHandler(ADCNotifyChange);
/* Check for incoming COM messages */
COMReceiveHandler();
}
}
/**
* Idle hook function
*/
void vApplicationIdleHook(void)
{
/* Called when the scheduler has no tasks to run */
/* In here we could implement full stats for FreeRTOS
Although this would need us to enable stats in FreeRTOS
which is *very* costly. With the function below we can
either print it out or just watch the variable using JTAG */
/* 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 */
/* For example a value of 75 would mean we are spending 75% of FreeRTOS Cycles in idle */
ulIdleCycleCount++;
IdleTimePercent = ((ulIdleCycleCount / xTaskGetTickCount()) * 100);
}