diff --git a/examples/var-som-mx7_m4/board.c b/examples/var-som-mx7_m4/board.c new file mode 100644 index 000000000..26a8ecbd0 --- /dev/null +++ b/examples/var-som-mx7_m4/board.c @@ -0,0 +1,104 @@ +/* + * 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 "board.h" +#include "debug_console_imx.h" +#include "ccm_imx7d.h" +#include "rdc.h" +#include "wdog_imx.h" +#include "pin_mux.h" + +/* Initialize clock. */ +void BOARD_ClockInit(void) +{ + /* OSC/PLL is already initialized by Cortex-A7 (u-boot) */ + + /* + * Disable WDOG3 + * Note : The WDOG clock Root is shared by all the 4 WDOGs, so FreeROTS + * code should avoid closing it + */ + CCM_UpdateRoot(CCM, ccmRootWdog, ccmRootmuxWdogOsc24m, 0, 0); + CCM_EnableRoot(CCM, ccmRootWdog); + CCM_ControlGate(CCM, ccmCcgrGateWdog3, ccmClockNeededRun); + + RDC_SetPdapAccess(RDC, BOARD_WDOG_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + WDOG_DisablePowerdown(BOARD_WDOG_BASEADDR); + + CCM_ControlGate(CCM, ccmCcgrGateWdog3, ccmClockNotNeeded); + + /* We need system PLL Div2 to run M4 core */ + CCM_ControlGate(CCM, ccmPllGateSys, ccmClockNeededRun); + CCM_ControlGate(CCM, ccmPllGateSysDiv2, ccmClockNeededRun); + + /* Enable clock gate for IP bridge and IO mux */ + CCM_ControlGate(CCM, ccmCcgrGateIpmux1, ccmClockNeededRun); + CCM_ControlGate(CCM, ccmCcgrGateIpmux2, ccmClockNeededRun); + CCM_ControlGate(CCM, ccmCcgrGateIpmux3, ccmClockNeededRun); + CCM_ControlGate(CCM, ccmCcgrGateIomux, ccmClockNeededRun); + CCM_ControlGate(CCM, ccmCcgrGateIomuxLpsr, ccmClockNeededRun); + + /* Enable clock gate for RDC */ + CCM_ControlGate(CCM, ccmCcgrGateRdc, ccmClockNeededRun); +} + +/* Initialize debug console. */ +void dbg_uart_init(void) +{ + /* Set debug uart for M4 core domain access only */ + RDC_SetPdapAccess(RDC, BOARD_DEBUG_UART_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select board debug clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_DEBUG_UART_CCM_ROOT, ccmRootmuxUartOsc24m, 0, 0); + /* Enable debug uart clock */ + CCM_EnableRoot(CCM, BOARD_DEBUG_UART_CCM_ROOT); + /* + * IC Limitation + * M4 stop will cause A7 UART lose functionality + * So we need UART clock all the time + */ + CCM_ControlGate(CCM, BOARD_DEBUG_UART_CCM_CCGR, ccmClockNeededAll); + + /* Config debug uart pins */ + configure_uart_pins(BOARD_DEBUG_UART_BASEADDR); + + DbgConsole_Init(BOARD_DEBUG_UART_BASEADDR, get_uart_clock_freq(BOARD_DEBUG_UART_BASEADDR), 115200); +} + +void BOARD_RdcInit(void) +{ + /* Move M4 core to specific RDC domain */ + RDC_SetDomainID(RDC, rdcMdaM4, BOARD_DOMAIN_ID, false); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/board.h b/examples/var-som-mx7_m4/board.h new file mode 100644 index 000000000..2f0886579 --- /dev/null +++ b/examples/var-som-mx7_m4/board.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2015-2016, 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. + */ + +#if !defined(__BOARD_H__) +#define __BOARD_H__ + +#include "pin_mux.h" +#include "rdc.h" +#include "rdc_defs_imx7d.h" +#include "ccm_imx7d.h" +#include "clock_freq.h" + +/* The board name */ +#define BOARD_NAME "VAR-SOM-MX7_M4" +#define BOARD_DOMAIN_ID (1) + +/* ADC information for this board */ +#define BOARD_ADC_RDC_PDAP rdcPdapAdc1 +#define BOARD_ADC_CCM_CCGR ccmCcgrGateAdc +#define BOARD_ADC_BASEADDR ADC1 +#define BOARD_ADC_IRQ_NUM ADC1_IRQn +#define BOARD_ADC_HANDLER ADC1_Handler +#define BOARD_ADC_INPUT_CHANNEL (3) + +/* WDOG information for this board */ +#define BOARD_WDOG_RDC_PDAP rdcPdapWdog3 +#define BOARD_WDOG_CCM_ROOT ccmRootWdog +#define BOARD_WDOG_CCM_CCGR ccmCcgrGateWdog3 +#define BOARD_WDOG_BASEADDR WDOG3 +#define BOARD_WDOG_IRQ_NUM WDOG3_IRQn +#define BOARD_WDOG_HANDLER WDOG3_Handler + +/* SEMA4 information for this board */ +#define BOARD_SEMA4_RDC_PDAP rdcPdapSemaphoreHs +#define BOARD_SEMA4_CCM_CCGR ccmCcgrGateSemaHs +#define BOARD_SEMA4_BASEADDR SEMA4 +#define BOARD_SEMA4_IRQ_NUM SEMA4_HS_M4_IRQn +#define BOARD_SEMA4_HANDLER SEMA4_HS_M4_Handler + +/* GPT instance A information for this board */ +#define BOARD_GPTA_RDC_PDAP rdcPdapGpt3 +#define BOARD_GPTA_CCM_ROOT ccmRootGpt3 +#define BOARD_GPTA_CCM_CCGR ccmCcgrGateGpt3 +#define BOARD_GPTA_BASEADDR GPT3 +#define BOARD_GPTA_IRQ_NUM GPT3_IRQn +#define BOARD_GPTA_HANDLER GPT3_Handler +/* GPT instance B information for this board */ +#define BOARD_GPTB_RDC_PDAP rdcPdapGpt4 +#define BOARD_GPTB_CCM_ROOT ccmRootGpt4 +#define BOARD_GPTB_CCM_CCGR ccmCcgrGateGpt4 +#define BOARD_GPTB_BASEADDR GPT4 +#define BOARD_GPTB_IRQ_NUM GPT4_IRQn +#define BOARD_GPTB_HANDLER GPT4_Handler + +/* GPIO information for this board */ +#define BOARD_GPIO_LED_CCM_CCGR ccmCcgrGateGpio1 +#define BOARD_GPIO_LED_RDC_PDAP rdcPdapGpio1 +#define BOARD_GPIO_LED_CONFIG (&gpioLed) +#define BOARD_GPIO_KEY_CCM_CCGR ccmCcgrGateGpio1 +#define BOARD_GPIO_KEY_RDC_PDAP rdcPdapGpio1 +#define BOARD_GPIO_KEY_CONFIG (&gpioKeyBack) +#define BOARD_GPIO_KEY_IRQ_NUM GPIO1_INT15_0_IRQn +#define BOARD_GPIO_KEY_HANDLER GPIO1_INT15_0_Handler + +/* Debug UART information for this board */ +#define BOARD_DEBUG_UART_RDC_PDAP rdcPdapUart2 +#define BOARD_DEBUG_UART_CCM_ROOT ccmRootUart2 +#define BOARD_DEBUG_UART_CCM_CCGR ccmCcgrGateUart2 +#define BOARD_DEBUG_UART_BASEADDR UART2 +#define BOARD_DEBUG_UART_IRQ_NUM UART2_IRQn +#define BOARD_DEBUG_UART_HANDLER UART2_Handler + +/* MU information for this board*/ +#define BOARD_MU_HANDLER MU_M4_Handler +#define BOARD_MU_IRQ_NUM MU_M4_IRQn +#define BOARD_MU_BASE_ADDR MUB +#define BOARD_MU_CCM_CCGR ccmCcgrGateMu +#define BOARD_MU_RDC_PDAP rdcPdapMuB + +/* I2C information for this board */ +#define BOARD_I2C_RDC_PDAP rdcPdapI2c2 +#define BOARD_I2C_CCM_ROOT ccmRootI2c2 +#define BOARD_I2C_CCM_CCGR ccmCcgrGateI2c2 +#define BOARD_I2C_BASEADDR I2C2 +#define BOARD_I2C_IRQ_NUM I2C2_IRQn +#define BOARD_I2C_HANDLER I2C2_Handler +#define BOARD_I2C_ISL12057_ADDR (0x68) + +/* FlexCAN information for this board */ +#define BOARD_FLEXCAN_RDC_PDAP rdcPdapFlexCan2 +#define BOARD_FLEXCAN_CCM_ROOT ccmRootCan2 +#define BOARD_FLEXCAN_CCM_CCGR ccmCcgrGateCan2 +#define BOARD_FLEXCAN_BASEADDR CAN2 +#define BOARD_FLEXCAN_IRQ_NUM FLEXCAN2_IRQn +#define BOARD_FLEXCAN_HANDLER FLEXCAN2_Handler + +/* GPC information for this board*/ +#define BOARD_GPC_BASEADDR GPC + +/* SIM_WAKEUP CG information*/ +#define BOARD_SIM_WAKEUP_CCGR ccmCcgrGateSimWakeup + +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus */ + +void hardware_init(void); +void dbg_uart_init(void); +/* Function to initialize clock base on board configuration. */ +void BOARD_ClockInit(void); +void BOARD_RdcInit(void); + +#if defined(__cplusplus) +} +#endif /* __cplusplus */ + +#endif /* __BOARD_H__ */ diff --git a/examples/var-som-mx7_m4/clock_freq.c b/examples/var-som-mx7_m4/clock_freq.c new file mode 100644 index 000000000..3c5715bc4 --- /dev/null +++ b/examples/var-som-mx7_m4/clock_freq.c @@ -0,0 +1,252 @@ +/* + * 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 "clock_freq.h" +#include "ccm_imx7d.h" +#include "ccm_analog_imx7d.h" + +/*FUNCTION********************************************************************** + * + * Function Name : get_gpt_clock_freq + * Description : Get clock frequency applys to the GPT module + * + *END**************************************************************************/ +uint32_t get_gpt_clock_freq(GPT_Type* base) +{ + uint32_t root; + uint32_t hz; + uint32_t pre, post; + + switch((uint32_t)base) + { + case GPT3_BASE: + root = CCM_GetRootMux(CCM, ccmRootGpt3); + CCM_GetRootDivider(CCM, ccmRootGpt3, &pre, &post); + break; + case GPT4_BASE: + root = CCM_GetRootMux(CCM, ccmRootGpt4); + CCM_GetRootDivider(CCM, ccmRootGpt4, &pre, &post); + break; + default: + return 0; + } + + switch(root) + { + case ccmRootmuxGptOsc24m: + hz = 24000000; + break; + case ccmRootmuxGptSysPllPfd0: + hz = CCM_ANALOG_GetPfdFreq(CCM_ANALOG, ccmAnalogPfd0Frac); + break; + default: + return 0; + } + + return hz / (pre + 1) / (post + 1); +} + +/*FUNCTION********************************************************************** + * + * Function Name : get_ecspi_clock_freq + * Description : Get clock frequency applys to the ECSPI module + * + *END**************************************************************************/ +uint32_t get_ecspi_clock_freq(ECSPI_Type* base) +{ + uint32_t root; + uint32_t hz; + uint32_t pre, post; + + switch((uint32_t)base) + { + case ECSPI1_BASE: + root = CCM_GetRootMux(CCM, ccmRootEcspi1); + CCM_GetRootDivider(CCM, ccmRootEcspi1, &pre, &post); + break; + case ECSPI2_BASE: + root = CCM_GetRootMux(CCM, ccmRootEcspi2); + CCM_GetRootDivider(CCM, ccmRootEcspi2, &pre, &post); + break; + default: + return 0; + } + + switch(root) + { + case ccmRootmuxEcspiOsc24m: + hz = 24000000; + break; + case ccmRootmuxEcspiSysPllPfd4: + hz = CCM_ANALOG_GetPfdFreq(CCM_ANALOG, ccmAnalogPfd4Frac); + break; + default: + return 0; + } + + return hz / (pre + 1) / (post + 1); +} + +/*FUNCTION********************************************************************** + * + * Function Name : get_flexcan_clock_freq + * Description : Get clock frequency applys to the FLEXCAN module + * + *END**************************************************************************/ +uint32_t get_flexcan_clock_freq(CAN_Type* base) +{ + uint32_t root; + uint32_t hz; + uint32_t pre, post; + + switch((uint32_t)base) + { + case CAN1_BASE: + root = CCM_GetRootMux(CCM, ccmRootCan1); + CCM_GetRootDivider(CCM, ccmRootCan1, &pre, &post); + break; + case CAN2_BASE: + root = CCM_GetRootMux(CCM, ccmRootCan2); + CCM_GetRootDivider(CCM, ccmRootCan2, &pre, &post); + break; + default: + return 0; + } + + switch(root) + { + case ccmRootmuxCanOsc24m: + hz = 24000000; + break; + case ccmRootmuxCanSysPllDiv4: + hz = CCM_ANALOG_GetSysPllFreq(CCM_ANALOG) >> 2; + break; + case ccmRootmuxCanSysPllDiv1: + hz = CCM_ANALOG_GetSysPllFreq(CCM_ANALOG); + break; + default: + return 0; + } + + return hz / (pre + 1) / (post + 1); +} + +/*FUNCTION********************************************************************** + * + * Function Name : get_I2C_clock_freq + * Description : Get clock frequency applys to the I2C module + * + *END**************************************************************************/ +uint32_t get_i2c_clock_freq(I2C_Type* base) +{ + uint32_t root; + uint32_t hz; + uint32_t pre, post; + + switch((uint32_t)base) + { + case I2C1_BASE: + root = CCM_GetRootMux(CCM, ccmRootI2c1); + CCM_GetRootDivider(CCM, ccmRootI2c1, &pre, &post); + break; + case I2C2_BASE: + root = CCM_GetRootMux(CCM, ccmRootI2c2); + CCM_GetRootDivider(CCM, ccmRootI2c2, &pre, &post); + break; + case I2C3_BASE: + root = CCM_GetRootMux(CCM, ccmRootI2c3); + CCM_GetRootDivider(CCM, ccmRootI2c3, &pre, &post); + break; + case I2C4_BASE: + root = CCM_GetRootMux(CCM, ccmRootI2c4); + CCM_GetRootDivider(CCM, ccmRootI2c4, &pre, &post); + break; + default: + return 0; + } + + switch(root) + { + case ccmRootmuxI2cOsc24m: + hz = 24000000; + break; + case ccmRootmuxI2cSysPllDiv4: + hz = CCM_ANALOG_GetSysPllFreq(CCM_ANALOG) >> 2; + break; + default: + return 0; + } + + return hz / (pre + 1) / (post + 1); +} + +/*FUNCTION********************************************************************** + * + * Function Name : get_uart_clock_freq + * Description : Get clock frequency applys to the UART module + * + *END**************************************************************************/ +uint32_t get_uart_clock_freq(UART_Type* base) +{ + uint32_t root; + uint32_t hz; + uint32_t pre, post; + + switch((uint32_t)base) + { + case UART2_BASE: + root = CCM_GetRootMux(CCM, ccmRootUart2); + CCM_GetRootDivider(CCM, ccmRootUart2, &pre, &post); + break; + default: + return 0; + } + + switch(root) + { + case ccmRootmuxUartOsc24m: + hz = 24000000; + break; + case ccmRootmuxUartSysPllDiv2: + hz = CCM_ANALOG_GetSysPllFreq(CCM_ANALOG) >> 1; + break; + case ccmRootmuxUartSysPllDiv1: + hz = CCM_ANALOG_GetSysPllFreq(CCM_ANALOG); + break; + default: + return 0; + } + + return hz / (pre + 1) / (post + 1); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/clock_freq.h b/examples/var-som-mx7_m4/clock_freq.h new file mode 100644 index 000000000..da2ba6d77 --- /dev/null +++ b/examples/var-som-mx7_m4/clock_freq.h @@ -0,0 +1,98 @@ +/* + * 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 __CLOCK_FREQ_H__ +#define __CLOCK_FREQ_H__ + +#include "device_imx.h" + +/*! + * @addtogroup clock_freq_helper + * @{ + */ + +/******************************************************************************* + * API + ******************************************************************************/ + +#if defined(__cplusplus) +extern "C" { +#endif + +/*! + * @brief Get clock frequency applys to the GPT module + * + * @param base GPT base pointer. + * @return clock frequency (in HZ) applys to the GPT module + */ +uint32_t get_gpt_clock_freq(GPT_Type* base); + +/*! + * @brief Get clock frequency applys to the ECSPI module + * + * @param base ECSPI base pointer. + * @return clock frequency (in HZ) applys to the ECSPI module + */ +uint32_t get_ecspi_clock_freq(ECSPI_Type* base); + +/*! + * @brief Get clock frequency applys to the FLEXCAN module + * + * @param base CAN base pointer. + * @return clock frequency (in HZ) applys to the FLEXCAN module + */ +uint32_t get_flexcan_clock_freq(CAN_Type* base); + +/*! + * @brief Get clock frequency applys to the I2C module + * + * @param base I2C base pointer. + * @return clock frequency (in HZ) applys to the I2C module + */ +uint32_t get_i2c_clock_freq(I2C_Type* base); + +/*! + * @brief Get clock frequency applys to the UART module + * + * @param base UART base pointer. + * @return clock frequency (in HZ) applys to the UART module + */ +uint32_t get_uart_clock_freq(UART_Type* base); + +#if defined(__cplusplus) +} +#endif + +/*! @}*/ + +#endif /* __CLOCK_FREQ_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/FreeRTOSConfig.h new file mode 100644 index 000000000..6d8eb1904 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/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 +#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 0 +#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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/CMakeLists.txt new file mode 100644 index 000000000..281bc1259 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/CMakeLists.txt @@ -0,0 +1,174 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(blinking_imx_demo_gpt + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../main.c" + "${ProjDirPath}/../gpt_timer.c" + "${ProjDirPath}/../hw_timer.h" + "${ProjDirPath}/../gpio_ctrl.c" + "${ProjDirPath}/../gpio_ctrl.h" + "${ProjDirPath}/../../../../../platform/drivers/src/gpio_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/gpio_imx.h" + "${ProjDirPath}/../../../../../platform/drivers/src/gpt.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/gpt.h" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc_semaphore.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_semaphore.h" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" +) +SET_TARGET_PROPERTIES(blinking_imx_demo_gpt PROPERTIES OUTPUT_NAME "blinking_imx_demo_gpt.elf") + +TARGET_LINK_LIBRARIES(blinking_imx_demo_gpt -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(blinking_imx_demo_gpt m) +TARGET_LINK_LIBRARIES(blinking_imx_demo_gpt c) +TARGET_LINK_LIBRARIES(blinking_imx_demo_gpt gcc) +TARGET_LINK_LIBRARIES(blinking_imx_demo_gpt nosys) +TARGET_LINK_LIBRARIES(blinking_imx_demo_gpt -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/blinking_imx_demo_gpt.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/blinking_imx_demo_gpt.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET blinking_imx_demo_gpt POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/blinking_imx_demo_gpt.elf ${EXECUTABLE_OUTPUT_PATH}/blinking_imx_demo_gpt.hex) +ADD_CUSTOM_COMMAND(TARGET blinking_imx_demo_gpt POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/blinking_imx_demo_gpt.elf ${EXECUTABLE_OUTPUT_PATH}/blinking_imx_demo_gpt.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_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/var-som-mx7_m4/demo_apps/blinking_imx_demo/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/ds5/.cproject new file mode 100644 index 000000000..2674b23e7 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/ds5/.project b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/ds5/.project new file mode 100644 index 000000000..68ba09c2a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/ds5/.project @@ -0,0 +1,86 @@ + + + blinking_imx_demo_gpt_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.csource2virtual:/virtualsource/gpt_timer.c1PARENT-1-PROJECT_LOC/gpt_timer.csource2virtual:/virtualsource/hw_timer.h1PARENT-1-PROJECT_LOC/hw_timer.hsource2virtual:/virtualsource/gpio_ctrl.c1PARENT-1-PROJECT_LOC/gpio_ctrl.csource2virtual:/virtualsource/gpio_ctrl.h1PARENT-1-PROJECT_LOC/gpio_ctrl.hdriver2virtual:/virtualdriver/gpio_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/gpio_imx.cdriver2virtual:/virtualdriver/gpio_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/gpio_imx.hdriver2virtual:/virtualdriver/gpt.c1PARENT-5-PROJECT_LOC/platform/drivers/src/gpt.cdriver2virtual:/virtualdriver/gpt.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/gpt.hdriver2virtual:/virtualdriver/rdc_semaphore.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc_semaphore.cdriver2virtual:/virtualdriver/rdc_semaphore.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_semaphore.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cboard2virtual:/virtualboard/gpio_pins.c1PARENT-3-PROJECT_LOC/gpio_pins.cboard2virtual:/virtualboard/gpio_pins.h1PARENT-3-PROJECT_LOC/gpio_pins.h + + + diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpio_ctrl.c b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpio_ctrl.c new file mode 100644 index 000000000..45aece0c8 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpio_ctrl.c @@ -0,0 +1,194 @@ +/* + * 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 +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.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" + +static SemaphoreHandle_t xSemaphore; + +static void GPIO_Ctrl_InitLedPin() +{ +#ifdef BOARD_GPIO_LED_CONFIG + gpio_init_config_t ledInit = { + .pin = BOARD_GPIO_LED_CONFIG->pin, + .direction = gpioDigitalOutput, + .interruptMode = gpioNoIntmode + }; + + /* 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_LED_RDC_PDAP); + + GPIO_Init(BOARD_GPIO_LED_CONFIG->base, &ledInit); + + RDC_SEMAPHORE_Unlock(BOARD_GPIO_LED_RDC_PDAP); +#endif +} + +static void GPIO_Ctrl_InitKeyPin() +{ +#ifdef BOARD_GPIO_KEY_CONFIG + gpio_init_config_t keyInit = { + .pin = BOARD_GPIO_KEY_CONFIG->pin, + .direction = gpioDigitalInput, + .interruptMode = gpioIntFallingEdge + }; + + /* 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_KEY_RDC_PDAP); + + GPIO_Init(BOARD_GPIO_KEY_CONFIG->base, &keyInit); + + RDC_SEMAPHORE_Unlock(BOARD_GPIO_KEY_RDC_PDAP); + + /* Set GPT interrupt priority 3 */ + NVIC_SetPriority(BOARD_GPIO_KEY_IRQ_NUM, 3); +#endif +} + +void GPIO_Ctrl_Init() +{ + xSemaphore = xSemaphoreCreateBinary(); + + GPIO_Ctrl_InitLedPin(); + GPIO_Ctrl_InitKeyPin(); +} + +void GPIO_Ctrl_ToggleLed() +{ + static bool on = false; + +#ifdef BOARD_GPIO_LED_CONFIG + RDC_SEMAPHORE_Lock(BOARD_GPIO_LED_RDC_PDAP); + + GPIO_WritePinOutput(BOARD_GPIO_LED_CONFIG->base, + BOARD_GPIO_LED_CONFIG->pin, on ? gpioPinSet : gpioPinClear); + + RDC_SEMAPHORE_Unlock(BOARD_GPIO_LED_RDC_PDAP); +#else + PRINTF("%c ", on ? '+' : '-'); +#endif + + on = !on; +} + +void GPIO_Ctrl_WaitKeyPressed() +{ +#ifdef BOARD_GPIO_KEY_CONFIG + uint32_t i, debounce; + + do + { + debounce = 0; + + RDC_SEMAPHORE_Lock(BOARD_GPIO_KEY_RDC_PDAP); + + /* Clear the interrupt state */ + GPIO_ClearStatusFlag(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin); + /* Enable GPIO pin interrupt */ + GPIO_SetPinIntMode(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin, true); + + RDC_SEMAPHORE_Unlock(BOARD_GPIO_KEY_RDC_PDAP); + + /* Enable the IRQ. */ + NVIC_EnableIRQ(BOARD_GPIO_KEY_IRQ_NUM); + + PRINTF("\n\rPress the (%s) key to switch the blinking frequency:\n\r", BOARD_GPIO_KEY_CONFIG->name); + xSemaphoreTake(xSemaphore, portMAX_DELAY); + + for (i = 0; i < 3; i++) + { + /* Susupend Task to wait Key stable. */ + vTaskDelay(5); + + /* Check key value. */ + if (0 == GPIO_ReadPinInput(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin)) + { + /* Increase debounce counter. */ + debounce ++; + } + } + + if (debounce >= 2) + { + break; + } + } while (1); +#else + /* Without key on board, we return every 5 seconds */ + PRINTF("\n\rWait 5 seconds to switch blinking frequency:\n\r"); + xSemaphoreTake(xSemaphore, configTICK_RATE_HZ * 5); +#endif +} + +#ifdef BOARD_GPIO_KEY_CONFIG +void BOARD_GPIO_KEY_HANDLER() +{ + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + + /* 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); + + /* 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 + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpio_ctrl.h b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpio_ctrl.h new file mode 100644 index 000000000..a61a01726 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpio_ctrl.h @@ -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. + */ + +#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(void); + +/*! + * @brief Wait user to press key + */ +void GPIO_Ctrl_WaitKeyPressed(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __GPIO_CTRL_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpt_timer.c b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpt_timer.c new file mode 100644 index 000000000..d092c45e4 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/gpt_timer.c @@ -0,0 +1,121 @@ +/* + * 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 "FreeRTOS.h" +#include "semphr.h" +#include "board.h" +#include "gpt.h" +#include "hw_timer.h" + +static SemaphoreHandle_t xSemaphore; + +void Hw_Timer_Init(void) +{ + gpt_init_config_t config = { + .freeRun = false, + .waitEnable = true, + .stopEnable = true, + .dozeEnable = true, + .dbgEnable = false, + .enableMode = true + }; + + /* Initialize GPT module */ + GPT_Init(BOARD_GPTA_BASEADDR, &config); + + /* Set GPT clock source to 24M OSC */ + GPT_SetClockSource(BOARD_GPTA_BASEADDR, gptClockSourceOsc); + + /* Set GPT interrupt priority 3 */ + NVIC_SetPriority(BOARD_GPTA_IRQ_NUM, 3); + + /* Enable NVIC interrupt */ + NVIC_EnableIRQ(BOARD_GPTA_IRQ_NUM); + + xSemaphore = xSemaphoreCreateBinary(); +} + +void Hw_Timer_Delay(uint32_t ms) +{ + uint64_t counter = 24000ULL * ms; /* First get the counter needed by delay time */ + uint32_t high; + uint32_t div24m, div; + + /* Get the value that exceed maximum register counter */ + high = (uint32_t)(counter >> 32); + + /* high could not exceed 24000, so that predivider is enough */ + div24m = high / 4096; /* We need PRESCALER24M only if high exceed PRESCALER maximum value */ + div = high / (div24m + 1); /* Get PRESCALER value */ + + /* Now set prescaler */ + GPT_SetOscPrescaler(BOARD_GPTA_BASEADDR, div24m); + GPT_SetPrescaler(BOARD_GPTA_BASEADDR, div); + + /* Set GPT compare value */ + GPT_SetOutputCompareValue(BOARD_GPTA_BASEADDR, gptOutputCompareChannel1, + (uint32_t)(counter / (div24m + 1) / (div + 1))); + + /* Enable GPT Output Compare1 interrupt */ + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, true); + + /* GPT start */ + GPT_Enable(BOARD_GPTA_BASEADDR); + + /* Wait until GPT event happens. */ + xSemaphoreTake(xSemaphore, portMAX_DELAY); +} + +void BOARD_GPTA_HANDLER(void) +{ + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + + /* When GPT time-out, we disable GPT to make sure this is a one-shot event. */ + GPT_Disable(BOARD_GPTA_BASEADDR); + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, false); + GPT_ClearStatusFlag(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1); + + /* Unlock the task to process the event. */ + xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken); + + /* Perform a context switch to wake the higher priority task. */ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/hardware_init.c new file mode 100644 index 000000000..6d46d4af0 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/hardware_init.c @@ -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. + */ + +#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 grasp board GPT exclusively */ + RDC_SetPdapAccess(RDC, BOARD_GPTA_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* In this demo, we need to access RDC SEMAPHORE1 on this board */ + RDC_SetPdapAccess(RDC, rdcPdapSemaphore1, 0xFF, false, false); + + /* 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, BOARD_GPIO_KEY_RDC_PDAP, 0xFF, false/*true*/, false); + + /* Enable PLL PFD0 for GPTA */ + CCM_ControlGate(CCM, ccmPllGateSys, ccmClockNeededRunWait); + CCM_ControlGate(CCM, ccmPllGatePfd0, ccmClockNeededRunWait); + + /* Select GPTA clock derived from PLL PFD0 */ + CCM_UpdateRoot(CCM, BOARD_GPTA_CCM_ROOT, ccmRootmuxGptSysPllPfd0, 0, 0); + /* Enable clock used by GPTA */ + CCM_EnableRoot(CCM, BOARD_GPTA_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTA_CCM_CCGR, ccmClockNeededRunWait); + + /* Enable RDC SEMAPHORE GATE needed in this demo */ + CCM_ControlGate(CCM, ccmCcgrGateSema1, ccmClockNeededRunWait); + + /* Enable gpio clock gate, led and key share same CCGR on this board */ + CCM_ControlGate(CCM, BOARD_GPIO_KEY_CCM_CCGR, ccmClockNeededRunWait); + + /* Configure gpio pin IOMUX */ + configure_gpio_pin(BOARD_GPIO_KEY_CONFIG); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/hw_timer.h b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/hw_timer.h new file mode 100644 index 000000000..5a8781922 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/hw_timer.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 __HW_TIMER_H__ +#define __HW_TIMER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * @brief Initialize hardware timer, must be called before Hardware_Timer_Delay(). + */ +void Hw_Timer_Init(void); + +/*! + * @brief Block task for some time with hardware timer, this timer is not multi-thread + * safe and could only called in one task. + * + * @param ms milliseconds to delay + */ +void Hw_Timer_Delay(uint32_t ms); + +#ifdef __cplusplus +} +#endif + +#endif /* __HW_TIMER_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/main.c b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/main.c new file mode 100644 index 000000000..e280647b0 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/blinking_imx_demo/main.c @@ -0,0 +1,109 @@ +/* + * 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 "FreeRTOS.h" +#include "task.h" +#include "board.h" +#include "debug_console_imx.h" +#include "gpio_ctrl.h" +#include "hw_timer.h" + +#define BLINKING_INTERVAL_MIN (100) + +static volatile uint32_t blinkingInterval = BLINKING_INTERVAL_MIN; + +/****************************************************************************** +* +* Function Name: ToggleTask +* Comments: this task is used to turn toggle on/off LED. +* +******************************************************************************/ +void ToggleTask(void *pvParameters) +{ + while (true) + { + GPIO_Ctrl_ToggleLed(); + /* Use Hardware timer to get accurate delay */ + Hw_Timer_Delay(blinkingInterval); + } +} + +/****************************************************************************** +* +* Function Name: SwitchTask +* Comments: this task is used to change blinking frequency. +* +******************************************************************************/ +void SwitchTask(void *pvParameters) +{ + while (true) + { + PRINTF("\n\r====== Blinking interval %dms ======\n\r", blinkingInterval); + GPIO_Ctrl_WaitKeyPressed(); + blinkingInterval += 100; + if (blinkingInterval > 1000) + blinkingInterval = BLINKING_INTERVAL_MIN; + /* Delay for 1 second to avoid glitch */ + vTaskDelay(configTICK_RATE_HZ); + } +} + +/****************************************************************************** +* +* Function Name: main +* Comments: main function, toggle LED and switch the blinking frequency by key. +* +******************************************************************************/ +int main(void) +{ + /* Initialize board specified hardware. */ + hardware_init(); + + Hw_Timer_Init(); + GPIO_Ctrl_Init(); + + PRINTF("\n\r================= Blinking Demo ==================\n\r"); + + /* Create a the APP main task. */ + xTaskCreate(ToggleTask, "Toggle Task", configMINIMAL_STACK_SIZE, + NULL, tskIDLE_PRIORITY+1, NULL); + xTaskCreate(SwitchTask, "Switch Task", configMINIMAL_STACK_SIZE, + NULL, tskIDLE_PRIORITY+2, NULL); + + /* Start FreeRTOS scheduler. */ + vTaskStartScheduler(); + + /* should never reach this point. */ + while (true); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/hello_world/FreeRTOSConfig.h new file mode 100644 index 000000000..fb1d76ada --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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 +#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 0 +#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 0 + +/* 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/var-som-mx7_m4/demo_apps/hello_world/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/CMakeLists.txt new file mode 100644 index 000000000..7b23972eb --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/CMakeLists.txt @@ -0,0 +1,162 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(hello_world + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" +) +SET_TARGET_PROPERTIES(hello_world PROPERTIES OUTPUT_NAME "hello_world.elf") + +TARGET_LINK_LIBRARIES(hello_world -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(hello_world m) +TARGET_LINK_LIBRARIES(hello_world c) +TARGET_LINK_LIBRARIES(hello_world gcc) +TARGET_LINK_LIBRARIES(hello_world nosys) +TARGET_LINK_LIBRARIES(hello_world -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/hello_world.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/hello_world.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET hello_world POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/hello_world.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world.hex) +ADD_CUSTOM_COMMAND(TARGET hello_world POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/hello_world.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/hello_world/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/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/var-som-mx7_m4/demo_apps/hello_world/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/hello_world/ds5/.cproject new file mode 100644 index 000000000..d0a4f6bbe --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world/ds5/.project b/examples/var-som-mx7_m4/demo_apps/hello_world/ds5/.project new file mode 100644 index 000000000..0057af757 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.c + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/hello_world/hardware_init.c new file mode 100644 index 000000000..9081bfd1c --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/hardware_init.c @@ -0,0 +1,48 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* initialize debug uart */ + dbg_uart_init(); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world/main.c b/examples/var-som-mx7_m4/demo_apps/hello_world/main.c new file mode 100644 index 000000000..e7a09867a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world/main.c @@ -0,0 +1,86 @@ +/* + * 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +// Includes +/////////////////////////////////////////////////////////////////////////////// +#include "FreeRTOS.h" +#include "task.h" +#include "board.h" +#include "debug_console_imx.h" + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +/*! + * @brief A basic user-defined task + */ +void HelloTask(void *pvParameters) +{ + uint8_t receiveBuff; + + // Print the initial banner + PRINTF("\r\nHello World!\n\n\r"); + + while(1) + { + // Main routine that simply echoes received characters forever + + // First, get character + receiveBuff = GETCHAR(); + + // Now echo the received character + PUTCHAR(receiveBuff); + } +} + +/*! + * @brief Main function + */ +int main(void) +{ + // Initialize demo application pins setting and clock setting. + hardware_init(); + + // Create a demo task which will print Hello world and echo user's input. + xTaskCreate(HelloTask, "Print Task", configMINIMAL_STACK_SIZE, + NULL, tskIDLE_PRIORITY+1, NULL); + + // Start FreeRTOS scheduler. + vTaskStartScheduler(); + + // Should never reach this point. + while (true); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/FreeRTOSConfig.h new file mode 100644 index 000000000..fb1d76ada --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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 +#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 0 +#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 0 + +/* 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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/CMakeLists.txt new file mode 100644 index 000000000..488604b61 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/CMakeLists.txt @@ -0,0 +1,162 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_ddr.ld -static") + +# RELEASE LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -T${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_ddr.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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(hello_world_ddr + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../../hello_world/main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" +) +SET_TARGET_PROPERTIES(hello_world_ddr PROPERTIES OUTPUT_NAME "hello_world_ddr.elf") + +TARGET_LINK_LIBRARIES(hello_world_ddr -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(hello_world_ddr m) +TARGET_LINK_LIBRARIES(hello_world_ddr c) +TARGET_LINK_LIBRARIES(hello_world_ddr gcc) +TARGET_LINK_LIBRARIES(hello_world_ddr nosys) +TARGET_LINK_LIBRARIES(hello_world_ddr -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/hello_world_ddr.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/hello_world_ddr.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET hello_world_ddr POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/hello_world_ddr.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world_ddr.hex) +ADD_CUSTOM_COMMAND(TARGET hello_world_ddr POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/hello_world_ddr.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world_ddr.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/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/var-som-mx7_m4/demo_apps/hello_world_ddr/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/ds5/.cproject new file mode 100644 index 000000000..5bbc06887 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/ds5/.project b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/ds5/.project new file mode 100644 index 000000000..e1442421e --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_ddr_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-2-PROJECT_LOC/hello_world/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.c + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/hardware_init.c new file mode 100644 index 000000000..6ce266abd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ddr/hardware_init.c @@ -0,0 +1,74 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void RDC_memory_init(void) +{ + uint32_t start, end; +#if defined(__CC_ARM) + extern uint32_t Image$$VECTOR_ROM$$Base[]; + extern uint32_t Image$$ER_m_text$$Limit[]; + extern uint32_t Image$$RW_m_data$$Base[]; + extern uint32_t Image$$RW_m_data$$Limit[]; + + start = (uint32_t)Image$$VECTOR_ROM$$Base & 0xFFFFF000; + end = (uint32_t)(Image$$ER_m_text$$Limit + (Image$$RW_m_data$$Limit - Image$$RW_m_data$$Base)); + end = (end + 0xFFF) & 0xFFFFF000; +#else + extern uint32_t __FLASH_START[]; + extern uint32_t __FLASH_END[]; + + start = (uint32_t)__FLASH_START & 0xFFFFF000; + end = ((uint32_t)__FLASH_END + 0xFFF) & 0xFFFFF000; +#endif + + RDC_SetMrAccess(RDC, rdcMrMmdc, start, end, (3 << (BOARD_DOMAIN_ID * 2)), true, false); +} + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Bound part of the DDR Memory to M4 Core */ + RDC_memory_init(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* Initialize debug uart */ + dbg_uart_init(); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/FreeRTOSConfig.h new file mode 100644 index 000000000..fb1d76ada --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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 +#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 0 +#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 0 + +/* 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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/CMakeLists.txt new file mode 100644 index 000000000..469ae2336 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/CMakeLists.txt @@ -0,0 +1,162 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_ocram.ld -static") + +# RELEASE LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -T${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_ocram.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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(hello_world_ocram + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../../hello_world/main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" +) +SET_TARGET_PROPERTIES(hello_world_ocram PROPERTIES OUTPUT_NAME "hello_world_ocram.elf") + +TARGET_LINK_LIBRARIES(hello_world_ocram -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(hello_world_ocram m) +TARGET_LINK_LIBRARIES(hello_world_ocram c) +TARGET_LINK_LIBRARIES(hello_world_ocram gcc) +TARGET_LINK_LIBRARIES(hello_world_ocram nosys) +TARGET_LINK_LIBRARIES(hello_world_ocram -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/hello_world_ocram.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/hello_world_ocram.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET hello_world_ocram POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/hello_world_ocram.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world_ocram.hex) +ADD_CUSTOM_COMMAND(TARGET hello_world_ocram POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/hello_world_ocram.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world_ocram.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/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/var-som-mx7_m4/demo_apps/hello_world_ocram/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/ds5/.cproject new file mode 100644 index 000000000..9a56c3c58 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/ds5/.project b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/ds5/.project new file mode 100644 index 000000000..86fb5c311 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_ocram_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-2-PROJECT_LOC/hello_world/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.c + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/hardware_init.c new file mode 100644 index 000000000..598d2de0e --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_ocram/hardware_init.c @@ -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. + */ + +#include "board.h" +#include "pin_mux.h" + +void RDC_memory_init(void) +{ + uint32_t start, end; +#if defined(__CC_ARM) + extern uint32_t Image$$VECTOR_ROM$$Base[]; + extern uint32_t Image$$ER_m_text$$Limit[]; + extern uint32_t Image$$RW_m_data$$Base[]; + extern uint32_t Image$$RW_m_data$$Limit[]; + + start = (uint32_t)Image$$VECTOR_ROM$$Base & 0xFFFFFF80; + end = (uint32_t)(Image$$ER_m_text$$Limit + (Image$$RW_m_data$$Limit - Image$$RW_m_data$$Base)); + end = (end + 0x7F) & 0xFFFFFF80; +#else + extern uint32_t __FLASH_START[]; + extern uint32_t __FLASH_END[]; + + start = (uint32_t)__FLASH_START & 0xFFFFFF80; + end = ((uint32_t)__FLASH_END + 0x7F) & 0xFFFFFF80; +#endif + + /* Grant all domains read/write access because in DSM mode Linux need to + * save/restore OCRAM content */ + RDC_SetMrAccess(RDC, rdcMrOcram, start, end, 0xFF, true, false); +} + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Bound part of the OCRAM Memory to M4 Core */ + RDC_memory_init(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* Initialize debug uart */ + dbg_uart_init(); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/FreeRTOSConfig.h new file mode 100644 index 000000000..fb1d76ada --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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 +#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 0 +#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 0 + +/* 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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/CMakeLists.txt new file mode 100644 index 000000000..8c9ff2aaf --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/CMakeLists.txt @@ -0,0 +1,162 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_qspia.ld -static") + +# RELEASE LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -T${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4_qspia.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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(hello_world_qspi + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../../hello_world/main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" +) +SET_TARGET_PROPERTIES(hello_world_qspi PROPERTIES OUTPUT_NAME "hello_world_qspi.elf") + +TARGET_LINK_LIBRARIES(hello_world_qspi -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(hello_world_qspi m) +TARGET_LINK_LIBRARIES(hello_world_qspi c) +TARGET_LINK_LIBRARIES(hello_world_qspi gcc) +TARGET_LINK_LIBRARIES(hello_world_qspi nosys) +TARGET_LINK_LIBRARIES(hello_world_qspi -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/hello_world_qspi.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/hello_world_qspi.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET hello_world_qspi POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/hello_world_qspi.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world_qspi.hex) +ADD_CUSTOM_COMMAND(TARGET hello_world_qspi POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/hello_world_qspi.elf ${EXECUTABLE_OUTPUT_PATH}/hello_world_qspi.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/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/var-som-mx7_m4/demo_apps/hello_world_qspi/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/ds5/.cproject new file mode 100644 index 000000000..f1b2803da --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/ds5/.project b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/ds5/.project new file mode 100644 index 000000000..eb6d69049 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_qspi_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-2-PROJECT_LOC/hello_world/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.c + + + diff --git a/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/hardware_init.c new file mode 100644 index 000000000..1a79b063d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/hello_world_qspi/hardware_init.c @@ -0,0 +1,74 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void RDC_memory_init(void) +{ + uint32_t start, end; +#if defined(__CC_ARM) + extern uint32_t Image$$VECTOR_ROM$$Base[]; + extern uint32_t Image$$ER_m_text$$Limit[]; + extern uint32_t Image$$RW_m_data$$Base[]; + extern uint32_t Image$$RW_m_data$$Limit[]; + + start = (uint32_t)Image$$VECTOR_ROM$$Base & 0xFFFFF000; + end = (uint32_t)(Image$$ER_m_text$$Limit + (Image$$RW_m_data$$Limit - Image$$RW_m_data$$Base)); + end = (end + 0xFFF) & 0xFFFFF000; +#else + extern uint32_t __FLASH_START[]; + extern uint32_t __FLASH_END[]; + + start = (uint32_t)__FLASH_START & 0xFFFFF000; + end = ((uint32_t)__FLASH_END + 0xFFF) & 0xFFFFF000; +#endif + + RDC_SetMrAccess(RDC, rdcMrQspi, start, end, (3 << (BOARD_DOMAIN_ID * 2)), true, false); +} + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Bound part of the QSPI Flash Memory to M4 Core */ + RDC_memory_init(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* Initialize debug uart */ + dbg_uart_init(); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/gpc.c b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/gpc.c new file mode 100644 index 000000000..d21b5cd2b --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/gpc.c @@ -0,0 +1,102 @@ +/* + * 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 "gpc.h" + +/* + * Initialize GPC settings for dual core low power management + */ +void GPC_Init(GPC_Type * base) +{ + /* + * Disable all M4 interrupt as GPC wakeup source + */ + base->IMR1_M4 = GPC_IMR1_M4_IMR1_M4_MASK; + base->IMR2_M4 = GPC_IMR2_M4_IMR2_M4_MASK; + base->IMR3_M4 = GPC_IMR3_M4_IMR3_M4_MASK; + base->IMR4_M4 = GPC_IMR4_M4_IMR4_M4_MASK; + + /* + * Initialize the GPC settings for M4 + */ + base->LPCR_M4 |= GPC_LPCR_M4_EN_M4_PUP_MASK | + GPC_LPCR_M4_EN_M4_PDN_MASK; /* EN_M4_PUP, EN_M4_PDN*/ + base->PGC_ACK_SEL_M4 = GPC_PGC_ACK_SEL_M4_M4_VIRTUAL_PGC_PUP_ACK_MASK | + GPC_PGC_ACK_SEL_M4_M4_VIRTUAL_PGC_PDN_ACK_MASK; /* change dummy to virtual*/ + base->MISC |= GPC_MISC_M4_PDN_REQ_MASK_MASK; /* not mask M4 power down*/ + + /* + * M4 Virtual domain and Fast Mega domain must use the same PUP/PDN slot + * Align to A7, SLT 1 and SLT 5 are used for Fast Mega and M4 Virtual domain + */ + base->SLT_CFG[1] = GPC_SLT_CFG_M4_VIRTUAL_PDN_SLOT_CONTROL_MASK | GPC_SLT_CFG_FASTMEGA_PDN_SLOT_CONTROL_MASK; + base->SLT_CFG[5] = GPC_SLT_CFG_M4_VIRTUAL_PUP_SLOT_CONTROL_MASK | GPC_SLT_CFG_FASTMEGA_PUP_SLOT_CONTROL_MASK; + + /* + * Fast map to both A7 and M4 + * - M4 only have access to byte 1, A7 only have access to byte 0 + * - set to 1 for "map" + */ + base->PGC_CPU_MAPPING = GPC_PGC_CPU_MAPPING_FASTMEGA_M4_DOMAIN_MASK; +} + +/* + * Enable an interrupt source as GPC wakeup source for M4 core + */ +void GPC_EnableM4WakeupIRQ(GPC_Type* base, uint32_t irq_no, GPC_IRQ_WAKEUP_MODE wakeup_mode) +{ + uint32_t reg_index, reg_offset; + volatile uint32_t* target_reg; + + if (irq_no < TOTAL_IRQ_NUM) { + reg_index = irq_no / IRQ_PER_REGISTER; + reg_offset = irq_no % IRQ_PER_REGISTER; + target_reg = &base->IMR1_M4 + reg_index; + if (wakeup_mode == GPC_IRQ_WAKEUP_ENABLE) { + /*enable the IRQ as wakeup source*/ + *target_reg &= ~(1 << reg_offset); + } + else { + /*disable the IRQ as wakeup source*/ + *target_reg |= 1 << reg_offset; + } + } +} + +/* + * Configure LPCR_M4_LPM, the configured LPM state will be entered + * the next time WFI is executed + */ +void GPC_SetM4NextLPM(GPC_Type* base, uint32_t lpm_val) +{ + if (lpm_val < 4) { + base->LPCR_M4 = (base->LPCR_M4 & ~GPC_LPCR_M4_LPM0_MASK) | lpm_val; + } +} diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/gpc.h b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/gpc.h new file mode 100644 index 000000000..8c61adfe7 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/gpc.h @@ -0,0 +1,49 @@ +/* + * 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 __GPC_H__ +#define __GPC_H__ +#include "device_imx.h" + +#define TOTAL_IRQ_NUM 128 +#define IRQ_PER_REGISTER 32 + +typedef enum gpc_irq_wakeup_mode { + GPC_IRQ_WAKEUP_ENABLE, + GPC_IRQ_WAKEUP_DISABLE, +} GPC_IRQ_WAKEUP_MODE; + +void GPC_Init(GPC_Type* base); + +void GPC_EnableM4WakeupIRQ(GPC_Type* base, uint32_t irq_no, GPC_IRQ_WAKEUP_MODE wakeup_mode); + +void GPC_SetM4NextLPM(GPC_Type* base, uint32_t lpm_val); + +#endif diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/lpm_mcore.c b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/lpm_mcore.c new file mode 100644 index 000000000..dd3e27b21 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/lpm_mcore.c @@ -0,0 +1,703 @@ +/* + * Copyright (c) 2015-2016, 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 "board.h" +#include "lpm_mcore.h" +#include "debug_console_imx.h" +#include "ccm_imx7d.h" +#include "mu_imx.h" +#include "FreeRTOS.h" +#include "gpt.h" + +#define MAXIMUM_24M_DIV 15 + +static LPM_POWER_STATUS_M4 m4_lpm_state = LPM_M4_STATE_RUN; + +static P_WAKEUP_INT_ELE g_wakeup_int_list; + +#if defined(__GNUC__) || defined(__CC_ARM) +static void RAM_Wfi(void) __attribute__((section(".ram_function"))); +static void RAM_Wfi_End(void) __attribute__((section(".ram_function_end"))); +#elif defined(__ICCARM__) +#pragma default_function_attributes = @ ".ram_function" +static void RAM_Wfi(void); +static void RAM_Wfi_End(void); +#pragma default_function_attributes = +#endif + +static void GPT_Patch_Prepare(void); + +static void (*runInRAM)(void) = NULL; + +/* + * Send Message to A7 + */ +static void LPM_MCORE_SendMessage(uint32_t msg) +{ + while (0 == (MUB_SR & MU_SR_TEn(0x8 >> LPM_MCORE_MU_CHANNEL))); + MUB->TR[LPM_MCORE_MU_CHANNEL] = msg; + while ((MUB_SR & MU_SR_EP_MASK) != 0); +} + +#if (defined(LPM_MCORE_PRINT_DEBUG_INFO) && (LPM_MCORE_PRINT_DEBUG_INFO)) +/* + * Provide a spinning delay, the actual delay time is dependent on the CPU freq + */ +static void my_delay(void) +{ + uint32_t i, j, k; + for (i=0; i!=DELAY_CNT; i++) + for (j=0; j!=DELAY_CNT; j++) + for (k=0; k!=DELAY_CNT; k++) + __NOP(); + return; +} + +/* + * Use the delay function to demostrate current CPU running freq + */ +static void verify_clock_speed(void) +{ + uint32_t i; + for (i=0; i!=DELAY_LOOP_CNT_LOW_SPEED; i++) { + my_delay(); + PRINTF("\rVerify M4 Speed : %2d of %d ... ", i+1, DELAY_LOOP_CNT_LOW_SPEED); + } + PRINTF("Done.\r\n"); +} +#endif + +/* + * Tool function to copy function area [func_start, func_end] to M4 data area + * which is TCM in 7Dual Project + */ +static uint8_t* RAM_Function_Copy(uint8_t* func_start, uint8_t* func_end) +{ + uint8_t* ram_code_ptr; + uint32_t ram_function_start; + + ram_function_start = (uint32_t)func_start & ~0x3; + ram_code_ptr = pvPortMalloc((uint8_t*)func_end - (uint8_t*)ram_function_start); + memcpy(ram_code_ptr, (uint8_t*)ram_function_start, (uint32_t)func_end - + (uint32_t)ram_function_start); + ram_code_ptr = (uint8_t *)((uint32_t)ram_code_ptr | ((uint32_t)func_start & 0x3)); + + return ram_code_ptr; +} + +/* + * This is the critical section of code which should run in TCM and don't + * have any other dependency. It will be runtime copied from linked address + * to TCM address + * Entering it will allow A7 to shutdown highbus. After M4 get wakeup, it + * will request A7 to resume highbus. When exiting, the highbus resouces + * have been live again + */ +static void RAM_Wfi(void) { + + /* + * Use MU to tell A7 high bus can be released + * Note : Function call is not working in this RAM migrated function + */ + while (0 == (MUB_SR & MU_SR_TEn(0x8 >> LPM_MCORE_MU_CHANNEL))); + MUB->TR[LPM_MCORE_MU_CHANNEL] = MSG_LPM_M4_RELEASE_HIGHBUS; + while ((MUB_SR & MU_SR_EP_MASK) != 0); + + /* + * this WFI will only be wakeup by wakeup interrupt registered + * by "LPM_MCORE_RegisterWakeupInterrupt" + */ + __WFI(); + + /* + * Tell A7 that M4 has return from LPM mode + */ + while (0 == (MUB_SR & MU_SR_TEn(0x8 >> LPM_MCORE_MU_CHANNEL))); + MUB->TR[LPM_MCORE_MU_CHANNEL] = MSG_LPM_M4_RUN; + while ((MUB_SR & MU_SR_EP_MASK) != 0); + /* + * After wakeup, req A7 to resume clock, wait until getting ACK + */ + while (0 == (MUB_SR & MU_SR_TEn(0x8 >> LPM_MCORE_MU_CHANNEL))); + MUB->TR[LPM_MCORE_MU_CHANNEL] = MSG_LPM_M4_REQUEST_HIGHBUS; + while ((MUB_SR & MU_SR_EP_MASK) != 0); + + while (1) + { + if ((MUB_SR & (MU_SR_RFn(0x8 >> LPM_MCORE_MU_CHANNEL))) != 0) + if (MUB->RR[LPM_MCORE_MU_CHANNEL] == MSG_LPM_A7_HIGHBUS_READY) + break; + } + + /* + * manual clear MU pending interrupt + */ + NVIC->ICPR[((uint32_t)(MU_M4_IRQn) >> 5)] = (1 << ((uint32_t)(MU_M4_IRQn) & 0x1F)); +} + +/* + * Stub function which only serves as the end address of function "RAM_Wfi" + */ +static void RAM_Wfi_End(void) +{ + return; +} + +/*! + * @brief Check if "RAM_Wfi" is located inside TCM, if not so, copy it to TCM + */ +void prepare_ram_wfi() +{ + if (((uint32_t)RAM_Wfi < 0x1FFF8000) || ((uint32_t)RAM_Wfi > 0x20007FFF)) + // If no, copy the RAM_Wfi function to TCM. + runInRAM = (void(*)(void))RAM_Function_Copy((uint8_t *)RAM_Wfi, + (uint8_t *)RAM_Wfi_End); + else + // If yes, just assign RAM_Wfi to runInRAM pointer. + runInRAM = RAM_Wfi; +} + +/* + * initialize the wakeup interrupt list + */ +static void lpm_init_wakeup_interrupt_list() { + g_wakeup_int_list = NULL; +} + +/* + * add a new irq to wakeup interrupt link list + */ +static void lpm_add_wakeup_interrupt_list(uint32_t irq_no) +{ + P_WAKEUP_INT_ELE cur_ele = g_wakeup_int_list; + P_WAKEUP_INT_ELE p; + + if (cur_ele == NULL) { + /* + * first element to add + */ + p = pvPortMalloc(sizeof(WAKEUP_INT_ELE)); + p->irq_no = irq_no; + p->next = NULL; + g_wakeup_int_list = p; + } else { + for (;;) { + if (cur_ele->irq_no == irq_no) { + /* + * already in the link list + * - return directly + */ + break; + } + else if (cur_ele->next == NULL) { + /* + * can't find the element + * - insert into the end + */ + p = pvPortMalloc(sizeof(WAKEUP_INT_ELE)); + p->irq_no = irq_no; + p->next = NULL; + cur_ele->next = p; + } else { + cur_ele = cur_ele->next; + } + } + } +} + +/* + * remove an exsiting irq to wakeup interrupt link list + */ +static void lpm_del_wakeup_interrupt_list(uint32_t irq_no) +{ + P_WAKEUP_INT_ELE cur_ele = g_wakeup_int_list; + P_WAKEUP_INT_ELE p; + + if (cur_ele != NULL) { + if (cur_ele->irq_no == irq_no) { + /*first element is the target*/ + p = g_wakeup_int_list; + g_wakeup_int_list = p->next; + vPortFree(p); + } else { + for (;;) { + p = cur_ele->next; + if (p == NULL) { + /* + * can't find the element + * - return directly + */ + break; + } else { + if (p->irq_no == irq_no) { + /* + * Find the target "p" + */ + cur_ele->next = p->next; + vPortFree(p); + break; + } else { + cur_ele = cur_ele->next; + } + } + } + } + } +} + + +/* + * register a IRQ source as M4 wakeup source + */ +void LPM_MCORE_RegisterWakeupInterrupt(GPC_Type * base, uint32_t irq_no, GPC_IRQ_WAKEUP_MODE wakeup_mode) +{ + /*register wakeup interrupt for M4 in GPC*/ + GPC_EnableM4WakeupIRQ(base, irq_no, wakeup_mode); + + if (wakeup_mode == GPC_IRQ_WAKEUP_ENABLE) { + /*add an element to link list*/ + lpm_add_wakeup_interrupt_list(irq_no); + } else { + /*delete an element to link list*/ + lpm_del_wakeup_interrupt_list(irq_no); + } +} + + +/* + * Low Power Management initialization + */ +void LPM_MCORE_Init(GPC_Type * base) +{ + // Init GPC + GPC_Init(base); + + // Copy critical function to TCM Space + prepare_ram_wfi(); + + // Init the wakeup interrupt link list + lpm_init_wakeup_interrupt_list(); + + // GPT4 Patch, see function implementation for details + GPT_Patch_Prepare(); +} + + +/* + * get the current m4 LPM state + */ +LPM_POWER_STATUS_M4 LPM_MCORE_GetPowerStatus(GPC_Type * base) +{ + return m4_lpm_state; +} + +/* + * on-the-fly change m4 parent clock between 24MHz and 240MHz + */ +void LPM_MCORE_ChangeM4Clock(LPM_M4_CLOCK_SPEED target) +{ + // change CCM Root to change M4 clock + switch (target) { + case LPM_M4_LOW_FREQ: + if (CCM_GetRootMux(CCM, ccmRootM4) != ccmRootmuxM4Osc24m) { + #if (defined(LPM_MCORE_PRINT_DEBUG_INFO) && (LPM_MCORE_PRINT_DEBUG_INFO)) + PRINTF("Change M4 clock freq to 24M\r\n"); + #endif + CCM_SetRootMux(CCM, ccmRootM4, ccmRootmuxM4Osc24m); + } + break; + case LPM_M4_HIGH_FREQ: + if (CCM_GetRootMux(CCM, ccmRootM4) != ccmRootmuxM4SysPllDiv2) { + #if (defined(LPM_MCORE_PRINT_DEBUG_INFO) && (LPM_MCORE_PRINT_DEBUG_INFO)) + PRINTF("Change M4 clock freq to SysPLL Div2 (240M)\r\n"); + #endif + CCM_SetRootMux(CCM, ccmRootM4, ccmRootmuxM4SysPllDiv2); + } + break; + default: + break; + } +#if (defined(LPM_MCORE_PRINT_DEBUG_INFO) && (LPM_MCORE_PRINT_DEBUG_INFO)) + verify_clock_speed(); +#endif +} + +/* + * cycle M4 low power mode to next state, the state machine is + * + * +---> "RUN" ---> "WAIT" ---> "STOP" ---+ + * | | + * +--------------------------------------+ + */ +void LPM_MCORE_SetPowerStatus(GPC_Type * base, LPM_POWER_STATUS_M4 m4_next_lpm) +{ + uint32_t next_lpm = GPC_LPCR_M4_LPM0(0); + switch (m4_next_lpm) { + case LPM_M4_STATE_RUN: + next_lpm = GPC_LPCR_M4_LPM0(0); + break; + case LPM_M4_STATE_WAIT: + next_lpm = GPC_LPCR_M4_LPM0(1); + break; + case LPM_M4_STATE_STOP: + next_lpm = GPC_LPCR_M4_LPM0(2); + break; + default: + break; + } + + /* + * Patch, let GPC-M4 observe the GPR0 interrupt for a period as long + * as 5 32KHz clock cycle before set it to a Low power status + */ + if (m4_next_lpm != LPM_M4_STATE_RUN) + { + uint32_t i; + LPM_MCORE_RegisterWakeupInterrupt(GPC, GPT4_IRQn, GPC_IRQ_WAKEUP_ENABLE); + for (i=0; i!=GPC_SYNC_DELAY_CNT; i++) + __NOP(); + LPM_MCORE_RegisterWakeupInterrupt(GPC, GPT4_IRQn, GPC_IRQ_WAKEUP_DISABLE); + } + + GPC_SetM4NextLPM(base, next_lpm); + + /*change lpm state variable*/ + m4_lpm_state = m4_next_lpm; +} + + + +/* + * Give readable string of current M4 lpm state + */ +const char* LPM_MCORE_GetPowerStatusString(void) +{ + switch (m4_lpm_state) { + case LPM_M4_STATE_RUN: + return "RUN"; + case LPM_M4_STATE_WAIT: + return "WAIT"; + case LPM_M4_STATE_STOP: + return "STOP"; + default: + return "UNKNOWN"; + } +} + +/* + * Check if A7 LPM Driver is ready, an "Once Ready, Always Ready" logic is used + */ +uint32_t LPM_MCORE_CheckPeerReady(void) +{ + static uint32_t a7_ready = 0; + if (!a7_ready) { + a7_ready = MU_GetFlags(MUB) & MU_SR_Fn(1); + } + return a7_ready; +} + +/* + * Use MU Flag to indicate to A7 that low power management in M4 is ready + */ +void LPM_MCORE_SetSelfReady(void) +{ + MU_SetFlags(MUB, MU_CR_Fn(1)); +} + +/* + * This function modify BASEPRI to configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY and + * wakeup interrupt's NVIC->Priority to configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY - 1 + * The effect is all non-wakeup interrupt gets mute + * The original basepri settings are stored into pBasepriBackup + * The original wakeup interrupt nvic->priority settings are stored into linklist + */ +void lpm_disable_non_wakeup_interrupt(uint32_t* pBasepriBackup) +{ + P_WAKEUP_INT_ELE ele; + uint32_t irq_no; +#if defined(__CC_ARM) + register uint32_t __regBasePri __ASM("basepri"); + *pBasepriBackup = __regBasePri; + __regBasePri = (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - __NVIC_PRIO_BITS)); +#else + *pBasepriBackup = __get_BASEPRI(); + __set_BASEPRI(configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - __NVIC_PRIO_BITS)); +#endif + /* + * Make exceptions to wakeup interrupts, they are stored in "g_wakeup_int_list" + */ + ele = g_wakeup_int_list; + for (;;) { + if (ele == NULL) + break; + + /* + * Store the current Priority into ele backup field + * Change the Priority to "configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY - 1" + */ + irq_no = ele->irq_no; + ele->irq_priority_backup = NVIC->IP[irq_no]; + NVIC->IP[irq_no] = (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY - 1) << (8 - __NVIC_PRIO_BITS); + + /* + * Move to next + */ + ele = ele->next; + } + __DSB(); + __ISB(); +} + +/* + * This function restores BASEPRI and wakeup interrupt nvic priority settings + * It recover interrupt settings made by lpm_disable_non_wakeup_interrupt + */ +void lpm_enable_non_wakeup_interrupt(uint32_t basePriBackup) +{ + P_WAKEUP_INT_ELE ele; + uint32_t irq_no; +#if defined(__CC_ARM) + register uint32_t __regBasePri __ASM("basepri"); +#endif + /* + * first restore wakeup interrupt priority + */ + ele = g_wakeup_int_list; + for (;;) { + if (ele == NULL) + break; + + /* + * Restore the original priority + */ + irq_no = ele->irq_no; + NVIC->IP[irq_no] = ele->irq_priority_backup; + + /* + * Move to next + */ + ele = ele->next; + } +#if defined(__CC_ARM) + __regBasePri = basePriBackup & 0xFF; +#else + __set_BASEPRI(basePriBackup); +#endif + // infinite_loop(); + // Are these necessary? + __DSB(); + __ISB(); +} + + +/* + * The sleep function inserted into FreeRTOS idle task hook + */ +void LPM_MCORE_WaitForInt(void) +{ + uint32_t priMaskBackup; + + /* + * Only when + * 1. A7 peer is ready + * 2. safe sleep function has been put into TCM + * 3. m4 true sleep mode has been allowed + * 4. m4 current lpm mode is wait / stop + * The "power save wfi" routine will be executed + * Otherwise "normal wfi" will be executed + * + * In Power Save WFI + * - PRIMASK is set, so all interrupt handler won't be executed + * - BASEPRI and NVIC->Priority is modified so that only wakeup interrupt can + * wake up M4 from WFI + * - After M4 wake up, NVIC->Priority, BASEPRI and PRIMASK are restored so that + * the system return to normal mode + * + * There is a critical section code which is in "runInRAM", inside it M4 will + * inform A7 it release the high bus. A7 can then shutdown the high bus which + * will make all highbus related peripherals losing functionality, including + * DDR, so code in "runInRAM" should run in TCM and don't have any access to + * other part of memory + */ + if (LPM_MCORE_CheckPeerReady() && (runInRAM != NULL)) + { + volatile uint32_t* reg_lpcr_m4 = &GPC->LPCR_M4; + + uint32_t next_lpm_mode = *reg_lpcr_m4 & GPC_LPCR_M4_LPM0_MASK; + uint32_t basePriBackup; + + /* Save current PRIMASK value. */ + priMaskBackup = __get_PRIMASK(); + + /* + * Set PRIMASK to avoid execution of any enabled ISR. + * Note : PRIMASK will not prevent interrupt to wake up M4 from WFI + * but it will prevent interrupt handler from running + */ + __set_PRIMASK(1); + /* Barriers are normally not required but do ensure the code is completely + * within the specified behaviour for the architecture. + */ + __DSB(); + __ISB(); + /* + * Some of the code should be moved out of "runInRAM" + */ + switch (next_lpm_mode) { + case LPCR_M4_RUN: + /* + * STOP -> RUN + */ + /* + * tell A7 the next LPM mode is RUN + */ + /* + * the WFI will be wakeup by any enabled interrupt + */ + __WFI(); + break; + case LPCR_M4_WAIT: + case LPCR_M4_STOP: + /* + * RUN -> WAIT or WAIT -> STOP + */ + /* + * tell A7 the next LPM mode is WAIT/STOP + */ + if (next_lpm_mode == LPCR_M4_WAIT) + LPM_MCORE_SendMessage(MSG_LPM_M4_WAIT); + else if (next_lpm_mode == LPCR_M4_STOP) + LPM_MCORE_SendMessage(MSG_LPM_M4_STOP); + /* + * do modification to BASEPRI and NVIC->Priority settings so that + * all interrupt except wakeup interrupt are disabled + */ + lpm_disable_non_wakeup_interrupt(&basePriBackup); + + /* + * Inside "runInRAM", M4 will inform A7 that it release the highbus. Later + * when M4 is waken up, it will request A7 to resume highbus. This section + * of code must run in TCM to avoid accessing highbus dependent resouces + */ + runInRAM(); + + // Restore Basepri and NVIC->Priority settings + lpm_enable_non_wakeup_interrupt(basePriBackup); + break; + default: + break; + } + /* + * Recover PRIMASK register value. this will enable the wakeup interrupt + * handler and will activate the main task immediately + */ + __set_PRIMASK(priMaskBackup); + + /* Barriers are normally not required but do ensure the code is completely + * within the specified behaviour for the architecture. */ + __DSB(); + __ISB(); + } + else { + /* + * Normal WFI which will be wakeup by any enabled interrupt + */ + __WFI(); + } +} + +/* + * This function implement a patch for "TO1.1" chips + * - In "TO1.1" chips. Everytime a WFI is executed, IC set an internal + * "dsm-request" signal. The signal is NOT deasserted when WFI is + * executed, until a GPC wakeup interrupt happens. When this signal + * asserts, setting "LPM_M4" to "WAIT" or "STOP" will immediately + * cause the M4 core enter sleep mode, rather than the next time "WFI" + * is executed. Only a wakeup interrupt can clear the "dsm-request" signal + * + * - The issue is like IC Errata ticket "ERR007265" in i.MX6 + * + * - As suggested by IC, software should let GPC observe an interrupt long + * enough before setting "LPM_M4". Here we utilize an GPT to trigger this + * interrupt. + * + * An GPT will be configured to generate a interrupt at the very beginning, + * this interrupt is masked by M4 NVIC so M4 will not respond to it. But + * every time M4 is wake up, before the next time GPC.LPM_M4 is modified, + * GPC.M4_IMR will be set to unmask this pending interrupt to GPC module + * only, the IRQ will be unmasked for a interval long enough (longer than + * 5 32K clock cycle as suggested by IC) and then be masked again. + * + * - The function configures GPTB to generate a pending interrupt. + */ +static void GPT_Patch_Prepare(void) { + uint64_t counter = 24000 * 5; /* Requrie 5ms to generate the pending interrupt*/ + uint32_t high; + uint32_t div24m, div; + + gpt_init_config_t config = { + .freeRun = false, + .waitEnable = true, + .stopEnable = true, + .dozeEnable = true, + .dbgEnable = false, + .enableMode = true + }; + + GPT_Init(BOARD_GPTB_BASEADDR, &config); + + /* Set GPT clock source to 24M OSC */ + GPT_SetClockSource(BOARD_GPTB_BASEADDR, gptClockSourceOsc); + + /* Get the value that exceed maximum register counter */ + high = (uint32_t)(counter >> 32); + + div24m = MAXIMUM_24M_DIV; /*Since we use 24MHz as GPT peripheral clock, here we set the 24M divider to maximum value*/ + div = high / (div24m + 1); /* Get PRESCALER value */ + + /* Now set prescaler */ + GPT_SetOscPrescaler(BOARD_GPTB_BASEADDR, div24m); + GPT_SetPrescaler(BOARD_GPTB_BASEADDR, div); + + /* Set GPT compare value */ + GPT_SetOutputCompareValue(BOARD_GPTB_BASEADDR, gptOutputCompareChannel1, + (uint32_t)(counter / (div24m + 1) / (div + 1))); + + /* Enable GPT Output Compare1 interrupt */ + GPT_SetIntCmd(BOARD_GPTB_BASEADDR, gptStatusFlagOutputCompare1, true); + + /* GPT start */ + GPT_Enable(BOARD_GPTB_BASEADDR); + + /* Wait until timer reaches*/ + while ((BOARD_GPTB_BASEADDR->SR & gptStatusFlagOutputCompare1) == gptStatusFlagOutputCompare1) { + GPT_Disable(BOARD_GPTB_BASEADDR); + } +} diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/lpm_mcore.h b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/lpm_mcore.h new file mode 100644 index 000000000..6a7a843a6 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/common/lpm_mcore.h @@ -0,0 +1,132 @@ +/* + * 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 __LPM_MCORE_H__ +#define __LPM_MCORE_H__ + +#include "gpc.h" +#include "device_imx.h" + +#define DELAY_LOOP_CNT_LOW_SPEED 10 +#define DELAY_CNT 100 + +#define LPCR_M4_RUN 0 +#define LPCR_M4_WAIT 1 +#define LPCR_M4_STOP 2 + +#define LPM_MCORE_MU_CHANNEL 0 + +#define LPM_MCORE_PRINT_DEBUG_INFO 0 + +#define MSG_LPM_M4_RUN 0x5A5A0001 +#define MSG_LPM_M4_WAIT 0x5A5A0002 +#define MSG_LPM_M4_STOP 0x5A5A0003 + +#define MSG_LPM_M4_REQUEST_HIGHBUS 0x2222CCCC +#define MSG_LPM_M4_RELEASE_HIGHBUS 0x2222BBBB + +#define MSG_LPM_A7_HIGHBUS_READY 0xFFFF6666 + +#define GPC_SYNC_DELAY_CNT 65536 + +/* + * LPM state of M4 core + */ +typedef enum lpm_power_status_m4 { + LPM_M4_STATE_RUN, + LPM_M4_STATE_WAIT, + LPM_M4_STATE_STOP, +} LPM_POWER_STATUS_M4; + +/* + * Clock Speed of M4 core + */ +typedef enum lpm_m4_clock_speed { + LPM_M4_HIGH_FREQ, + LPM_M4_LOW_FREQ +} LPM_M4_CLOCK_SPEED; + +/* + * Linklist of wakeup interrupt + */ +typedef struct wakeup_int_ele WAKEUP_INT_ELE, *P_WAKEUP_INT_ELE; +struct wakeup_int_ele { + P_WAKEUP_INT_ELE next; + uint32_t irq_no; + uint32_t irq_priority_backup; +}; + +/* + * low power driver initialization + */ +void LPM_MCORE_Init(GPC_Type * base); + +/* + * get the current lpm state of M4 core + */ +LPM_POWER_STATUS_M4 LPM_MCORE_GetPowerStatus(GPC_Type * base); + +/* + * set the next lpm state of M4 core, the state will be entered + * next time WFI is executed + */ +void LPM_MCORE_SetPowerStatus(GPC_Type * base, LPM_POWER_STATUS_M4 m4_next_lpm); + +/* + * provide readable information of current m4 core lpm state + */ +const char* LPM_MCORE_GetPowerStatusString(void); + +/* + * register/unregister a peripherail interrupt to M4 core wakeup interrupt + */ +void LPM_MCORE_RegisterWakeupInterrupt(GPC_Type * base, uint32_t irq_no, GPC_IRQ_WAKEUP_MODE wakeup_mode); + +/* + * change the m4 core clock between 24MHz(OSC) and 240MHz (SysPllDiv2) + */ +void LPM_MCORE_ChangeM4Clock(LPM_M4_CLOCK_SPEED target); + +/* + * Check if A7 LPM driver is ready + */ +uint32_t LPM_MCORE_CheckPeerReady(void); + +/* + * Set M4 LPM driver ready flag to A7 Peer + */ +void LPM_MCORE_SetSelfReady(void); + +/* + * Function to inserted into FreeRTOS idletask hook + */ +void LPM_MCORE_WaitForInt(void); + +#endif diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/FreeRTOSConfig.h new file mode 100644 index 000000000..416dbb2aa --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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 +#endif + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 1 +#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 0 +#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 2 + +/* 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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt new file mode 100644 index 000000000..f8bb57774 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt @@ -0,0 +1,178 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../common) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../common) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(rand_wfi_imx7d + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../main.c" + "${ProjDirPath}/../../common/gpc.c" + "${ProjDirPath}/../../common/gpc.h" + "${ProjDirPath}/../../common/lpm_mcore.c" + "${ProjDirPath}/../../common/lpm_mcore.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../gpt_timer.c" + "${ProjDirPath}/../gpt_timer.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/gpt.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/gpt.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/mu_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/mu_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc_semaphore.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_semaphore.h" +) +SET_TARGET_PROPERTIES(rand_wfi_imx7d PROPERTIES OUTPUT_NAME "rand_wfi_imx7d.elf") + +TARGET_LINK_LIBRARIES(rand_wfi_imx7d -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(rand_wfi_imx7d m) +TARGET_LINK_LIBRARIES(rand_wfi_imx7d c) +TARGET_LINK_LIBRARIES(rand_wfi_imx7d gcc) +TARGET_LINK_LIBRARIES(rand_wfi_imx7d nosys) +TARGET_LINK_LIBRARIES(rand_wfi_imx7d -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/rand_wfi_imx7d.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/rand_wfi_imx7d.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET rand_wfi_imx7d POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/rand_wfi_imx7d.elf ${EXECUTABLE_OUTPUT_PATH}/rand_wfi_imx7d.hex) +ADD_CUSTOM_COMMAND(TARGET rand_wfi_imx7d POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/rand_wfi_imx7d.elf ${EXECUTABLE_OUTPUT_PATH}/rand_wfi_imx7d.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/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/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject new file mode 100644 index 000000000..9c643250d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project new file mode 100644 index 000000000..f84699736 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project @@ -0,0 +1,86 @@ + + + rand_wfi_imx7d_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.csource2virtual:/virtualsource/gpc.c1PARENT-2-PROJECT_LOC/common/gpc.csource2virtual:/virtualsource/gpc.h1PARENT-2-PROJECT_LOC/common/gpc.hsource2virtual:/virtualsource/lpm_mcore.c1PARENT-2-PROJECT_LOC/common/lpm_mcore.csource2virtual:/virtualsource/lpm_mcore.h1PARENT-2-PROJECT_LOC/common/lpm_mcore.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cboard2virtual:/virtualboard/gpio_pins.c1PARENT-4-PROJECT_LOC/gpio_pins.cboard2virtual:/virtualboard/gpio_pins.h1PARENT-4-PROJECT_LOC/gpio_pins.htimer2virtual:/virtualtimer/gpt_timer.c1PARENT-1-PROJECT_LOC/gpt_timer.ctimer2virtual:/virtualtimer/gpt_timer.h1PARENT-1-PROJECT_LOC/gpt_timer.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.hdriver2virtual:/virtualdriver/gpt.c1PARENT-6-PROJECT_LOC/platform/drivers/src/gpt.cdriver2virtual:/virtualdriver/gpt.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/gpt.hdriver2virtual:/virtualdriver/mu_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/mu_imx.cdriver2virtual:/virtualdriver/mu_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/mu_imx.hdriver2virtual:/virtualdriver/rdc_semaphore.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc_semaphore.cdriver2virtual:/virtualdriver/rdc_semaphore.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_semaphore.h + + + diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c new file mode 100644 index 000000000..e26407255 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c @@ -0,0 +1,132 @@ +/* + * 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 "FreeRTOS.h" +#include "semphr.h" +#include "gpt.h" +#include "gpt_timer.h" +#include "board.h" + +#define MAXIMUM_24M_DIV 15 + +static SemaphoreHandle_t xSemaphore; + +void GPT_Timer_Init() +{ + gpt_init_config_t config = { + .freeRun = false, + .waitEnable = true, + .stopEnable = true, + .dozeEnable = true, + .dbgEnable = false, + .enableMode = true + }; + + xSemaphore = xSemaphoreCreateBinary(); + + /* Initialize GPT module */ + GPT_Init(BOARD_GPTA_BASEADDR, &config); + + /* Set GPT clock source to 24M OSC */ + GPT_SetClockSource(BOARD_GPTA_BASEADDR, gptClockSourceOsc); + + /* Set GPT interrupt priority 3 */ + NVIC_SetPriority(BOARD_GPTA_IRQ_NUM, 3); + + /* Enable NVIC interrupt */ + NVIC_EnableIRQ(BOARD_GPTA_IRQ_NUM); +} + +/* + * Set GPT to triggle interrupt in future time + */ +void GPT_Set_Timer_Delay(uint32_t ms) +{ + uint64_t counter = 24000ULL * ms; /* First get the counter needed by delay time */ + uint32_t high; + uint32_t div24m, div; + + /* Get the value that exceed maximum register counter */ + high = (uint32_t)(counter >> 32); + + div24m = MAXIMUM_24M_DIV; /*Since we use 24MHz as GPT peripheral clock, here we set the 24M divider to maximum value*/ + div = high / (div24m + 1); /* Get PRESCALER value */ + + /* Now set prescaler */ + GPT_SetOscPrescaler(BOARD_GPTA_BASEADDR, div24m); + GPT_SetPrescaler(BOARD_GPTA_BASEADDR, div); + + /* Set GPT compare value */ + GPT_SetOutputCompareValue(BOARD_GPTA_BASEADDR, gptOutputCompareChannel1, + (uint32_t)(counter / (div24m + 1) / (div + 1))); + + /* Enable GPT Output Compare1 interrupt */ + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, true); + + /* GPT start */ + GPT_Enable(BOARD_GPTA_BASEADDR); +} + +/* + * Block the current task until GPT interrupt happens + */ +void GPT_Wait_Timer_Expire(void) +{ + /* Wait until next GPT event happens. */ + xSemaphoreTake(xSemaphore, portMAX_DELAY); +} + +/* + * GPT Interrupt Handler + */ +void BOARD_GPTA_HANDLER() +{ + BaseType_t xHigherPriorityTaskWoken; + + /* When GPT timeout, we disable GPT to make sure this is a oneshot event */ + GPT_Disable(BOARD_GPTA_BASEADDR); + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, false); + GPT_ClearStatusFlag(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1); + + xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken); + /*portYIELD_FROM_ISR is necessary to activate task switch immediately*/ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h new file mode 100644 index 000000000..0bab0ffae --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h @@ -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. + */ + +#ifndef __GPT_TIMER_H__ +#define __GPT_TIMER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * @brief Initialize GPT timer, must be called before GPT_Timer_Delay(). + */ +void GPT_Timer_Init(void); + +/*! + * @brief Block task for some time with GPT, this timer is not multi-thread + * safe and could only called in one task. + * + * @param ms milliseconds to delay + */ +void GPT_Set_Timer_Delay(uint32_t ms); + +void GPT_Wait_Timer_Expire(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __GPT_TIMER_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/hardware_init.c new file mode 100644 index 000000000..87a693d22 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/hardware_init.c @@ -0,0 +1,92 @@ +/* + * 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 "board.h" +#include "gpio_pins.h" + +void hardware_init(void) +{ + uint32_t i; + /* + * Set GPC_LPCR_M4 to run. In Low Power Demo, when M4 enters STOP, the + * whole system may enter DSM. A7 will rekick A7 after exit DSM. GPC + * register status will not auto reset so a manual reset is performed + * here + * GPC RDC is default set by U-Boot to be shared by A7 and M4 + */ + GPC_LPCR_M4 = GPC_LPCR_M4 & (~GPC_LPCR_M4_LPM0_MASK); + + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* + * In order to wakeup M4 from LPM, all PLLCTRLs need to be set to "NeededRun" + */ + for (i=0; i!=33; i++) { + CCM_BASE_PTR->PLL_CTRL[i].PLL_CTRL = ccmClockNeededRun; + } + + + /* Enable clock gate for wakeup mix*/ + CCM_ControlGate(CCM, BOARD_SIM_WAKEUP_CCGR, ccmClockNeededAll); + + /* initialize debug uart */ + dbg_uart_init(); + + /* In this demo, we need to grasp board GPT exclusively */ + RDC_SetPdapAccess(RDC, BOARD_GPTA_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select GPTA clock derived from OSC24M */ + CCM_UpdateRoot(CCM, BOARD_GPTA_CCM_ROOT, ccmRootmuxGptOsc24m, 0, 0); + + /* Enable clock used by GPTA */ + CCM_EnableRoot(CCM, BOARD_GPTA_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTA_CCM_CCGR, ccmClockNeededAll); + + /* In this demo, we need GPT4 to work as a patch to fix GPC sync issue */ + RDC_SetPdapAccess(RDC, BOARD_GPTB_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select GPTB clock derived from OSC24M */ + CCM_UpdateRoot(CCM, BOARD_GPTB_CCM_ROOT, ccmRootmuxGptOsc24m, 0, 0); + + /* Enable clock used by GPTB */ + CCM_EnableRoot(CCM, BOARD_GPTB_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTB_CCM_CCGR, ccmClockNeededAll); + + /* Enable MU clock*/ + CCM_ControlGate(CCM, BOARD_MU_CCM_CCGR, ccmClockNeededAll); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/main.c b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/main.c new file mode 100644 index 000000000..e53d08bb6 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/low_power_imx7d/rand_wfi/main.c @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2015-2016, 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +// Includes +/////////////////////////////////////////////////////////////////////////////// +#include "FreeRTOS.h" +#include "stdlib.h" +#include "task.h" +#include "board.h" +#include "debug_console_imx.h" +#include "gpt_timer.h" +#include "lpm_mcore.h" +#if defined(__GNUC__) +#include +#include +#endif + +/////////////////////////////////////////////////////////////////////////////// +// Macros +/////////////////////////////////////////////////////////////////////////////// +#define PERIOD_MIN 15 +#define PERIOD_MAX 20 + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +/*! + * @brief Set random time gpt timer to wakeup the system + */ +static uint32_t gpt_set_ramdom_period(uint32_t min_s, uint32_t max_s) +{ + uint32_t delay_s, delta_s; + /*Generate the random number*/ + if (max_s <= min_s) + delay_s = min_s; + else { + delta_s = max_s - min_s; + delay_s = rand() % delta_s + min_s; + } + + /*Set the GPT with delay_s, Taks will blocks until GPT event happens*/ + GPT_Set_Timer_Delay(1000 * delay_s); + return delay_s; +} + +/*! + * @brief the main power mode cycling task + */ +void LowPowerTask(void *pvParameters) +{ + uint32_t elapsed_time, total_time; + char control_char; + + PRINTF("\r\nLow Power Demo\r\n"); + + /* + * Wait For A7 Side Become Ready + */ + PRINTF("********************************\r\n"); + PRINTF("Please wait :\r\n"); + PRINTF(" 1) A7 peer is ready\r\n"); + PRINTF("Then press \"S\" to start the demo\r\n"); + PRINTF("********************************\r\n"); + + for (;;) { + PRINTF("\r\nPress \"S\" to start the demo : "); + control_char = GETCHAR(); + PRINTF("%c", control_char); + if ((control_char == 's') || (control_char == 'S')) { + break; + } + } + PRINTF("\r\n"); + + while (!LPM_MCORE_CheckPeerReady()) { + /* + * Note, when vTaskDelay is called, idle task hook function + * get opportunity to run + */ + vTaskDelay(5); + } + + LPM_MCORE_RegisterWakeupInterrupt(BOARD_GPC_BASEADDR, BOARD_GPTA_IRQ_NUM, GPC_IRQ_WAKEUP_ENABLE); + + LPM_MCORE_SetSelfReady(); + + total_time = 0; + while(1) + { + switch (LPM_MCORE_GetPowerStatus(BOARD_GPC_BASEADDR)) { + case LPM_M4_STATE_RUN: + /*---> WAIT*/ + LPM_MCORE_ChangeM4Clock(LPM_M4_LOW_FREQ); + LPM_MCORE_SetPowerStatus(BOARD_GPC_BASEADDR, LPM_M4_STATE_WAIT); + break; + case LPM_M4_STATE_WAIT: + /*---> STOP*/ + LPM_MCORE_ChangeM4Clock(LPM_M4_LOW_FREQ); + LPM_MCORE_SetPowerStatus(BOARD_GPC_BASEADDR, LPM_M4_STATE_STOP); + break; + case LPM_M4_STATE_STOP: + /*---> RUN*/ + LPM_MCORE_ChangeM4Clock(LPM_M4_HIGH_FREQ); + LPM_MCORE_SetPowerStatus(BOARD_GPC_BASEADDR, LPM_M4_STATE_RUN); + break; + default: + break; + } + + elapsed_time = gpt_set_ramdom_period(PERIOD_MIN, PERIOD_MAX); + PRINTF("GPT will triggle interrupt in %ds\r\n", elapsed_time); + + PRINTF("go to mode %s\r\n", LPM_MCORE_GetPowerStatusString()); + + /*wait GPT interrupt handler getting executed*/ + GPT_Wait_Timer_Expire(); + total_time += elapsed_time; + PRINTF("GPT Event! Total time %ds\r\n", total_time); + } +} + +/*! + * @brief Custom function to be run in idletask + */ +void vApplicationIdleHook(void) +{ + /* Waiting for Wake up event. */ + LPM_MCORE_WaitForInt(); +} + +/*! + * @brief Main function + */ +int main(void) +{ + // Initialize demo application pins setting and clock setting. + hardware_init(); + + PRINTF(" ************************************************************************\r\n"); + PRINTF(" * i.MX 7Dual Dual Core Low Power Demo - M4 side *\r\n"); + PRINTF(" * *\r\n"); + PRINTF(" * A GPT will change the M4 Power Mode with random period *\r\n"); + PRINTF(" * *\r\n"); + PRINTF(" ************************************************************************\r\n"); + + // Init the GPT Timer + GPT_Timer_Init(); + + // Low Power Management Initialization + LPM_MCORE_Init(BOARD_GPC_BASEADDR); + + // Create a demo task which will demo M4 core cycling through different power modes. + xTaskCreate(LowPowerTask, "Low Power Task", configMINIMAL_STACK_SIZE, // xTaskGenericCreate + NULL, tskIDLE_PRIORITY+1, NULL); + + // Start FreeRTOS scheduler. + vTaskStartScheduler(); + + // Should never reach this point. + while (true); +} + +#if defined(__GNUC__) +/*! + * @brief Function to override ARMGCC default function _sbrk + * + * _sbrk is called by malloc. ARMGCC default _sbrk compares "SP" register and + * heap end, if heap end is larger than "SP", then _sbrk returns error and + * memory allocation failed. This function changes to compare __HeapLimit with + * heap end. + * + * Then rand() function used in this project will call malloc in GCC compiler, + * so the customized version of _sbrk is needed here + */ +caddr_t _sbrk(int incr) +{ + extern uint32_t end __asm("end"); + extern uint32_t heap_limit __asm("__HeapLimit"); + static uint32_t *heap_end; + char *prev_heap_end; + + if (heap_end == NULL) + heap_end = &end; + + prev_heap_end = (char*)heap_end; + + if (heap_end + incr > &heap_limit) + { + errno = ENOMEM; + return (caddr_t)-1; + } + + heap_end += incr; + + return (caddr_t)prev_heap_end; +} +#endif +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf b/examples/var-som-mx7_m4/demo_apps/rpmsg/common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf new file mode 100644 index 000000000..184fbdc21 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf @@ -0,0 +1,90 @@ +#! armcc -E +/* +** ################################################################### +** Processors: MCIMX7D7DVK10SA +** MCIMX7D7DVM10SA +** MCIMX7D3DVK10SA +** MCIMX7D3EVM10SA +** +** Compiler: ARM C/C++ Compiler +** Reference manual: IMX7DRM, Rev.A, February 2015 +** Version: rev. 1.0, 2015-07-08 +** +** Abstract: +** Linker file for the ARM C/C++ Compiler +** +** 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. +** +** http: www.freescale.com +** mail: support@freescale.com +** +** ################################################################### +*/ + +#define m_interrupts_start 0x1FFF8000 +#define m_interrupts_size 0x00000240 + +#define m_text_start 0x1FFF8240 +#define m_text_size 0x00007DC0 + +#define m_data_start 0x20000000 +#define m_data_size 0x8000 + +/* Sizes */ +#if (defined(__stack_size__)) + #define Stack_Size __stack_size__ +#else + #define Stack_Size 0x0400 +#endif + +#if (defined(__heap_size__)) + #define Heap_Size __heap_size__ +#else + #define Heap_Size 0x4000 +#endif + +LR_m_text m_text_start m_text_size { ; load region size_region + ER_m_text m_text_start m_text_size { ; load address = execution address + * (InRoot$$Sections) + .ANY (+RO) + } + RW_m_data m_data_start m_data_size { ; RW data + .ANY (+RW +ZI) + } + ARM_LIB_HEAP m_data_start+m_data_size-Heap_Size-Stack_Size EMPTY Heap_Size { ; Heap region growing up + } + ARM_LIB_STACK m_data_start+m_data_size EMPTY -Stack_Size { ; Stack region growing down + } +} + +LR_m_interrupts m_interrupts_start m_interrupts_size { + VECTOR_ROM m_interrupts_start m_interrupts_size { ; load address = execution address + * (RESET,+FIRST) + } +} diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/CMakeLists.txt new file mode 100644 index 000000000..207d004a3 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/CMakeLists.txt @@ -0,0 +1,172 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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 -fno-strict-aliasing -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 -Xlinker --defsym=__stack_size__=0x400 -Xlinker --defsym=__heap_size__=0x4000") + +# 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 -fno-strict-aliasing -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 -Xlinker --defsym=__stack_size__=0x400 -Xlinker --defsym=__heap_size__=0x4000") + +# 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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(rpmsg_pingpong_bm_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/env.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio_ring.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_rtos.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/remote_device.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../pingpong_bm.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/mu_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/mu_imx.h" +) +SET_TARGET_PROPERTIES(rpmsg_pingpong_bm_example PROPERTIES OUTPUT_NAME "rpmsg_pingpong_bm_example.elf") + +TARGET_LINK_LIBRARIES(rpmsg_pingpong_bm_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(rpmsg_pingpong_bm_example m) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_bm_example c) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_bm_example gcc) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_bm_example nosys) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_bm_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/rpmsg_pingpong_bm_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/rpmsg_pingpong_bm_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET rpmsg_pingpong_bm_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_bm_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_bm_example.hex) +ADD_CUSTOM_COMMAND(TARGET rpmsg_pingpong_bm_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_bm_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_bm_example.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject new file mode 100644 index 000000000..34d735009 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project new file mode 100644 index 000000000..f021611e5 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_pingpong_bm_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.srpmsg2virtual:/virtualrpmsg/platform.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.hrpmsg2virtual:/virtualrpmsg/rpmsg_platform_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.hrpmsg2virtual:/virtualrpmsg/rpmsg.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.hrpmsg2virtual:/virtualrpmsg/rpmsg_ext.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.hrpmsg2virtual:/virtualrpmsg/hil.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.hrpmsg2virtual:/virtualrpmsg/llist.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.hrpmsg2virtual:/virtualrpmsg/sh_mem.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.hrpmsg2virtual:/virtualrpmsg/config.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.hrpmsg2virtual:/virtualrpmsg/env.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/env.hrpmsg2virtual:/virtualrpmsg/rpmsg_core.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.hrpmsg2virtual:/virtualrpmsg/virtio.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.hrpmsg2virtual:/virtualrpmsg/virtio_ring.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio_ring.hrpmsg2virtual:/virtualrpmsg/virtqueue.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.hrpmsg2virtual:/virtualrpmsg/rpmsg_rtos.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.hrpmsg2virtual:/virtualrpmsg/rpmsg_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hrpmsg2virtual:/virtualrpmsg/platform.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.crpmsg2virtual:/virtualrpmsg/platform_info.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.crpmsg2virtual:/virtualrpmsg/hil.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.crpmsg2virtual:/virtualrpmsg/llist.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.crpmsg2virtual:/virtualrpmsg/sh_mem.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.crpmsg2virtual:/virtualrpmsg/config.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.crpmsg2virtual:/virtualrpmsg/remote_device.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/remote_device.crpmsg2virtual:/virtualrpmsg/rpmsg.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.crpmsg2virtual:/virtualrpmsg/rpmsg_ext.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.crpmsg2virtual:/virtualrpmsg/rpmsg_core.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.crpmsg2virtual:/virtualrpmsg/virtio.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.crpmsg2virtual:/virtualrpmsg/virtqueue.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.crpmsg2virtual:/virtualrpmsg/rpmsg_porting.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/pingpong_bm.c1PARENT-1-PROJECT_LOC/pingpong_bm.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.hdriver2virtual:/virtualdriver/mu_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/mu_imx.cdriver2virtual:/virtualdriver/mu_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/mu_imx.h + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/hardware_init.c new file mode 100644 index 000000000..aa6947512 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/hardware_init.c @@ -0,0 +1,54 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* initialize debug uart */ + dbg_uart_init(); + + /* 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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/pingpong_bm.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/pingpong_bm.c new file mode 100644 index 000000000..2051bc286 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_bm/pingpong_bm.c @@ -0,0 +1,148 @@ +/* + * 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +// Includes +/////////////////////////////////////////////////////////////////////////////// +#include +#include "rpmsg/rpmsg.h" +#include "board.h" +#include "mu_imx.h" +#include "debug_console_imx.h" + +//////////////////////////////////////////////////////////////////////////////// +// Definitions +//////////////////////////////////////////////////////////////////////////////// +/* + * APP decided interrupt priority + */ +#define APP_MU_IRQ_PRIORITY 3 + +typedef struct the_message +{ + uint32_t DATA; +} THE_MESSAGE, * THE_MESSAGE_PTR; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// +/* Globals */ +static volatile struct rpmsg_channel *app_chnl; +static volatile int pingpong_finished = 0; +static THE_MESSAGE msg; + +static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len, + void * priv, unsigned long src) +{ + if(len > sizeof(THE_MESSAGE)) + { + PRINTF("Received size %d exceed pingpong buffer size\r\n", len); + return; + } + + /* Drop extra message received after pingpong finished */ + if (pingpong_finished) + return; + + /* Store received message to global buffer */ + memcpy(&msg, data, len); + + PRINTF("Get Data From Master Side : %d\r\n", msg.DATA); + + /* Send the message back to the remoteproc */ + msg.DATA++; + rpmsg_send((struct rpmsg_channel *)app_chnl, &msg, sizeof(THE_MESSAGE)); + + /* Set pingpong_finished to 1 per requirement */ +} + +/* rpmsg_rx_callback will call into this for a channel creation event*/ +static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) +{ + /* We should give the created rp_chnl handler to app layer */ + app_chnl = rp_chnl; + PRINTF("Name service handshake is done, M4 has setup a rpmsg channel [%d ---> %d]\r\n", app_chnl->src, app_chnl->dst); +} + +static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) +{ +} + +/* + * MU Interrrupt ISR + */ +void BOARD_MU_HANDLER(void) +{ + /* + * calls into rpmsg_handler provided by middleware + */ + rpmsg_handler(); +} + +/*! + * @brief Main function + */ +int main (void) +{ + struct remote_device *rdev; + + hardware_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); + + /* Print the initial banner */ + PRINTF("\r\nRPMSG PingPong Bare Metal Demo...\r\n"); + + /* RPMSG Init as REMOTE */ + PRINTF("RPMSG Init as Remote\r\n"); + rpmsg_init(0 /*REMOTE_CPU_ID*/, &rdev, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, RPMSG_MASTER); + + /* wait until the pingpong demo finished */ + while (!pingpong_finished) + { + } + + PRINTF("\r\nMessage pingpong finished\r\n"); + + rpmsg_deinit(rdev); + + return 0; +} + +/******************************************************************************* + * EOF + ******************************************************************************/ + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/FreeRTOSConfig.h new file mode 100644 index 000000000..c57902e47 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_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 +#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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/CMakeLists.txt new file mode 100644 index 000000000..1b912363b --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/CMakeLists.txt @@ -0,0 +1,199 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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 -fno-strict-aliasing -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 -fno-strict-aliasing -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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(rpmsg_pingpong_freertos_example + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../pingpong_freertos.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_rtos.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/env.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio_ring.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_rtos.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/remote_device.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/mu_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/mu_imx.h" +) +SET_TARGET_PROPERTIES(rpmsg_pingpong_freertos_example PROPERTIES OUTPUT_NAME "rpmsg_pingpong_freertos_example.elf") + +TARGET_LINK_LIBRARIES(rpmsg_pingpong_freertos_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(rpmsg_pingpong_freertos_example m) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_freertos_example c) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_freertos_example gcc) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_freertos_example nosys) +TARGET_LINK_LIBRARIES(rpmsg_pingpong_freertos_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/rpmsg_pingpong_freertos_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/rpmsg_pingpong_freertos_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET rpmsg_pingpong_freertos_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_freertos_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_freertos_example.hex) +ADD_CUSTOM_COMMAND(TARGET rpmsg_pingpong_freertos_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_freertos_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_pingpong_freertos_example.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject new file mode 100644 index 000000000..728658c74 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project new file mode 100644 index 000000000..1b4ab5f6f --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_pingpong_freertos_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/pingpong_freertos.c1PARENT-1-PROJECT_LOC/pingpong_freertos.crpmsg2virtual:/virtualrpmsg/rpmsg_rtos.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.hrpmsg2virtual:/virtualrpmsg/platform.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.hrpmsg2virtual:/virtualrpmsg/rpmsg_platform_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.hrpmsg2virtual:/virtualrpmsg/rpmsg.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.hrpmsg2virtual:/virtualrpmsg/rpmsg_ext.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.hrpmsg2virtual:/virtualrpmsg/hil.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.hrpmsg2virtual:/virtualrpmsg/llist.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.hrpmsg2virtual:/virtualrpmsg/sh_mem.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.hrpmsg2virtual:/virtualrpmsg/config.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.hrpmsg2virtual:/virtualrpmsg/env.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/env.hrpmsg2virtual:/virtualrpmsg/rpmsg_core.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.hrpmsg2virtual:/virtualrpmsg/virtio.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.hrpmsg2virtual:/virtualrpmsg/virtio_ring.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio_ring.hrpmsg2virtual:/virtualrpmsg/virtqueue.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.hrpmsg2virtual:/virtualrpmsg/rpmsg_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hrpmsg2virtual:/virtualrpmsg/rpmsg_rtos.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.crpmsg2virtual:/virtualrpmsg/platform.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.crpmsg2virtual:/virtualrpmsg/platform_info.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.crpmsg2virtual:/virtualrpmsg/hil.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.crpmsg2virtual:/virtualrpmsg/llist.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.crpmsg2virtual:/virtualrpmsg/sh_mem.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.crpmsg2virtual:/virtualrpmsg/config.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.crpmsg2virtual:/virtualrpmsg/remote_device.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/remote_device.crpmsg2virtual:/virtualrpmsg/rpmsg.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.crpmsg2virtual:/virtualrpmsg/rpmsg_ext.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.crpmsg2virtual:/virtualrpmsg/rpmsg_core.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.crpmsg2virtual:/virtualrpmsg/virtio.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.crpmsg2virtual:/virtualrpmsg/virtqueue.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.crpmsg2virtual:/virtualrpmsg/rpmsg_porting.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.cfreertos2virtual:/virtualfreertos/croutine.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.hdriver2virtual:/virtualdriver/mu_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/mu_imx.cdriver2virtual:/virtualdriver/mu_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/mu_imx.h + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/hardware_init.c new file mode 100644 index 000000000..aa6947512 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/hardware_init.c @@ -0,0 +1,54 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* initialize debug uart */ + dbg_uart_init(); + + /* 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/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/pingpong_freertos.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/pingpong_freertos.c new file mode 100644 index 000000000..6d0c03d82 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/pingpong_freertos/pingpong_freertos.c @@ -0,0 +1,136 @@ +/* + * 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +// Includes +/////////////////////////////////////////////////////////////////////////////// +#include "rpmsg/rpmsg_rtos.h" +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "board.h" +#include "mu_imx.h" +#include "debug_console_imx.h" + +//////////////////////////////////////////////////////////////////////////////// +// Definitions +//////////////////////////////////////////////////////////////////////////////// +#define APP_TASK_STACK_SIZE 256 + +/* + * APP decided interrupt priority + */ +#define APP_MU_IRQ_PRIORITY 3 + +typedef struct the_message +{ + uint32_t DATA; +} THE_MESSAGE, * THE_MESSAGE_PTR; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +static void PingPongTask (void* param) +{ + int result; + struct remote_device *rdev = NULL; + struct rpmsg_channel *app_chnl = NULL; + THE_MESSAGE msg = {0}; + int len; + + /* Print the initial banner */ + PRINTF("\r\nRPMSG PingPong FreeRTOS RTOS API Demo...\r\n"); + + PRINTF("RPMSG Init as Remote\r\n"); + result = rpmsg_rtos_init(0 /*REMOTE_CPU_ID*/, &rdev, RPMSG_MASTER, &app_chnl); + assert(0 == result); + + PRINTF("Name service handshake is done, M4 has setup a rpmsg channel [%d ---> %d]\r\n", app_chnl->src, app_chnl->dst); + + while (true) + { + /* receive/send data to channel default ept */ + result = rpmsg_rtos_recv(app_chnl->rp_ept, &msg, &len, sizeof(THE_MESSAGE), NULL, 0xFFFFFFFF); + assert(0 == result); + PRINTF("Get Data From Master Side : %d\r\n", msg.DATA); + msg.DATA++; + result = rpmsg_rtos_send(app_chnl->rp_ept, &msg, sizeof(THE_MESSAGE), app_chnl->dst); + assert(0 == result); + } + + /* If destruction required */ + /* + PRINTF("\r\nMessage pingpong finished\r\n"); + + rpmsg_rtos_deinit(rdev); + */ +} + +/* + * MU Interrrupt ISR + */ +void BOARD_MU_HANDLER(void) +{ + /* + * calls into rpmsg_handler provided by middleware + */ + rpmsg_handler(); +} + +/*! + * @brief Main function + */ +int main (void) +{ + hardware_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(PingPongTask, "Ping Pong Task", APP_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL); + + /* Start FreeRTOS scheduler. */ + vTaskStartScheduler(); + + /* Should never reach this point. */ + while(true); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/CMakeLists.txt new file mode 100644 index 000000000..eae2fa59b --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/CMakeLists.txt @@ -0,0 +1,172 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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 -fno-strict-aliasing -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 -Xlinker --defsym=__stack_size__=0x400 -Xlinker --defsym=__heap_size__=0x4000") + +# 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 -fno-strict-aliasing -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 -Xlinker --defsym=__stack_size__=0x400 -Xlinker --defsym=__heap_size__=0x4000") + +# 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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(rpmsg_str_echo_bm_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/env.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio_ring.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_rtos.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/remote_device.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../str_echo_bm.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/mu_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/mu_imx.h" +) +SET_TARGET_PROPERTIES(rpmsg_str_echo_bm_example PROPERTIES OUTPUT_NAME "rpmsg_str_echo_bm_example.elf") + +TARGET_LINK_LIBRARIES(rpmsg_str_echo_bm_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(rpmsg_str_echo_bm_example m) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_bm_example c) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_bm_example gcc) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_bm_example nosys) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_bm_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/rpmsg_str_echo_bm_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/rpmsg_str_echo_bm_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET rpmsg_str_echo_bm_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_bm_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_bm_example.hex) +ADD_CUSTOM_COMMAND(TARGET rpmsg_str_echo_bm_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_bm_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_bm_example.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject new file mode 100644 index 000000000..7e08b2b7d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project new file mode 100644 index 000000000..56e280da0 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_str_echo_bm_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.srpmsg2virtual:/virtualrpmsg/platform.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.hrpmsg2virtual:/virtualrpmsg/rpmsg_platform_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.hrpmsg2virtual:/virtualrpmsg/rpmsg.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.hrpmsg2virtual:/virtualrpmsg/rpmsg_ext.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.hrpmsg2virtual:/virtualrpmsg/hil.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.hrpmsg2virtual:/virtualrpmsg/llist.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.hrpmsg2virtual:/virtualrpmsg/sh_mem.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.hrpmsg2virtual:/virtualrpmsg/config.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.hrpmsg2virtual:/virtualrpmsg/env.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/env.hrpmsg2virtual:/virtualrpmsg/rpmsg_core.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.hrpmsg2virtual:/virtualrpmsg/virtio.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.hrpmsg2virtual:/virtualrpmsg/virtio_ring.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio_ring.hrpmsg2virtual:/virtualrpmsg/virtqueue.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.hrpmsg2virtual:/virtualrpmsg/rpmsg_rtos.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.hrpmsg2virtual:/virtualrpmsg/rpmsg_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hrpmsg2virtual:/virtualrpmsg/platform.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.crpmsg2virtual:/virtualrpmsg/platform_info.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.crpmsg2virtual:/virtualrpmsg/hil.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.crpmsg2virtual:/virtualrpmsg/llist.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.crpmsg2virtual:/virtualrpmsg/sh_mem.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.crpmsg2virtual:/virtualrpmsg/config.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.crpmsg2virtual:/virtualrpmsg/remote_device.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/remote_device.crpmsg2virtual:/virtualrpmsg/rpmsg.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.crpmsg2virtual:/virtualrpmsg/rpmsg_ext.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.crpmsg2virtual:/virtualrpmsg/rpmsg_core.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.crpmsg2virtual:/virtualrpmsg/virtio.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.crpmsg2virtual:/virtualrpmsg/virtqueue.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.crpmsg2virtual:/virtualrpmsg/rpmsg_porting.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/bm/rpmsg_porting.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/str_echo_bm.c1PARENT-1-PROJECT_LOC/str_echo_bm.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.hdriver2virtual:/virtualdriver/mu_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/mu_imx.cdriver2virtual:/virtualdriver/mu_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/mu_imx.h + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/hardware_init.c new file mode 100644 index 000000000..aa6947512 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/hardware_init.c @@ -0,0 +1,54 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* initialize debug uart */ + dbg_uart_init(); + + /* 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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/str_echo_bm.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/str_echo_bm.c new file mode 100644 index 000000000..c96d5050c --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_bm/str_echo_bm.c @@ -0,0 +1,205 @@ +/* + * 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 "rpmsg/rpmsg_ext.h" +#include "string.h" +#include "assert.h" +#include "board.h" +#include "mu_imx.h" +#include "debug_console_imx.h" + +/* + * APP decided interrupt priority + */ +#define APP_MU_IRQ_PRIORITY 3 + +/* + * For the most worst case, master will send 3 consecutive messages which remote + * do not process. + * The synchronization between remote and master is that each time endpoint callback + * is called, the MU Receive interrupt is temperorily disabled. Until the next time + * remote consumes the message, the interrupt will not be enabled again. + * When the interrupt is not enabled, Master can not send the notify, it will blocks + * there and can not send further message. + * In the worst case, master send the first message, it triggles the ISR in remote + * side, remote ISR clear the MU status bit so master can send the second message + * and notify again, master can continue to send the 3rd message but will blocks + * when trying to notify. Meanwhile, remote side is still in the first ISR which + * has a loop to receive all the 3 messages. + * Master is blocked and can not send the 4th message, remote side ISR stores all + * this 3 messages to app buffer and informs the app layer to consume them. After + * 3 messages are consumed, the ISR is enabled again and the second notify is received. + * This unblocks the master to complete the 3rd notify and send the 4th message. + * The situation goes on and we can see application layer need a maximum size 3 + * buffer to hold the unconsumed messages. STRING_BUFFER_CNT is therefore set to 3 + */ +#define STRING_BUFFER_CNT 3 + +typedef struct +{ + unsigned long src; + void* data; + int len; +} app_message_t; + +/* Globals */ +static struct rpmsg_channel *app_chnl = NULL; +static app_message_t app_msg[STRING_BUFFER_CNT]; +static char app_buf[512]; /* Each RPMSG buffer can carry less than 512 payload */ +static uint8_t app_idx = 0; +static uint8_t handler_idx = 0; +static volatile int32_t msg_count = 0; + +static void rpmsg_enable_rx_int(bool enable) +{ + if (enable) + { + if ((--msg_count) == 0) + MU_EnableRxFullInt(MUB, RPMSG_MU_CHANNEL); + } + else + { + if ((msg_count++) == 0) + MU_DisableRxFullInt(MUB, RPMSG_MU_CHANNEL); + } +} + +static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len, + void * priv, unsigned long src) +{ + /* + * Temperorily Disable MU Receive Interrupt to avoid master + * sending too many messages and remote will fail to keep pace + * to consume (flow control) + */ + rpmsg_enable_rx_int(false); + + /* Hold the RPMsg rx buffer to be used in main loop */ + rpmsg_hold_rx_buffer(rp_chnl, data); + app_msg[handler_idx].src = src; + app_msg[handler_idx].data = data; + app_msg[handler_idx].len = len; + + /* Move to next free message index */ + handler_idx = (handler_idx + 1) % STRING_BUFFER_CNT; +} + +/* rpmsg_rx_callback will call into this for a channel creation event*/ +static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) +{ + /* We should give the created rp_chnl handler to app layer */ + app_chnl = rp_chnl; + + PRINTF("Name service handshake is done, M4 has setup a rpmsg channel [%d ---> %d]\r\n", app_chnl->src, app_chnl->dst); +} + +static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) +{ +} + +/* + * MU Interrrupt ISR + */ +void BOARD_MU_HANDLER(void) +{ + /* + * calls into rpmsg_handler provided by middleware + */ + rpmsg_handler(); +} + +/*! + * @brief Main function + */ +int main(void) +{ + struct remote_device *rdev; + int len; + void *tx_buf; + unsigned long size; + + hardware_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); + + /* Print the initial banner */ + PRINTF("\r\nRPMSG String Echo Bare Metal Demo...\r\n"); + + /* RPMSG Init as REMOTE */ + PRINTF("RPMSG Init as Remote\r\n"); + rpmsg_init(0, &rdev, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, RPMSG_MASTER); + + /* + * str_echo demo loop + */ + for (;;) + { + /* Wait message to be available */ + while (msg_count == 0) + { + } + + /* Copy string from RPMsg rx buffer */ + len = app_msg[app_idx].len; + assert(len < sizeof(app_buf)); + memcpy(app_buf, app_msg[app_idx].data, len); + app_buf[len] = 0; /* End string by '\0' */ + + if ((len == 2) && (app_buf[0] == 0xd) && (app_buf[1] == 0xa)) + PRINTF("Get New Line From Master Side From Slot %d\r\n", app_idx); + else + PRINTF("Get Message From Master Side : \"%s\" [len : %d] from slot %d\r\n", app_buf, len, app_idx); + + /* Get tx buffer from RPMsg */ + tx_buf = rpmsg_alloc_tx_buffer(app_chnl, &size, RPMSG_TRUE); + assert(tx_buf); + /* Copy string to RPMsg tx buffer */ + memcpy(tx_buf, app_buf, len); + /* Echo back received message with nocopy send */ + rpmsg_sendto_nocopy(app_chnl, tx_buf, len, app_msg[app_idx].src); + + /* Release held RPMsg rx buffer */ + rpmsg_release_rx_buffer(app_chnl, app_msg[app_idx].data); + app_idx = (app_idx + 1) % STRING_BUFFER_CNT; + + /* Once a message is consumed, minus the msg_count and might enable MU interrupt again */ + rpmsg_enable_rx_int(true); + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/FreeRTOSConfig.h new file mode 100644 index 000000000..c57902e47 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_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 +#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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/CMakeLists.txt new file mode 100644 index 000000000..19eeddcd4 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/CMakeLists.txt @@ -0,0 +1,199 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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 -fno-strict-aliasing -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 -fno-strict-aliasing -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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(rpmsg_str_echo_freertos_example + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../str_echo_freertos.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_rtos.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/env.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio_ring.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_rtos.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/hil/hil.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/llist/llist.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/common/shm/sh_mem.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/config/config.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/remote_device.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_ext.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/rpmsg/rpmsg_core.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtio.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/virtio/virtqueue.c" + "${ProjDirPath}/../../../../../../middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/mu_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/mu_imx.h" +) +SET_TARGET_PROPERTIES(rpmsg_str_echo_freertos_example PROPERTIES OUTPUT_NAME "rpmsg_str_echo_freertos_example.elf") + +TARGET_LINK_LIBRARIES(rpmsg_str_echo_freertos_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(rpmsg_str_echo_freertos_example m) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_freertos_example c) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_freertos_example gcc) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_freertos_example nosys) +TARGET_LINK_LIBRARIES(rpmsg_str_echo_freertos_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/rpmsg_str_echo_freertos_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/rpmsg_str_echo_freertos_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET rpmsg_str_echo_freertos_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_freertos_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_freertos_example.hex) +ADD_CUSTOM_COMMAND(TARGET rpmsg_str_echo_freertos_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_freertos_example.elf ${EXECUTABLE_OUTPUT_PATH}/rpmsg_str_echo_freertos_example.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject new file mode 100644 index 000000000..a71b62033 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project new file mode 100644 index 000000000..f868bbfa6 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_str_echo_freertos_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/str_echo_freertos.c1PARENT-1-PROJECT_LOC/str_echo_freertos.crpmsg2virtual:/virtualrpmsg/rpmsg_rtos.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.hrpmsg2virtual:/virtualrpmsg/platform.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.hrpmsg2virtual:/virtualrpmsg/rpmsg_platform_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/rpmsg_platform_porting.hrpmsg2virtual:/virtualrpmsg/rpmsg.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.hrpmsg2virtual:/virtualrpmsg/rpmsg_ext.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.hrpmsg2virtual:/virtualrpmsg/hil.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.hrpmsg2virtual:/virtualrpmsg/llist.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.hrpmsg2virtual:/virtualrpmsg/sh_mem.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.hrpmsg2virtual:/virtualrpmsg/config.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.hrpmsg2virtual:/virtualrpmsg/env.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/env.hrpmsg2virtual:/virtualrpmsg/rpmsg_core.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.hrpmsg2virtual:/virtualrpmsg/virtio.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.hrpmsg2virtual:/virtualrpmsg/virtio_ring.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio_ring.hrpmsg2virtual:/virtualrpmsg/virtqueue.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.hrpmsg2virtual:/virtualrpmsg/rpmsg_porting.h1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hrpmsg2virtual:/virtualrpmsg/rpmsg_rtos.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_rtos.crpmsg2virtual:/virtualrpmsg/platform.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform.crpmsg2virtual:/virtualrpmsg/platform_info.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.crpmsg2virtual:/virtualrpmsg/hil.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/hil/hil.crpmsg2virtual:/virtualrpmsg/llist.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/llist/llist.crpmsg2virtual:/virtualrpmsg/sh_mem.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/common/shm/sh_mem.crpmsg2virtual:/virtualrpmsg/config.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/config/config.crpmsg2virtual:/virtualrpmsg/remote_device.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/remote_device.crpmsg2virtual:/virtualrpmsg/rpmsg.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg.crpmsg2virtual:/virtualrpmsg/rpmsg_ext.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_ext.crpmsg2virtual:/virtualrpmsg/rpmsg_core.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/rpmsg/rpmsg_core.crpmsg2virtual:/virtualrpmsg/virtio.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtio.crpmsg2virtual:/virtualrpmsg/virtqueue.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/virtio/virtqueue.crpmsg2virtual:/virtualrpmsg/rpmsg_porting.c1PARENT-6-PROJECT_LOC/middleware/multicore/open-amp/porting/env/freertos/rpmsg_porting.cfreertos2virtual:/virtualfreertos/croutine.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-6-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.hdriver2virtual:/virtualdriver/mu_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/mu_imx.cdriver2virtual:/virtualdriver/mu_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/mu_imx.h + + + diff --git a/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/hardware_init.c new file mode 100644 index 000000000..aa6947512 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/hardware_init.c @@ -0,0 +1,54 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* initialize debug uart */ + dbg_uart_init(); + + /* 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/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/str_echo_freertos.c b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/str_echo_freertos.c new file mode 100644 index 000000000..b34b3d7b8 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/rpmsg/str_echo_freertos/str_echo_freertos.c @@ -0,0 +1,146 @@ +/* + * 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 "rpmsg/rpmsg_rtos.h" +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "string.h" +#include "board.h" +#include "mu_imx.h" +#include "debug_console_imx.h" + +//////////////////////////////////////////////////////////////////////////////// +// Definitions +//////////////////////////////////////////////////////////////////////////////// +#define APP_TASK_STACK_SIZE 256 + +/* + * APP decided interrupt priority + */ +#define APP_MU_IRQ_PRIORITY 3 + +/* Globals */ +static char app_buf[512]; /* Each RPMSG buffer can carry less than 512 payload */ + +/*! + * @brief A basic RPMSG task + */ +static void StrEchoTask(void *pvParameters) +{ + int result; + struct remote_device *rdev = NULL; + struct rpmsg_channel *app_chnl = NULL; + void *rx_buf; + int len; + unsigned long src; + void *tx_buf; + unsigned long size; + + /* 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); + + /* + * str_echo demo loop + */ + for (;;) + { + /* Get RPMsg rx buffer with message */ + result = rpmsg_rtos_recv_nocopy(app_chnl->rp_ept, &rx_buf, &len, &src, 0xFFFFFFFF); + assert(result == 0); + + /* Copy string from RPMsg rx buffer */ + assert(len < sizeof(app_buf)); + memcpy(app_buf, rx_buf, len); + app_buf[len] = 0; /* End string by '\0' */ + + if ((len == 2) && (app_buf[0] == 0xd) && (app_buf[1] == 0xa)) + PRINTF("Get New Line From Master Side\r\n"); + else + PRINTF("Get Message From Master Side : \"%s\" [len : %d]\r\n", app_buf, len); + + /* Get tx buffer from RPMsg */ + tx_buf = rpmsg_rtos_alloc_tx_buffer(app_chnl->rp_ept, &size); + assert(tx_buf); + /* Copy string to RPMsg tx buffer */ + memcpy(tx_buf, app_buf, len); + /* Echo back received message with nocopy send */ + result = rpmsg_rtos_send_nocopy(app_chnl->rp_ept, tx_buf, len, src); + assert(result == 0); + + /* Release held RPMsg rx buffer */ + result = rpmsg_rtos_recv_nocopy_free(app_chnl->rp_ept, rx_buf); + assert(result == 0); + } +} + +/* + * MU Interrrupt ISR + */ +void BOARD_MU_HANDLER(void) +{ + /* + * calls into rpmsg_handler provided by middleware + */ + rpmsg_handler(); +} + +int main(void) +{ + hardware_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 + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/FreeRTOSConfig.h b/examples/var-som-mx7_m4/demo_apps/sema4_demo/FreeRTOSConfig.h new file mode 100644 index 000000000..bd4ca6f57 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/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 +#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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/CMakeLists.txt new file mode 100644 index 000000000..517dd7712 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/CMakeLists.txt @@ -0,0 +1,166 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(sema4_demo + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/MemMang/heap_2.c" + "${ProjDirPath}/../FreeRTOSConfig.h" + "${ProjDirPath}/../main.c" + "${ProjDirPath}/../sema4_mutex.c" + "${ProjDirPath}/../sema4_mutex.h" + "${ProjDirPath}/../../../../../platform/drivers/src/sema4.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/sema4.h" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/croutine.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/event_groups.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/FreeRTOS.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/list.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/mpu_wrappers.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/portable.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/projdefs.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/queue.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/semphr.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/StackMacros.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/task.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include/timers.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/croutine.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/event_groups.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/list.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/queue.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/tasks.c" + "${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/timers.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" +) +SET_TARGET_PROPERTIES(sema4_demo PROPERTIES OUTPUT_NAME "sema4_demo.elf") + +TARGET_LINK_LIBRARIES(sema4_demo -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(sema4_demo m) +TARGET_LINK_LIBRARIES(sema4_demo c) +TARGET_LINK_LIBRARIES(sema4_demo gcc) +TARGET_LINK_LIBRARIES(sema4_demo nosys) +TARGET_LINK_LIBRARIES(sema4_demo -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/sema4_demo.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/sema4_demo.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET sema4_demo POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/sema4_demo.elf ${EXECUTABLE_OUTPUT_PATH}/sema4_demo.hex) +ADD_CUSTOM_COMMAND(TARGET sema4_demo POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/sema4_demo.elf ${EXECUTABLE_OUTPUT_PATH}/sema4_demo.bin) diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_all.bat b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_all.sh b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_debug.bat b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_debug.sh b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_release.bat b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_release.sh b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/clean.bat b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/clean.sh b/examples/var-som-mx7_m4/demo_apps/sema4_demo/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_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/var-som-mx7_m4/demo_apps/sema4_demo/ds5/.cproject b/examples/var-som-mx7_m4/demo_apps/sema4_demo/ds5/.cproject new file mode 100644 index 000000000..d390d98ff --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/ds5/.project b/examples/var-som-mx7_m4/demo_apps/sema4_demo/ds5/.project new file mode 100644 index 000000000..ad26914e4 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/ds5/.project @@ -0,0 +1,86 @@ + + + sema4_demo_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + freertos2virtual:/virtualfreertos/port.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.cfreertos2virtual:/virtualfreertos/portmacro.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.hstartup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sfreertos2virtual:/virtualfreertos/heap_2.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/portable/MemMang/heap_2.cboard2virtual:/virtualboard/FreeRTOSConfig.h1PARENT-1-PROJECT_LOC/FreeRTOSConfig.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.csource2virtual:/virtualsource/sema4_mutex.c1PARENT-1-PROJECT_LOC/sema4_mutex.csource2virtual:/virtualsource/sema4_mutex.h1PARENT-1-PROJECT_LOC/sema4_mutex.hdriver2virtual:/virtualdriver/sema4.c1PARENT-5-PROJECT_LOC/platform/drivers/src/sema4.cdriver2virtual:/virtualdriver/sema4.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/sema4.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.hfreertos2virtual:/virtualfreertos/croutine.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/croutine.hfreertos2virtual:/virtualfreertos/event_groups.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/event_groups.hfreertos2virtual:/virtualfreertos/FreeRTOS.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/FreeRTOS.hfreertos2virtual:/virtualfreertos/list.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/list.hfreertos2virtual:/virtualfreertos/mpu_wrappers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/mpu_wrappers.hfreertos2virtual:/virtualfreertos/portable.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/portable.hfreertos2virtual:/virtualfreertos/projdefs.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/projdefs.hfreertos2virtual:/virtualfreertos/queue.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/queue.hfreertos2virtual:/virtualfreertos/semphr.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/semphr.hfreertos2virtual:/virtualfreertos/StackMacros.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/StackMacros.hfreertos2virtual:/virtualfreertos/task.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/task.hfreertos2virtual:/virtualfreertos/timers.h1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/include/timers.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hfreertos2virtual:/virtualfreertos/croutine.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/croutine.cfreertos2virtual:/virtualfreertos/event_groups.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/event_groups.cfreertos2virtual:/virtualfreertos/list.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/list.cfreertos2virtual:/virtualfreertos/queue.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/queue.cfreertos2virtual:/virtualfreertos/tasks.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/tasks.cfreertos2virtual:/virtualfreertos/timers.c1PARENT-5-PROJECT_LOC/rtos/FreeRTOS/Source/timers.csystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.c + + + diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/hardware_init.c b/examples/var-som-mx7_m4/demo_apps/sema4_demo/hardware_init.c new file mode 100644 index 000000000..0cd686acd --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/hardware_init.c @@ -0,0 +1,52 @@ +/* + * 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 SEMA4 access between domains */ + RDC_SetPdapAccess(RDC, BOARD_SEMA4_RDC_PDAP, 0xFF, false, false); + + /* Enable clock used by SEMA4 */ + CCM_ControlGate(CCM, BOARD_SEMA4_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/main.c b/examples/var-som-mx7_m4/demo_apps/sema4_demo/main.c new file mode 100644 index 000000000..d24111fb2 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/main.c @@ -0,0 +1,114 @@ +/* + * 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +// Includes +/////////////////////////////////////////////////////////////////////////////// +#include "FreeRTOS.h" +#include "task.h" +#include "board.h" +#include "debug_console_imx.h" +#include "sema4_mutex.h" + +#define SEMA4_DEMO_GATE (3) + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// +static void Sema4Test() +{ + SEMA4_Mutex_Lock(SEMA4_DEMO_GATE); + PRINTF("\n\r...SEMA4 mutex lock successfully!\n\r"); + SEMA4_Mutex_Unlock(SEMA4_DEMO_GATE); +} + +/*! + * @brief A basic user-defined task + */ +void Sema4Task(void *pvParameters) +{ + uint8_t receiveBuff; + + // Print the initial banner + PRINTF("================== SEMA4 demo ==================\n\r"); + + while(1) + { + // Main routine that triggers a SEMA4 lock + PRINTF("Enter command:\n\r"); + PRINTF("----- 'm' to manually trigger a SEMA4 lock\n\r"); + PRINTF("----- 'a' to automatically trigger SEMA4 lock every 5 seconds\n\r"); + + // First, get character + receiveBuff = GETCHAR(); + // Now echo the received character + PUTCHAR(receiveBuff); + + if (receiveBuff == 'm') + { + Sema4Test(); + } + else if (receiveBuff == 'a') + { + while (true) + { + Sema4Test(); + PRINTF("Wait for 5 seconds......\n\r"); + vTaskDelay(5 * configTICK_RATE_HZ); + } + } + } +} + +/*! + * @brief Main function + */ +int main(void) +{ + // Initialize demo application pins setting and clock setting. + hardware_init(); + + // Initialize SEMA4 mutex gate and reset + SEMA4_Mutex_Init(SEMA4_DEMO_GATE, true); + + // Create a demo task. + xTaskCreate(Sema4Task, "SEMA4 Task", configMINIMAL_STACK_SIZE, + NULL, tskIDLE_PRIORITY+1, NULL); + + // Start FreeRTOS scheduler. + vTaskStartScheduler(); + + // Should never reach this point. + while (true); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/sema4_mutex.c b/examples/var-som-mx7_m4/demo_apps/sema4_demo/sema4_mutex.c new file mode 100644 index 000000000..a52cfbab1 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/sema4_mutex.c @@ -0,0 +1,150 @@ +/* + * 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 "FreeRTOS.h" +#include "semphr.h" +#include "task.h" +#include "board.h" +#include "sema4_mutex.h" +#include "sema4.h" +#include "debug_console_imx.h" + +static SemaphoreHandle_t xSemaphore[16]; +static uint32_t recursiveDepth[16]; +static bool nvicInit; + +void SEMA4_Mutex_Init(uint32_t gate, bool reset) +{ + assert(gate < 16); + assert(!xSemaphore[gate]); + + /* We use counting semaphore because the sequence of take/give could not + * be guarenteed. */ + xSemaphore[gate] = xSemaphoreCreateCounting(1, 0); + + /* Reset the gate when required */ + if (reset) + { + SEMA4_ResetGate(BOARD_SEMA4_BASEADDR, gate); + SEMA4_ResetNotification(BOARD_SEMA4_BASEADDR, gate); + } + + /* NVIC initialize */ + if (!nvicInit) + { + NVIC_SetPriority(BOARD_SEMA4_IRQ_NUM, 3); + NVIC_EnableIRQ(BOARD_SEMA4_IRQ_NUM); + nvicInit = true; + } +} + +void SEMA4_Mutex_Lock(uint32_t gate) +{ + bool locked = false; + + assert(gate < 16); + + /* If already locked by this processor, just add recursive depth */ + if (SEMA4_GetLockProcessor(BOARD_SEMA4_BASEADDR, gate) == SEMA4_PROCESSOR_SELF) + { + recursiveDepth[gate]++; + return; + } + + while (true) + { + /* Critical section with ISR */ + taskDISABLE_INTERRUPTS(); + + /* Enable unlock interrupt of this gate */ + SEMA4_SetIntCmd(BOARD_SEMA4_BASEADDR, SEMA4_GATE_STATUS_FLAG(gate), true); + if (SEMA4_TryLock(BOARD_SEMA4_BASEADDR, gate) == statusSema4Success) + { + recursiveDepth[gate]++; + /* Got the SEMA4, unlock interrupt is not needed any more */ + SEMA4_SetIntCmd(BOARD_SEMA4_BASEADDR, SEMA4_GATE_STATUS_FLAG(gate), false); + locked = true; + } + + taskENABLE_INTERRUPTS(); + + if (locked) + break; + else + { + PRINTF("\n\r...Lock pending, waiting for the other core unlock the gate\n\r"); + /* Wait for unlock interrupt */ + xSemaphoreTake(xSemaphore[gate], portMAX_DELAY); + /* Got the unlock event, indicating the interrupt was disabled in ISR */ + } + } +} + +void SEMA4_Mutex_Unlock(uint32_t gate) +{ + if ((--recursiveDepth[gate]) == 0) + SEMA4_Unlock(BOARD_SEMA4_BASEADDR, gate); +} + +void BOARD_SEMA4_HANDLER() +{ + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + uint32_t i; + uint16_t flag; + + for (i = 0; i < 16; i++) + { + flag = SEMA4_GATE_STATUS_FLAG(i); + if (xSemaphore[i] && SEMA4_GetIntEnabled(BOARD_SEMA4_BASEADDR, flag) && + SEMA4_GetStatusFlag(BOARD_SEMA4_BASEADDR, flag)) + { + /* Because the status cannot be cleared manually, we have to disable the gate's + * interrupt to avoid endlessly going into ISR */ + SEMA4_SetIntCmd(BOARD_SEMA4_BASEADDR, flag, false); + + /* Unlock the task to process the event. */ + xSemaphoreGiveFromISR(xSemaphore[i], &xHigherPriorityTaskWoken); + + /* Perform a context switch to wake the higher priority task. */ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + } + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/demo_apps/sema4_demo/sema4_mutex.h b/examples/var-som-mx7_m4/demo_apps/sema4_demo/sema4_mutex.h new file mode 100644 index 000000000..b380111a9 --- /dev/null +++ b/examples/var-som-mx7_m4/demo_apps/sema4_demo/sema4_mutex.h @@ -0,0 +1,63 @@ +/* + * 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 __SEMA4_MUTEX_H__ +#define __SEMA4_MUTEX_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * @brief Initialize SEMA4 mutex with specific gate. + */ +void SEMA4_Mutex_Init(uint32_t gate, bool reset); + +/*! + * @brief Lock the SEMA4 gate, blocking when obtained by the other core + */ +void SEMA4_Mutex_Lock(uint32_t gate); + +/*! + * @brief Unlock the SEMA4 gate + */ +void SEMA4_Mutex_Unlock(uint32_t gate); + +#ifdef __cplusplus +} +#endif + +#endif /* __SEMA4_MUTEX_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/CMakeLists.txt new file mode 100644 index 000000000..ea6ba4dd8 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/CMakeLists.txt @@ -0,0 +1,136 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPRINTF_FLOAT_ENABLE") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__NDEBUG") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DCPU_MCIMX7D_M4") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DPRINTF_FLOAT_ENABLE") + +# CXX MACRO + +# INCLUDE_DIRECTORIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(adc_imx7d_example + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/adc_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/adc_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(adc_imx7d_example PROPERTIES OUTPUT_NAME "adc_imx7d_example.elf") + +TARGET_LINK_LIBRARIES(adc_imx7d_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(adc_imx7d_example m) +TARGET_LINK_LIBRARIES(adc_imx7d_example c) +TARGET_LINK_LIBRARIES(adc_imx7d_example gcc) +TARGET_LINK_LIBRARIES(adc_imx7d_example nosys) +TARGET_LINK_LIBRARIES(adc_imx7d_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/adc_imx7d_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/adc_imx7d_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET adc_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/adc_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/adc_imx7d_example.hex) +ADD_CUSTOM_COMMAND(TARGET adc_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/adc_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/adc_imx7d_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/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/var-som-mx7_m4/driver_examples/adc_imx7d/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/ds5/.cproject new file mode 100644 index 000000000..41f62d95f --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/adc_imx7d/ds5/.project b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/ds5/.project new file mode 100644 index 000000000..04b0e18e0 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/ds5/.project @@ -0,0 +1,86 @@ + + + adc_imx7d_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/adc_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/adc_imx7d.cdriver2virtual:/virtualdriver/adc_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/adc_imx7d.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/adc_imx7d/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/hardware_init.c new file mode 100644 index 000000000..52fcabcf4 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/hardware_init.c @@ -0,0 +1,54 @@ +/* + * 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 "board.h" +#include "pin_mux.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 example, we need to grasp ADC1 module exclusively */ + RDC_SetPdapAccess(RDC, BOARD_ADC_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Enable ADC clock */ + CCM_ControlGate(CCM, BOARD_ADC_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/adc_imx7d/main.c b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/main.c new file mode 100644 index 000000000..42bb2e173 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/adc_imx7d/main.c @@ -0,0 +1,92 @@ +/* + * 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 +#include "adc_imx7d.h" +#include "debug_console_imx.h" +#include "board.h" + +int main(void) +{ + adc_init_config_t adcConfig = { + .sampleRate = 2000, + // For i.MX7D this value should always be set to true. + .levelShifterEnable = true + }; + + adc_logic_ch_init_config_t adcChannelConfig = { + .inputChannel = BOARD_ADC_INPUT_CHANNEL, + .coutinuousEnable = true, + .convertRate = 1, + .averageEnable = true, + .averageNumber = adcAvgNum32 + }; + + // Initialize board specified hardware. + hardware_init(); + + PRINTF("\n-------------- ADC imx7d driver example --------------\n\n\r"); + PRINTF("This example demonstrates usage of ADC driver on i.MX processor.\n\r"); + PRINTF("It Continuous convert Analog Input, and print the result to terminal \n\r"); + + // Initialize ADC module. + ADC_Init(BOARD_ADC_BASEADDR, &adcConfig); + + // Enable Convert finish interrupt on Logic Channel A + ADC_SetIntSigCmd(BOARD_ADC_BASEADDR, adcIntConvertChA, true); + ADC_SetIntCmd(BOARD_ADC_BASEADDR, adcIntConvertChA, true); + + /* Set ADC Interrupt priority */ + NVIC_SetPriority(BOARD_ADC_IRQ_NUM, 3); + + /* Call core API to enable the IRQ. */ + NVIC_EnableIRQ(BOARD_ADC_IRQ_NUM); + + // Initialize ADC Logic Channel A module. + ADC_LogicChInit(BOARD_ADC_BASEADDR, adcLogicChA, &adcChannelConfig); + + // Start Continuous Conversion on Logic Channel A. + ADC_SetConvertCmd(BOARD_ADC_BASEADDR, adcLogicChA, true); + + while(1); +} + +void BOARD_ADC_HANDLER(void) +{ + float voltage; + ADC_ClearStatusFlag(BOARD_ADC_BASEADDR, adcStatusConvertChA); + voltage = (1.8 * ADC_GetConvertResult(BOARD_ADC_BASEADDR, adcLogicChA))/0xFFF; + PRINTF("Current analog value: %3.2fv\n\r", voltage); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/CMakeLists.txt new file mode 100644 index 000000000..75c683605 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/CMakeLists.txt @@ -0,0 +1,138 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(flexcan_loopback_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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" + "${ProjDirPath}/../../../../../../platform/drivers/src/flexcan.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/flexcan.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/gpt.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/gpt.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(flexcan_loopback_example PROPERTIES OUTPUT_NAME "flexcan_loopback_example.elf") + +TARGET_LINK_LIBRARIES(flexcan_loopback_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(flexcan_loopback_example m) +TARGET_LINK_LIBRARIES(flexcan_loopback_example c) +TARGET_LINK_LIBRARIES(flexcan_loopback_example gcc) +TARGET_LINK_LIBRARIES(flexcan_loopback_example nosys) +TARGET_LINK_LIBRARIES(flexcan_loopback_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/flexcan_loopback_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/flexcan_loopback_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET flexcan_loopback_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/flexcan_loopback_example.elf ${EXECUTABLE_OUTPUT_PATH}/flexcan_loopback_example.hex) +ADD_CUSTOM_COMMAND(TARGET flexcan_loopback_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/flexcan_loopback_example.elf ${EXECUTABLE_OUTPUT_PATH}/flexcan_loopback_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject new file mode 100644 index 000000000..61eaa7d2d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project new file mode 100644 index 000000000..c64560329 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project @@ -0,0 +1,86 @@ + + + flexcan_loopback_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cboard2virtual:/virtualboard/gpio_pins.c1PARENT-4-PROJECT_LOC/gpio_pins.cboard2virtual:/virtualboard/gpio_pins.h1PARENT-4-PROJECT_LOC/gpio_pins.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/flexcan.c1PARENT-6-PROJECT_LOC/platform/drivers/src/flexcan.cdriver2virtual:/virtualdriver/flexcan.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/flexcan.hdriver2virtual:/virtualdriver/gpt.c1PARENT-6-PROJECT_LOC/platform/drivers/src/gpt.cdriver2virtual:/virtualdriver/gpt.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/gpt.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/hardware_init.c new file mode 100644 index 000000000..ad34e0e31 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/hardware_init.c @@ -0,0 +1,70 @@ +/* + * 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 "board.h" +#include "pin_mux.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 example, we need to grasp board flexcan exclusively */ + RDC_SetPdapAccess(RDC, BOARD_FLEXCAN_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select board flexcan derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_FLEXCAN_CCM_ROOT, ccmRootmuxUartOsc24m, 0, 0); + /* Enable flexcan clock */ + CCM_EnableRoot(CCM, BOARD_FLEXCAN_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_FLEXCAN_CCM_CCGR, ccmClockNeededRunWait); + + /* FLEXCAN Pin setting */ + configure_flexcan_pins(BOARD_FLEXCAN_BASEADDR); + + /* In this example, we need to grasp board GPT exclusively */ + RDC_SetPdapAccess(RDC, BOARD_GPTA_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select GPTA clock derived from OSC 24M */ + CCM_UpdateRoot(CCM, BOARD_GPTA_CCM_ROOT, ccmRootmuxGptOsc24m, 0, 0); + + /* Enable clock used by GPTA */ + CCM_EnableRoot(CCM, BOARD_GPTA_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTA_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/main.c b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/main.c new file mode 100644 index 000000000..980e8ea0c --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_loopback/main.c @@ -0,0 +1,212 @@ +/* + * 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 +#include "board.h" +#include "debug_console_imx.h" +#include "flexcan.h" +#include "gpt.h" + +#define TX_MSG_BUF_NUM 13 +#define RX_MSG_BUF_NUM 9 + +#define TX_IDENTIFIER 0x123 +#define RX_IDENTIFIER 0x123 +#define GLOBAL_MASK 0x123 + +//////////////////////////////////////////////////////////////////////////////// +// Constant +//////////////////////////////////////////////////////////////////////////////// +const flexcan_timing_t timing_table[] = { + {7, 3, 7, 7, 6}, /* 125 kHz from 24 MHz OSC */ + {3, 3, 7, 7, 6}, /* 250 kHz from 24 MHz OSC */ + {1, 3, 7, 7, 6}, /* 500 kHz from 24 MHz OSC */ + {0, 3, 7, 7, 6}, /* 1 MHz from 24 MHz OSC */ +}; + +//////////////////////////////////////////////////////////////////////////////// +// Global +//////////////////////////////////////////////////////////////////////////////// +volatile flexcan_msgbuf_t rxBuffer; +volatile bool rxCanReceive; +volatile flexcan_msgbuf_t *txMsgBufPtr; +volatile flexcan_msgbuf_t *rxMsgBufPtr; +volatile uint8_t data = 0; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// +void init_flexcan(void) +{ + flexcan_init_config_t initConfig = { + .timing = timing_table[0], + .operatingMode = flexcanLoopBackMode, + .maxMsgBufNum = 16 + }; + + /* Initialize FlexCAN module. */ + FLEXCAN_Init(BOARD_FLEXCAN_BASEADDR, &initConfig); + /* Enable FlexCAN Clock. */ + FLEXCAN_Enable(BOARD_FLEXCAN_BASEADDR); + /* Set FlexCAN to use Global mask mode. */ + FLEXCAN_SetRxMaskMode(BOARD_FLEXCAN_BASEADDR, flexcanRxMaskGlobal); + /* Set FlexCAN global mask. */ + FLEXCAN_SetRxGlobalMask(BOARD_FLEXCAN_BASEADDR, ~CAN_ID_STD(GLOBAL_MASK)); + + /* Clear Tx and Rx message buffer interrupt pending bit. */ + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM); + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + /* Enable Tx and Rx message buffer interrupt. */ + FLEXCAN_SetMsgBufIntCmd(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM, true); + FLEXCAN_SetMsgBufIntCmd(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM, true); + + /* Initialize Global variable. */ + rxCanReceive = false; + txMsgBufPtr = FLEXCAN_GetMsgBufPtr(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM); + rxMsgBufPtr = FLEXCAN_GetMsgBufPtr(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + + /* Setup Rx MsgBuf to receive Frame. */ + rxMsgBufPtr->idStd = RX_IDENTIFIER; + rxMsgBufPtr->code = flexcanRxEmpty; + + /* Setup Tx MsgBuf to transmit Frame. */ + txMsgBufPtr->prio = 0x0; /* We don't use local priority */ + txMsgBufPtr->idStd = TX_IDENTIFIER; /* Set Tx Identifier */ + txMsgBufPtr->idExt = 0x0; /* We don't use Extend Id. */ + txMsgBufPtr->dlc = 0x1; /* Send only 1 byte data. */ + txMsgBufPtr->rtr = 0x0; /* Send data frame. */ + txMsgBufPtr->ide = 0x0; /* Frame format is standard. */ + txMsgBufPtr->srr = 0x1; /* Don't care in standard id mode. */ + + /* Set FlexCAN interrupt priority. */ + NVIC_SetPriority(BOARD_FLEXCAN_IRQ_NUM, 3); + /* Enable FlexCAN interrupt. */ + NVIC_EnableIRQ(BOARD_FLEXCAN_IRQ_NUM); +} + +void init_gpt_timer(void) +{ + uint32_t freq; + gpt_init_config_t config = { + .freeRun = false, + .waitEnable = true, + .stopEnable = true, + .dozeEnable = true, + .dbgEnable = false, + .enableMode = true + }; + + /* Initialize GPT module */ + GPT_Init(BOARD_GPTA_BASEADDR, &config); + /* Set GPT clock source */ + GPT_SetClockSource(BOARD_GPTA_BASEADDR, gptClockSourceOsc); + /* Divide GPTA osc clock source frequency by 2, and divide additional 2 inside GPT module */ + GPT_SetOscPrescaler(BOARD_GPTA_BASEADDR, 1); + GPT_SetPrescaler(BOARD_GPTA_BASEADDR, 1); + + /* Get GPT clock frequency */ + freq = 24000000/4; /* A is bound to OSC directly, with OSC divider 2 */ + /* Set both GPT modules to 1 second duration */ + GPT_SetOutputCompareValue(BOARD_GPTA_BASEADDR, gptOutputCompareChannel1, freq); + /* Set GPT interrupt priority to same value to avoid handler preemption */ + NVIC_SetPriority(BOARD_GPTA_IRQ_NUM, 3); + /* Enable NVIC interrupt */ + NVIC_EnableIRQ(BOARD_GPTA_IRQ_NUM); + /* Enable GPT Output Compare1 interrupt */ + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, true); + /* GPT start */ + GPT_Enable(BOARD_GPTA_BASEADDR); +} + +int main(void) +{ + /* Initialize board specified hardware. */ + hardware_init(); + + PRINTF("\n\r********* FLEXCAN LOOPBACK TEST *********"); + PRINTF("\n\r Message format: Standard (11 bit id)"); + PRINTF("\n\r Message buffer %d used for Rx.", RX_MSG_BUF_NUM); + PRINTF("\n\r Message buffer %d used for Tx.", TX_MSG_BUF_NUM); + PRINTF("\n\r Interrupt Mode: Enabled"); + PRINTF("\n\r Operating Mode: TX and RX --> LoopBack"); + PRINTF("\n\r*****************************************\n\r"); + + init_flexcan(); + init_gpt_timer(); + + while (true) + { + if (rxCanReceive) + { + rxCanReceive = false; + PRINTF("\r\n\r\nDLC=%d, mb_idx=0x%3x", rxBuffer.dlc, rxBuffer.idStd); + PRINTF("\r\nRX MB data: 0x"); + for (uint8_t i = 0; i < rxBuffer.dlc; i++) + PRINTF("%x ", *(&rxBuffer.data0 + i)); + } + } +} + +void BOARD_GPTA_HANDLER(void) +{ + GPT_ClearStatusFlag(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1); + + /* Prepare data for transmit */ + txMsgBufPtr->data0 = data; /* Load data to message buf. */ + txMsgBufPtr->code = flexcanTxDataOrRemte; /* Start transmit. */ +} + +void BOARD_FLEXCAN_HANDLER(void) +{ + /* Solve Tx interrupt */ + if (FLEXCAN_GetMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM)) + { + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM); + data++; + } + + /* Solve Rx interrupt */ + if (FLEXCAN_GetMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM)) + { + /* Lock message buffer for receive data. */ + FLEXCAN_LockRxMsgBuf(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + rxBuffer = *rxMsgBufPtr; + FLEXCAN_UnlockAllRxMsgBuf(BOARD_FLEXCAN_BASEADDR); + + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + + rxCanReceive = true; + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/CMakeLists.txt new file mode 100644 index 000000000..a50405996 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/CMakeLists.txt @@ -0,0 +1,138 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(flexcan_network_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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" + "${ProjDirPath}/../../../../../../platform/drivers/src/flexcan.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/flexcan.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/gpt.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/gpt.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(flexcan_network_example PROPERTIES OUTPUT_NAME "flexcan_network_example.elf") + +TARGET_LINK_LIBRARIES(flexcan_network_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(flexcan_network_example m) +TARGET_LINK_LIBRARIES(flexcan_network_example c) +TARGET_LINK_LIBRARIES(flexcan_network_example gcc) +TARGET_LINK_LIBRARIES(flexcan_network_example nosys) +TARGET_LINK_LIBRARIES(flexcan_network_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/flexcan_network_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/flexcan_network_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET flexcan_network_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/flexcan_network_example.elf ${EXECUTABLE_OUTPUT_PATH}/flexcan_network_example.hex) +ADD_CUSTOM_COMMAND(TARGET flexcan_network_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/flexcan_network_example.elf ${EXECUTABLE_OUTPUT_PATH}/flexcan_network_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/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/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject new file mode 100644 index 000000000..3bd4d9ef4 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/ds5/.project b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/ds5/.project new file mode 100644 index 000000000..a3a44d536 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/ds5/.project @@ -0,0 +1,86 @@ + + + flexcan_network_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cboard2virtual:/virtualboard/gpio_pins.c1PARENT-4-PROJECT_LOC/gpio_pins.cboard2virtual:/virtualboard/gpio_pins.h1PARENT-4-PROJECT_LOC/gpio_pins.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/flexcan.c1PARENT-6-PROJECT_LOC/platform/drivers/src/flexcan.cdriver2virtual:/virtualdriver/flexcan.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/flexcan.hdriver2virtual:/virtualdriver/gpt.c1PARENT-6-PROJECT_LOC/platform/drivers/src/gpt.cdriver2virtual:/virtualdriver/gpt.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/gpt.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/hardware_init.c new file mode 100644 index 000000000..ad34e0e31 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/hardware_init.c @@ -0,0 +1,70 @@ +/* + * 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 "board.h" +#include "pin_mux.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 example, we need to grasp board flexcan exclusively */ + RDC_SetPdapAccess(RDC, BOARD_FLEXCAN_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select board flexcan derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_FLEXCAN_CCM_ROOT, ccmRootmuxUartOsc24m, 0, 0); + /* Enable flexcan clock */ + CCM_EnableRoot(CCM, BOARD_FLEXCAN_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_FLEXCAN_CCM_CCGR, ccmClockNeededRunWait); + + /* FLEXCAN Pin setting */ + configure_flexcan_pins(BOARD_FLEXCAN_BASEADDR); + + /* In this example, we need to grasp board GPT exclusively */ + RDC_SetPdapAccess(RDC, BOARD_GPTA_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select GPTA clock derived from OSC 24M */ + CCM_UpdateRoot(CCM, BOARD_GPTA_CCM_ROOT, ccmRootmuxGptOsc24m, 0, 0); + + /* Enable clock used by GPTA */ + CCM_EnableRoot(CCM, BOARD_GPTA_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTA_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/main.c b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/main.c new file mode 100644 index 000000000..2332019e8 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/flexcan/flexcan_network/main.c @@ -0,0 +1,221 @@ +/* + * 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 +#include "board.h" +#include "debug_console_imx.h" +#include "flexcan.h" +#include "gpt.h" + +#define NODE 1 +#define TX_MSG_BUF_NUM 8 +#define RX_MSG_BUF_NUM 9 + +#if (1 == NODE) + #define TX_IDENTIFIER 0x123 + #define RX_IDENTIFIER 0x321 + #define GLOBAL_MASK 0x321 +#else + #define TX_IDENTIFIER 0x321 + #define RX_IDENTIFIER 0x123 + #define GLOBAL_MASK 0x123 +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Constant +//////////////////////////////////////////////////////////////////////////////// +const flexcan_timing_t timing_table[] = { + {7, 3, 7, 7, 6}, /* 125 kHz from 24 MHz OSC */ + {3, 3, 7, 7, 6}, /* 250 kHz from 24 MHz OSC */ + {1, 3, 7, 7, 6}, /* 500 kHz from 24 MHz OSC */ + {0, 3, 7, 7, 6}, /* 1 MHz from 24 MHz OSC */ +}; + +//////////////////////////////////////////////////////////////////////////////// +// Global +//////////////////////////////////////////////////////////////////////////////// +volatile flexcan_msgbuf_t rxBuffer; +volatile bool rxCanReceive; +volatile flexcan_msgbuf_t *txMsgBufPtr; +volatile flexcan_msgbuf_t *rxMsgBufPtr; +volatile uint8_t data = 0; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +void init_flexcan(void) +{ + flexcan_init_config_t initConfig = { + .timing = timing_table[0], + .operatingMode = flexcanNormalMode, + .maxMsgBufNum = 16 + }; + + /* Initialize FlexCAN module. */ + FLEXCAN_Init(BOARD_FLEXCAN_BASEADDR, &initConfig); + /* Enable FlexCAN Clock. */ + FLEXCAN_Enable(BOARD_FLEXCAN_BASEADDR); + /* Set FlexCAN to use Global mask mode. */ + FLEXCAN_SetRxMaskMode(BOARD_FLEXCAN_BASEADDR, flexcanRxMaskGlobal); + /* Set FlexCAN global mask. */ + FLEXCAN_SetRxGlobalMask(BOARD_FLEXCAN_BASEADDR, ~CAN_ID_STD(GLOBAL_MASK)); + + /* Clear Tx and Rx message buffer interrupt pending bit. */ + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM); + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + /* Enable Tx and Rx message buffer interrupt. */ + FLEXCAN_SetMsgBufIntCmd(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM, true); + FLEXCAN_SetMsgBufIntCmd(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM, true); + + /* Initialize Global variable. */ + rxCanReceive = false; + txMsgBufPtr = FLEXCAN_GetMsgBufPtr(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM); + rxMsgBufPtr = FLEXCAN_GetMsgBufPtr(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + + /* Setup Rx MsgBuf to receive Frame. */ + rxMsgBufPtr->idStd = RX_IDENTIFIER; + rxMsgBufPtr->code = flexcanRxEmpty; + + txMsgBufPtr->prio = 0x0; /* We don't use local priority */ + txMsgBufPtr->idStd = TX_IDENTIFIER; /* Set Tx Identifier */ + txMsgBufPtr->idExt = 0x0; /* We don't use Extend Id. */ + txMsgBufPtr->dlc = 0x1; /* Send only 1 byte data. */ + txMsgBufPtr->rtr = 0x0; /* Send data frame. */ + txMsgBufPtr->ide = 0x0; /* Frame format is standard. */ + txMsgBufPtr->srr = 0x1; /* Don't care in standard id mode. */ + + /* Set FlexCAN interrupt priority. */ + NVIC_SetPriority(BOARD_FLEXCAN_IRQ_NUM, 3); + /* Enable FlexCAN interrupt. */ + NVIC_EnableIRQ(BOARD_FLEXCAN_IRQ_NUM); +} + +void init_gpt(void) +{ + uint32_t freq; + gpt_init_config_t config = { + .freeRun = false, + .waitEnable = true, + .stopEnable = true, + .dozeEnable = true, + .dbgEnable = false, + .enableMode = true + }; + + /* Initialize GPT module */ + GPT_Init(BOARD_GPTA_BASEADDR, &config); + /* Set GPT clock source */ + GPT_SetClockSource(BOARD_GPTA_BASEADDR, gptClockSourceOsc); + /* Divide GPTA osc clock source frequency by 2, and divide additional 2 inside GPT module */ + GPT_SetOscPrescaler(BOARD_GPTA_BASEADDR, 1); + GPT_SetPrescaler(BOARD_GPTA_BASEADDR, 1); + + /* Get GPT clock frequency */ + freq = 24000000/4; /* A is bound to OSC directly, with OSC divider 2 */ + /* Set both GPT modules to 1 second duration */ + GPT_SetOutputCompareValue(BOARD_GPTA_BASEADDR, gptOutputCompareChannel1, freq); + /* Set GPT interrupt priority to same value to avoid handler preemption */ + NVIC_SetPriority(BOARD_GPTA_IRQ_NUM, 3); + /* Enable NVIC interrupt */ + NVIC_EnableIRQ(BOARD_GPTA_IRQ_NUM); + /* Enable GPT Output Compare1 interrupt */ + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, true); + /* GPT start */ + GPT_Enable(BOARD_GPTA_BASEADDR); +} + +int main(void) +{ + /* Initialize board specified hardware. */ + hardware_init(); + + PRINTF("\n\r********* FLEXCAN NETWORK TEST *********"); + PRINTF("\n\r Message format: Standard (11 bit id)"); + PRINTF("\n\r Message buffer %d used for Rx.", RX_MSG_BUF_NUM); + PRINTF("\n\r Message buffer %d used for Tx.", TX_MSG_BUF_NUM); + PRINTF("\n\r Interrupt Mode: Enabled"); + PRINTF("\n\r Operating Mode: TX and RX --> Normal"); + PRINTF("\n\r****************************************\n\r"); + + PRINTF("\n\r\n\rNODE is %d\n\r", NODE); + + init_flexcan(); + init_gpt(); + + while (true) + { + if (rxCanReceive) + { + rxCanReceive = false; + PRINTF("\r\n\r\nDLC=%d, mb_idx=0x%3x", rxBuffer.dlc, rxBuffer.idStd); + PRINTF("\r\nRX MB data: 0x"); + for (uint8_t i = 0; i < rxBuffer.dlc; i++) + PRINTF("%x ", *(&rxBuffer.data0 + i)); + } + } +} + +void BOARD_GPTA_HANDLER(void) +{ + GPT_ClearStatusFlag(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1); + + /* Prepare data for transmit */ + txMsgBufPtr->data0 = data; /* Load data to message buf. */ + txMsgBufPtr->code = flexcanTxDataOrRemte; /* Start transmit. */ +} + +void BOARD_FLEXCAN_HANDLER(void) +{ + /* Solve Tx interrupt */ + if (FLEXCAN_GetMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM)) + { + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM); + data++; + } + + /* Solve Rx interrupt */ + if (FLEXCAN_GetMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM)) + { + /* Lock message buffer for receive data. */ + FLEXCAN_LockRxMsgBuf(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + rxBuffer = *rxMsgBufPtr; + FLEXCAN_UnlockAllRxMsgBuf(BOARD_FLEXCAN_BASEADDR); + + FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM); + + rxCanReceive = true; + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/CMakeLists.txt new file mode 100644 index 000000000..af034fb5d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/CMakeLists.txt @@ -0,0 +1,136 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(gpio_imx_example + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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" + "${ProjDirPath}/../../../../../platform/drivers/src/gpio_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/gpio_imx.h" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(gpio_imx_example PROPERTIES OUTPUT_NAME "gpio_imx_example.elf") + +TARGET_LINK_LIBRARIES(gpio_imx_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(gpio_imx_example m) +TARGET_LINK_LIBRARIES(gpio_imx_example c) +TARGET_LINK_LIBRARIES(gpio_imx_example gcc) +TARGET_LINK_LIBRARIES(gpio_imx_example nosys) +TARGET_LINK_LIBRARIES(gpio_imx_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/gpio_imx_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/gpio_imx_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET gpio_imx_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/gpio_imx_example.elf ${EXECUTABLE_OUTPUT_PATH}/gpio_imx_example.hex) +ADD_CUSTOM_COMMAND(TARGET gpio_imx_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/gpio_imx_example.elf ${EXECUTABLE_OUTPUT_PATH}/gpio_imx_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/gpio_imx/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/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/var-som-mx7_m4/driver_examples/gpio_imx/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/gpio_imx/ds5/.cproject new file mode 100644 index 000000000..61ebeec7e --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/gpio_imx/ds5/.project b/examples/var-som-mx7_m4/driver_examples/gpio_imx/ds5/.project new file mode 100644 index 000000000..97eca7fb1 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/ds5/.project @@ -0,0 +1,86 @@ + + + gpio_imx_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.cboard2virtual:/virtualboard/gpio_pins.c1PARENT-3-PROJECT_LOC/gpio_pins.cboard2virtual:/virtualboard/gpio_pins.h1PARENT-3-PROJECT_LOC/gpio_pins.hsource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/gpio_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/gpio_imx.cdriver2virtual:/virtualdriver/gpio_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/gpio_imx.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/gpio_imx/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/gpio_imx/hardware_init.c new file mode 100644 index 000000000..3c5b0e173 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/hardware_init.c @@ -0,0 +1,54 @@ +/* + * 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, BOARD_GPIO_KEY_RDC_PDAP, 0xFF, false, false); + + /* Enable gpio clock gate */ + CCM_ControlGate(CCM, BOARD_GPIO_KEY_CCM_CCGR, ccmClockNeededRunWait); + /* Configure gpio pin IOMUX */ + configure_gpio_pin(BOARD_GPIO_KEY_CONFIG); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/gpio_imx/main.c b/examples/var-som-mx7_m4/driver_examples/gpio_imx/main.c new file mode 100644 index 000000000..f062aefd3 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpio_imx/main.c @@ -0,0 +1,295 @@ +/* + * 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 "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) + +/* button relevent variables */ +static uint8_t keyPressCount; +static bool on = false; +#ifdef BOARD_GPIO_KEY_CONFIG +static volatile uint8_t button_pressed_flag; +#endif + +/*! + * @brief Initialize GPIO_LED controller. + */ +static void GPIO_Ctrl_InitLedPin(void) +{ +#ifdef BOARD_GPIO_LED_CONFIG + /* GPIO module initialize, configure "LED" as output and drive the output high level */ + gpio_init_config_t ledInitConfig = { + .pin = BOARD_GPIO_LED_CONFIG->pin, + .direction = gpioDigitalOutput, + .interruptMode = gpioNoIntmode + }; + GPIO_Init(BOARD_GPIO_LED_CONFIG->base, &ledInitConfig); +#endif +} + +/*! + * @brief Initialize GPIO INT\POLLING controller. + */ +static void GPIO_Ctrl_InitKeyPin(uint32_t gpioMode) +{ +#ifdef BOARD_GPIO_KEY_CONFIG + if (GPIO_INTERRUPT == gpioMode) + { + /* GPIO module initialize, configure button as interrupt mode. */ + gpio_init_config_t keyInitConfig = { + .pin = BOARD_GPIO_KEY_CONFIG->pin, + .direction = gpioDigitalInput, + .interruptMode = gpioIntFallingEdge, + }; + GPIO_Init(BOARD_GPIO_KEY_CONFIG->base, &keyInitConfig); + /* Enable interrupt. */ + NVIC_EnableIRQ(BOARD_GPIO_KEY_IRQ_NUM); + } + else + { + /* GPIO module initialize, configure button as GPIO functionality. */ + gpio_init_config_t keyInitConfig = { + .pin = BOARD_GPIO_KEY_CONFIG->pin, + .direction = gpioDigitalInput, + .interruptMode = gpioNoIntmode, + }; + GPIO_Init(BOARD_GPIO_KEY_CONFIG->base, &keyInitConfig); + } +#endif +} + +/*! + * @brief Wait user to press key in INT\NOINT mode. + */ +static void GPIO_WaitKeyPressed(uint32_t gpioMode) +{ +#ifdef BOARD_GPIO_KEY_CONFIG + uint32_t i, j, debounce; + + if (GPIO_INTERRUPT == gpioMode) + { + do + { + debounce = 0; + + /* Clear the interrupt state, this operation is necessary, because the GPIO module maybe confuse + the first rising edge as interrupt*/ + GPIO_ClearStatusFlag(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin); + /* Enable GPIO pin interrupt */ + GPIO_SetPinIntMode(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin, true); + + /* Waitting for Key pressed. */ + while(button_pressed_flag == 0); + button_pressed_flag = 0; + + 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 (0 == GPIO_ReadPinInput(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin)) + { + debounce++; + } + } + + if (debounce > 2) + { + break; + } + } while (1); + } + else + { + /* Wait for Key Released. */ + do + { + debounce = 0; + while (0 == GPIO_ReadPinInput(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->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(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin)) + { + debounce++; + } + } + + if (debounce > 2) + { + break; + } + } + while (1); + + /* Wait for Key Pressed. */ + do + { + debounce = 0; + while (1 == GPIO_ReadPinInput(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->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 (0 == GPIO_ReadPinInput(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin)) + { + debounce++; + } + } + + if (debounce > 2) + { + break; + } + } + while (1); + } +#else + GETCHAR(); +#endif +} + +/*! + * @brief Toggle the led + */ +static void GPIO_LED_Toggle(void) +{ +#ifdef BOARD_GPIO_LED_CONFIG + GPIO_WritePinOutput(BOARD_GPIO_LED_CONFIG->base,BOARD_GPIO_LED_CONFIG->pin, on ? gpioPinSet : gpioPinClear); + keyPressCount++; + PRINTF("Button pressed %d times\n\r", keyPressCount); +#else + PRINTF("%c ", on ? '+' : '-'); +#endif + on = !on; +} + +/****************************************************************************** +* +* Function Name: main +* Comments: GPIO module initialize, interrupt and IO operation. +* This example include 2 step: +* 1)Configure BUTTON1 as interrupt mode, falling edge, and test +* by pressing the button 3 times to trigger interrupt. +* 2)Configure BUTTON1 as GPIO functionality +* and check the button's state(pressed or released) through switch LED +* to on or off if this board has LED. +* +******************************************************************************/ +int main(void) +{ + /* hardware initialiize, include RDC, IOMUX, Uart debug initialize */ + hardware_init(); + PRINTF("\n\r====================== GPIO Example ========================\n\r"); + + /* GPIO module initialize, configure "LED" as output and button as interrupt mode. */ + GPIO_Ctrl_InitLedPin(); + GPIO_Ctrl_InitKeyPin(GPIO_INTERRUPT); + + /* wait for user to press button */ +#ifdef BOARD_GPIO_KEY_CONFIG + PRINTF("\n\r=================== GPIO Interrupt =====================\n\r"); + PRINTF("The (%s) button is configured to trigger GPIO interrupt\n\r", BOARD_GPIO_KEY_CONFIG->name); + PRINTF("Press the (%s) button 3 times to continue.\n\n\r", BOARD_GPIO_KEY_CONFIG->name); +#else + PRINTF("\n\r============ Use key to simulate GPIO button ==============\n\r"); + PRINTF("Input any data from terminal 3 times to continues.\n\n\r"); +#endif + keyPressCount = 0; + while(keyPressCount < 3) + { + GPIO_WaitKeyPressed(GPIO_INTERRUPT); + keyPressCount++; + PRINTF("Button pressed %d time. \n\r", keyPressCount); + } + + GPIO_Ctrl_InitKeyPin(GPIO_POLLING); + keyPressCount = 0; + + /* Configure button as GPIO functionality + and check the button's state(pressed or released) to switch LED on or off */ + /* Check the buttion's status(pressed or released) */ + PRINTF("\n\r================= GPIO Functionality==================\n\r"); + PRINTF("The button state is now polled.\n\r"); + PRINTF("Press the button to switch LED on or off\n\n\r"); + while(true) + { + GPIO_WaitKeyPressed(GPIO_POLLING); + GPIO_LED_Toggle(); + } +} + +/****************************************************************************** +* Function Name: BOARD_GPIO_BTN_HANDLER +* Comments: The interrupt service routine triggered by gpio +* Note: Need to consider how to eliminate the button shake problem +******************************************************************************/ +#ifdef BOARD_GPIO_KEY_CONFIG +void BOARD_GPIO_KEY_HANDLER(void) +{ + button_pressed_flag = 1; + /* clear the interrupt status */ + GPIO_ClearStatusFlag(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin); + + /* Disable GPIO pin interrupt */ + GPIO_SetPinIntMode(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin, false); +} +#endif + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/CMakeLists.txt new file mode 100644 index 000000000..eaa052e64 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/CMakeLists.txt @@ -0,0 +1,134 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(gpt_example + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/gpt.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/gpt.h" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(gpt_example PROPERTIES OUTPUT_NAME "gpt_example.elf") + +TARGET_LINK_LIBRARIES(gpt_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(gpt_example m) +TARGET_LINK_LIBRARIES(gpt_example c) +TARGET_LINK_LIBRARIES(gpt_example gcc) +TARGET_LINK_LIBRARIES(gpt_example nosys) +TARGET_LINK_LIBRARIES(gpt_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/gpt_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/gpt_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET gpt_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/gpt_example.elf ${EXECUTABLE_OUTPUT_PATH}/gpt_example.hex) +ADD_CUSTOM_COMMAND(TARGET gpt_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/gpt_example.elf ${EXECUTABLE_OUTPUT_PATH}/gpt_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/gpt/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/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/var-som-mx7_m4/driver_examples/gpt/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/gpt/ds5/.cproject new file mode 100644 index 000000000..5de9d8237 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/gpt/ds5/.project b/examples/var-som-mx7_m4/driver_examples/gpt/ds5/.project new file mode 100644 index 000000000..e35df3905 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/ds5/.project @@ -0,0 +1,86 @@ + + + gpt_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/gpt.c1PARENT-5-PROJECT_LOC/platform/drivers/src/gpt.cdriver2virtual:/virtualdriver/gpt.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/gpt.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/gpt/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/gpt/hardware_init.c new file mode 100644 index 000000000..b43ffbb67 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/hardware_init.c @@ -0,0 +1,68 @@ +/* + * 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 "board.h" +#include "pin_mux.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 example, we need to grasp board GPT exclusively */ + RDC_SetPdapAccess(RDC, BOARD_GPTA_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + RDC_SetPdapAccess(RDC, BOARD_GPTB_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Enable PLL PFD0 for GPTB */ + CCM_ControlGate(CCM, ccmPllGateSys, ccmClockNeededRunWait); + CCM_ControlGate(CCM, ccmPllGatePfd0, ccmClockNeededRunWait); + + /* Select GPTA clock derived from OSC 24M */ + CCM_UpdateRoot(CCM, BOARD_GPTB_CCM_ROOT, ccmRootmuxGptOsc24m, 0, 0); + /* Select GPTB clock derived from PLL PFD0 clock divide 4 (pre=2 post=2) */ + CCM_UpdateRoot(CCM, BOARD_GPTB_CCM_ROOT, ccmRootmuxGptSysPllPfd0, 1, 1); + + /* Enable clock used by GPTA */ + CCM_EnableRoot(CCM, BOARD_GPTA_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTA_CCM_CCGR, ccmClockNeededRunWait); + /* Enable clock used by GPTB */ + CCM_EnableRoot(CCM, BOARD_GPTB_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_GPTB_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/gpt/main.c b/examples/var-som-mx7_m4/driver_examples/gpt/main.c new file mode 100644 index 000000000..edf299ca1 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/gpt/main.c @@ -0,0 +1,135 @@ +/* + * 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 "gpt.h" +#include "board.h" +#include "clock_freq.h" +#include "debug_console_imx.h" + +/* This case will run for 5 seconds */ +static volatile uint32_t num = 10; +static uint32_t counterA, counterB; + +int main(void) +{ + uint32_t freqA, freqB; + gpt_init_config_t config = { + .freeRun = false, + .waitEnable = true, + .stopEnable = true, + .dozeEnable = true, + .dbgEnable = false, + .enableMode = true + }; + + hardware_init(); + + /* Initialize GPT module */ + GPT_Init(BOARD_GPTA_BASEADDR, &config); + GPT_Init(BOARD_GPTB_BASEADDR, &config); + + /* Set GPT clock source, when use OSC as clock source, we need to make sure the OSC freq + * after divided by OscPrescaler should be less than half of the peripheral clock set by + * CCM */ + GPT_SetClockSource(BOARD_GPTA_BASEADDR, gptClockSourceOsc); + GPT_SetClockSource(BOARD_GPTB_BASEADDR, gptClockSourcePeriph); + + /* Divide GPTA osc clock source frequency by 2, and divide additional 2 inside GPT module */ + GPT_SetOscPrescaler(BOARD_GPTA_BASEADDR, 1); + GPT_SetPrescaler(BOARD_GPTA_BASEADDR, 1); + /* Divide GPTB clock source frequency by 2 inside GPT module */ + GPT_SetPrescaler(BOARD_GPTB_BASEADDR, 1); + + /* Get GPT clock frequency */ + freqA = 24000000 / 2; /* A is bound to OSC directly, with OSC divider 2 */ + freqB = get_gpt_clock_freq(BOARD_GPTB_BASEADDR); /* Get B peripheral clock freq */ + /* GPTA and GPTB frequency is divided by 2 inside module */ + freqA /= 2; + freqB /= 2; + + /* Set both GPT modules to 1 second duration */ + GPT_SetOutputCompareValue(BOARD_GPTA_BASEADDR, gptOutputCompareChannel1, freqA); + GPT_SetOutputCompareValue(BOARD_GPTB_BASEADDR, gptOutputCompareChannel1, freqB); + + /* Set GPT interrupt priority to same value to avoid handler preemption */ + NVIC_SetPriority(BOARD_GPTA_IRQ_NUM, 3); + NVIC_SetPriority(BOARD_GPTB_IRQ_NUM, 3); + /* Enable NVIC interrupt */ + NVIC_EnableIRQ(BOARD_GPTA_IRQ_NUM); + NVIC_EnableIRQ(BOARD_GPTB_IRQ_NUM); + + /* Enable GPT Output Compare1 interrupt */ + GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, true); + GPT_SetIntCmd(BOARD_GPTB_BASEADDR, gptStatusFlagOutputCompare1, true); + + PRINTF("GPT timer will now start\n\r"); + PRINTF("counter/freq ratio should be close to 0.0 or 1.0 ...\n\r"); + /* GPT start */ + GPT_Enable(BOARD_GPTA_BASEADDR); + GPT_Enable(BOARD_GPTB_BASEADDR); + + while (true) + { + __WFI(); + + while ((num & 1) != 0); /* wait both timer handled */ + + PRINTF("\tGPT A freq %u, counter %u.\n\r", freqA, counterA); + PRINTF("\tGPT B freq %u, counter %u.\n\r", freqB, counterB); + + if (num == 0) + { + /* Stop GPT */ + GPT_Disable(BOARD_GPTA_BASEADDR); + GPT_Disable(BOARD_GPTB_BASEADDR); + PRINTF("GPT example finished...\n\r"); + } + } +} + +void BOARD_GPTA_HANDLER() +{ + GPT_ClearStatusFlag(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1); + + if (num && --num) + counterB = GPT_ReadCounter(BOARD_GPTB_BASEADDR); +} + +void BOARD_GPTB_HANDLER() +{ + GPT_ClearStatusFlag(BOARD_GPTB_BASEADDR, gptStatusFlagOutputCompare1); + + if (num && --num) + counterA = GPT_ReadCounter(BOARD_GPTA_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/CMakeLists.txt new file mode 100644 index 000000000..2e51254f9 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/CMakeLists.txt @@ -0,0 +1,136 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPRINTF_FLOAT_ENABLE") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__NDEBUG") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DCPU_MCIMX7D_M4") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DPRINTF_FLOAT_ENABLE") + +# CXX MACRO + +# INCLUDE_DIRECTORIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(i2c_imx_interrupt_rtc_imx7d_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/i2c_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/i2c_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(i2c_imx_interrupt_rtc_imx7d_example PROPERTIES OUTPUT_NAME "i2c_imx_interrupt_rtc_imx7d_example.elf") + +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_rtc_imx7d_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_rtc_imx7d_example m) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_rtc_imx7d_example c) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_rtc_imx7d_example gcc) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_rtc_imx7d_example nosys) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_rtc_imx7d_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/i2c_imx_interrupt_rtc_imx7d_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/i2c_imx_interrupt_rtc_imx7d_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET i2c_imx_interrupt_rtc_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_rtc_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_rtc_imx7d_example.hex) +ADD_CUSTOM_COMMAND(TARGET i2c_imx_interrupt_rtc_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_rtc_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_rtc_imx7d_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/ds5/.cproject new file mode 100644 index 000000000..8078e532a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/ds5/.project b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/ds5/.project new file mode 100644 index 000000000..d6e7f7309 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/ds5/.project @@ -0,0 +1,86 @@ + + + i2c_imx_interrupt_rtc_imx7d_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/i2c_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/i2c_imx.cdriver2virtual:/virtualdriver/i2c_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/i2c_imx.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/hardware_init.c new file mode 100644 index 000000000..3ffd20579 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/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 "board.h" +#include "pin_mux.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 example, we need to grasp board I2C exclusively */ + RDC_SetPdapAccess(RDC, BOARD_I2C_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select I2C clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_I2C_CCM_ROOT, ccmRootmuxI2cOsc24m, 0, 0); + /* Enable I2C clock */ + CCM_EnableRoot(CCM, BOARD_I2C_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_I2C_CCM_CCGR, ccmClockNeededRunWait); + + /* I2C Pin setting */ + configure_i2c_pins(BOARD_I2C_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/main.c b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/main.c new file mode 100644 index 000000000..dfcc7a17d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_interrupt_rtc_imx7d/main.c @@ -0,0 +1,433 @@ +/* + * 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 +#include "board.h" +#include "debug_console_imx.h" +#include "i2c_imx.h" + +#define DS1307_REG_SECS 0x00 /* 00-59 */ +#define DS1307_REG_MIN 0x01 /* 00-59 */ +#define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ +#define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ +#define DS1307_BIT_PM 0x20 /* in REG_HOUR */ +#define DS1307_REG_WDAY 0x03 /* 01-07 */ +#define DS1307_REG_MDAY 0x04 /* 01-31 */ +#define DS1307_REG_MONTH 0x05 /* 01-12 */ +#define DS1307_REG_YEAR 0x06 /* 00-99 */ +#define DS1337_REG_CONTROL 0x0e +#define DS1337_BIT_nEOSC 0x80 +#define DS1337_REG_STATUS 0x0f +#define DS1337_BIT_OSF 0x80 + +#define bcd2bin(x) (((x) & 0x0f) + ((x) >> 4) * 10) +#define bin2bcd(x) ((((x) / 10) << 4) + (x) % 10) + +typedef struct _i2c_state { + const uint8_t* cmdBuff; /*!< The buffer of I2C command. */ + const uint8_t* txBuff; /*!< The buffer of data being sent.*/ + uint8_t* rxBuff; /*!< The buffer of received data. */ + volatile uint32_t cmdSize; /*!< The remaining number of commands to be transmitted. */ + volatile uint32_t txSize; /*!< The remaining number of bytes to be transmitted. */ + volatile uint32_t rxSize; /*!< The remaining number of bytes to be received. */ + volatile bool isBusy; /*!< True if there is an active transmission. */ + volatile uint32_t operateDir; /*!< Overall I2C bus operating direction. */ + volatile uint32_t currentDir; /*!< Current Data transfer direction. */ + volatile uint32_t currentMode; /*!< Current I2C Bus role of this module. */ +} i2c_state_t; + +/* I2C runtime state structure */ +static i2c_state_t i2cState; + +static uint8_t txBuffer[5]; +static uint8_t rxBuffer[7]; +static uint8_t cmdBuffer[5]; + +static void report_date(void); +static void I2C_XFER_Config(i2c_init_config_t* initConfig); +static bool I2C_XFER_Write(const uint8_t* cmdBuff, uint32_t cmdSize, const uint8_t* txBuffer, uint32_t txSize); +static bool I2C_XFER_Read(const uint8_t* cmdBuff, uint32_t cmdSize, uint8_t* rxBuffer, uint32_t rxSize); +static bool I2C_XFER_IsBusy(void); + +int main(void) +{ + /* Setup I2C init structure. */ + i2c_init_config_t i2cInitConfig = { + .baudRate = 400000u, + .slaveAddress = 0x00 + }; + + /* Initialize board specified hardware. */ + hardware_init(); + + /* Get current module clock frequency. */ + i2cInitConfig.clockRate = get_i2c_clock_freq(BOARD_I2C_BASEADDR); + + PRINTF("\n\r++++++++++++++++ I2C Send/Receive interrupt Example ++++++++++++++++\n\r"); + PRINTF("This example will configure on board RTC through I2C Bus\n\r"); + PRINTF("and read the date to see if the RTC is configured successfully. \n\r"); + + PRINTF("[1].Initialize the I2C module with initialize structure. \n\r"); + I2C_XFER_Config(&i2cInitConfig); + + /* Finally, enable the I2C module */ + I2C_Enable(BOARD_I2C_BASEADDR); + + PRINTF("[2].Read on-board RTC control & status registers\n\r"); + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1337_REG_CONTROL; + cmdBuffer[2] = (BOARD_I2C_ISL12057_ADDR << 1) + 1; + I2C_XFER_Read(cmdBuffer, 3, rxBuffer, 2); + while (I2C_XFER_IsBusy()); + + PRINTF("[3].If oscillator off, turn it on, so clock can tick\n\r"); + if (rxBuffer[0] & DS1337_BIT_nEOSC) { + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1337_REG_CONTROL; + txBuffer[0] = rxBuffer[0] & ~DS1337_BIT_nEOSC; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while (I2C_XFER_IsBusy()); + PRINTF("Oscillator turned on!\n\r"); + } + + PRINTF("[4].If oscillator fault, clear flag, and warn\n\r"); + if (rxBuffer[1] & DS1337_BIT_OSF) { + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1337_REG_STATUS; + txBuffer[0] = rxBuffer[1] & ~DS1337_BIT_OSF; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while (I2C_XFER_IsBusy()); + PRINTF("SET TIME!\n\r"); + } + + PRINTF("[5].Ensure RTC uses in 24-hours format\n\r"); + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1307_REG_HOUR; + cmdBuffer[2] = (BOARD_I2C_ISL12057_ADDR << 1) + 1; + I2C_XFER_Read(cmdBuffer, 3, rxBuffer, 1); + while (I2C_XFER_IsBusy()); + if (rxBuffer[0] & DS1307_BIT_12HR) { + /* use txBuffer[1] for binary conversion before swtching to bcd */ + txBuffer[1] = bcd2bin(rxBuffer[0] & 0x1f); + if (txBuffer[1] == 12) + txBuffer[1] = 0; + if (rxBuffer[0] & DS1307_BIT_PM) + txBuffer[1] += 12; + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1307_REG_HOUR; + txBuffer[0] = bin2bcd(txBuffer[1]); + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while (I2C_XFER_IsBusy()); + PRINTF("RTC switched to 24-hours format!\n\r"); + } + + PRINTF("[6].Get current date\n\r"); + report_date(); + + PRINTF("\n\rExample finished!!!\n\r"); + while (true) + __WFI(); +} + +static void report_date(void) +{ + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1307_REG_SECS; + cmdBuffer[2] = (BOARD_I2C_ISL12057_ADDR << 1) + 1; + I2C_XFER_Read(cmdBuffer, 3, rxBuffer, 7); + while (I2C_XFER_IsBusy()); + + PRINTF("DATE [gg/mm/yyyy hh:mm:ss]: %02d/%02d/%04d %02d:%02d:%02d\n\r", + bcd2bin(rxBuffer[DS1307_REG_MDAY] & 0x3f), + bcd2bin(rxBuffer[DS1307_REG_MONTH] & 0x1f), + 2000 + bcd2bin(rxBuffer[DS1307_REG_YEAR]), + bcd2bin(rxBuffer[DS1307_REG_HOUR] & 0x3f), + bcd2bin(rxBuffer[DS1307_REG_MIN] & 0x7f), + bcd2bin(rxBuffer[DS1307_REG_SECS] & 0x7f)); +} + +static void I2C_XFER_Config(i2c_init_config_t* initConfig) +{ + /* Initialize I2C state structure content. */ + i2cState.cmdBuff = 0; + i2cState.txBuff = 0; + i2cState.rxBuff = 0; + i2cState.cmdSize = 0; + i2cState.txSize = 0; + i2cState.rxSize = 0; + i2cState.isBusy = false; + i2cState.operateDir = i2cDirectionReceive; + i2cState.currentDir = i2cDirectionReceive; + i2cState.currentMode = i2cModeSlave; + + /* Initialize I2C baud rate, mode, transfer direction and slave address. */ + I2C_Init(BOARD_I2C_BASEADDR, initConfig); + + /* Set I2C Interrupt priority */ + NVIC_SetPriority(BOARD_I2C_IRQ_NUM, 3); + + /* Call core API to enable the IRQ. */ + NVIC_EnableIRQ(BOARD_I2C_IRQ_NUM); + + /* Finally, enable the I2C module */ + I2C_Enable(BOARD_I2C_BASEADDR); +} + +static bool I2C_XFER_Write(const uint8_t* cmdBuff, uint32_t cmdSize, + const uint8_t* txBuffer, uint32_t txSize) +{ + if ((i2cState.isBusy) || (0 == txSize)) + return false; + + /* Initialize i2c transfer struct */ + i2cState.cmdBuff = cmdBuff; + i2cState.cmdSize = cmdSize; + i2cState.txBuff = txBuffer; + i2cState.txSize = txSize; + i2cState.isBusy = true; + i2cState.operateDir = i2cDirectionTransmit; + + /* Clear I2C interrupt flag to avoid spurious interrupt */ + I2C_ClearStatusFlag(BOARD_I2C_BASEADDR, i2cStatusInterrupt); + + if (I2C_GetStatusFlag(BOARD_I2C_BASEADDR, i2cStatusBusBusy)) + { + /* Reset i2c transfer state. */ + i2cState.operateDir = i2cDirectionReceive; + i2cState.isBusy = false; + return false; + } + + /* Set I2C work under Tx mode */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionTransmit); + i2cState.currentDir = i2cDirectionTransmit; + + /* Switch to Master Mode and Send Start Signal. */ + I2C_SetWorkMode(BOARD_I2C_BASEADDR, i2cModeMaster); + i2cState.currentMode = i2cModeMaster; + + if (0 != cmdSize) + { + I2C_WriteByte(BOARD_I2C_BASEADDR, *i2cState.cmdBuff); + i2cState.cmdBuff++; + i2cState.cmdSize--; + } + else + { + I2C_WriteByte(BOARD_I2C_BASEADDR, *i2cState.txBuff); + i2cState.txBuff++; + i2cState.txSize--; + } + + /* Enable I2C interrupt, subsequent data transfer will be handled in ISR. */ + I2C_SetIntCmd(BOARD_I2C_BASEADDR, true); + + return true; +} + +static bool I2C_XFER_Read(const uint8_t* cmdBuff, uint32_t cmdSize, + uint8_t* rxBuffer, uint32_t rxSize) +{ + if ((i2cState.isBusy) || (0 == rxSize)) + return false; + + /* Initialize i2c transfer struct */ + i2cState.cmdBuff = cmdBuff; + i2cState.cmdSize = cmdSize; + i2cState.rxBuff = rxBuffer; + i2cState.rxSize = rxSize; + i2cState.isBusy = true; + i2cState.operateDir = i2cDirectionReceive; + + /* Clear I2C interrupt flag to avoid spurious interrupt */ + I2C_ClearStatusFlag(BOARD_I2C_BASEADDR, i2cStatusInterrupt); + + if (I2C_GetStatusFlag(BOARD_I2C_BASEADDR, i2cStatusBusBusy)) + { + /* Reset i2c transfer state. */ + i2cState.operateDir = i2cDirectionReceive; + i2cState.isBusy = false; + return false; + } + + /* Set I2C work under Tx mode */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionTransmit); + i2cState.currentDir = i2cDirectionTransmit; + + /* Switch to Master Mode and Send Start Signal. */ + I2C_SetWorkMode(BOARD_I2C_BASEADDR, i2cModeMaster); + i2cState.currentMode = i2cModeMaster; + + /* Is there command to be sent before receive data? */ + if (0 != i2cState.cmdSize) + { + if (1 == i2cState.cmdSize) + I2C_SendRepeatStart(BOARD_I2C_BASEADDR); + I2C_WriteByte(BOARD_I2C_BASEADDR, *i2cState.cmdBuff); + i2cState.cmdBuff++; + i2cState.cmdSize--; + } + else + { + /* Change to receive state. */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionReceive); + i2cState.currentDir = i2cDirectionReceive; + + if (1 == rxSize) + /* Send Nack */ + I2C_SetAckBit(BOARD_I2C_BASEADDR, false); + else + /* Send Ack */ + I2C_SetAckBit(BOARD_I2C_BASEADDR, true); + /* dummy read to clock in 1st byte */ + I2C_ReadByte(BOARD_I2C_BASEADDR); + } + + /* Enable I2C interrupt, subsequent data transfer will be handled in ISR. */ + I2C_SetIntCmd(BOARD_I2C_BASEADDR, true); + + return true; +} + +static bool I2C_XFER_IsBusy(void) +{ + return i2cState.isBusy; +} + +void BOARD_I2C_HANDLER(void) +{ + /* Clear interrupt flag. */ + I2C_ClearStatusFlag(BOARD_I2C_BASEADDR, i2cStatusInterrupt); + + /* Exit the ISR if no transfer is happening for this instance. */ + if (!i2cState.isBusy) + return; + + if (i2cModeMaster == i2cState.currentMode) + { + if (i2cDirectionTransmit == i2cState.currentDir) + { + if ((I2C_GetStatusFlag(BOARD_I2C_BASEADDR, i2cStatusReceivedAck)) || + ((0 == i2cState.txSize) && (0 == i2cState.cmdSize))) + { + if ((i2cDirectionTransmit == i2cState.operateDir) || + (I2C_GetStatusFlag(BOARD_I2C_BASEADDR, i2cStatusReceivedAck))) + { + /* Switch to Slave mode and Generate a Stop Signal. */ + I2C_SetWorkMode(BOARD_I2C_BASEADDR, i2cModeSlave); + i2cState.currentMode = i2cModeSlave; + + /* Switch back to Rx direction. */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionReceive); + i2cState.currentDir = i2cDirectionReceive; + + /* Close I2C interrupt. */ + I2C_SetIntCmd(BOARD_I2C_BASEADDR, false); + /* Release I2C Bus. */ + i2cState.isBusy = false; + } + else + { + /* Switch back to Rx direction. */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionReceive); + i2cState.currentDir = i2cDirectionReceive; + + if (1 == i2cState.rxSize) + /* Send Nack */ + I2C_SetAckBit(BOARD_I2C_BASEADDR, false); + else + /* Send Ack */ + I2C_SetAckBit(BOARD_I2C_BASEADDR, true); + /* dummy read to clock in 1st byte */ + *i2cState.rxBuff = I2C_ReadByte(BOARD_I2C_BASEADDR); + } + } + else + { + if (0 != i2cState.cmdSize) + { + if ((1 == i2cState.cmdSize) && (i2cDirectionReceive == i2cState.operateDir)) + I2C_SendRepeatStart(BOARD_I2C_BASEADDR); + I2C_WriteByte(BOARD_I2C_BASEADDR, *i2cState.cmdBuff); + i2cState.cmdBuff++; + i2cState.cmdSize--; + } + else + { + I2C_WriteByte(BOARD_I2C_BASEADDR, *i2cState.txBuff); + i2cState.txBuff++; + i2cState.txSize--; + } + } + } + else + { + /* Normal read operation. */ + if (2 == i2cState.rxSize) + /* Send Nack */ + I2C_SetAckBit(BOARD_I2C_BASEADDR, false); + else + /* Send Nack */ + I2C_SetAckBit(BOARD_I2C_BASEADDR, true); + + if (1 == i2cState.rxSize) + { + /* Switch back to Tx direction to avoid additional I2C bus read. */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionTransmit); + i2cState.currentDir = i2cDirectionTransmit; + } + *i2cState.rxBuff = I2C_ReadByte(BOARD_I2C_BASEADDR); + i2cState.rxBuff++; + i2cState.rxSize--; + + /* receive finished. */ + if (0 == i2cState.rxSize) + { + /* Switch to Slave mode and Generate a Stop Signal. */ + I2C_SetWorkMode(BOARD_I2C_BASEADDR, i2cModeSlave); + i2cState.currentMode = i2cModeSlave; + + /* Switch back to Rx direction. */ + I2C_SetDirMode(BOARD_I2C_BASEADDR, i2cDirectionReceive); + i2cState.currentDir = i2cDirectionReceive; + + /* Close I2C interrupt. */ + I2C_SetIntCmd(BOARD_I2C_BASEADDR, false); + /* Release I2C Bus. */ + i2cState.isBusy = false; + } + } + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/CMakeLists.txt new file mode 100644 index 000000000..0df930771 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/CMakeLists.txt @@ -0,0 +1,136 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPRINTF_FLOAT_ENABLE") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D__NDEBUG") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DCPU_MCIMX7D_M4") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DPRINTF_FLOAT_ENABLE") + +# CXX MACRO + +# INCLUDE_DIRECTORIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(i2c_imx_polling_rtc_imx7d_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/i2c_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/i2c_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(i2c_imx_polling_rtc_imx7d_example PROPERTIES OUTPUT_NAME "i2c_imx_polling_rtc_imx7d_example.elf") + +TARGET_LINK_LIBRARIES(i2c_imx_polling_rtc_imx7d_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(i2c_imx_polling_rtc_imx7d_example m) +TARGET_LINK_LIBRARIES(i2c_imx_polling_rtc_imx7d_example c) +TARGET_LINK_LIBRARIES(i2c_imx_polling_rtc_imx7d_example gcc) +TARGET_LINK_LIBRARIES(i2c_imx_polling_rtc_imx7d_example nosys) +TARGET_LINK_LIBRARIES(i2c_imx_polling_rtc_imx7d_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/i2c_imx_polling_rtc_imx7d_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/i2c_imx_polling_rtc_imx7d_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET i2c_imx_polling_rtc_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_rtc_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_rtc_imx7d_example.hex) +ADD_CUSTOM_COMMAND(TARGET i2c_imx_polling_rtc_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_rtc_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_rtc_imx7d_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/ds5/.cproject new file mode 100644 index 000000000..a915cc9a2 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/ds5/.project b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/ds5/.project new file mode 100644 index 000000000..4b6a9121f --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/ds5/.project @@ -0,0 +1,86 @@ + + + i2c_imx_polling_rtc_imx7d_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/i2c_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/i2c_imx.cdriver2virtual:/virtualdriver/i2c_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/i2c_imx.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/hardware_init.c new file mode 100644 index 000000000..3ffd20579 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/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 "board.h" +#include "pin_mux.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 example, we need to grasp board I2C exclusively */ + RDC_SetPdapAccess(RDC, BOARD_I2C_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Select I2C clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_I2C_CCM_ROOT, ccmRootmuxI2cOsc24m, 0, 0); + /* Enable I2C clock */ + CCM_EnableRoot(CCM, BOARD_I2C_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_I2C_CCM_CCGR, ccmClockNeededRunWait); + + /* I2C Pin setting */ + configure_i2c_pins(BOARD_I2C_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/main.c b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/main.c new file mode 100644 index 000000000..8939b15d5 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/i2c_imx/i2c_polling_rtc_imx7d/main.c @@ -0,0 +1,347 @@ +/* + * 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 +#include "board.h" +#include "debug_console_imx.h" +#include "i2c_imx.h" + +#define DS1307_REG_SECS 0x00 /* 00-59 */ +#define DS1307_REG_MIN 0x01 /* 00-59 */ +#define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ +#define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ +#define DS1307_BIT_PM 0x20 /* in REG_HOUR */ +#define DS1307_REG_WDAY 0x03 /* 01-07 */ +#define DS1307_REG_MDAY 0x04 /* 01-31 */ +#define DS1307_REG_MONTH 0x05 /* 01-12 */ +#define DS1307_REG_YEAR 0x06 /* 00-99 */ +#define DS1337_REG_CONTROL 0x0e +#define DS1337_BIT_nEOSC 0x80 +#define DS1337_REG_STATUS 0x0f +#define DS1337_BIT_OSF 0x80 + +#define bcd2bin(x) (((x) & 0x0f) + ((x) >> 4) * 10) +#define bin2bcd(x) ((((x) / 10) << 4) + (x) % 10) + +static uint8_t txBuffer[5]; +static uint8_t rxBuffer[7]; +static uint8_t cmdBuffer[5]; + +static void report_date(void); +static bool I2C_MasterSendDataPolling(I2C_Type *base, + const uint8_t *cmdBuff, + uint32_t cmdSize, + const uint8_t *txBuff, + uint32_t txSize); +static bool I2C_MasterReceiveDataPolling(I2C_Type *base, + const uint8_t *cmdBuff, + uint32_t cmdSize, + uint8_t *rxBuff, + uint32_t rxSize); + +int main(void) +{ + /* Setup I2C init structure. */ + i2c_init_config_t i2cInitConfig = { + .baudRate = 400000u, + .slaveAddress = 0x00 + }; + + /* Initialize board specified hardware. */ + hardware_init(); + + /* Get current module clock frequency. */ + i2cInitConfig.clockRate = get_i2c_clock_freq(BOARD_I2C_BASEADDR); + + PRINTF("\n\r++++++++++++++++ I2C Send/Receive polling Example ++++++++++++++++\n\r"); + PRINTF("This example will configure on board RTC through I2C Bus\n\r"); + PRINTF("and read the date to see if the RTC is configured successfully. \n\r"); + + PRINTF("[1].Initialize the I2C module with initialize structure. \n\r"); + I2C_Init(BOARD_I2C_BASEADDR, &i2cInitConfig); + + /* Finally, enable the I2C module */ + I2C_Enable(BOARD_I2C_BASEADDR); + + PRINTF("[2].Read on-board RTC control & status registers\n\r"); + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1337_REG_CONTROL; + cmdBuffer[2] = (BOARD_I2C_ISL12057_ADDR << 1) + 1; + I2C_MasterReceiveDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 3, rxBuffer, 2); + + PRINTF("[3].If oscillator off, turn it on, so clock can tick\n\r"); + if (rxBuffer[0] & DS1337_BIT_nEOSC) { + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1337_REG_CONTROL; + txBuffer[0] = rxBuffer[0] & ~DS1337_BIT_nEOSC; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + PRINTF("Oscillator turned on!\n\r"); + } + + PRINTF("[4].If oscillator fault, clear flag, and warn\n\r"); + if (rxBuffer[1] & DS1337_BIT_OSF) { + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1337_REG_STATUS; + txBuffer[0] = rxBuffer[1] & ~DS1337_BIT_OSF; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + PRINTF("SET TIME!\n\r"); + } + + PRINTF("[5].Ensure RTC uses in 24-hours format\n\r"); + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1307_REG_HOUR; + cmdBuffer[2] = (BOARD_I2C_ISL12057_ADDR << 1) + 1; + I2C_MasterReceiveDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 3, rxBuffer, 1); + if (rxBuffer[0] & DS1307_BIT_12HR) { + /* use txBuffer[1] for binary conversion before swtching to bcd */ + txBuffer[1] = bcd2bin(rxBuffer[0] & 0x1f); + if (txBuffer[1] == 12) + txBuffer[1] = 0; + if (rxBuffer[0] & DS1307_BIT_PM) + txBuffer[1] += 12; + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1307_REG_HOUR; + txBuffer[0] = bin2bcd(txBuffer[1]); + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + PRINTF("RTC switched to 24-hours format!\n\r"); + } + + PRINTF("[6].Get current date\n\r"); + report_date(); + + PRINTF("\n\rExample finished!!!\n\r"); + while (true) + __WFI(); +} + +static void report_date(void) +{ + cmdBuffer[0] = BOARD_I2C_ISL12057_ADDR << 1; + cmdBuffer[1] = DS1307_REG_SECS; + cmdBuffer[2] = (BOARD_I2C_ISL12057_ADDR << 1) + 1; + I2C_MasterReceiveDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 3, rxBuffer, 7); + + PRINTF("DATE [gg/mm/yyyy hh:mm:ss]: %02d/%02d/%04d %02d:%02d:%02d\n\r", + bcd2bin(rxBuffer[DS1307_REG_MDAY] & 0x3f), + bcd2bin(rxBuffer[DS1307_REG_MONTH] & 0x1f), + 2000 + bcd2bin(rxBuffer[DS1307_REG_YEAR]), + bcd2bin(rxBuffer[DS1307_REG_HOUR] & 0x3f), + bcd2bin(rxBuffer[DS1307_REG_MIN] & 0x7f), + bcd2bin(rxBuffer[DS1307_REG_SECS] & 0x7f)); +} + +static bool I2C_MasterSendDataPolling(I2C_Type *base, + const uint8_t *cmdBuff, + uint32_t cmdSize, + const uint8_t *txBuff, + uint32_t txSize) +{ + if (I2C_GetStatusFlag(base, i2cStatusBusBusy)) + return false; + + /* Set I2C work under Tx mode */ + I2C_SetDirMode(base, i2cDirectionTransmit); + + /* Switch to Master Mode and Send Start Signal. */ + I2C_SetWorkMode(base, i2cModeMaster); + + /* Send first byte */ + if (0 != cmdSize) + { + I2C_WriteByte(base, *cmdBuff++); + cmdSize--; + } + else + { + I2C_WriteByte(base, *txBuff++); + txSize--; + } + + while (1) + { + /* Wait I2C transmission status flag assert. */ + while (!I2C_GetStatusFlag(base, i2cStatusInterrupt)); + + /* Clear I2C transmission status flag. */ + I2C_ClearStatusFlag(base, i2cStatusInterrupt); + + /* Transmit complete. */ + if ((I2C_GetStatusFlag(base, i2cStatusReceivedAck)) || + ((0 == txSize) && (0 == cmdSize))) + { + /* Switch to Slave mode and Generate a Stop Signal. */ + I2C_SetWorkMode(base, i2cModeSlave); + + /* Switch back to Rx direction. */ + I2C_SetDirMode(base, i2cDirectionReceive); + return true; + } + else + { + if (0 != cmdSize) + { + I2C_WriteByte(base, *cmdBuff++); + cmdSize--; + } + else + { + I2C_WriteByte(base, *txBuff++); + txSize--; + } + } + } +} + +static bool I2C_MasterReceiveDataPolling(I2C_Type *base, + const uint8_t *cmdBuff, + uint32_t cmdSize, + uint8_t *rxBuff, + uint32_t rxSize) +{ + uint32_t currentDir = i2cDirectionReceive; + + /* Clear I2C interrupt flag to avoid spurious interrupt */ + I2C_ClearStatusFlag(base, i2cStatusInterrupt); + + if (I2C_GetStatusFlag(base, i2cStatusBusBusy)) + { + return false; + } + + /* Set I2C work under Tx mode */ + I2C_SetDirMode(base, i2cDirectionTransmit); + + /* Switch to Master Mode and Send Start Signal. */ + I2C_SetWorkMode(base, i2cModeMaster); + + if (0 != cmdSize) + { + currentDir = i2cDirectionTransmit; + if (1 == cmdSize) + I2C_SendRepeatStart(base); + I2C_WriteByte(base, *cmdBuff++); + cmdSize--; + } + else + { + /* Change to receive state. */ + I2C_SetDirMode(base, i2cDirectionReceive); + + if (1 == rxSize) + /* Send Nack */ + I2C_SetAckBit(base, false); + else + /* Send Ack */ + I2C_SetAckBit(base, true); + /* dummy read to clock in 1st byte */ + *rxBuff = I2C_ReadByte(base); + } + + while (1) + { + /* Wait I2C transmission status flag assert. */ + while (!I2C_GetStatusFlag(base, i2cStatusInterrupt)); + + /* Clear I2C transmission status flag. */ + I2C_ClearStatusFlag(base, i2cStatusInterrupt); + + if (i2cDirectionTransmit == currentDir) + { + if (0 < cmdSize) + { + if (I2C_GetStatusFlag(base, i2cStatusReceivedAck)) + { + /* Switch to Slave mode and Generate a Stop Signal. */ + I2C_SetWorkMode(base, i2cModeSlave); + + /* Switch back to Rx direction. */ + I2C_SetDirMode(base, i2cDirectionReceive); + return false; + } + else + { + if (1 == cmdSize) + I2C_SendRepeatStart(base); + I2C_WriteByte(base, *cmdBuff++); + cmdSize--; + } + } + else + { + /* Change to receive state. */ + I2C_SetDirMode(base, i2cDirectionReceive); + currentDir = i2cDirectionReceive; + + if (1 == rxSize) + /* Send Nack */ + I2C_SetAckBit(base, false); + else + /* Send Ack */ + I2C_SetAckBit(base, true); + /* dummy read to clock in 1st byte */ + *rxBuff = I2C_ReadByte(base); + } + } + else + { + /* Normal read operation. */ + if (2 == rxSize) + /* Send Nack */ + I2C_SetAckBit(base, false); + else + /* Send Nack */ + I2C_SetAckBit(base, true); + + if (1 == rxSize) + /* Switch back to Tx direction to avoid additional I2C bus read. */ + I2C_SetDirMode(base, i2cDirectionTransmit); + *rxBuff = I2C_ReadByte(base); + rxBuff++; + rxSize--; + + /* receive finished. */ + if (0 == rxSize) + { + /* Switch to Slave mode and Generate a Stop Signal. */ + I2C_SetWorkMode(base, i2cModeSlave); + + /* Switch back to Rx direction. */ + I2C_SetDirMode(base, i2cDirectionReceive); + + return true; + } + } + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/CMakeLists.txt new file mode 100644 index 000000000..a9a2980f1 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/CMakeLists.txt @@ -0,0 +1,132 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(uart_imx_interrupt_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(uart_imx_interrupt_example PROPERTIES OUTPUT_NAME "uart_imx_interrupt_example.elf") + +TARGET_LINK_LIBRARIES(uart_imx_interrupt_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(uart_imx_interrupt_example m) +TARGET_LINK_LIBRARIES(uart_imx_interrupt_example c) +TARGET_LINK_LIBRARIES(uart_imx_interrupt_example gcc) +TARGET_LINK_LIBRARIES(uart_imx_interrupt_example nosys) +TARGET_LINK_LIBRARIES(uart_imx_interrupt_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/uart_imx_interrupt_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/uart_imx_interrupt_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET uart_imx_interrupt_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/uart_imx_interrupt_example.elf ${EXECUTABLE_OUTPUT_PATH}/uart_imx_interrupt_example.hex) +ADD_CUSTOM_COMMAND(TARGET uart_imx_interrupt_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/uart_imx_interrupt_example.elf ${EXECUTABLE_OUTPUT_PATH}/uart_imx_interrupt_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/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/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject new file mode 100644 index 000000000..7eed1b9ed --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project new file mode 100644 index 000000000..20ff7e2f1 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project @@ -0,0 +1,86 @@ + + + uart_imx_interrupt_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/hardware_init.c new file mode 100644 index 000000000..b9efeaf23 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/hardware_init.c @@ -0,0 +1,57 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* In this example, we need to grasp board debug uart exclusively */ + RDC_SetPdapAccess(RDC, BOARD_DEBUG_UART_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* Select board debug clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_DEBUG_UART_CCM_ROOT, ccmRootmuxUartOsc24m, 0, 0); + /* Enable debug uart clock */ + CCM_EnableRoot(CCM, BOARD_DEBUG_UART_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_DEBUG_UART_CCM_CCGR, ccmClockNeededRunWait); + + /* UART Pin setting */ + configure_uart_pins(BOARD_DEBUG_UART_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/main.c b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/main.c new file mode 100644 index 000000000..9b22f1fae --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_interrupt/main.c @@ -0,0 +1,220 @@ +/* + * 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 +#include "uart_imx.h" +#include "board.h" + +typedef struct _uart_state { + const uint8_t* txBuff; /*!< The buffer of data being sent.*/ + uint8_t* rxBuff; /*!< The buffer of received data. */ + volatile uint32_t txSize; /*!< The remaining number of bytes to be transmitted. */ + volatile uint32_t rxSize; /*!< The remaining number of bytes to be received. */ + volatile bool isTxBusy; /*!< True if there is an active transmit. */ + volatile bool isRxBusy; /*!< True if there is an active receive. */ +} uart_state_t; + +const uint8_t buffStart[] = "\n\r++++++++++++++++ UART Send/Receive Interrupt Driven Example +++++++++++++++++\n\r"; +const uint8_t bufferData[] = "\n\rType characters from keyboard, the board will receive and then echo them to terminal screen\n\r"; + +/* Uart runtime state structure */ +static uart_state_t uartState; + +static void UART_XFER_Config(uart_init_config_t* initConfig); +static bool UART_XFER_Write(uint8_t* txBuffer, uint32_t length); +static uint32_t UART_XFER_GetWriteStatus(void); +static bool UART_XFER_Read(uint8_t* rxBuffer, uint32_t length); +static uint32_t UART_XFER_GetReadStatus(void); + +int main(void) +{ + // Setup UART init structure. + uart_init_config_t initConfig = { + .baudRate = 115200u, + .wordLength = uartWordLength8Bits, + .stopBitNum = uartStopBitNumOne, + .parity = uartParityDisable, + .direction = uartDirectionTxRx + }; + uint8_t rxChar, txChar; + + // Initialize board specified hardware. + hardware_init(); + + // Get current module clock frequency. + initConfig.clockRate = get_uart_clock_freq(BOARD_DEBUG_UART_BASEADDR); + + // Initialize the uart module with initialize structure. + UART_XFER_Config(&initConfig); + + // Inform to start non blocking example. + UART_XFER_Write((uint8_t*)buffStart, sizeof(buffStart)); + // Wait until transmission is finished. + while (UART_XFER_GetWriteStatus()); + + // Inform user of what to do + UART_XFER_Write((uint8_t*)bufferData, sizeof(bufferData)); + // Wait until transmission is finished. + while (UART_XFER_GetWriteStatus()); + + while (true) + { + // Call received API + UART_XFER_Read(&rxChar, 1u); + + // Wait until we receive a character + while (UART_XFER_GetReadStatus()); + + // Echo received character + txChar = rxChar; + UART_XFER_Write(&txChar, 1u); + } +} + +static void UART_XFER_Config(uart_init_config_t* initConfig) +{ + /* Assert */ + + /* Initialize UART state structure content. */ + uartState.txBuff = 0; + uartState.rxBuff = 0; + uartState.txSize = 0; + uartState.rxSize = 0; + uartState.isTxBusy = false; + uartState.isRxBusy = false; + + /* Initialize UART baud rate, bit count, parity, stop bit and direction. */ + UART_Init(BOARD_DEBUG_UART_BASEADDR, initConfig); + + UART_SetTxFifoWatermark(BOARD_DEBUG_UART_BASEADDR, 16); + UART_SetRxFifoWatermark(BOARD_DEBUG_UART_BASEADDR, 1); + + /* Set UART Interrupt priority */ + NVIC_SetPriority(BOARD_DEBUG_UART_IRQ_NUM, 3); + + /* Call core API to enable the IRQ. */ + NVIC_EnableIRQ(BOARD_DEBUG_UART_IRQ_NUM); + + /* Finally, enable the UART module */ + UART_Enable(BOARD_DEBUG_UART_BASEADDR); +} + +static bool UART_XFER_Write(uint8_t* txBuffer, uint32_t length) +{ + if ((uartState.isTxBusy) || (0 == length)) + return false; + + uartState.txBuff = txBuffer; + uartState.txSize = length; + uartState.isTxBusy = true; + + UART_SetIntCmd(BOARD_DEBUG_UART_BASEADDR, uartIntTxReady, true); + return true; +} + +static uint32_t UART_XFER_GetWriteStatus(void) +{ + return uartState.txSize; +} + +static bool UART_XFER_Read(uint8_t* rxBuffer, uint32_t length) +{ + if ((uartState.isRxBusy) || (0 == length)) + return false; + uartState.rxBuff = rxBuffer; + uartState.rxSize = length; + uartState.isRxBusy = true; + + UART_SetIntCmd(BOARD_DEBUG_UART_BASEADDR, uartIntRxReady, true); + return true; +} + +static uint32_t UART_XFER_GetReadStatus(void) +{ + return uartState.rxSize; +} + +void BOARD_DEBUG_UART_HANDLER(void) +{ + /* Exit the ISR if no transfer is happening for this instance. */ + if ((!uartState.isTxBusy) && (!uartState.isRxBusy)) + return; + + if (UART_GetStatusFlag(BOARD_DEBUG_UART_BASEADDR, uartStatusRxReady)) + { + /* Check to see if there are any more bytes to receive. */ + if (uartState.rxSize) + { + while (UART_GetStatusFlag(BOARD_DEBUG_UART_BASEADDR, uartStatusRxReady)) + { + *(uartState.rxBuff) = (uint8_t)UART_Getchar(BOARD_DEBUG_UART_BASEADDR); + uartState.rxBuff++; + uartState.rxSize--; + if (uartState.rxSize == 0U) + { + UART_SetIntCmd(BOARD_DEBUG_UART_BASEADDR, uartIntRxReady, false); + + uartState.isRxBusy = false; + break; + } + } + } + } + + if (UART_GetStatusFlag(BOARD_DEBUG_UART_BASEADDR, uartStatusTxReady)) + { + /* Check to see if there are any more bytes to send. */ + if (uartState.txSize) + { + while (UART_GetStatusFlag(BOARD_DEBUG_UART_BASEADDR, uartStatusTxReady)) + { + /* Transmit data and update tx size/buff */ + UART_Putchar(BOARD_DEBUG_UART_BASEADDR, *(uartState.txBuff)); + uartState.txBuff++; + uartState.txSize--; + if (uartState.txSize == 0U) + { + /* Transmit complete */ + /* Disable the transmitter ready interrupt */ + UART_SetIntCmd(BOARD_DEBUG_UART_BASEADDR, uartIntTxReady, false); + + /* Update the information of the module driver state */ + uartState.isTxBusy = false; + break; + } + } + } + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/CMakeLists.txt new file mode 100644 index 000000000..97d1f98fa --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/CMakeLists.txt @@ -0,0 +1,132 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../../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${ProjDirPath}/../../../../../../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(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(uart_imx_polling_example + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(uart_imx_polling_example PROPERTIES OUTPUT_NAME "uart_imx_polling_example.elf") + +TARGET_LINK_LIBRARIES(uart_imx_polling_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(uart_imx_polling_example m) +TARGET_LINK_LIBRARIES(uart_imx_polling_example c) +TARGET_LINK_LIBRARIES(uart_imx_polling_example gcc) +TARGET_LINK_LIBRARIES(uart_imx_polling_example nosys) +TARGET_LINK_LIBRARIES(uart_imx_polling_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/uart_imx_polling_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/uart_imx_polling_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET uart_imx_polling_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/uart_imx_polling_example.elf ${EXECUTABLE_OUTPUT_PATH}/uart_imx_polling_example.hex) +ADD_CUSTOM_COMMAND(TARGET uart_imx_polling_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/uart_imx_polling_example.elf ${EXECUTABLE_OUTPUT_PATH}/uart_imx_polling_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.bat new file mode 100644 index 000000000..0cf721f0d --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.sh new file mode 100755 index 000000000..382752959 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.bat new file mode 100644 index 000000000..e9ccfdd9a --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.sh new file mode 100755 index 000000000..effd076cc --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.bat new file mode 100644 index 000000000..075934933 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.sh new file mode 100755 index 000000000..a12067d68 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/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/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject new file mode 100644 index 000000000..781f8100c --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/ds5/.project b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/ds5/.project new file mode 100644 index 000000000..1857f4174 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/ds5/.project @@ -0,0 +1,86 @@ + + + uart_imx_polling_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-6-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-6-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-6-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-6-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-6-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-6-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-6-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-4-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-4-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-4-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-4-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-4-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-4-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-6-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-6-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/hardware_init.c new file mode 100644 index 000000000..b9efeaf23 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/hardware_init.c @@ -0,0 +1,57 @@ +/* + * 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 "board.h" +#include "pin_mux.h" + +void hardware_init(void) +{ + /* Board specific RDC settings */ + BOARD_RdcInit(); + + /* In this example, we need to grasp board debug uart exclusively */ + RDC_SetPdapAccess(RDC, BOARD_DEBUG_UART_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Board specific clock settings */ + BOARD_ClockInit(); + + /* Select board debug clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_DEBUG_UART_CCM_ROOT, ccmRootmuxUartOsc24m, 0, 0); + /* Enable debug uart clock */ + CCM_EnableRoot(CCM, BOARD_DEBUG_UART_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_DEBUG_UART_CCM_CCGR, ccmClockNeededRunWait); + + /* UART Pin setting */ + configure_uart_pins(BOARD_DEBUG_UART_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/main.c b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/main.c new file mode 100644 index 000000000..5888f6fdd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/uart_imx/uart_polling/main.c @@ -0,0 +1,117 @@ +/* + * 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +// Includes +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include "uart_imx.h" +#include "board.h" + +/////////////////////////////////////////////////////////////////////////////// +// Consts +/////////////////////////////////////////////////////////////////////////////// +const uint8_t bufferData1[] = "\n\r++++++++++++++++ UART Send/Receive Polling Example +++++++++++++++++\n\r"; +const uint8_t bufferData2[] = "\n\rType characters from keyboard, the board will receive and then echo them to terminal screen\n\r"; + +static void UART_SendDataPolling(UART_Type *base, const uint8_t *txBuff, uint32_t txSize); +static void UART_ReceiveDataPolling(UART_Type *base, uint8_t *rxBuff, uint32_t rxSize); + +int main(void) +{ + // Setup UART init structure. + uart_init_config_t initConfig = { + .baudRate = 115200u, + .wordLength = uartWordLength8Bits, + .stopBitNum = uartStopBitNumOne, + .parity = uartParityDisable, + .direction = uartDirectionTxRx + }; + uint8_t rxChar = 0; + uint32_t byteCount = 0; + + /* Initialize board specified hardware. */ + hardware_init(); + + // Get current module clock frequency. + initConfig.clockRate = get_uart_clock_freq(BOARD_DEBUG_UART_BASEADDR); + + /* Initialize UART baud rate, bit count, parity, stop bit and direction. */ + UART_Init(BOARD_DEBUG_UART_BASEADDR, &initConfig); + + /* Set UART build-in hardware FIFO Watermark. */ + UART_SetTxFifoWatermark(BOARD_DEBUG_UART_BASEADDR, 16); + UART_SetRxFifoWatermark(BOARD_DEBUG_UART_BASEADDR, 1); + + /* Finally, enable the UART module */ + UART_Enable(BOARD_DEBUG_UART_BASEADDR); + + byteCount = sizeof(bufferData1); + UART_SendDataPolling(BOARD_DEBUG_UART_BASEADDR, bufferData1, byteCount); + + byteCount = sizeof(bufferData2); + UART_SendDataPolling(BOARD_DEBUG_UART_BASEADDR, bufferData2, byteCount); + + while (true) + { + /* Wait to receive input data */ + UART_ReceiveDataPolling(BOARD_DEBUG_UART_BASEADDR, &rxChar, 1u); + + /* Send any character that received */ + UART_SendDataPolling(BOARD_DEBUG_UART_BASEADDR, &rxChar, 1u); + } +} + +static void UART_SendDataPolling(UART_Type *base, const uint8_t *txBuff, uint32_t txSize) +{ + while (txSize--) + { + while (!UART_GetStatusFlag(base, uartStatusTxComplete)); + UART_Putchar(base, *txBuff++); + } +} + +static void UART_ReceiveDataPolling(UART_Type *base, uint8_t *rxBuff, uint32_t rxSize) +{ + while (rxSize--) + { + while (!UART_GetStatusFlag(base, uartStatusRxReady)); + *rxBuff = UART_Getchar(base); + rxBuff++; + + if (UART_GetStatusFlag(base, uartStatusRxOverrun)) + UART_ClearStatusFlag(base, uartStatusRxOverrun); + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/CMakeLists.txt b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/CMakeLists.txt new file mode 100644 index 000000000..cda635132 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/CMakeLists.txt @@ -0,0 +1,132 @@ +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}) + +# DEBUG LINK FILE +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -T${ProjDirPath}/../../../../../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${ProjDirPath}/../../../../../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(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/CMSIS/Include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/drivers/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../platform/utilities/inc) + INCLUDE_DIRECTORIES(${ProjDirPath}/../../..) +ENDIF() + +# ADD_EXECUTABLE +ADD_EXECUTABLE(wdog_imx_example + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S" + "${ProjDirPath}/../../../../../platform/utilities/src/debug_console_imx.c" + "${ProjDirPath}/../../../../../platform/utilities/inc/debug_console_imx.h" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.c" + "${ProjDirPath}/../../../../../platform/utilities/src/print_scan.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_analog_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/ccm_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/lmem.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_defs_imx7d.h" + "${ProjDirPath}/../../../../../platform/drivers/inc/wdog_imx.h" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_analog_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/ccm_imx7d.c" + "${ProjDirPath}/../../../../../platform/drivers/src/lmem.c" + "${ProjDirPath}/../../../../../platform/drivers/src/rdc.c" + "${ProjDirPath}/../../../../../platform/drivers/src/wdog_imx.c" + "${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.c" + "${ProjDirPath}/../../../../../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}/../main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(wdog_imx_example PROPERTIES OUTPUT_NAME "wdog_imx_example.elf") + +TARGET_LINK_LIBRARIES(wdog_imx_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(wdog_imx_example m) +TARGET_LINK_LIBRARIES(wdog_imx_example c) +TARGET_LINK_LIBRARIES(wdog_imx_example gcc) +TARGET_LINK_LIBRARIES(wdog_imx_example nosys) +TARGET_LINK_LIBRARIES(wdog_imx_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/wdog_imx_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/wdog_imx_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET wdog_imx_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/wdog_imx_example.elf ${EXECUTABLE_OUTPUT_PATH}/wdog_imx_example.hex) +ADD_CUSTOM_COMMAND(TARGET wdog_imx_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/wdog_imx_example.elf ${EXECUTABLE_OUTPUT_PATH}/wdog_imx_example.bin) diff --git a/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_all.bat b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_all.bat new file mode 100644 index 000000000..6d41d8620 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_all.sh b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_all.sh new file mode 100755 index 000000000..ebb0c2515 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_debug.bat b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_debug.bat new file mode 100644 index 000000000..bf3b902d2 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_debug.sh b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_debug.sh new file mode 100755 index 000000000..571868b73 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_release.bat b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_release.bat new file mode 100644 index 000000000..e229a8305 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_release.sh b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/build_release.sh new file mode 100755 index 000000000..035ce4e89 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/clean.bat b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/clean.bat new file mode 100644 index 000000000..ffea088dd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/clean.sh b/examples/var-som-mx7_m4/driver_examples/wdog_imx/armgcc/clean.sh new file mode 100755 index 000000000..795ad8716 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/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/var-som-mx7_m4/driver_examples/wdog_imx/ds5/.cproject b/examples/var-som-mx7_m4/driver_examples/wdog_imx/ds5/.cproject new file mode 100644 index 000000000..438fecf93 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/var-som-mx7_m4/driver_examples/wdog_imx/ds5/.project b/examples/var-som-mx7_m4/driver_examples/wdog_imx/ds5/.project new file mode 100644 index 000000000..040b592cd --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/ds5/.project @@ -0,0 +1,86 @@ + + + wdog_imx_example_var-som-mx7_m4 + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + startup2virtual:/virtualstartup/startup_MCIMX7D_M4.s1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-5-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-5-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-5-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-5-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-5-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-5-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-3-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-3-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-3-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-3-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-3-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-3-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/uart_imx.c1PARENT-5-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/var-som-mx7_m4/driver_examples/wdog_imx/hardware_init.c b/examples/var-som-mx7_m4/driver_examples/wdog_imx/hardware_init.c new file mode 100644 index 000000000..8f0d50f13 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/hardware_init.c @@ -0,0 +1,55 @@ +/* + * 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 "board.h" +#include "pin_mux.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 example, we need to grasp board WDOG exclusively */ + RDC_SetPdapAccess(RDC, BOARD_WDOG_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + + /* Enable clock used by peripherals */ + CCM_EnableRoot(CCM, BOARD_WDOG_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_WDOG_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/driver_examples/wdog_imx/main.c b/examples/var-som-mx7_m4/driver_examples/wdog_imx/main.c new file mode 100644 index 000000000..af29975b3 --- /dev/null +++ b/examples/var-som-mx7_m4/driver_examples/wdog_imx/main.c @@ -0,0 +1,81 @@ +/* + * 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 "wdog_imx.h" +#include "board.h" +#include "debug_console_imx.h" + +/* This case will cause M4 reset after 5.5 seconds */ +static uint32_t num = 5; + +int main(void) +{ + wdog_init_config_t config = { + .wdw = false, /*!< true: suspend in low power wait, false: not suspend */ + .wdt = true, /*!< true: assert WDOG_B when timeout, false: not assert WDOG_B */ + .wdbg = true, /*!< true: suspend in debug mode, false: not suspend */ + .wdzst = false /*!< true: suspend in doze and stop mode, false: not suspend */ + }; + + hardware_init(); + + WDOG_Init(BOARD_WDOG_BASEADDR, &config); + + /* Enable WDOG interrupt 0.5 second before WDOG timeout */ + NVIC_SetPriority(BOARD_WDOG_IRQ_NUM, 3); + NVIC_EnableIRQ(BOARD_WDOG_IRQ_NUM); + /* Refresh WDOG to reload counter */ + WDOG_Refresh(BOARD_WDOG_BASEADDR); + WDOG_EnableInt(BOARD_WDOG_BASEADDR, 1); + + PRINTF("WDOG with timeout 1.5 seconds will now start\n\r"); + /* Enable WDOG with timeout 1.5 second */ + WDOG_Enable(BOARD_WDOG_BASEADDR, 2); + + while (true) + { + __WFI(); + PRINTF("WDOG was refreshed %d\n\r", num); + if (num == 0) + PRINTF("Counter down to 0, WDOG is starved now...\n\r", num); + } +} + +void BOARD_WDOG_HANDLER() +{ + WDOG_ClearStatusFlag(BOARD_WDOG_BASEADDR); + + if (--num) + WDOG_Refresh(BOARD_WDOG_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/gpio_pins.c b/examples/var-som-mx7_m4/gpio_pins.c new file mode 100644 index 000000000..327b8a027 --- /dev/null +++ b/examples/var-som-mx7_m4/gpio_pins.c @@ -0,0 +1,90 @@ +/* + * 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" + +gpio_config_t gpioLed = { + "LED", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO13, /* muxReg */ + 0, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO13, /* padReg */ + 0, /* padConfig */ + GPIO1, /* base */ + 13 /* pin */ +}; + +gpio_config_t gpioKeyMenu = { + "MENU", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_BDR0, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR0, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR0_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR0_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR0_HYS_MASK, + GPIO2, /* base */ + 28 /* pin */ +}; + +gpio_config_t gpioKeyHome = { + "HOME", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_BDR1, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR1, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR1_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR1_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_BDR1_HYS_MASK, + GPIO2, /* base */ + 29 /* pin */ +}; + +gpio_config_t gpioKeyBack = { + "BACK", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO11, /* muxReg */ + 0, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO11, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO11_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO11_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO11_HYS_MASK, + GPIO1, /* base */ + 11 /* pin */ +}; + +void configure_gpio_pin(gpio_config_t *config) +{ + assert(config); + + *(config->muxReg) = config->muxConfig; + *(config->padReg) = config->padConfig; +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/gpio_pins.h b/examples/var-som-mx7_m4/gpio_pins.h new file mode 100644 index 000000000..9b11c8484 --- /dev/null +++ b/examples/var-som-mx7_m4/gpio_pins.h @@ -0,0 +1,64 @@ +/* + * 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 GPIO pin configuration */ +extern gpio_config_t gpioLed; +extern gpio_config_t gpioKeyMenu; +extern gpio_config_t gpioKeyHome; +extern gpio_config_t gpioKeyBack; + +/*! @brief Configure specific GPIO pin */ +void configure_gpio_pin(gpio_config_t *config); + +#endif /* __GPIO_PINS_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/pin_mux.c b/examples/var-som-mx7_m4/pin_mux.c new file mode 100644 index 000000000..529a1d42d --- /dev/null +++ b/examples/var-som-mx7_m4/pin_mux.c @@ -0,0 +1,163 @@ +/* + * 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. + */ + +/*! +** @addtogroup pin_mux_module pin_mux module documentation +** @{ +*/ + +/* MODULE pin_mux. */ + +#include "device_imx.h" +#include "pin_mux.h" + +void configure_flexcan_pins(CAN_Type* base) +{ + switch((uint32_t)base) + { + case CAN1_BASE: + // CAN1 is not used in VAR-SOM-MX7 + break; + case CAN2_BASE: + // CAN2_TX + IOMUXC_SW_MUX_CTL_PAD_I2C3_SDA = IOMUXC_SW_MUX_CTL_PAD_I2C3_SDA_MUX_MODE(2); + IOMUXC_SW_PAD_CTL_PAD_I2C3_SDA = IOMUXC_SW_PAD_CTL_PAD_I2C3_SDA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C3_SDA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C3_SDA_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C3_SDA_HYS_MASK; + + // CAN2_RX + IOMUXC_SW_MUX_CTL_PAD_I2C3_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C3_SCL_MUX_MODE(2); + IOMUXC_FLEXCAN2_RX_SELECT_INPUT = IOMUXC_FLEXCAN2_RX_SELECT_INPUT_DAISY(1); + IOMUXC_SW_PAD_CTL_PAD_I2C3_SCL = IOMUXC_SW_PAD_CTL_PAD_I2C3_SCL_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C3_SCL_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C3_SCL_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C3_SCL_HYS_MASK; + break; + } +} + +void configure_i2c_pins(I2C_Type* base) +{ + switch((uint32_t)base) + { + case I2C1_BASE: + // I2C1 iomux configuration + IOMUXC_SW_MUX_CTL_PAD_I2C1_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C1_SCL_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C1_SCL_SION_MASK; + IOMUXC_SW_MUX_CTL_PAD_I2C1_SDA = IOMUXC_SW_MUX_CTL_PAD_I2C1_SDA_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C1_SDA_SION_MASK; + + IOMUXC_I2C1_SCL_SELECT_INPUT = IOMUXC_I2C1_SCL_SELECT_INPUT_DAISY(1); + IOMUXC_I2C1_SDA_SELECT_INPUT = IOMUXC_I2C1_SDA_SELECT_INPUT_DAISY(1); + + IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL = IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C1_SCL_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA = IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C1_SDA_HYS_MASK; + break; + case I2C2_BASE: + // I2C2 iomux configuration + IOMUXC_SW_MUX_CTL_PAD_I2C2_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C2_SCL_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C2_SCL_SION_MASK; + IOMUXC_SW_MUX_CTL_PAD_I2C2_SDA = IOMUXC_SW_MUX_CTL_PAD_I2C2_SDA_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C2_SDA_SION_MASK; + + IOMUXC_I2C2_SCL_SELECT_INPUT = IOMUXC_I2C2_SCL_SELECT_INPUT_DAISY(1); + IOMUXC_I2C2_SDA_SELECT_INPUT = IOMUXC_I2C2_SDA_SELECT_INPUT_DAISY(1); + + IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL = IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA = IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C2_SDA_HYS_MASK; + break; + case I2C3_BASE: + // I2C3 is not used in VAR-SOM-MX7 + break; + case I2C4_BASE: + // I2C4 iomux configuration + IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_SYNC = IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_SYNC_MUX_MODE(3) | + IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_SYNC_SION_MASK; + IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_BCLK = IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_BCLK_MUX_MODE(3) | + IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_BCLK_SION_MASK; + + IOMUXC_I2C4_SCL_SELECT_INPUT = IOMUXC_I2C4_SCL_SELECT_INPUT_DAISY(3); + IOMUXC_I2C4_SDA_SELECT_INPUT = IOMUXC_I2C4_SDA_SELECT_INPUT_DAISY(3); + + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_SYNC = IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_SYNC_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_SYNC_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_SYNC_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_SYNC_HYS_MASK; + + IOMUXC_SW_MUX_CTL_PAD_SAI1_RX_BCLK = IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_BCLK_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_BCLK_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_BCLK_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_SAI1_RX_BCLK_HYS_MASK; + break; + default: + break; + } +} + +void configure_uart_pins(UART_Type* base) +{ + switch((uint32_t)base) + { + case UART2_BASE: + // UART2 iomux configuration + IOMUXC_SW_MUX_CTL_PAD_LCD_CLK = IOMUXC_SW_MUX_CTL_PAD_LCD_CLK_MUX_MODE(4); + IOMUXC_SW_MUX_CTL_PAD_LCD_ENABLE = IOMUXC_SW_MUX_CTL_PAD_LCD_ENABLE_MUX_MODE(4); + IOMUXC_SW_PAD_CTL_PAD_LCD_CLK = IOMUXC_SW_PAD_CTL_PAD_LCD_CLK_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_LCD_CLK_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_LCD_CLK_HYS_MASK | + IOMUXC_SW_PAD_CTL_PAD_LCD_CLK_DSE(0); + IOMUXC_SW_PAD_CTL_PAD_LCD_ENABLE = IOMUXC_SW_PAD_CTL_PAD_LCD_ENABLE_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_LCD_ENABLE_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_LCD_ENABLE_HYS_MASK | + IOMUXC_SW_PAD_CTL_PAD_LCD_ENABLE_DSE(0); + break; + default: + break; + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/var-som-mx7_m4/pin_mux.h b/examples/var-som-mx7_m4/pin_mux.h new file mode 100644 index 000000000..adb5cc757 --- /dev/null +++ b/examples/var-som-mx7_m4/pin_mux.h @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/*! +** @addtogroup pin_mux_module pin_mux module documentation +** @{ +*/ + +#ifndef __PIN_MUX_H__ +#define __PIN_MUX_H__ + +/* MODULE pin_mux. */ + +#include "device_imx.h" + +/* +** =================================================================== +** Method : pin_mux_CAN (component PinSettings) +*/ +/*! +** @brief +** CAN method sets registers according routing +** settings. Call this method code to route desired pins into: +** CAN1, CAN2 +** peripherals. +** @param +** CAN_Type* base - CAN base address 1..2 +*/ +/* ===================================================================*/ +void configure_flexcan_pins(CAN_Type* base); + +/* +** =================================================================== +** Method : pin_mux_I2C (component PinSettings) +*/ +/*! +** @brief +** I2C method sets registers according routing settings. Call +** this method code to route desired pins into: +** I2C1, I2C2, I2C3, I2C4 +** peripherals. +** @param +** I2C_Type* base - I2C base address 1..4 +*/ +/* ===================================================================*/ +void configure_i2c_pins(I2C_Type* base); + +/* +** =================================================================== +** Method : pin_mux_UART (component PinSettings) +*/ +/*! +** @brief +** UART method sets registers according routing settings. Call +** this method code to route desired pins into: +** UART1, UART2, UART3, UART4, UART5, UART6, UART7 +** peripherals. +** @param +** UART_Type* base - UART base address 1..7 +*/ +/* ===================================================================*/ +void configure_uart_pins(UART_Type* base); + +#endif /* __PIN_MUX_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/