summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul Munoz <munoz0raul@gmail.com>2017-05-29 16:16:07 -0300
committerStefan Agner <stefan.agner@toradex.com>2017-05-29 13:27:56 -0700
commit3570f3e3ef3f1c13ead7cc904361ee3fbba83353 (patch)
treebb0e4fda90604d09e87fd3e368b5faf30c93bc7c
parent732fc749ed8de98d5f47aae3c4c803bafc527c28 (diff)
examples: gpio_freertos: example with gpio, FreeRTOS and rpmsg
This example control two leds and two buttons and also communicates between M4 and A7 using rpmsg. Signed-off-by: Raul Munoz <raul.munoz@toradex.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/FreeRTOSConfig.h163
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/CMakeLists.txt190
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.bat7
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.sh7
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.bat9
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.sh7
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.bat3
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.sh3
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.bat3
-rwxr-xr-xexamples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.sh3
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.c217
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.h76
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/hardware_init.c60
-rw-r--r--examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/main.c263
14 files changed, 1011 insertions, 0 deletions
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/FreeRTOSConfig.h b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/FreeRTOSConfig.h
new file mode 100644
index 0000000..c57902e
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/FreeRTOSConfig.h
@@ -0,0 +1,163 @@
+/*
+ FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
+ All rights reserved
+
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
+
+ ***************************************************************************
+ * *
+ * FreeRTOS provides completely free yet professionally developed, *
+ * robust, strictly quality controlled, supported, and cross *
+ * platform software that has become a de facto standard. *
+ * *
+ * Help yourself get started quickly and support the FreeRTOS *
+ * project by purchasing a FreeRTOS tutorial book, reference *
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *
+ * *
+ * Thank you! *
+ * *
+ ***************************************************************************
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
+
+ >>! NOTE: The modification to the GPL is included to allow you to distribute
+ >>! a combined work that includes FreeRTOS without being obliged to provide
+ >>! the source code for proprietary components outside of the FreeRTOS
+ >>! kernel.
+
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following
+ link: http://www.freertos.org/a00114.html
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong?" *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,
+ license and Real Time Engineers Ltd. contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.
+
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
+ licenses offer ticketed support, indemnification and middleware.
+
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety
+ engineered and independently SIL3 certified version for use in safety and
+ mission critical applications that require provable dependability.
+
+ 1 tab == 4 spaces!
+*/
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+/* Ensure stdint is only used by the compiler, and not the assembler. */
+#ifdef __ICCARM__
+ #include <stdint.h>
+#endif
+
+#define configUSE_PREEMPTION 1
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configCPU_CLOCK_HZ (240000000ul)
+#define configTICK_RATE_HZ ((TickType_t)1000)
+#define configMAX_PRIORITIES (5)
+#define configMINIMAL_STACK_SIZE ((unsigned short)130)
+#define configTOTAL_HEAP_SIZE ((size_t)(20 * 1024))
+#define configMAX_TASK_NAME_LEN (10)
+#define configUSE_TRACE_FACILITY 0
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 0
+#define configUSE_MUTEXES 0
+#define configQUEUE_REGISTRY_SIZE 8
+#define configCHECK_FOR_STACK_OVERFLOW 0
+#define configUSE_RECURSIVE_MUTEXES 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configGENERATE_RUN_TIME_STATS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES (2)
+
+/* Software timer definitions. */
+#define configUSE_TIMERS 0
+#define configTIMER_TASK_PRIORITY (2)
+#define configTIMER_QUEUE_LENGTH 10
+#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)
+
+/* Set the following definitions to 1 to include the API function, or zero
+to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 0
+#define INCLUDE_vTaskDelay 1
+
+/* Cortex-M specific definitions. */
+#ifdef __NVIC_PRIO_BITS
+ /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
+ #define configPRIO_BITS __NVIC_PRIO_BITS
+#else
+ #define configPRIO_BITS 4 /* 15 priority levels */
+#endif
+
+/* The lowest interrupt priority that can be used in a call to a "set priority"
+function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0xf
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 1
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
+
+/* Normal assert() semantics without relying on the provision of an assert.h
+header file. */
+#define configASSERT(x) if((x) == 0) {taskDISABLE_INTERRUPTS(); for(;;);}
+
+/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
+standard names. */
+#define vPortSVCHandler SVC_Handler
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+
+#endif /* FREERTOS_CONFIG_H */
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/CMakeLists.txt b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/CMakeLists.txt
new file mode 100644
index 0000000..fb0303b
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/CMakeLists.txt
@@ -0,0 +1,190 @@
+INCLUDE(CMakeForceCompiler)
+
+SET(ProjectName gpio_freertos)
+PROJECT(${ProjectName})
+
+# CROSS COMPILER SETTING
+SET(CMAKE_SYSTEM_NAME Generic)
+CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
+
+# THE VERSION NUMBER
+SET (Tutorial_VERSION_MAJOR 1)
+SET (Tutorial_VERSION_MINOR 0)
+
+# ENABLE ASM
+ENABLE_LANGUAGE(ASM)
+
+SET(CMAKE_STATIC_LIBRARY_PREFIX)
+SET(CMAKE_STATIC_LIBRARY_SUFFIX)
+
+SET(CMAKE_EXECUTABLE_LIBRARY_PREFIX)
+SET(CMAKE_EXECUTABLE_LIBRARY_SUFFIX)
+
+SET(CMAKE_SKIP_INSTALL_RULES TRUE)
+
+# CURRENT DIRECTORY
+SET(ProjDirPath ${CMAKE_CURRENT_SOURCE_DIR})
+SET(BspRootDirPath ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../..)
+
+# RELEASE/DEBUG LINK FILE
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T MCIMX7D_M4_ocram.ld -static -L ${BspRootDirPath}/platform/devices/MCIMX7D/linker/gcc/")
+
+# DEFAULT ASM FLAGS
+SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+
+# DEFAULT C FLAGS
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99")
+
+# DEFAULT LD FLAGS
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -z max-page-size=4096 -Xlinker muldefs")
+
+# DEBUG ASM FLAGS
+SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g")
+
+# DEBUG C FLAGS
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
+
+# DEBUG LD FLAGS
+SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g")
+
+# RELEASE C FLAGS
+SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os")
+
+# ASM MACRO
+SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -D__DEBUG")
+
+# C MACRO
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCPU_MCIMX7D_M4")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__DEBUG")
+SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__NDEBUG")
+
+# INCLUDE_DIRECTORIES
+INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..)
+INCLUDE_DIRECTORIES(${ProjDirPath}/..)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/CMSIS/Include)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/include)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/devices/MCIMX7D/startup)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/drivers/inc)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/platform/utilities/inc)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/rtos/FreeRTOS/Source/include)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/middleware/multicore/open-amp)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/middleware/multicore/open-amp/porting/imx7d_m4)
+INCLUDE_DIRECTORIES(${BspRootDirPath}/middleware/multicore/open-amp/porting/env/freertos)
+
+
+# ADD_EXECUTABLE
+ADD_EXECUTABLE(${ProjectName}
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h"
+ "${BspRootDirPath}/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/portable/MemMang/heap_2.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/imx7d_m4/platform.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg_ext.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/common/hil/hil.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/common/llist/llist.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/common/shm/sh_mem.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/config/config.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/env/env.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg_core.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/virtio/virtio.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/virtio/virtio_ring.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/virtio/virtqueue.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/croutine.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/event_groups.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/FreeRTOS.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/list.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/mpu_wrappers.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/portable.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/projdefs.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/queue.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/semphr.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/StackMacros.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/task.h"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/include/timers.h"
+ "${BspRootDirPath}/platform/utilities/src/debug_console_imx.c"
+ "${BspRootDirPath}/platform/utilities/inc/debug_console_imx.h"
+ "${BspRootDirPath}/platform/utilities/src/print_scan.c"
+ "${BspRootDirPath}/platform/utilities/src/print_scan.h"
+ "${BspRootDirPath}/platform/drivers/inc/ccm_analog_imx7d.h"
+ "${BspRootDirPath}/platform/drivers/inc/ccm_imx7d.h"
+ "${BspRootDirPath}/platform/drivers/inc/lmem.h"
+ "${BspRootDirPath}/platform/drivers/src/rdc_semaphore.c"
+ "${BspRootDirPath}/platform/drivers/inc/rdc_semaphore.h"
+ "${BspRootDirPath}/platform/drivers/inc/rdc.h"
+ "${BspRootDirPath}/platform/drivers/inc/rdc_defs_imx7d.h"
+ "${BspRootDirPath}/platform/drivers/inc/wdog_imx.h"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/imx7d_m4/platform.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/common/hil/hil.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/common/llist/llist.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/common/shm/sh_mem.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/config/config.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/remote_device.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg_ext.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/rpmsg/rpmsg_core.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/virtio/virtio.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/virtio/virtqueue.c"
+ "${BspRootDirPath}/middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/croutine.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/event_groups.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/list.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/queue.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/tasks.c"
+ "${BspRootDirPath}/rtos/FreeRTOS/Source/timers.c"
+ "${BspRootDirPath}/platform/drivers/src/ccm_analog_imx7d.c"
+ "${BspRootDirPath}/platform/drivers/src/ccm_imx7d.c"
+ "${BspRootDirPath}/platform/drivers/src/lmem.c"
+ "${BspRootDirPath}/platform/drivers/src/rdc.c"
+ "${BspRootDirPath}/platform/drivers/src/wdog_imx.c"
+ "${BspRootDirPath}/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c"
+ "${BspRootDirPath}/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.h"
+ "${BspRootDirPath}/platform/drivers/src/gpio_imx.c"
+ "${BspRootDirPath}/platform/drivers/inc/gpio_imx.h"
+ "${BspRootDirPath}/platform/drivers/src/mu_imx.c"
+ "${BspRootDirPath}/platform/drivers/inc/mu_imx.h"
+ "${ProjDirPath}/../../../../pin_mux.c"
+ "${ProjDirPath}/../../../../pin_mux.h"
+ "${ProjDirPath}/../../../../board.c"
+ "${ProjDirPath}/../../../../board.h"
+ "${ProjDirPath}/../../../../clock_freq.c"
+ "${ProjDirPath}/../../../../clock_freq.h"
+ "${ProjDirPath}/../hardware_init.c"
+ "${ProjDirPath}/../../../../gpio_pins.c"
+ "${ProjDirPath}/../../../../gpio_pins.h"
+ "${ProjDirPath}/../gpio_ctrl.c"
+ "${ProjDirPath}/../gpio_ctrl.h"
+ "${ProjDirPath}/../FreeRTOSConfig.h"
+ "${ProjDirPath}/../main.c"
+ "${BspRootDirPath}/platform/drivers/src/uart_imx.c"
+ "${BspRootDirPath}/platform/drivers/inc/uart_imx.h"
+)
+SET_TARGET_PROPERTIES(${ProjectName} PROPERTIES OUTPUT_NAME "${ProjectName}.elf")
+
+TARGET_LINK_LIBRARIES(${ProjectName} -Wl,--start-group)
+# LIBRARIES
+IF(CMAKE_BUILD_TYPE MATCHES Debug)
+ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
+ENDIF()
+
+# SYSTEM LIBRARIES
+TARGET_LINK_LIBRARIES(${ProjectName} m)
+TARGET_LINK_LIBRARIES(${ProjectName} c)
+TARGET_LINK_LIBRARIES(${ProjectName} gcc)
+TARGET_LINK_LIBRARIES(${ProjectName} nosys)
+TARGET_LINK_LIBRARIES(${ProjectName} -Wl,--end-group)
+
+# MAP FILE
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -Map=${ProjectName}.map")
+
+# BIN AND HEX
+ADD_CUSTOM_COMMAND(TARGET ${ProjectName} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/${ProjectName}.elf ${EXECUTABLE_OUTPUT_PATH}/${ProjectName}.hex)
+# bin does not support sparse memory area, which our default linker file uses...
+#ADD_CUSTOM_COMMAND(TARGET ${ProjectName} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/${ProjectName}.elf ${EXECUTABLE_OUTPUT_PATH}/${ProjectName}.bin)
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.bat b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.bat
new file mode 100644
index 0000000..426a29f
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.bat
@@ -0,0 +1,7 @@
+cd release
+call build_release.bat
+cd ..
+cd debug
+call build_debug.bat
+cd ..
+pause
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.sh b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.sh
new file mode 100755
index 0000000..99e6267
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/build_all.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+cd debug/
+./build_debug.sh
+cd ..
+cd release/
+./build_release.sh
+cd ..
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.bat b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.bat
new file mode 100644
index 0000000..fc53949
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.bat
@@ -0,0 +1,9 @@
+cd debug
+rd /s /Q CMakeFiles/
+del /s /Q /F Makefile cmake_install.cmake CMakeCache.txt *.elf *.bin *.map *.hex
+cd ..
+cd release
+rd /s /Q CMakeFiles/
+del /s /Q /F Makefile cmake_install.cmake CMakeCache.txt *.elf *.bin *.map *.hex
+cd ..
+pause
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.sh b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.sh
new file mode 100755
index 0000000..4b188ab
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/clean.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+cd debug
+rm -rf Makefile cmake_install.cmake CMakeCache.txt CMakeFiles *.elf *.bin *.map *.hex .cproject .project
+cd ..
+cd release
+rm -rf Makefile cmake_install.cmake CMakeCache.txt CMakeFiles *.elf *.bin *.map *.hex
+cd ..
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.bat b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.bat
new file mode 100644
index 0000000..ea7473c
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.bat
@@ -0,0 +1,3 @@
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
+mingw32-make -j4
+pause
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.sh b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.sh
new file mode 100755
index 0000000..a839f78
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/debug/build_debug.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
+make -j4
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.bat b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.bat
new file mode 100644
index 0000000..1e066fb
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.bat
@@ -0,0 +1,3 @@
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..
+mingw32-make -j4
+pause
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.sh b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.sh
new file mode 100755
index 0000000..576604f
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/armgcc/release/build_release.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
+make -j4
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.c b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.c
new file mode 100644
index 0000000..b5972f7
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.c
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2015, Freescale Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * o Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * o Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/****************************************************************************
+*
+* Comments:
+* This file contains the functions which write and read the SPI memories
+* using the ECSPI driver in interrupt mode.
+*
+****************************************************************************/
+
+#include <stdbool.h>
+#include "gpio_pins.h"
+#include "board.h"
+#include "gpio_ctrl.h"
+#include "gpio_imx.h"
+#include "rdc_semaphore.h"
+#include "debug_console_imx.h"
+
+#define GPIO_DEBOUNCE_DELAY (100000)
+
+
+void GPIO_Ctrl_InitSwitch1Pin()
+{
+#ifdef BOARD_GPIO_SWITCH1_CONFIG
+ /* Acquire RDC semaphore before access GPIO to avoid conflict, it's
+ * necessary when GPIO RDC is configured as Semaphore Required */
+ RDC_SEMAPHORE_Lock(BOARD_GPIO_SWITCH1_RDC_PDAP);
+ GPIO_Init(BOARD_GPIO_SWITCH1_CONFIG->base, &Switch1);
+ RDC_SEMAPHORE_Unlock(BOARD_GPIO_SWITCH1_RDC_PDAP);
+#endif
+}
+
+void GPIO_Ctrl_InitLed1Pin()
+{
+#ifdef BOARD_GPIO_LED1_CONFIG
+ /* Acquire RDC semaphore before access GPIO to avoid conflict, it's
+ * necessary when GPIO RDC is configured as Semaphore Required */
+ RDC_SEMAPHORE_Lock(BOARD_GPIO_LED1_RDC_PDAP);
+ GPIO_Init(BOARD_GPIO_LED1_CONFIG->base, &Led1);
+ RDC_SEMAPHORE_Unlock(BOARD_GPIO_LED1_RDC_PDAP);
+#endif
+}
+
+void GPIO_Ctrl_InitSwitch2Pin()
+{
+#ifdef BOARD_GPIO_SWITCH2_CONFIG
+ /* Acquire RDC semaphore before access GPIO to avoid conflict, it's
+ * necessary when GPIO RDC is configured as Semaphore Required */
+ RDC_SEMAPHORE_Lock(BOARD_GPIO_SWITCH2_RDC_PDAP);
+ GPIO_Init(BOARD_GPIO_SWITCH2_CONFIG->base, &Switch2);
+ RDC_SEMAPHORE_Unlock(BOARD_GPIO_SWITCH2_RDC_PDAP);
+#endif
+}
+
+void GPIO_Ctrl_InitLed2Pin()
+{
+#ifdef BOARD_GPIO_LED2_CONFIG
+ /* Acquire RDC semaphore before access GPIO to avoid conflict, it's
+ * necessary when GPIO RDC is configured as Semaphore Required */
+ RDC_SEMAPHORE_Lock(BOARD_GPIO_LED2_RDC_PDAP);
+ GPIO_Init(BOARD_GPIO_LED2_CONFIG->base, &Led2);
+ RDC_SEMAPHORE_Unlock(BOARD_GPIO_LED2_RDC_PDAP);
+#endif
+}
+
+
+
+
+void GPIO_Ctrl_Init()
+{
+ GPIO_Ctrl_InitSwitch1Pin();
+ GPIO_Ctrl_InitLed1Pin();
+ GPIO_Ctrl_InitSwitch2Pin();
+ GPIO_Ctrl_InitLed2Pin();
+}
+
+void GPIO_Ctrl_ToggleLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc)
+{
+ static bool onLed0 = 0;
+ onLed0 = GPIO_ReadPinOutput(boardGpioConfig->base, boardGpioConfig->pin);
+ if(onLed0 == 0)
+ {
+ RDC_SEMAPHORE_Lock(boardGpioRdc);
+ GPIO_WritePinOutput(boardGpioConfig->base,
+ boardGpioConfig->pin, gpioPinSet);
+ RDC_SEMAPHORE_Unlock(boardGpioRdc);
+ }
+ else
+ {
+ RDC_SEMAPHORE_Lock(boardGpioRdc);
+ GPIO_WritePinOutput(boardGpioConfig->base,
+ boardGpioConfig->pin, gpioPinClear);
+ RDC_SEMAPHORE_Unlock(boardGpioRdc);
+ }
+}
+
+void GPIO_Ctrl_ClearLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc)
+{
+ RDC_SEMAPHORE_Lock(boardGpioRdc);
+ GPIO_WritePinOutput(boardGpioConfig->base,
+ boardGpioConfig->pin, gpioPinClear);
+ RDC_SEMAPHORE_Unlock(boardGpioRdc);
+}
+
+void GPIO_Ctrl_SetLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc)
+{
+
+ RDC_SEMAPHORE_Lock(boardGpioRdc);
+ GPIO_WritePinOutput(boardGpioConfig->base,
+ boardGpioConfig->pin, gpioPinSet);
+ RDC_SEMAPHORE_Unlock(boardGpioRdc);
+}
+
+void GPIO_Ctrl_WriteLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc, uint32_t value)
+{
+ RDC_SEMAPHORE_Lock(boardGpioRdc);
+ GPIO_WritePinOutput(boardGpioConfig->base,
+ boardGpioConfig->pin, value);
+ RDC_SEMAPHORE_Unlock(boardGpioRdc);
+}
+
+
+uint32_t GPIO_Ctrl_GetKey(gpio_config_t *boardGpioConfig)
+{
+ return GPIO_ReadPinInput(boardGpioConfig->base, boardGpioConfig->pin);
+}
+
+void GPIO_WaitKeyPressed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc)
+{
+ uint32_t i, j, debounce;
+ /* Wait for Key Released. */
+ do
+ {
+ debounce = 0;
+ while (0 == GPIO_ReadPinInput(boardGpioConfig->base, boardGpioConfig->pin));
+
+ for (i = 0; i < 3; i++)
+ {
+ /* Delay to wait key value stable. The cycle number should be changed
+ * according to M4 Core clock frequncy.
+ */
+ for (j = 0 ; j < GPIO_DEBOUNCE_DELAY; j++)
+ {
+ __NOP();
+ }
+
+ if (1 == GPIO_ReadPinInput(boardGpioConfig->base, boardGpioConfig->pin))
+ {
+ debounce++;
+ }
+ }
+
+ if (debounce > 2)
+ {
+ break;
+ }
+ }
+ while (1);
+}
+#ifdef BOARD_GPIO_KEY_CONFIG
+void BOARD_GPIO_KEY_HANDLER()
+{
+
+
+ /* When user input captured, we disable GPIO interrupt */
+ NVIC_DisableIRQ(BOARD_GPIO_KEY_IRQ_NUM);
+
+ RDC_SEMAPHORE_Lock(BOARD_GPIO_KEY_RDC_PDAP);
+
+ /* Disable GPIO pin interrupt */
+ GPIO_SetPinIntMode(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin, false);
+ /* Clear the interrupt state */
+ GPIO_ClearStatusFlag(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin);
+
+ RDC_SEMAPHORE_Unlock(BOARD_GPIO_KEY_RDC_PDAP);
+
+#ifdef xSemaphoreGiveFromISR
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+ /* Unlock the task to process the event. */
+ xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken);
+
+ /* Perform a context switch to wake the higher priority task. */
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+#endif
+}
+#endif
+
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.h b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.h
new file mode 100644
index 0000000..4b20ce1
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/gpio_ctrl.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015, Freescale Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * o Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * o Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __GPIO_CTRL_H__
+#define __GPIO_CTRL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ * @brief Initialize GPIO controller.
+ */
+void GPIO_Ctrl_Init(void);
+
+/*!
+ * @brief Toggle LED on/off status
+ */
+void GPIO_Ctrl_ToggleLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc);
+/*!
+ * @brief Clear LED on/off status
+ */
+void GPIO_Ctrl_ClearLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc);
+/*!
+ * @brief Set LED on/off status
+ */
+void GPIO_Ctrl_SetLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc);
+/*!
+ * @brief write LED on/off status
+ */
+void GPIO_Ctrl_WriteLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc, uint32_t value);
+/*!
+ * @brief Get Key on/off status
+ */
+uint32_t GPIO_Ctrl_GetKey(gpio_config_t *boardGpioConfig);
+
+/*!
+ * @brief Get Key on/off status
+ */
+void GPIO_WaitKeyPressed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GPIO_CTRL_H__ */
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/hardware_init.c b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/hardware_init.c
new file mode 100644
index 0000000..a2a4a47
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/hardware_init.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, Freescale Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * o Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * o Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gpio_pins.h"
+#include "board.h"
+
+void hardware_init(void)
+{
+ /* Board specific RDC settings */
+ BOARD_RdcInit();
+ /* Board specific clock settings */
+ BOARD_ClockInit();
+ /* initialize debug uart */
+ dbg_uart_init();
+
+ /* In this demo, we need to share board GPIO, we can set sreq argument to true
+ * when the peer core could also access GPIO with RDC_SEMAPHORE, or the peer
+ * core doesn't access the GPIO at all */
+ RDC_SetPdapAccess(RDC, rdcPdapGpio2, 0xFF, false/*true*/, false);
+
+ /* Enable gpio clock gate */
+ // CCM_ControlGate(CCM, BOARD_GPIO_KEY_CCM_CCGR, ccmClockNeededRunWait);
+
+ /* RDC MU*/
+ RDC_SetPdapAccess(RDC, BOARD_MU_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false);
+
+ /* Enable clock gate for MU*/
+ CCM_ControlGate(CCM, BOARD_MU_CCM_CCGR, ccmClockNeededRun);
+}
+
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/
diff --git a/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/main.c b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/main.c
new file mode 100644
index 0000000..ee5db19
--- /dev/null
+++ b/examples/imx7_colibri_m4/demo_apps/rpmsg/gpio_freertos/main.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2015, Freescale Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * o Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * o Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include "board.h"
+#include "gpio_pins.h"
+#include "gpio_imx.h"
+#include "gpio_ctrl.h"
+#include "debug_console_imx.h"
+#include "rpmsg/rpmsg_rtos.h"
+#include "FreeRTOS.h"
+#include "task.h"
+#include "gpt.h"
+#include "semphr.h"
+#include "string.h"
+#include "mu_imx.h"
+#include "rdc_semaphore.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Definitions
+////////////////////////////////////////////////////////////////////////////////
+#define APP_TASK_STACK_SIZE 256
+
+/*
+ * APP decided interrupt priority
+ */
+#define APP_MU_IRQ_PRIORITY 3
+
+
+/******************************************************************************
+ *
+ * Function Name: ToggleTask
+ * Comments: this task is used to turn toggle on/off LED.
+ *
+ ******************************************************************************/
+static void StrEchoTask(void *pvParameters)
+{
+ bool key1PressCount = 0;
+ bool key1PressCountOld = 0;
+ bool key2PressCount = 0;
+ bool key2PressCountOld = 0;
+ bool sendNewData = 0;
+
+ int result;
+ struct remote_device *rdev = NULL;
+ struct rpmsg_channel *app_chnl = NULL;
+ char str_buffer[256] ;
+ int len;
+ void *rx_buf;
+ void *tx_buf;
+ unsigned long size;
+ unsigned long src;
+
+ /* Print the initial banner */
+ PRINTF("\r\nRPMSG String Echo FreeRTOS RTOS API Demo...\r\n");
+
+ /* RPMSG Init as REMOTE */
+ PRINTF("RPMSG Init as Remote\r\n");
+ result = rpmsg_rtos_init(0 /*REMOTE_CPU_ID*/, &rdev, RPMSG_MASTER, &app_chnl);
+ assert(result == 0);
+ PRINTF("Name service handshake is done, M4 has setup a rpmsg channel [%d ---> %d]\r\n", app_chnl->src, app_chnl->dst);
+
+ /* Initialize enviroments and led status */
+ key1PressCount = GPIO_Ctrl_GetKey(BOARD_GPIO_SWITCH1_CONFIG);
+ key1PressCountOld = key1PressCount;
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED1_CONFIG, BOARD_GPIO_LED1_RDC_PDAP, key1PressCount);
+
+ key2PressCount = GPIO_Ctrl_GetKey(BOARD_GPIO_SWITCH2_CONFIG);
+ key2PressCountOld = key2PressCount;
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED2_CONFIG, BOARD_GPIO_LED2_RDC_PDAP, key2PressCount);
+
+ sendNewData = 1;
+ PRINTF("================== RPMSG DONE===================\n\r");
+
+ while(true)
+ {
+ /* wait for user change button leve */
+ key1PressCount = GPIO_Ctrl_GetKey(BOARD_GPIO_SWITCH1_CONFIG);
+ key2PressCount = GPIO_Ctrl_GetKey(BOARD_GPIO_SWITCH2_CONFIG);
+
+ /* Get RPMsg rx buffer with message */
+ result = rpmsg_rtos_recv_nocopy(app_chnl->rp_ept, &rx_buf, &len, &src, 0);
+
+ /* Copy string from RPMsg rx buffer */
+ assert(len < sizeof(str_buffer));
+ memcpy(str_buffer, rx_buf, len);
+ str_buffer[len] = 0; /* End string by '\0' */
+
+
+ /*Parse MSG*/
+ char * pch1;
+ char * pch2;
+ pch1 = strstr (str_buffer, "Led");
+ if(pch1)
+ {
+ pch1 = pch1 + 3;
+ pch2 = pch1 + 2;
+ /*What LED 1 or 2*/
+ if(*pch1 == '1')
+ {
+ /* What Value 1 or 0*/
+ if(*pch2 == '1')
+ {
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED1_CONFIG, BOARD_GPIO_LED1_RDC_PDAP, 1);
+ }
+ else
+ {
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED1_CONFIG, BOARD_GPIO_LED1_RDC_PDAP, 0);
+ }
+ }
+ if(*pch1 == '2')
+ {
+ /* What Value 1 or 0*/
+ if(*pch2 == '1')
+ {
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED2_CONFIG, BOARD_GPIO_LED2_RDC_PDAP, 1);
+ }
+ else
+ {
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED2_CONFIG, BOARD_GPIO_LED2_RDC_PDAP, 0);
+ }
+ }
+ }
+
+ /* free rx buffer */
+ result = rpmsg_rtos_recv_nocopy_free(app_chnl->rp_ept, rx_buf);
+
+ /* If button change, than print and update LED */
+ if(key1PressCount != key1PressCountOld)
+ {
+ key1PressCountOld = key1PressCount;
+ /* update led status */
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED1_CONFIG, BOARD_GPIO_LED1_RDC_PDAP, key1PressCount);
+ sendNewData = 1;
+ }
+ /* If button change, than print and update LED */
+ if(key2PressCount != key2PressCountOld)
+ {
+ /* update led status */
+ key2PressCountOld = key2PressCount;
+ GPIO_Ctrl_WriteLed(BOARD_GPIO_LED2_CONFIG, BOARD_GPIO_LED2_RDC_PDAP, key2PressCount);
+ sendNewData = 1;
+ }
+
+ /* Switch changed*/
+ if(sendNewData == 1)
+ {
+ sendNewData = 0;
+ memset(str_buffer, 0, sizeof(str_buffer));
+
+ PRINTF("================== key1PressCount = %d ==================\n\r", key1PressCount);
+ PRINTF("================== key2PressCount = %d ==================\n\r", key2PressCount);
+
+ /* Create message */
+ len = snprintf(str_buffer, sizeof(str_buffer),"KEY1=%d; KEY2=%d\n",
+ key1PressCount, key2PressCount);
+
+ /* Release tx buffer */
+ tx_buf = rpmsg_rtos_alloc_tx_buffer(app_chnl->rp_ept, &size);
+ if(tx_buf == NULL)
+ {
+ PRINTF("\r\n ERROR = rpmsg_rtos_alloc_tx_buffer\r\n");
+ continue;
+ }
+
+ /* Copy string to RPMsg tx buffer */
+ memcpy(tx_buf, str_buffer, len);
+
+ /* Send message... */
+ result = rpmsg_rtos_send_nocopy(app_chnl->rp_ept, tx_buf, len, app_chnl->dst);
+ if(result != 0)
+ {
+ PRINTF("\r\n ERROR = rpmsg_rtos_send_nocopy\r\n");
+ }
+ assert(result == 0);
+ }
+ }
+
+}
+/*
+ * MU Interrrupt ISR
+ */
+void BOARD_MU_HANDLER(void)
+{
+ /*
+ * calls into rpmsg_handler provided by middleware
+ */
+ rpmsg_handler();
+}
+
+
+/******************************************************************************
+ *
+ * Function Name: main
+ * Comments: Hello World Example with GPIO.
+ * This example include:
+ * Configure BUTTON1 as GPIO functionality
+ * and check the button's state(pressed or released). According to the Button
+ * status, copy it to the LED
+ *
+ ******************************************************************************/
+int main(void)
+{
+ /* hardware initialiize, include RDC, IOMUX, Uart debug initialize */
+ hardware_init();
+ PRINTF("\n\r\n\r\n\r");
+ PRINTF("=======================================================\n\r");
+ PRINTF("============ GPIO FreeRtos and MCC Example ============\n\r");
+ PRINTF("========== Play with Led and Button and MCC ===========\n\r");
+ PRINTF("=======================================================\n\r");
+
+
+ /* GPIO module initialize, configure "LED" as output and button as interrupt mode. */
+ GPIO_Ctrl_Init();
+
+ /*
+ * Prepare for the MU Interrupt
+ * MU must be initialized before rpmsg init is called
+ */
+ MU_Init(BOARD_MU_BASE_ADDR);
+ NVIC_SetPriority(BOARD_MU_IRQ_NUM, APP_MU_IRQ_PRIORITY);
+ NVIC_EnableIRQ(BOARD_MU_IRQ_NUM);
+
+ /* Create a demo task. */
+ xTaskCreate(StrEchoTask, "String Echo Task", APP_TASK_STACK_SIZE,
+ NULL, tskIDLE_PRIORITY+1, NULL);
+
+ /* Start FreeRTOS scheduler. */
+ vTaskStartScheduler();
+
+ /* Should never reach this point. */
+ while (true);
+}
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/