From f7cd9b461ca33845339f4a11f49bdc142696827a Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Tue, 28 Jun 2016 09:51:29 +0200 Subject: Apalis_TK1_K20: SPI Communication, ADC, TSC, GPIO Support for Communication between TK1 SoC and K20 MCU This patch includes ADC, TSC and GPIO functionality. Signed-off-by: Dominik Sliwa --- source/main.c | 83 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 21 deletions(-) (limited to 'source/main.c') 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 */ + } } -- cgit v1.2.3