aboutsummaryrefslogtreecommitdiffstats
path: root/boards/base/RaspberryPi/example-FreeRTOS/main.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-07-09 18:47:59 +1000
committerinmarket <andrewh@inmarket.com.au>2014-07-09 18:47:59 +1000
commit6dea259ea2dd0afc4b610961e211d77460cfd0c6 (patch)
tree225a157a5ac0c7cf8d4e1b451b47075a57e3110b /boards/base/RaspberryPi/example-FreeRTOS/main.c
parentab9ce99647965d0d3e9ea65ea92ad694c8b8ee1b (diff)
downloaduGFX-6dea259ea2dd0afc4b610961e211d77460cfd0c6.tar.gz
uGFX-6dea259ea2dd0afc4b610961e211d77460cfd0c6.tar.bz2
uGFX-6dea259ea2dd0afc4b610961e211d77460cfd0c6.zip
Example added for FreeRTOS on Raspberry Pi
Diffstat (limited to 'boards/base/RaspberryPi/example-FreeRTOS/main.c')
-rw-r--r--boards/base/RaspberryPi/example-FreeRTOS/main.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/boards/base/RaspberryPi/example-FreeRTOS/main.c b/boards/base/RaspberryPi/example-FreeRTOS/main.c
new file mode 100644
index 00000000..3a64a7bb
--- /dev/null
+++ b/boards/base/RaspberryPi/example-FreeRTOS/main.c
@@ -0,0 +1,82 @@
+#include <FreeRTOS.h>
+#include <task.h>
+
+#include "Drivers/interrupts.h"
+
+#include "gfx.h"
+
+static void displayTask(void *pvParameters) {
+ coord_t width, height;
+ // Get the screen size
+ width = gdispGetWidth();
+ height = gdispGetHeight();
+
+ // Code Here
+ gdispDrawBox(10, 10, width/2, height/2, Yellow);
+ gdispFillArea(width/2, height/2, width/2-10, height/2-10, Blue);
+ gdispDrawLine(5, 30, width-50, height-40, Red);
+
+ while(1)
+ {
+ vTaskDelay(1000);
+ }
+
+ return;
+}
+
+/**
+ * This is the systems main entry, some call it a boot thread.
+ *
+ * -- Absolutely nothing wrong with this being called main(), just it doesn't have
+ * -- the same prototype as you'd see in a linux program.
+ **/
+int main(void) {
+
+ DisableInterrupts();
+ InitInterruptController();
+
+ // Initialize and clear the display
+ gfxInit();
+
+ xTaskCreate(displayTask,
+ (portCHAR *)"Display Task",
+ 128,
+ NULL,
+ 0,
+ NULL);
+
+ vTaskStartScheduler();
+
+ /*
+ * We should never get here, but just in case something goes wrong,
+ * we'll place the CPU into a safe loop.
+ */
+ while(1) {
+ ;
+ }
+
+ return 0;
+}
+
+void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
+{
+ ( void ) pcTaskName;
+ ( void ) pxTask;
+
+ /* Run time task stack overflow checking is performed if
+ configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
+ called if a task stack overflow is detected. Note the system/interrupt
+ stack is not checked. */
+ taskDISABLE_INTERRUPTS();
+ for( ;; );
+}
+/*-----------------------------------------------------------*/
+
+void vApplicationTickHook( void )
+{
+ /* This function will be called by each tick interrupt if
+ configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
+ added here, but the tick hook is called from an interrupt context, so
+ code must not attempt to block, and only the interrupt safe FreeRTOS API
+ functions can be used (those that end in FromISR()). */
+}