From b4cf828c2e5c7a565f888fdf40afc916cac1ed10 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 9 Feb 2017 14:27:09 -0800 Subject: initial commit of Low Power Demo Signed-off-by: Stefan Agner --- .../low_power_demo/armgcc/CMakeLists.txt | 137 +++++++++++++++++++++ .../low_power_demo/armgcc/build_all.bat | 5 + .../low_power_demo/armgcc/build_all.sh | 5 + .../low_power_demo/armgcc/build_debug.bat | 3 + .../low_power_demo/armgcc/build_debug.sh | 3 + .../low_power_demo/armgcc/build_release.bat | 3 + .../low_power_demo/armgcc/build_release.sh | 3 + .../low_power_demo/armgcc/clean.bat | 3 + .../imx7_colibri_m4/low_power_demo/armgcc/clean.sh | 3 + .../imx7_colibri_m4/low_power_demo/gpio_pins.c | 44 +++++++ .../imx7_colibri_m4/low_power_demo/gpio_pins.h | 58 +++++++++ .../imx7_colibri_m4/low_power_demo/hardware_init.c | 53 ++++++++ examples/imx7_colibri_m4/low_power_demo/main.c | 84 +++++++++++++ 13 files changed, 404 insertions(+) create mode 100644 examples/imx7_colibri_m4/low_power_demo/armgcc/CMakeLists.txt create mode 100644 examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.bat create mode 100755 examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.sh create mode 100644 examples/imx7_colibri_m4/low_power_demo/armgcc/build_debug.bat create mode 100755 examples/imx7_colibri_m4/low_power_demo/armgcc/build_debug.sh create mode 100644 examples/imx7_colibri_m4/low_power_demo/armgcc/build_release.bat create mode 100755 examples/imx7_colibri_m4/low_power_demo/armgcc/build_release.sh create mode 100644 examples/imx7_colibri_m4/low_power_demo/armgcc/clean.bat create mode 100755 examples/imx7_colibri_m4/low_power_demo/armgcc/clean.sh create mode 100644 examples/imx7_colibri_m4/low_power_demo/gpio_pins.c create mode 100644 examples/imx7_colibri_m4/low_power_demo/gpio_pins.h create mode 100644 examples/imx7_colibri_m4/low_power_demo/hardware_init.c create mode 100644 examples/imx7_colibri_m4/low_power_demo/main.c diff --git a/examples/imx7_colibri_m4/low_power_demo/armgcc/CMakeLists.txt b/examples/imx7_colibri_m4/low_power_demo/armgcc/CMakeLists.txt new file mode 100644 index 0000000..098ce0d --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/CMakeLists.txt @@ -0,0 +1,137 @@ +INCLUDE(CMakeForceCompiler) + +# 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) + + +# CURRENT DIRECTORY +SET(ProjDirPath ${CMAKE_CURRENT_SOURCE_DIR}) +SET(BspRootDirPath ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${BspRootDirPath}/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_tcm.ld -static") + +# RELEASE LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -T${BspRootDirPath}/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_tcm.ld -static") + +# DEBUG ASM FLAGS +SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99") + +# DEBUG C FLAGS +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0 -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") + +# DEBUG LD FLAGS +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs") + +# RELEASE ASM FLAGS +SET(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99") + +# RELEASE C FLAGS +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os -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") + +# RELEASE LD FLAGS +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs") + +# ASM MACRO +SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -D__DEBUG") + +# C MACRO +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__DEBUG") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCPU_MCIMX7D_M4") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__NDEBUG") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DCPU_MCIMX7D_M4") + +# CXX MACRO + +# INCLUDE_DIRECTORIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) + INCLUDE_DIRECTORIES(${ProjDirPath}/../..) + 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}/../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../..) + 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(${ProjDirPath}/../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(low_power_demo + "${BspRootDirPath}/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${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/inc/rdc.h" + "${BspRootDirPath}/platform/drivers/inc/rdc_defs_imx7d.h" + "${BspRootDirPath}/platform/drivers/inc/wdog_imx.h" + "${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" + "${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}/../main.c" + "${BspRootDirPath}/platform/drivers/src/gpio_imx.c" + "${BspRootDirPath}/platform/drivers/inc/gpio_imx.h" + "${BspRootDirPath}/platform/drivers/src/uart_imx.c" + "${BspRootDirPath}/platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(low_power_demo PROPERTIES OUTPUT_NAME "low_power_demo.elf") + +TARGET_LINK_LIBRARIES(low_power_demo -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(low_power_demo m) +TARGET_LINK_LIBRARIES(low_power_demo c) +TARGET_LINK_LIBRARIES(low_power_demo gcc) +TARGET_LINK_LIBRARIES(low_power_demo nosys) +TARGET_LINK_LIBRARIES(low_power_demo -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/low_power_demo.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/low_power_demo.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET low_power_demo POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/low_power_demo.elf ${EXECUTABLE_OUTPUT_PATH}/low_power_demo.hex) +ADD_CUSTOM_COMMAND(TARGET low_power_demo POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/low_power_demo.elf ${EXECUTABLE_OUTPUT_PATH}/low_power_demo.bin) diff --git a/examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.bat b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +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/low_power_demo/armgcc/build_all.sh b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.sh new file mode 100755 index 0000000..98ff335 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +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/low_power_demo/armgcc/build_debug.bat b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/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/low_power_demo/armgcc/build_debug.sh b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_colibri_m4/low_power_demo/armgcc/build_release.bat b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/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/low_power_demo/armgcc/build_release.sh b/examples/imx7_colibri_m4/low_power_demo/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/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/low_power_demo/armgcc/clean.bat b/examples/imx7_colibri_m4/low_power_demo/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_colibri_m4/low_power_demo/armgcc/clean.sh b/examples/imx7_colibri_m4/low_power_demo/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_colibri_m4/low_power_demo/gpio_pins.c b/examples/imx7_colibri_m4/low_power_demo/gpio_pins.c new file mode 100644 index 0000000..cc1748d --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/gpio_pins.c @@ -0,0 +1,44 @@ +/* + * 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 +#include "gpio_pins.h" + +void configure_gpio_pin(gpio_config_t *config) +{ + assert(config); + + *(config->muxReg) = config->muxConfig; + *(config->padReg) = config->padConfig; +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_colibri_m4/low_power_demo/gpio_pins.h b/examples/imx7_colibri_m4/low_power_demo/gpio_pins.h new file mode 100644 index 0000000..aea0d55 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/gpio_pins.h @@ -0,0 +1,58 @@ +/* + * 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_PINS_H__ +#define __GPIO_PINS_H__ + +#include "device_imx.h" + +/*! @brief i.MX GPIO initialize structure. */ +typedef struct _gpio_config +{ + const char *name; + __IO uint32_t *muxReg; + uint32_t muxConfig; + __IO uint32_t *padReg; + uint32_t padConfig; + GPIO_Type *base; + uint32_t pin; +} gpio_config_t; + +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus */ + +/*! @brief Configure specific GPIO pin */ +void configure_gpio_pin(gpio_config_t *config); + +#endif /* __GPIO_PINS_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_colibri_m4/low_power_demo/hardware_init.c b/examples/imx7_colibri_m4/low_power_demo/hardware_init.c new file mode 100644 index 0000000..0b11809 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/hardware_init.c @@ -0,0 +1,53 @@ +/* + * 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 without RDC SEMAPHORE */ + RDC_SetPdapAccess(RDC, rdcPdapGpio1, 0xFF, false, false); + RDC_SetPdapAccess(RDC, rdcPdapGpio4, 0xFF, false, false); + + /* Enable gpio clock gate */ + CCM_ControlGate(CCM, BOARD_GPIO_KEY_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_colibri_m4/low_power_demo/main.c b/examples/imx7_colibri_m4/low_power_demo/main.c new file mode 100644 index 0000000..71d0052 --- /dev/null +++ b/examples/imx7_colibri_m4/low_power_demo/main.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017, Toradex + * 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 +#include "board.h" +#include "gpio_pins.h" +#include "gpio_imx.h" +#include "debug_console_imx.h" + +#define GPIO_INTERRUPT (1) +#define GPIO_POLLING (0) +#define GPIO_DEBOUNCE_DELAY (100000) + +gpio_config_t gpioLcdA0 = { + .name = "LCD A0 [SSPRXD]", + .muxReg = &IOMUXC_SW_MUX_CTL_PAD_I2C1_SCL, /* GPIO4 IO08 */ + .muxConfig = 0, + .padReg = &IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL, + .padConfig = 0, + .base = GPIO4, + .pin = 8, +}; + +/*! + * @brief Initialize LCD display + */ +static void LCD_Init(void) +{ + configure_gpio_pin(&gpioLcdA0); + + gpio_init_config_t lcdA0InitConfig = { + .pin = gpioLcdA0.pin, + .direction = gpioDigitalOutput, + .interruptMode = gpioNoIntmode + }; + GPIO_Init(gpioLcdA0.base, &lcdA0InitConfig); + + +} + +/*! + * @brief Main entry point + */ +int main(void) +{ + /* hardware initialiize, include RDC, IOMUX and UART debug */ + hardware_init(); + PRINTF("\n\r=> Low Power Demo\n\r"); + + /* GPIO module initialize, configure "LED" as output and button as interrupt mode. */ + LCD_Init(); + + while(true); + + return 0; +} + -- cgit v1.2.3