summaryrefslogtreecommitdiff
path: root/source/main.c
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2016-06-28 09:51:29 +0200
committerDominik Sliwa <dominik.sliwa@toradex.com>2017-01-25 16:49:22 +0100
commitf7cd9b461ca33845339f4a11f49bdc142696827a (patch)
tree058f5e4f20307f26bf4d7d811047d4c90a25522e /source/main.c
parentfc8127294072ecff476706f073314738512ec1c9 (diff)
Apalis_TK1_K20: SPI Communication, ADC, TSC, GPIOapalis-tk1-k20-freertos-v8
Support for Communication between TK1 SoC and K20 MCU This patch includes ADC, TSC and GPIO functionality. Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Diffstat (limited to 'source/main.c')
-rw-r--r--source/main.c83
1 files changed, 62 insertions, 21 deletions
diff --git a/source/main.c b/source/main.c
index 094da3a..e035d4e 100644
--- a/source/main.c
+++ b/source/main.c
@@ -37,7 +37,9 @@
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
-/*#include "fsl_debug_console.h"*/
+#include "fsl_debug_console.h"
+#include "com_task.h"
+#include "adc_task.h"
/* FreeRTOS kernel includes. */
#include "FreeRTOS.h"
@@ -46,38 +48,77 @@
#include "timers.h"
+#if ((defined USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI))
+#define CONTROLLER_ID kUSB_ControllerKhci0
+#endif
+#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI))
+#define CONTROLLER_ID kUSB_ControllerEhci0
+#endif
+
/* Task priorities. */
-#define hello_task_PRIORITY (configMAX_PRIORITIES - 1)
+#define debug_task_PRIORITY 1
+#define USB_HOST_INTERRUPT_PRIORITY (5U)
+
+/* Task handles */
+
+TaskHandle_t usb_task_handle;
+#ifdef SDK_DEBUGCONSOLE
+TaskHandle_t debug_task_handle;
+#endif
+
/*!
- * @brief Task responsible for printing of "Hello world." message.
+ * @brief Debug task
*/
-static void hello_task(void *pvParameters) {
- for (;;) {
- /*PRINTF("Hello world.\r\n");*/
- /* Add your code here */
- vTaskSuspend(NULL);
- }
+#ifdef SDK_DEBUGCONSOLE
+static void debug_task(void *pvParameters) {
+ for (;;) {
+ vTaskDelay(10000);
+ }
}
-
+#endif
/*!
* @brief Application entry point.
*/
int main(void) {
- /* Init board hardware. */
- BOARD_InitPins();
- BOARD_BootClockRUN();
- BOARD_InitDebugConsole();
- /* Add your code here */
+ /* Init board hardware. */
+ BOARD_InitPins();
+ BOARD_BootClockRUN();
+ BOARD_InitDebugConsole();
+ PRINTF("Apalis K20 Firmware Version %d.%d\r\n", FW_MAJOR, FW_MINOR);
+
+ /* Create RTOS task */
+ if(xTaskCreate(spi_task, "SPI_task", 2000L / sizeof(portSTACK_TYPE), NULL, 4, &spi_task_handle) != pdPASS)
+ {
+ PRINTF("create SPI task error\r\n");
+ }
+
+#ifdef BOARD_USES_ADC
+ if(xTaskCreate(adc_task, "ADC_task", 2000L / sizeof(portSTACK_TYPE), NULL, 2, &adc_task_handle) != pdPASS)
+ {
+ PRINTF("create ADC task error\r\n");
+ }
+
+ if(xTaskCreate(tsc_task, "TSC_task", 2000L / sizeof(portSTACK_TYPE), NULL, 2, &tsc_task_handle) != pdPASS)
+ {
+ PRINTF("create TSC task error\r\n");
+ }
+#endif
+
+#ifdef SDK_DEBUGCONSOLE
+ if(xTaskCreate(debug_task, "Debug_task", configMINIMAL_STACK_SIZE, NULL, debug_task_PRIORITY, &debug_task_handle) != pdPASS)
+ {
+ PRINTF("create hello task error\r\n");
+ }
+#endif
- /* Create RTOS task */
- xTaskCreate(hello_task, "Hello_task", configMINIMAL_STACK_SIZE, NULL, hello_task_PRIORITY, NULL);
- vTaskStartScheduler();
+ NVIC_SetPriorityGrouping( 0 );
+ vTaskStartScheduler();
- for(;;) { /* Infinite loop to avoid leaving the main function */
- __asm("NOP"); /* something to use as a breakpoint stop while looping */
- }
+ for(;;) { /* Infinite loop to avoid leaving the main function */
+ __asm("NOP"); /* something to use as a breakpoint stop while looping */
+ }
}