/* * FreeRTOS V202104.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * http://www.FreeRTOS.org * http://aws.amazon.com/freertos * * 1 tab == 4 spaces! */ /****************************************************************************** * This project provides two demo applications. A simple blinky style project, * and a more comprehensive test and demo application. The * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to * select between the two. The simply blinky demo is implemented and described * in main_blinky.c. The more comprehensive test and demo application is * implemented and described in main_full.c. * * This file implements the code that is not demo specific, including the * hardware setup, standard FreeRTOS hook functions, and the ISR hander called * by the RTOS after interrupt entry (including nesting) has been taken care of. * * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT! * */ #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #include "board.h" #include "chip.h" #ifdef ADC_TOUCH #include "touch.h" #endif #ifdef ADC_KEY #include "keypad.h" #endif #if defined(__ICCARM__) || defined(__ICCRX__) /* for IAR compiler */ #pragma data_alignment=16*1024 static uint32_t MMUTable[4*1024]; #else static uint32_t MMUTable[4*1024] __attribute__((aligned(16*1024))); #endif extern int main_awtk(void); extern int sound_init(void); extern int ark_usb_init(void); extern void mipi_init(void); extern void sema_init(void); extern void McuAccessModule(void); #ifdef WIFI_SUPPORT static void wifi_reset(void) { gpio_direction_output(WIFI_RESET_IO, 1); mdelay(10); gpio_direction_output(WIFI_RESET_IO, 0); mdelay(20); gpio_direction_output(WIFI_RESET_IO, 1); mdelay(10); } #endif static void prvBoardLateInitTask( void *pvParameters ) { if(!ark_lcd_get_boot_status()) ark_lcd_enable(1); #ifdef WIFI_SUPPORT wifi_reset(); #endif #ifdef SDMMC_SUPPORT mmcsd_core_init(); mmc_init(); #endif #ifdef ADC_TOUCH adc_channel_enable(ADC_CH_TP); /* tp enable */ vSysctlConfigure(SYS_ANA1_CFG, 26, 1, 1); if (LoadTouchConfigure()) { AdjustTouch(); } #endif #ifdef MAILBOX_SUPPORT mailbox_msg_init(); McuAccessModule(); #endif #ifdef ADC_KEY KeypadInit(); #endif #if defined(AUDIO_REPLAY) || defined(AUDIO_RECORD) sound_init(); #endif #ifdef USB_SUPPORT ark_usb_init(); #endif /* you'd better init the rtc driver at last */ #ifdef RTC_SUPPORT rtc_init(); SystemTime_t tm; iGetLocalTime(&tm); printf("Time: %d-%.2d-%.2d %.2d:%.2d:%.2d.\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); #endif for (;;) { vTaskDelay(portMAX_DELAY); } } static void prvSetupHardware( void ) { /* Initialize interrupt contorller */ GIC_Initialize(); sema_init(); /* Disable watchdog */ wdt_stop(); /* Setup pinctrl */ vPinctrlSetup(); /* Setup clock */ vClkInit(); /* Configure a timer for delay */ vInitialiseTimerForDelay(); /* Initialize Debug Uart */ vDebugConsoleInitialise(); /* Configure ports used by LEDs. */ //vParTestInitialise(); /* enable cache */ MMU_Initialize(MMUTable); CP15_EnableSMP(); CP15_EnableMMU(); CP15_EnableDcache(); CP15_EnableIcache(); printf("sys_pll=%d\n", ulClkGetRate(CLK_SYSPLL)); printf("cpu_pll=%d\n", ulClkGetRate(CLK_CPUPLL)); printf("vpu_pll=%d\n", ulClkGetRate(CLK_VPUPLL)); printf("ddr_pll=%d\n", ulClkGetRate(CLK_DDRPLL)); printf("mfc_pll=%d\n", ulClkGetRate(CLK_MFCPLL)); printf("ahb_pll=%d\n", ulClkGetRate(CLK_AHBPLL)); printf("gpu_pll=%d\n", ulClkGetRate(CLK_GPUPLL)); printf("apb_clk=%d\n", ulClkGetRate(CLK_APB)); printf("mmc_clk=%d\n", ulClkGetRate(CLK_SDMMC0)); dma_init(); spi_init(); i2c_init(); wdt_init(); vdec_init(); itu_init(); pxp_init(); VideoDisplayBufInit(); //adc_init(); qoi_dec_init(); #if LCD_INTERFACE_TYPE == LCD_INTERFACE_CPU Cpulcd_Init(); #elif LCD_INTERFACE_TYPE == LCD_INTERFACE_MIPI mipi_init(); #endif lcd_init(); #ifdef ADC_TOUCH TouchInit(); #endif #ifdef REMOTE_SUPPORT RemoteKeyInit(); #endif blend2d_init(); } int main( void ) { /* Configure the hardware ready to run the demo. */ prvSetupHardware(); /* lateinit the hardware which needs call task funcs */ xTaskCreate(prvBoardLateInitTask, "lateinit", configMINIMAL_STACK_SIZE * 10, NULL, configMAX_PRIORITIES - 1, NULL); #ifdef WRAP_SUPPORT extern void wrap_demo(void); wrap_demo(); #else main_awtk(); #endif /* Start the tasks and timer running. */ vTaskStartScheduler(); /* If all is well, the scheduler will now be running, and the following line will never be reached. If the following line does execute, then there was insufficient FreeRTOS heap memory available for the idle and/or timer tasks to be created. See the memory management section on the FreeRTOS web site for more details. */ for( ;; ); }