From 308e5d4f0c1661a8cbdb8bf3c169506951de0c97 Mon Sep 17 00:00:00 2001 From: Eric Lee Date: Fri, 25 May 2018 13:06:15 +0800 Subject: [PATCH] Initial Commit, FreeRTOS on Cortex-M4 of SMARC-FiMX7 --- examples/imx7_smarc_m4/board.c | 105 +++ examples/imx7_smarc_m4/board.h | 198 ++++++ examples/imx7_smarc_m4/clock_freq.c | 256 ++++++++ examples/imx7_smarc_m4/clock_freq.h | 98 +++ .../demo_apps/blinking_imx_demo/FreeRTOSConfig.h | 163 +++++ .../blinking_imx_demo/armgcc/CMakeLists.txt | 174 +++++ .../blinking_imx_demo/armgcc/build_all.bat | 5 + .../blinking_imx_demo/armgcc/build_all.sh | 5 + .../blinking_imx_demo/armgcc/build_debug.bat | 3 + .../blinking_imx_demo/armgcc/build_debug.sh | 3 + .../blinking_imx_demo/armgcc/build_release.bat | 3 + .../blinking_imx_demo/armgcc/build_release.sh | 3 + .../demo_apps/blinking_imx_demo/armgcc/clean.bat | 3 + .../demo_apps/blinking_imx_demo/armgcc/clean.sh | 3 + .../demo_apps/blinking_imx_demo/ds5/.cproject | 137 ++++ .../demo_apps/blinking_imx_demo/ds5/.project | 86 +++ .../demo_apps/blinking_imx_demo/gpio_ctrl.c | 194 ++++++ .../demo_apps/blinking_imx_demo/gpio_ctrl.h | 60 ++ .../demo_apps/blinking_imx_demo/gpt_timer.c | 121 ++++ .../demo_apps/blinking_imx_demo/hardware_init.c | 79 +++ .../demo_apps/blinking_imx_demo/hw_timer.h | 58 ++ .../demo_apps/blinking_imx_demo/main.c | 109 ++++ .../demo_apps/ecspi_flash_demo/FreeRTOSConfig.h | 163 +++++ .../ecspi_flash_demo/armgcc/CMakeLists.txt | 168 +++++ .../ecspi_flash_demo/armgcc/build_all.bat | 5 + .../demo_apps/ecspi_flash_demo/armgcc/build_all.sh | 5 + .../ecspi_flash_demo/armgcc/build_debug.bat | 3 + .../ecspi_flash_demo/armgcc/build_debug.sh | 3 + .../ecspi_flash_demo/armgcc/build_release.bat | 3 + .../ecspi_flash_demo/armgcc/build_release.sh | 3 + .../demo_apps/ecspi_flash_demo/armgcc/clean.bat | 3 + .../demo_apps/ecspi_flash_demo/armgcc/clean.sh | 3 + .../demo_apps/ecspi_flash_demo/ds5/.cproject | 137 ++++ .../demo_apps/ecspi_flash_demo/ds5/.project | 86 +++ .../demo_apps/ecspi_flash_demo/ecspi_xfer.c | 227 +++++++ .../demo_apps/ecspi_flash_demo/ecspi_xfer.h | 55 ++ .../demo_apps/ecspi_flash_demo/hardware_init.c | 56 ++ .../demo_apps/ecspi_flash_demo/main.c | 124 ++++ .../demo_apps/ecspi_flash_demo/spi_memory.c | 241 +++++++ .../demo_apps/ecspi_flash_demo/spi_memory.h | 74 +++ .../demo_apps/hello_world/FreeRTOSConfig.h | 163 +++++ .../demo_apps/hello_world/armgcc/CMakeLists.txt | 162 +++++ .../demo_apps/hello_world/armgcc/build_all.bat | 5 + .../demo_apps/hello_world/armgcc/build_all.sh | 5 + .../demo_apps/hello_world/armgcc/build_debug.bat | 3 + .../demo_apps/hello_world/armgcc/build_debug.sh | 3 + .../demo_apps/hello_world/armgcc/build_release.bat | 3 + .../demo_apps/hello_world/armgcc/build_release.sh | 3 + .../demo_apps/hello_world/armgcc/clean.bat | 3 + .../demo_apps/hello_world/armgcc/clean.sh | 3 + .../demo_apps/hello_world/ds5/.cproject | 137 ++++ .../demo_apps/hello_world/ds5/.project | 86 +++ .../demo_apps/hello_world/hardware_init.c | 48 ++ .../imx7_smarc_m4/demo_apps/hello_world/main.c | 86 +++ .../demo_apps/hello_world_ddr/FreeRTOSConfig.h | 163 +++++ .../hello_world_ddr/armgcc/CMakeLists.txt | 162 +++++ .../demo_apps/hello_world_ddr/armgcc/build_all.bat | 5 + .../demo_apps/hello_world_ddr/armgcc/build_all.sh | 5 + .../hello_world_ddr/armgcc/build_debug.bat | 3 + .../hello_world_ddr/armgcc/build_debug.sh | 3 + .../hello_world_ddr/armgcc/build_release.bat | 3 + .../hello_world_ddr/armgcc/build_release.sh | 3 + .../demo_apps/hello_world_ddr/armgcc/clean.bat | 3 + .../demo_apps/hello_world_ddr/armgcc/clean.sh | 3 + .../demo_apps/hello_world_ddr/ds5/.cproject | 137 ++++ .../demo_apps/hello_world_ddr/ds5/.project | 86 +++ .../demo_apps/hello_world_ddr/hardware_init.c | 74 +++ .../demo_apps/hello_world_ocram/FreeRTOSConfig.h | 163 +++++ .../hello_world_ocram/armgcc/CMakeLists.txt | 162 +++++ .../hello_world_ocram/armgcc/build_all.bat | 5 + .../hello_world_ocram/armgcc/build_all.sh | 5 + .../hello_world_ocram/armgcc/build_debug.bat | 3 + .../hello_world_ocram/armgcc/build_debug.sh | 3 + .../hello_world_ocram/armgcc/build_release.bat | 3 + .../hello_world_ocram/armgcc/build_release.sh | 3 + .../demo_apps/hello_world_ocram/armgcc/clean.bat | 3 + .../demo_apps/hello_world_ocram/armgcc/clean.sh | 3 + .../demo_apps/hello_world_ocram/ds5/.cproject | 137 ++++ .../demo_apps/hello_world_ocram/ds5/.project | 86 +++ .../demo_apps/hello_world_ocram/hardware_init.c | 76 +++ .../demo_apps/low_power_imx7d/common/gpc.c | 102 +++ .../demo_apps/low_power_imx7d/common/gpc.h | 49 ++ .../demo_apps/low_power_imx7d/common/lpm_mcore.c | 703 +++++++++++++++++++++ .../demo_apps/low_power_imx7d/common/lpm_mcore.h | 132 ++++ .../low_power_imx7d/rand_wfi/FreeRTOSConfig.h | 163 +++++ .../low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt | 178 ++++++ .../low_power_imx7d/rand_wfi/armgcc/build_all.bat | 5 + .../low_power_imx7d/rand_wfi/armgcc/build_all.sh | 5 + .../rand_wfi/armgcc/build_debug.bat | 3 + .../low_power_imx7d/rand_wfi/armgcc/build_debug.sh | 3 + .../rand_wfi/armgcc/build_release.bat | 3 + .../rand_wfi/armgcc/build_release.sh | 3 + .../low_power_imx7d/rand_wfi/armgcc/clean.bat | 3 + .../low_power_imx7d/rand_wfi/armgcc/clean.sh | 3 + .../low_power_imx7d/rand_wfi/ds5/.cproject | 137 ++++ .../low_power_imx7d/rand_wfi/ds5/.project | 86 +++ .../demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c | 132 ++++ .../demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h | 60 ++ .../low_power_imx7d/rand_wfi/hardware_init.c | 92 +++ .../demo_apps/low_power_imx7d/rand_wfi/main.c | 229 +++++++ .../common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf | 90 +++ .../rpmsg/pingpong_bm/armgcc/CMakeLists.txt | 172 +++++ .../rpmsg/pingpong_bm/armgcc/build_all.bat | 5 + .../rpmsg/pingpong_bm/armgcc/build_all.sh | 5 + .../rpmsg/pingpong_bm/armgcc/build_debug.bat | 3 + .../rpmsg/pingpong_bm/armgcc/build_debug.sh | 3 + .../rpmsg/pingpong_bm/armgcc/build_release.bat | 3 + .../rpmsg/pingpong_bm/armgcc/build_release.sh | 3 + .../demo_apps/rpmsg/pingpong_bm/armgcc/clean.bat | 3 + .../demo_apps/rpmsg/pingpong_bm/armgcc/clean.sh | 3 + .../demo_apps/rpmsg/pingpong_bm/ds5/.cproject | 137 ++++ .../demo_apps/rpmsg/pingpong_bm/ds5/.project | 86 +++ .../demo_apps/rpmsg/pingpong_bm/hardware_init.c | 54 ++ .../demo_apps/rpmsg/pingpong_bm/pingpong_bm.c | 148 +++++ .../rpmsg/pingpong_freertos/FreeRTOSConfig.h | 163 +++++ .../pingpong_freertos/armgcc/.CMakeLists.txt.swp | Bin 0 -> 16384 bytes .../rpmsg/pingpong_freertos/armgcc/CMakeLists.txt | 199 ++++++ .../rpmsg/pingpong_freertos/armgcc/build_all.bat | 5 + .../rpmsg/pingpong_freertos/armgcc/build_all.sh | 5 + .../rpmsg/pingpong_freertos/armgcc/build_debug.bat | 3 + .../rpmsg/pingpong_freertos/armgcc/build_debug.sh | 3 + .../pingpong_freertos/armgcc/build_release.bat | 3 + .../pingpong_freertos/armgcc/build_release.sh | 3 + .../rpmsg/pingpong_freertos/armgcc/clean.bat | 3 + .../rpmsg/pingpong_freertos/armgcc/clean.sh | 3 + .../rpmsg/pingpong_freertos/ds5/.cproject | 137 ++++ .../demo_apps/rpmsg/pingpong_freertos/ds5/.project | 86 +++ .../rpmsg/pingpong_freertos/hardware_init.c | 54 ++ .../rpmsg/pingpong_freertos/pingpong_freertos.c | 136 ++++ .../rpmsg/str_echo_bm/armgcc/CMakeLists.txt | 172 +++++ .../rpmsg/str_echo_bm/armgcc/build_all.bat | 5 + .../rpmsg/str_echo_bm/armgcc/build_all.sh | 5 + .../rpmsg/str_echo_bm/armgcc/build_debug.bat | 3 + .../rpmsg/str_echo_bm/armgcc/build_debug.sh | 3 + .../rpmsg/str_echo_bm/armgcc/build_release.bat | 3 + .../rpmsg/str_echo_bm/armgcc/build_release.sh | 3 + .../demo_apps/rpmsg/str_echo_bm/armgcc/clean.bat | 3 + .../demo_apps/rpmsg/str_echo_bm/armgcc/clean.sh | 3 + .../demo_apps/rpmsg/str_echo_bm/ds5/.cproject | 137 ++++ .../demo_apps/rpmsg/str_echo_bm/ds5/.project | 86 +++ .../demo_apps/rpmsg/str_echo_bm/hardware_init.c | 54 ++ .../demo_apps/rpmsg/str_echo_bm/str_echo_bm.c | 205 ++++++ .../rpmsg/str_echo_freertos/FreeRTOSConfig.h | 163 +++++ .../rpmsg/str_echo_freertos/armgcc/CMakeLists.txt | 199 ++++++ .../rpmsg/str_echo_freertos/armgcc/build_all.bat | 5 + .../rpmsg/str_echo_freertos/armgcc/build_all.sh | 5 + .../rpmsg/str_echo_freertos/armgcc/build_debug.bat | 3 + .../rpmsg/str_echo_freertos/armgcc/build_debug.sh | 3 + .../str_echo_freertos/armgcc/build_release.bat | 3 + .../str_echo_freertos/armgcc/build_release.sh | 3 + .../rpmsg/str_echo_freertos/armgcc/clean.bat | 3 + .../rpmsg/str_echo_freertos/armgcc/clean.sh | 3 + .../rpmsg/str_echo_freertos/ds5/.cproject | 137 ++++ .../demo_apps/rpmsg/str_echo_freertos/ds5/.project | 86 +++ .../rpmsg/str_echo_freertos/hardware_init.c | 54 ++ .../rpmsg/str_echo_freertos/str_echo_freertos.c | 146 +++++ .../demo_apps/sema4_demo/FreeRTOSConfig.h | 163 +++++ .../demo_apps/sema4_demo/armgcc/CMakeLists.txt | 166 +++++ .../demo_apps/sema4_demo/armgcc/build_all.bat | 5 + .../demo_apps/sema4_demo/armgcc/build_all.sh | 5 + .../demo_apps/sema4_demo/armgcc/build_debug.bat | 3 + .../demo_apps/sema4_demo/armgcc/build_debug.sh | 3 + .../demo_apps/sema4_demo/armgcc/build_release.bat | 3 + .../demo_apps/sema4_demo/armgcc/build_release.sh | 3 + .../demo_apps/sema4_demo/armgcc/clean.bat | 3 + .../demo_apps/sema4_demo/armgcc/clean.sh | 3 + .../demo_apps/sema4_demo/ds5/.cproject | 137 ++++ .../demo_apps/sema4_demo/ds5/.project | 86 +++ .../demo_apps/sema4_demo/hardware_init.c | 52 ++ examples/imx7_smarc_m4/demo_apps/sema4_demo/main.c | 114 ++++ .../demo_apps/sema4_demo/sema4_mutex.c | 150 +++++ .../demo_apps/sema4_demo/sema4_mutex.h | 63 ++ .../adc_imx7d/armgcc/CMakeLists.txt | 136 ++++ .../driver_examples/adc_imx7d/armgcc/build_all.bat | 5 + .../driver_examples/adc_imx7d/armgcc/build_all.sh | 5 + .../adc_imx7d/armgcc/build_debug.bat | 3 + .../adc_imx7d/armgcc/build_debug.sh | 3 + .../adc_imx7d/armgcc/build_release.bat | 3 + .../adc_imx7d/armgcc/build_release.sh | 3 + .../driver_examples/adc_imx7d/armgcc/clean.bat | 3 + .../driver_examples/adc_imx7d/armgcc/clean.sh | 3 + .../driver_examples/adc_imx7d/ds5/.cproject | 137 ++++ .../driver_examples/adc_imx7d/ds5/.project | 86 +++ .../driver_examples/adc_imx7d/hardware_init.c | 54 ++ .../imx7_smarc_m4/driver_examples/adc_imx7d/main.c | 92 +++ .../ecspi_interrupt/master/armgcc/CMakeLists.txt | 134 ++++ .../ecspi_interrupt/master/armgcc/build_all.bat | 5 + .../ecspi_interrupt/master/armgcc/build_all.sh | 5 + .../ecspi_interrupt/master/armgcc/build_debug.bat | 3 + .../ecspi_interrupt/master/armgcc/build_debug.sh | 3 + .../master/armgcc/build_release.bat | 3 + .../ecspi_interrupt/master/armgcc/build_release.sh | 3 + .../ecspi/ecspi_interrupt/master/armgcc/clean.bat | 3 + .../ecspi/ecspi_interrupt/master/armgcc/clean.sh | 3 + .../ecspi/ecspi_interrupt/master/ds5/.cproject | 137 ++++ .../ecspi/ecspi_interrupt/master/ds5/.project | 86 +++ .../ecspi/ecspi_interrupt/master/hardware_init.c | 56 ++ .../ecspi/ecspi_interrupt/master/main.c | 288 +++++++++ .../ecspi_interrupt/slave/armgcc/CMakeLists.txt | 134 ++++ .../ecspi_interrupt/slave/armgcc/build_all.bat | 5 + .../ecspi_interrupt/slave/armgcc/build_all.sh | 5 + .../ecspi_interrupt/slave/armgcc/build_debug.bat | 3 + .../ecspi_interrupt/slave/armgcc/build_debug.sh | 3 + .../ecspi_interrupt/slave/armgcc/build_release.bat | 3 + .../ecspi_interrupt/slave/armgcc/build_release.sh | 3 + .../ecspi/ecspi_interrupt/slave/armgcc/clean.bat | 3 + .../ecspi/ecspi_interrupt/slave/armgcc/clean.sh | 3 + .../ecspi/ecspi_interrupt/slave/ds5/.cproject | 137 ++++ .../ecspi/ecspi_interrupt/slave/ds5/.project | 86 +++ .../ecspi/ecspi_interrupt/slave/hardware_init.c | 56 ++ .../ecspi/ecspi_interrupt/slave/main.c | 175 +++++ .../ecspi_polling/master/armgcc/CMakeLists.txt | 134 ++++ .../ecspi_polling/master/armgcc/build_all.bat | 5 + .../ecspi/ecspi_polling/master/armgcc/build_all.sh | 5 + .../ecspi_polling/master/armgcc/build_debug.bat | 3 + .../ecspi_polling/master/armgcc/build_debug.sh | 3 + .../ecspi_polling/master/armgcc/build_release.bat | 3 + .../ecspi_polling/master/armgcc/build_release.sh | 3 + .../ecspi/ecspi_polling/master/armgcc/clean.bat | 3 + .../ecspi/ecspi_polling/master/armgcc/clean.sh | 3 + .../ecspi/ecspi_polling/master/ds5/.cproject | 137 ++++ .../ecspi/ecspi_polling/master/ds5/.project | 86 +++ .../ecspi/ecspi_polling/master/hardware_init.c | 56 ++ .../ecspi/ecspi_polling/master/main.c | 135 ++++ .../ecspi_polling/slave/armgcc/CMakeLists.txt | 134 ++++ .../ecspi/ecspi_polling/slave/armgcc/build_all.bat | 5 + .../ecspi/ecspi_polling/slave/armgcc/build_all.sh | 5 + .../ecspi_polling/slave/armgcc/build_debug.bat | 3 + .../ecspi_polling/slave/armgcc/build_debug.sh | 3 + .../ecspi_polling/slave/armgcc/build_release.bat | 3 + .../ecspi_polling/slave/armgcc/build_release.sh | 3 + .../ecspi/ecspi_polling/slave/armgcc/clean.bat | 3 + .../ecspi/ecspi_polling/slave/armgcc/clean.sh | 3 + .../ecspi/ecspi_polling/slave/ds5/.cproject | 137 ++++ .../ecspi/ecspi_polling/slave/ds5/.project | 86 +++ .../ecspi/ecspi_polling/slave/hardware_init.c | 56 ++ .../ecspi/ecspi_polling/slave/main.c | 99 +++ .../flexcan/flexcan_loopback/armgcc/CMakeLists.txt | 138 ++++ .../flexcan/flexcan_loopback/armgcc/build_all.bat | 5 + .../flexcan/flexcan_loopback/armgcc/build_all.sh | 5 + .../flexcan_loopback/armgcc/build_debug.bat | 3 + .../flexcan/flexcan_loopback/armgcc/build_debug.sh | 3 + .../flexcan_loopback/armgcc/build_release.bat | 3 + .../flexcan_loopback/armgcc/build_release.sh | 3 + .../flexcan/flexcan_loopback/armgcc/clean.bat | 3 + .../flexcan/flexcan_loopback/armgcc/clean.sh | 3 + .../flexcan/flexcan_loopback/ds5/.cproject | 137 ++++ .../flexcan/flexcan_loopback/ds5/.project | 86 +++ .../flexcan/flexcan_loopback/hardware_init.c | 70 ++ .../flexcan/flexcan_loopback/main.c | 212 +++++++ .../flexcan/flexcan_network/armgcc/CMakeLists.txt | 138 ++++ .../flexcan/flexcan_network/armgcc/build_all.bat | 5 + .../flexcan/flexcan_network/armgcc/build_all.sh | 5 + .../flexcan/flexcan_network/armgcc/build_debug.bat | 3 + .../flexcan/flexcan_network/armgcc/build_debug.sh | 3 + .../flexcan_network/armgcc/build_release.bat | 3 + .../flexcan_network/armgcc/build_release.sh | 3 + .../flexcan/flexcan_network/armgcc/clean.bat | 3 + .../flexcan/flexcan_network/armgcc/clean.sh | 3 + .../flexcan/flexcan_network/ds5/.cproject | 137 ++++ .../flexcan/flexcan_network/ds5/.project | 86 +++ .../flexcan/flexcan_network/hardware_init.c | 70 ++ .../driver_examples/flexcan/flexcan_network/main.c | 221 +++++++ .../gpio_bank2_imx/armgcc/CMakeLists.txt | 140 ++++ .../gpio_bank2_imx/armgcc/build_all.bat | 5 + .../gpio_bank2_imx/armgcc/build_all.sh | 5 + .../gpio_bank2_imx/armgcc/build_debug.bat | 3 + .../gpio_bank2_imx/armgcc/build_debug.sh | 3 + .../gpio_bank2_imx/armgcc/build_release.bat | 3 + .../gpio_bank2_imx/armgcc/build_release.sh | 3 + .../gpio_bank2_imx/armgcc/clean.bat | 3 + .../driver_examples/gpio_bank2_imx/armgcc/clean.sh | 3 + .../driver_examples/gpio_bank2_imx/ds5/.cproject | 137 ++++ .../driver_examples/gpio_bank2_imx/ds5/.project | 86 +++ .../driver_examples/gpio_bank2_imx/gpio_ctrl.c | 214 +++++++ .../driver_examples/gpio_bank2_imx/gpio_ctrl.h | 76 +++ .../driver_examples/gpio_bank2_imx/hardware_init.c | 54 ++ .../driver_examples/gpio_bank2_imx/main.c | 94 +++ .../driver_examples/gpio_imx/armgcc/CMakeLists.txt | 136 ++++ .../driver_examples/gpio_imx/armgcc/build_all.bat | 5 + .../driver_examples/gpio_imx/armgcc/build_all.sh | 5 + .../gpio_imx/armgcc/build_debug.bat | 3 + .../driver_examples/gpio_imx/armgcc/build_debug.sh | 3 + .../gpio_imx/armgcc/build_release.bat | 3 + .../gpio_imx/armgcc/build_release.sh | 3 + .../driver_examples/gpio_imx/armgcc/clean.bat | 3 + .../driver_examples/gpio_imx/armgcc/clean.sh | 3 + .../driver_examples/gpio_imx/ds5/.cproject | 137 ++++ .../driver_examples/gpio_imx/ds5/.project | 86 +++ .../driver_examples/gpio_imx/hardware_init.c | 54 ++ .../imx7_smarc_m4/driver_examples/gpio_imx/main.c | 295 +++++++++ .../driver_examples/gpt/armgcc/CMakeLists.txt | 134 ++++ .../driver_examples/gpt/armgcc/build_all.bat | 5 + .../driver_examples/gpt/armgcc/build_all.sh | 5 + .../driver_examples/gpt/armgcc/build_debug.bat | 3 + .../driver_examples/gpt/armgcc/build_debug.sh | 3 + .../driver_examples/gpt/armgcc/build_release.bat | 3 + .../driver_examples/gpt/armgcc/build_release.sh | 3 + .../driver_examples/gpt/armgcc/clean.bat | 3 + .../driver_examples/gpt/armgcc/clean.sh | 3 + .../driver_examples/gpt/ds5/.cproject | 137 ++++ .../imx7_smarc_m4/driver_examples/gpt/ds5/.project | 86 +++ .../driver_examples/gpt/hardware_init.c | 68 ++ examples/imx7_smarc_m4/driver_examples/gpt/main.c | 135 ++++ .../i2c_interrupt_eeprom/armgcc/CMakeLists.txt | 134 ++++ .../i2c_interrupt_eeprom/armgcc/build_all.bat | 5 + .../i2c_interrupt_eeprom/armgcc/build_all.sh | 5 + .../i2c_interrupt_eeprom/armgcc/build_debug.bat | 3 + .../i2c_interrupt_eeprom/armgcc/build_debug.sh | 3 + .../i2c_interrupt_eeprom/armgcc/build_release.bat | 3 + .../i2c_interrupt_eeprom/armgcc/build_release.sh | 3 + .../i2c_imx/i2c_interrupt_eeprom/armgcc/clean.bat | 3 + .../i2c_imx/i2c_interrupt_eeprom/armgcc/clean.sh | 3 + .../i2c_imx/i2c_interrupt_eeprom/ds5/.cproject | 137 ++++ .../i2c_imx/i2c_interrupt_eeprom/ds5/.project | 86 +++ .../i2c_imx/i2c_interrupt_eeprom/hardware_init.c | 60 ++ .../i2c_imx/i2c_interrupt_eeprom/main.c | 390 ++++++++++++ .../armgcc/CMakeLists.txt | 136 ++++ .../armgcc/build_all.bat | 5 + .../i2c_interrupt_sensor_imx7d/armgcc/build_all.sh | 5 + .../armgcc/build_debug.bat | 3 + .../armgcc/build_debug.sh | 3 + .../armgcc/build_release.bat | 3 + .../armgcc/build_release.sh | 3 + .../i2c_interrupt_sensor_imx7d/armgcc/clean.bat | 3 + .../i2c_interrupt_sensor_imx7d/armgcc/clean.sh | 3 + .../i2c_interrupt_sensor_imx7d/ds5/.cproject | 137 ++++ .../i2c_interrupt_sensor_imx7d/ds5/.project | 86 +++ .../i2c_interrupt_sensor_imx7d/hardware_init.c | 60 ++ .../i2c_imx/i2c_interrupt_sensor_imx7d/main.c | 431 +++++++++++++ .../i2c_polling_eeprom/armgcc/CMakeLists.txt | 134 ++++ .../i2c_polling_eeprom/armgcc/build_all.bat | 5 + .../i2c_imx/i2c_polling_eeprom/armgcc/build_all.sh | 5 + .../i2c_polling_eeprom/armgcc/build_debug.bat | 3 + .../i2c_polling_eeprom/armgcc/build_debug.sh | 3 + .../i2c_polling_eeprom/armgcc/build_release.bat | 3 + .../i2c_polling_eeprom/armgcc/build_release.sh | 3 + .../i2c_imx/i2c_polling_eeprom/armgcc/clean.bat | 3 + .../i2c_imx/i2c_polling_eeprom/armgcc/clean.sh | 3 + .../i2c_imx/i2c_polling_eeprom/ds5/.cproject | 137 ++++ .../i2c_imx/i2c_polling_eeprom/ds5/.project | 86 +++ .../i2c_imx/i2c_polling_eeprom/hardware_init.c | 60 ++ .../i2c_imx/i2c_polling_eeprom/main.c | 310 +++++++++ .../i2c_polling_sensor_imx7d/armgcc/CMakeLists.txt | 136 ++++ .../i2c_polling_sensor_imx7d/armgcc/build_all.bat | 5 + .../i2c_polling_sensor_imx7d/armgcc/build_all.sh | 5 + .../armgcc/build_debug.bat | 3 + .../i2c_polling_sensor_imx7d/armgcc/build_debug.sh | 3 + .../armgcc/build_release.bat | 3 + .../armgcc/build_release.sh | 3 + .../i2c_polling_sensor_imx7d/armgcc/clean.bat | 3 + .../i2c_polling_sensor_imx7d/armgcc/clean.sh | 3 + .../i2c_imx/i2c_polling_sensor_imx7d/ds5/.cproject | 137 ++++ .../i2c_imx/i2c_polling_sensor_imx7d/ds5/.project | 86 +++ .../i2c_polling_sensor_imx7d/hardware_init.c | 60 ++ .../i2c_imx/i2c_polling_sensor_imx7d/main.c | 343 ++++++++++ .../uart_imx/uart_interrupt/armgcc/CMakeLists.txt | 132 ++++ .../uart_imx/uart_interrupt/armgcc/build_all.bat | 5 + .../uart_imx/uart_interrupt/armgcc/build_all.sh | 5 + .../uart_imx/uart_interrupt/armgcc/build_debug.bat | 3 + .../uart_imx/uart_interrupt/armgcc/build_debug.sh | 3 + .../uart_interrupt/armgcc/build_release.bat | 3 + .../uart_interrupt/armgcc/build_release.sh | 3 + .../uart_imx/uart_interrupt/armgcc/clean.bat | 3 + .../uart_imx/uart_interrupt/armgcc/clean.sh | 3 + .../uart_imx/uart_interrupt/ds5/.cproject | 137 ++++ .../uart_imx/uart_interrupt/ds5/.project | 86 +++ .../uart_imx/uart_interrupt/hardware_init.c | 57 ++ .../driver_examples/uart_imx/uart_interrupt/main.c | 220 +++++++ .../uart_imx/uart_polling/armgcc/CMakeLists.txt | 132 ++++ .../uart_imx/uart_polling/armgcc/build_all.bat | 5 + .../uart_imx/uart_polling/armgcc/build_all.sh | 5 + .../uart_imx/uart_polling/armgcc/build_debug.bat | 3 + .../uart_imx/uart_polling/armgcc/build_debug.sh | 3 + .../uart_imx/uart_polling/armgcc/build_release.bat | 3 + .../uart_imx/uart_polling/armgcc/build_release.sh | 3 + .../uart_imx/uart_polling/armgcc/clean.bat | 3 + .../uart_imx/uart_polling/armgcc/clean.sh | 3 + .../uart_imx/uart_polling/ds5/.cproject | 137 ++++ .../uart_imx/uart_polling/ds5/.project | 86 +++ .../uart_imx/uart_polling/hardware_init.c | 57 ++ .../driver_examples/uart_imx/uart_polling/main.c | 117 ++++ .../driver_examples/wdog_imx/armgcc/CMakeLists.txt | 132 ++++ .../driver_examples/wdog_imx/armgcc/build_all.bat | 5 + .../driver_examples/wdog_imx/armgcc/build_all.sh | 5 + .../wdog_imx/armgcc/build_debug.bat | 3 + .../driver_examples/wdog_imx/armgcc/build_debug.sh | 3 + .../wdog_imx/armgcc/build_release.bat | 3 + .../wdog_imx/armgcc/build_release.sh | 3 + .../driver_examples/wdog_imx/armgcc/clean.bat | 3 + .../driver_examples/wdog_imx/armgcc/clean.sh | 3 + .../driver_examples/wdog_imx/ds5/.cproject | 137 ++++ .../driver_examples/wdog_imx/ds5/.project | 86 +++ .../driver_examples/wdog_imx/hardware_init.c | 55 ++ .../imx7_smarc_m4/driver_examples/wdog_imx/main.c | 81 +++ examples/imx7_smarc_m4/gpio_pins.c | 172 +++++ examples/imx7_smarc_m4/gpio_pins.h | 74 +++ examples/imx7_smarc_m4/pin_mux.c | 297 +++++++++ examples/imx7_smarc_m4/pin_mux.h | 124 ++++ 399 files changed, 23459 insertions(+) create mode 100644 examples/imx7_smarc_m4/board.c create mode 100644 examples/imx7_smarc_m4/board.h create mode 100644 examples/imx7_smarc_m4/clock_freq.c create mode 100644 examples/imx7_smarc_m4/clock_freq.h create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpio_ctrl.c create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpio_ctrl.h create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpt_timer.c create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/hw_timer.h create mode 100644 examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/main.c create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.c create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.h create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/main.c create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/spi_memory.c create mode 100644 examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/spi_memory.h create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world/main.c create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ddr/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/hello_world_ocram/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/gpc.c create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/gpc.h create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/lpm_mcore.c create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/lpm_mcore.h create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/main.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/pingpong_bm.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/.CMakeLists.txt.swp create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/pingpong_freertos.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/str_echo_bm.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/str_echo_freertos.c create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/FreeRTOSConfig.h create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.project create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/hardware_init.c create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/main.c create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/sema4_mutex.c create mode 100644 examples/imx7_smarc_m4/demo_apps/sema4_demo/sema4_mutex.h create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/adc_imx7d/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.h create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpio_imx/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/gpt/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/gpt/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/main.c create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/CMakeLists.txt create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_all.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_all.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_debug.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_debug.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_release.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_release.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/clean.bat create mode 100755 examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/clean.sh create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.cproject create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.project create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/hardware_init.c create mode 100644 examples/imx7_smarc_m4/driver_examples/wdog_imx/main.c create mode 100644 examples/imx7_smarc_m4/gpio_pins.c create mode 100644 examples/imx7_smarc_m4/gpio_pins.h create mode 100644 examples/imx7_smarc_m4/pin_mux.c create mode 100644 examples/imx7_smarc_m4/pin_mux.h diff --git a/examples/imx7_smarc_m4/board.c b/examples/imx7_smarc_m4/board.c new file mode 100644 index 0000000..51b211d --- /dev/null +++ b/examples/imx7_smarc_m4/board.c @@ -0,0 +1,105 @@ +/* + * 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" +#include "uart_imx.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/imx7_smarc_m4/board.h b/examples/imx7_smarc_m4/board.h new file mode 100644 index 0000000..e83ce15 --- /dev/null +++ b/examples/imx7_smarc_m4/board.h @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. + * Copyright (c) 2017, Embedian, 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 "IMX7_SMARC_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_KEY_CCM_CCGR ccmCcgrGateGpio2 +#define BOARD_GPIO_LED_RDC_PDAP rdcPdapGpio1 +#define BOARD_GPIO_LED_CONFIG (&gpioLed) +#define BOARD_GPIO_KEY_RDC_PDAP rdcPdapGpio2 +#define BOARD_GPIO_KEY_CONFIG (&gpioKeyFunc1) +#define BOARD_GPIO_KEY_IRQ_NUM GPIO5_INT15_0_IRQn +#define BOARD_GPIO_KEY_HANDLER GPIO5_INT15_0_Handler + +/* Switch 1 (GPIO6) + * Golden Finger BALL NAME GPIO ALT + * P114 EPDC_DATA05 GPIO2_07 5 + */ +#define BOARD_GPIO_SWITCH1_RDC_PDAP rdcPdapGpio2 +#define BOARD_GPIO_SWITCH1_CONFIG (&gpioSwitch1) + +/* LED 1 (GPIO2) + * Golden Finger BALL NAME GPIO ALT + * P110 EPDC_DATA02 GPIO2_02 5 + */ +#define BOARD_GPIO_LED1_RDC_PDAP rdcPdapGpio2 +#define BOARD_GPIO_LED1_CONFIG (&gpioLed1) + +/* Switch 2 (GPIO8) + * Golden Finger BALL NAME GPIO ALT + * P116 EPDC_DATA06 GPIO2_06 5 + */ +#define BOARD_GPIO_SWITCH2_RDC_PDAP rdcPdapGpio2 +#define BOARD_GPIO_SWITCH2_CONFIG (&gpioSwitch2) + +/* LED 2 (GPIO4) + * Golden Finger BALL NAME GPIO ALT + * P112 EPDC_DATA04 GPIO2_04 5 + */ +#define BOARD_GPIO_LED2_RDC_PDAP rdcPdapGpio2 +#define BOARD_GPIO_LED2_CONFIG (&gpioLed2) + +/* SMARC SPI0 ECSPI1 information for flash demo */ +#define BOARD_ECSPI_RDC_PDAP rdcPdapEcspi1 +#define BOARD_ECSPI_CCM_ROOT ccmRootEcspi1 +#define BOARD_ECSPI_CCM_CCGR ccmCcgrGateEcspi1 +#define BOARD_ECSPI_CHANNEL ecspiSelectChannel0 +#define BOARD_ECSPI_IRQ_NUM eCSPI1_IRQn +#define BOARD_ECSPI_BASEADDR ECSPI1 +#define BOARD_ECSPI_HANDLER eCSPI1_Handler +/* ECSPI information for master mode */ +#define BOARD_ECSPI_MASTER_RDC_PDAP rdcPdapEcspi2 +#define BOARD_ECSPI_MASTER_CCM_ROOT ccmRootEcspi2 +#define BOARD_ECSPI_MASTER_CCM_CCGR ccmCcgrGateEcspi2 +#define BOARD_ECSPI_MASTER_BASEADDR ECSPI2 +#define BOARD_ECSPI_MASTER_CHANNEL ecspiSelectChannel0 +#define BOARD_ECSPI_MASTER_IRQ_NUM eCSPI2_IRQn +#define BOARD_ECSPI_MASTER_HANDLER eCSPI2_Handler +/* ECSPI information for slave mode */ +#define BOARD_ECSPI_SLAVE_RDC_PDAP rdcPdapEcspi2 +#define BOARD_ECSPI_SLAVE_CCM_ROOT ccmRootEcspi2 +#define BOARD_ECSPI_SLAVE_CCM_CCGR ccmCcgrGateEcspi2 +#define BOARD_ECSPI_SLAVE_BASEADDR ECSPI2 +#define BOARD_ECSPI_SLAVE_CHANNEL ecspiSelectChannel0 +#define BOARD_ECSPI_SLAVE_IRQ_NUM eCSPI2_IRQn +#define BOARD_ECSPI_SLAVE_HANDLER eCSPI2_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 + +/* I2C3 (I2C_LCD) information for this board */ +#define BOARD_I2C_RDC_PDAP rdcPdapI2c3 +#define BOARD_I2C_CCM_ROOT ccmRootI2c3 +#define BOARD_I2C_CCM_CCGR ccmCcgrGateI2c3 +#define BOARD_I2C_BASEADDR I2C3 +#define BOARD_I2C_IRQ_NUM I2C3_IRQn +#define BOARD_I2C_HANDLER I2C3_Handler +#define BOARD_I2C_FXAS21002_ADDR (0x20) +#define BOARD_I2C_FXOS8700_ADDR (0x1E) + +/* 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/imx7_smarc_m4/clock_freq.c b/examples/imx7_smarc_m4/clock_freq.c new file mode 100644 index 0000000..a60b4ce --- /dev/null +++ b/examples/imx7_smarc_m4/clock_freq.c @@ -0,0 +1,256 @@ +/* + * 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; + case ECSPI3_BASE: + root = CCM_GetRootMux(CCM, ccmRootEcspi3); + CCM_GetRootDivider(CCM, ccmRootEcspi3, &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/imx7_smarc_m4/clock_freq.h b/examples/imx7_smarc_m4/clock_freq.h new file mode 100644 index 0000000..da2ba6d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/FreeRTOSConfig.h new file mode 100644 index 0000000..dad2e0d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/CMakeLists.txt new file mode 100644 index 0000000..281bc12 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.cproject new file mode 100644 index 0000000..ab194ad --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.project b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.project new file mode 100644 index 0000000..55d753a --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/ds5/.project @@ -0,0 +1,86 @@ + + + blinking_imx_demo_gpt_imx7d_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpio_ctrl.c b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpio_ctrl.c new file mode 100644 index 0000000..45aece0 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpio_ctrl.h b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpio_ctrl.h new file mode 100644 index 0000000..a61a017 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpt_timer.c b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/gpt_timer.c new file mode 100644 index 0000000..d092c45 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/hardware_init.c new file mode 100644 index 0000000..c8a2caa --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/hardware_init.c @@ -0,0 +1,79 @@ +/* + * 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_LED_RDC_PDAP, 0xFF, false/*true*/, false); + /* BOARD_GPIO_LED_RDC_PDAP is same as BOARD_GPIO_KEY_RDC_PDAP, so bypass + * BOARD_GPIO_KEY_RDC_PDAP setting */ + + /* 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_LED_CONFIG); + configure_gpio_pin(BOARD_GPIO_KEY_CONFIG); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/hw_timer.h b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/hw_timer.h new file mode 100644 index 0000000..5a87819 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/blinking_imx_demo/main.c b/examples/imx7_smarc_m4/demo_apps/blinking_imx_demo/main.c new file mode 100644 index 0000000..e280647 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/ecspi_flash_demo/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/FreeRTOSConfig.h new file mode 100644 index 0000000..9eadd5f --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_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 1 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#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 1 +#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 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 /* 15 priority levels */ +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0xf + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 1 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +#define configASSERT(x) if((x) == 0) {taskDISABLE_INTERRUPTS(); for(;;);} + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler +#define xPortSysTickHandler SysTick_Handler + +#endif /* FREERTOS_CONFIG_H */ diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/CMakeLists.txt new file mode 100644 index 0000000..8b15b95 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/CMakeLists.txt @@ -0,0 +1,168 @@ +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(ecspi_flash_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}/../ecspi_xfer.c" + "${ProjDirPath}/../ecspi_xfer.h" + "${ProjDirPath}/../spi_memory.c" + "${ProjDirPath}/../spi_memory.h" + "${ProjDirPath}/../../../../../platform/drivers/src/ecspi.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/ecspi.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(ecspi_flash_demo PROPERTIES OUTPUT_NAME "ecspi_flash_demo.elf") + +TARGET_LINK_LIBRARIES(ecspi_flash_demo -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(ecspi_flash_demo m) +TARGET_LINK_LIBRARIES(ecspi_flash_demo c) +TARGET_LINK_LIBRARIES(ecspi_flash_demo gcc) +TARGET_LINK_LIBRARIES(ecspi_flash_demo nosys) +TARGET_LINK_LIBRARIES(ecspi_flash_demo -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/ecspi_flash_demo.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/ecspi_flash_demo.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET ecspi_flash_demo POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/ecspi_flash_demo.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_flash_demo.hex) +ADD_CUSTOM_COMMAND(TARGET ecspi_flash_demo POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/ecspi_flash_demo.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_flash_demo.bin) diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.cproject new file mode 100644 index 0000000..ef30b31 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.project b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.project new file mode 100644 index 0000000..f62f72e --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ds5/.project @@ -0,0 +1,86 @@ + + + ecspi_flash_demo_imx7_smarc_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/ecspi_xfer.c1PARENT-1-PROJECT_LOC/ecspi_xfer.csource2virtual:/virtualsource/ecspi_xfer.h1PARENT-1-PROJECT_LOC/ecspi_xfer.hsource2virtual:/virtualsource/spi_memory.c1PARENT-1-PROJECT_LOC/spi_memory.csource2virtual:/virtualsource/spi_memory.h1PARENT-1-PROJECT_LOC/spi_memory.hdriver2virtual:/virtualdriver/ecspi.c1PARENT-5-PROJECT_LOC/platform/drivers/src/ecspi.cdriver2virtual:/virtualdriver/ecspi.h1PARENT-5-PROJECT_LOC/platform/drivers/inc/ecspi.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/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.c b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.c new file mode 100644 index 0000000..6a3a7d8 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.c @@ -0,0 +1,227 @@ +/* + * 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 "semphr.h" +#include "device_imx.h" +#include "board.h" +#include "ecspi_xfer.h" +#include "uart_imx.h" +#include "debug_console_imx.h" + +typedef struct EcspiState +{ + uint8_t* txBuffPtr; /* Pointer to ECSPI Transmission Buffer */ + uint32_t txSize; /* The remaining number of bytes to be transmitted */ + uint8_t* rxBuffPtr; /* Pointer to ECSPI Receive Buffer */ + uint32_t rxSize; /* The remaining number of bytes to be transmitted */ + SemaphoreHandle_t xSemaphore; /* ECSPI internal synchronize semaphore. */ +} ecspi_state_t; + +/* ECSPI runtime state structure */ +static ecspi_state_t ecspiState; + +/****************************************************************************** +* +* Function Name: ECSPI_XFER_Config +* Comments: ECSPI module initialize +* +******************************************************************************/ +void ECSPI_XFER_Config(const ecspi_init_config_t* initConfig) +{ + /* Initialize ECSPI state structure content. */ + ecspiState.txBuffPtr = 0; + ecspiState.rxBuffPtr = 0; + ecspiState.txSize = 0; + ecspiState.rxSize = 0; + ecspiState.xSemaphore = xSemaphoreCreateBinary(); + + /* Initialize ECSPI, parameter configure */ + ECSPI_Init(BOARD_ECSPI_BASEADDR, initConfig); + + /* Call core API to enable the IRQ. */ + NVIC_EnableIRQ(BOARD_ECSPI_IRQ_NUM); + + /* The interrupt calls an interrupt safe API function - so its priority must + be equal to or lower than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. */ + NVIC_SetPriority(BOARD_ECSPI_IRQ_NUM, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY); +} + +/****************************************************************************** +* +* Function Name: ECSPI_XFER_TransmitBurst +* Comments: Fill the TXFIFO. +* +******************************************************************************/ +bool ECSPI_XFER_TransmitBurst(void) +{ + uint8_t bytes; + uint32_t data; + uint8_t i; + + /* Fill the TXFIFO */ + while((ecspiState.txSize > 0) && (ECSPI_GetStatusFlag(BOARD_ECSPI_BASEADDR, ecspiFlagTxfifoFull) == 0)) + { + bytes = ecspiState.txSize & 0x3; /* first get unaligned part trasmitted */ + bytes = bytes ? bytes : 4; /* if aligned, then must be 4 */ + + if(!(ecspiState.txBuffPtr)) + { + data = 0xFFFFFFFF; /* half-duplex receive data */ + } + else + { + data = 0; + for(i = 0; i < bytes; i++) + data = (data << 8) | *(ecspiState.txBuffPtr)++; + } + + ECSPI_SendData(BOARD_ECSPI_BASEADDR, data); + ecspiState.txSize -= bytes; + ecspiState.rxSize += bytes; + } + /* start transmission */ + ECSPI_StartBurst(BOARD_ECSPI_BASEADDR); + return true; +} + +/****************************************************************************** +* +* Function Name: ECSPI_XFER_ReceiveBurst +* Comments: Receive data from RXFIFO +* +******************************************************************************/ +bool ECSPI_XFER_ReceiveBurst(void) +{ + uint32_t data; + uint32_t bytes; + uint32_t i; + + while ((ecspiState.rxSize > 0) && (ECSPI_GetStatusFlag(BOARD_ECSPI_BASEADDR, ecspiFlagRxfifoReady) != 0)) + { + data = ECSPI_ReceiveData(BOARD_ECSPI_BASEADDR); /* read data from register */ + bytes = ecspiState.rxSize & 0x3; /* first get unaligned part received */ + bytes = bytes ? bytes : 4; /* if aligned, then must be 4 */ + + if(ecspiState.rxBuffPtr) /* not half-duplex transmit */ + { + for(i = bytes; i > 0; i--) + { + *(ecspiState.rxBuffPtr + i - 1) = data & 0xFF; + data >>= 8; + } + ecspiState.rxBuffPtr += bytes; + } + ecspiState.rxSize -= bytes; + } + return true; +} + +/****************************************************************************** +* +* Function Name: ECSPI_XFER_TransferBlocking +* Comments: Transmit and Receive an amount of data in blocking mode with +* interrupt. +* +******************************************************************************/ +bool ECSPI_XFER_TransferBlocking(uint8_t *txBuffer, uint8_t *rxBuffer, uint32_t transferSize) +{ + uint32_t len; + + if((transferSize == 0) || ((txBuffer == 0)&&(rxBuffer == 0))) + { + return false; + } + + /* Update the burst length to real size */ + len = (uint32_t)(transferSize * 8 - 1); + ECSPI_SetBurstLength(BOARD_ECSPI_BASEADDR, len); + + /* Configure the transfer */ + ecspiState.txBuffPtr = txBuffer; + ecspiState.rxBuffPtr = rxBuffer; + ecspiState.txSize = transferSize; + ecspiState.rxSize = 0; + + /* Fill the TXFIFO */ + ECSPI_XFER_TransmitBurst(); + /* Enable interrupts */ + ECSPI_SetIntCmd(BOARD_ECSPI_BASEADDR, ecspiFlagTxfifoEmpty, true); + + /* Wait until transfer data finish. */ + xSemaphoreTake(ecspiState.xSemaphore, portMAX_DELAY); + return true; +} + +/****************************************************************************** +* +* Function Name: BOARD_ECSPI_HANDLER +* Comments: The interrupt service routine triggered by ECSPI interrupt +* +******************************************************************************/ +void BOARD_ECSPI_HANDLER(void) +{ + portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; + + /* Receive data from RXFIFO */ + ECSPI_XFER_ReceiveBurst(); + + /* Push data left */ + if(ecspiState.txSize) + { + ECSPI_XFER_TransmitBurst(); + return; + } + + /* No data left to push, but still waiting for rx data, enable receive data available interrupt. */ + if(ecspiState.rxSize) + { + ECSPI_SetIntCmd(BOARD_ECSPI_BASEADDR, ecspiFlagRxfifoReady, true); + return; + } + + /* Disable interrupt */ + ECSPI_SetIntCmd(BOARD_ECSPI_BASEADDR, ecspiFlagTxfifoEmpty, false); + ECSPI_SetIntCmd(BOARD_ECSPI_BASEADDR, ecspiFlagRxfifoReady, false); + + /* Clear the status */ + ECSPI_ClearStatusFlag(BOARD_ECSPI_BASEADDR, ecspiFlagTxfifoTc); + ECSPI_ClearStatusFlag(BOARD_ECSPI_BASEADDR, ecspiFlagRxfifoOverflow); + + /* Unlock the task to process the event. */ + xSemaphoreGiveFromISR(ecspiState.xSemaphore, &xHigherPriorityTaskWoken); + + /* Perform a context switch to wake the higher priority task. */ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.h b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.h new file mode 100644 index 0000000..f4978a3 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/ecspi_xfer.h @@ -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. + */ + +#ifndef __ECSPI_XFER_H__ +#define __ECSPI_XFER_H__ + +#include +#include +#include "ecspi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void ECSPI_XFER_Config(const ecspi_init_config_t* initConfig); +bool ECSPI_XFER_TransmitBurst(void); +bool ECSPI_XFER_ReceiveBurst(void); +bool ECSPI_XFER_TransferBlocking(uint8_t *txBuffer, uint8_t *rxBuffer, uint32_t transferSize); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __ECSPI_XFER_H__ */ + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/hardware_init.c new file mode 100644 index 0000000..a052f33 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/hardware_init.c @@ -0,0 +1,56 @@ +/* + * 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 ECSPI */ + RDC_SetPdapAccess(RDC, BOARD_ECSPI_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + /* Select board ecspi clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_ECSPI_CCM_ROOT, ccmRootmuxEcspiOsc24m, 0, 0); + /* Enable ecspi clock gate */ + CCM_EnableRoot(CCM, BOARD_ECSPI_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_ECSPI_CCM_CCGR, ccmClockNeededRunWait); + /* Configure ecspi pin IOMUX */ + configure_ecspi_pins(BOARD_ECSPI_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/main.c b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/main.c new file mode 100644 index 0000000..588572e --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/main.c @@ -0,0 +1,124 @@ +/* + * 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 +#include "FreeRTOS.h" +#include "task.h" +#include "board.h" +#include "uart_imx.h" +#include "debug_console_imx.h" +#include "ecspi_xfer.h" +#include "spi_memory.h" +#include "clock_freq.h" + +/* define ECSPI module parameters configuration. */ +#define ECSPI_BURSTLENGTH (39) +#define ECSPI_STARTMODE (false) + +/* buffer used to transfer data */ +static uint8_t txData[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00}; +static uint8_t rxData[32] = {0}; + +/****************************************************************************** +* +* Function Name: vMemoryTask +* Comments: this task is used to operate memory, such as read status, write data +* in memory and read data from memory. +* +******************************************************************************/ +void vMemoryTask(void *pvParameters) +{ + PRINTF("\n--------------------------- ECSPI Flash Demo ----------------------------\n\n\r"); + PRINTF("This demo application demonstrates usage of ECSPI driver based on FreeRTOS.\n\r"); + PRINTF("It transfers data to/from external memory over SPI bus.\n\n\r"); + + PRINTF("Start Flash Memory Operating!\n\r"); + /* start SPI serial flash memory operation */ + /* Read the flash memory status register */ + M25P32_ReadStatus(); + + /* Disable protection */ + M25P32_SetProtection(false); + + /* Erase memory before tests, user can erase the memory according to need */ + //M25P32_EraseChip(); + + /* write data to memory */ + M25P32_WriteData(SPI_MEMORY_ADDR2, 32, txData); + + /* read data from memory */ + M25P32_ReadData(SPI_MEMORY_ADDR2, 32, rxData); + + PRINTF("Finish Flash Memory Operating!\n\r"); + + for(;;); +} + +/****************************************************************************** +* +* Function Name: main +* Comments: main function, MCU configured as master mode, read from and write to +* flash memory with FreeRTOS. +* +******************************************************************************/ +int main(void) +{ + /* Hardware initialiize, include RDC, CLOCK, IOMUX, ENABLE MODULE */ + hardware_init(); + + /* Ecspi module initialize, include configure parameters */ + ecspi_init_config_t ecspiInitConfig = { + .clockRate = get_ecspi_clock_freq(BOARD_ECSPI_BASEADDR), + .baudRate = 500000, + .mode = ecspiMasterMode, + .burstLength = ECSPI_BURSTLENGTH, + .channelSelect = BOARD_ECSPI_CHANNEL, + .clockPhase = ecspiClockPhaseFirstEdge, + .clockPolarity = ecspiClockPolarityActiveHigh, + .ecspiAutoStart = ECSPI_STARTMODE + }; + ECSPI_XFER_Config(&ecspiInitConfig); + + /* Create two tasks with different priority */ + xTaskCreate(vMemoryTask, "memory", configMINIMAL_STACK_SIZE, + NULL, tskIDLE_PRIORITY+1, NULL); + + /* Start task schedule */ + vTaskStartScheduler(); + + for(;;); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/spi_memory.c b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/spi_memory.c new file mode 100644 index 0000000..2f3bc24 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/ecspi_flash_demo/spi_memory.c @@ -0,0 +1,241 @@ +/* + * 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 "ecspi_xfer.h" +#include "uart_imx.h" +#include "debug_console_imx.h" +#include "spi_memory.h" + +/****************************************************************************** +* +* Function Name : M25P32_ReadStatus +* Comments : This function reads memory status register +* Return: Status read. +* +******************************************************************************/ +uint8_t M25P32_ReadStatus(void) +{ + uint8_t Txbuffer[2]; + uint8_t Rxbuffer[2]; + + PRINTF("Read memory status ... "); + /* write instruction */ + Txbuffer[0] = SPI_MEMORY_READ_STATUS; + Txbuffer[1] = 0xFF; + if(!ECSPI_XFER_TransferBlocking((uint8_t*)Txbuffer, (uint8_t*)Rxbuffer, 2)) + PRINTF("Read memory status error!\n\r"); + + /* The received second byte is real value of status register */ + PRINTF("0x%02x\n\r", Rxbuffer[1]); + return Rxbuffer[1]; +} + +/****************************************************************************** +* +* Function Name : M25P32_SetWriteEnable +* Comments : This function sets latch to enable/disable memory write +* operation +* +******************************************************************************/ +void M25P32_SetWriteEnable(bool enable) +{ + uint8_t Txbuffer[1]; + + if(enable) + { + PRINTF("Enable write latch in memory ..."); + Txbuffer[0] = SPI_MEMORY_WRITE_ENABLE; + } + else + { + PRINTF("Disable write latch in memory ..."); + Txbuffer[0] = SPI_MEMORY_WRITE_DISABLE; + } + /* write instruction */ + if(!ECSPI_XFER_TransferBlocking((uint8_t*)Txbuffer, 0, 1)) + PRINTF("Set memory write enable error!\n\r"); + + PRINTF("OK\n\r"); +} + +/****************************************************************************** +* +* Function Name : M25P32_SetProtection +* Comments : This function sets write protection in memory status register +* +******************************************************************************/ +void M25P32_SetProtection(bool protect) +{ + uint8_t protection; + uint8_t Txbuffer[2]; + + /* enable write operation */ + M25P32_SetWriteEnable(true); + /* read status register */ + M25P32_ReadStatus(); + + if(protect) + { + PRINTF("Write protect memory ... "); + protection = 0xFF; + } + else + { + PRINTF("Write unprotect memory ... "); + protection = 0x00; + } + + Txbuffer[0] = SPI_MEMORY_WRITE_STATUS; + Txbuffer[1] = protection; + /* write instruction */ + if(!ECSPI_XFER_TransferBlocking((uint8_t*)Txbuffer, 0, 2)) + PRINTF("Set memory protection error!\n\r"); + + PRINTF("OK\n\r"); + M25P32_ReadStatus(); +} + +/****************************************************************************** +* +* Function Name : M25P32_EraseChip +* Comments : This function erases the whole memory SPI chip +* +******************************************************************************/ +void M25P32_EraseChip(void) +{ + uint8_t Txbuffer[1]; + volatile uint32_t i, j; + + /* Enable Write */ + M25P32_SetWriteEnable(true); + M25P32_ReadStatus(); + + PRINTF("Erase whole memory chip:\n\r"); + Txbuffer[0] = SPI_MEMORY_BULK_ERASE; + /* write instruction */ + if(!ECSPI_XFER_TransferBlocking((uint8_t*)Txbuffer, 0, 1)) + PRINTF("Erase memory error!\n\r"); + + /* wait erase end */ + while(M25P32_ReadStatus() & 1) + { + //M25P32_ReadStatus(); + for(i=0; i<0xFFF; i++) + for(j=0; j<0xFF; j++); + } + + PRINTF("Erase chip ...OK\n\r"); +} + +/****************************************************************************** +* +* Function Name : M25P32_WriteData +* Comments : This function writes data buffer to memory using page write +* Return: Number of bytes written. +* +******************************************************************************/ +uint32_t M25P32_WriteData (uint32_t addr, uint32_t size, uint8_t* data) +{ + uint8_t Txbuffer[50]; + uint32_t i; + + /* Enable Write */ + M25P32_SetWriteEnable(true); + + PRINTF("Page write %d bytes to location 0x%08x in memory:\n\r", size, addr); + + /* Write instruction, address and data */ + Txbuffer[0] = SPI_MEMORY_PAGE_PROGRAM; + for(i=SPI_MEMORY_ADDRESS_BYTES; i; i--) + { + Txbuffer[i] = (uint8_t)(addr & 0xFF); + addr >>= 8; + } + for(i=SPI_MEMORY_ADDRESS_BYTES+1; i>= 8; + } + for(i=SPI_MEMORY_ADDRESS_BYTES+1; i>!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/imx7_smarc_m4/demo_apps/hello_world/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/CMakeLists.txt new file mode 100644 index 0000000..7b23972 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/hello_world/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.cproject new file mode 100644 index 0000000..f32ce31 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.project b/examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.project new file mode 100644 index 0000000..c17c266 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/hello_world/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/hello_world/hardware_init.c new file mode 100644 index 0000000..9081bfd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world/main.c b/examples/imx7_smarc_m4/demo_apps/hello_world/main.c new file mode 100644 index 0000000..e7a0986 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/FreeRTOSConfig.h new file mode 100644 index 0000000..fed1edf --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/CMakeLists.txt new file mode 100644 index 0000000..488604b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.cproject new file mode 100644 index 0000000..5acb16a --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.project b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.project new file mode 100644 index 0000000..f026558 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_ddr_imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ddr/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/hello_world_ddr/hardware_init.c new file mode 100644 index 0000000..6ce266a --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/FreeRTOSConfig.h new file mode 100644 index 0000000..fb1d76a --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/CMakeLists.txt new file mode 100644 index 0000000..469ae23 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.cproject new file mode 100644 index 0000000..80fd483 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.project b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.project new file mode 100644 index 0000000..4b2a4af --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/ds5/.project @@ -0,0 +1,86 @@ + + + hello_world_ocram_imx7_smarc_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/imx7_smarc_m4/demo_apps/hello_world_ocram/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/hello_world_ocram/hardware_init.c new file mode 100644 index 0000000..598d2de --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/common/gpc.c b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/gpc.c new file mode 100644 index 0000000..d21b5cd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/common/gpc.h b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/gpc.h new file mode 100644 index 0000000..8c61adf --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/common/lpm_mcore.c b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/lpm_mcore.c new file mode 100644 index 0000000..dd3e27b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/common/lpm_mcore.h b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/common/lpm_mcore.h new file mode 100644 index 0000000..6a7a843 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/FreeRTOSConfig.h new file mode 100644 index 0000000..416dbb2 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/CMakeLists.txt new file mode 100644 index 0000000..f8bb577 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject new file mode 100644 index 0000000..9c64325 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project new file mode 100644 index 0000000..3e6e0ce --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/ds5/.project @@ -0,0 +1,86 @@ + + + rand_wfi_imx7d_imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.c new file mode 100644 index 0000000..e264072 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/gpt_timer.h new file mode 100644 index 0000000..0bab0ff --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/hardware_init.c new file mode 100644 index 0000000..87a693d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/main.c b/examples/imx7_smarc_m4/demo_apps/low_power_imx7d/rand_wfi/main.c new file mode 100644 index 0000000..e53d08b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf b/examples/imx7_smarc_m4/demo_apps/rpmsg/common/linker/arm/MCIMX7D_M4_tcm_rpmsg.scf new file mode 100644 index 0000000..184fbdc --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/CMakeLists.txt new file mode 100644 index 0000000..207d004 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject new file mode 100644 index 0000000..e882d76 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project new file mode 100644 index 0000000..e705b71 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_pingpong_bm_example_imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/hardware_init.c new file mode 100644 index 0000000..aa69475 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/pingpong_bm.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_bm/pingpong_bm.c new file mode 100644 index 0000000..2051bc2 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/FreeRTOSConfig.h new file mode 100644 index 0000000..c57902e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/.CMakeLists.txt.swp b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/.CMakeLists.txt.swp new file mode 100644 index 0000000000000000000000000000000000000000..679904dd0b7b3a4a2f12fba1ab82d48f2990eb4a GIT binary patch literal 16384 zcmeHO%WvF77$2a#p8|2DGHH<##IBPNsEWwJ@p@CkdcC#1G!X*J@p==teqnn3Ct}#JglXO%?KqZ^d@o z^|y}j?bvbRG)#IwN|~^fOPwvtk31*gX9+)OP_%o$-VP)v$URvrtai!yR~`gSDDq2F~AsL z3@`>51B?O20AqkLz!>N;kVXf{bGW*^NRf*3WkctGietV=uMWxo9+Gbj$*(A`4;JV5 zhUCR1J23_r1B?O20AqkLz!+c*Fa{U{i~+^~V}LPm0T{4agw&z;G!6K%{@;!N&)iJN zPrw(z`@k!}%RmGi2j+n};4pAAa1-$BO@w>}dXId#-&vtiGWZ&9> z!y(tjTC*aV6vG;%zS5}Z$)Ko%r$td)QX0;|P>!v2vBte(Bsl(6Y z1q=zcIj&R@8%?wDCR16MnweCOY1S*!QgeB%hD?t`xis zX&Mq__6+KRd{mpXBAGS0{;;I&MD|WOwz-mTN1a6*&gN{D`~|dv-}XW)Em>>s;)WHs zvJ_-#N1F?!Br3J$?ne@SId-xbSV36Mej?5D@$ZD?c{sI$uw;k69|rWI-3jc}4TDnR zWaoq?wye}TD}iqH!ZRdjVeeO=Vy)wPsY`XJ^d3Lm==f{&hZWg0Va0QUQ%($f*6l%E zy>#eHU3)O+(*qZN$7?z51a5MO>pEzy!et&inG@%B(%L5}_Qiol&$W`gLX$DwtFxk1 zV7k)4zY9fjm)0b0Ev^ThqestTMjR!k@2*|?di{GuG_kMs7`Qmqrd@8tBSt#ZP(L0o z2L;r#Cv${Lugm3}ovXtQvD$rSWXT1Y>MR(&v^rc~>vMLuA!7QSZIGJD{Olrix4cFJ zoh@qa`O zgd2QyqH5SD6mh_a*!+N!BHt5tbraBw#!Q$v%oOante-4F~}JcpX03_TT6JuhFV zFE@o{X&O#OEzgrVTxAAx(?%x^W7qP`MY^5?9>C z)tkzaq#>%!2GYd1rUK*;7`Q!p8zicRp1}Q^nU|?0GsrTxc+zG z3~)I>ZMcKl!4Ad%V}LQh7+?%A1{ebujRB!jF~z2CsF+h#6-B65rVT+`mJBZY_Rt*p z_RuUoTI3q4ZsaqgbU;S$?2V4qrH4edv5J60U2_8~ehQL-VXfLU8coA&2*$DP{1eBW zizz!^`#kPO@iXK?*U{Z@w$8)G^Q$4srX%Aexz5ohI3}$OMH~~)h7QaqDps@@JDy`D z&aMrHd9$;on#V_U{W<6Hayr@Do4BOKx9EiX9t%H&Y2ii@dgk7okx)cSbopsF=PsS_ z?kSa=pjBFrL%NJJnVKL>o=PUY8KL&1w@!ScPkkv5zPLO@1zT8utXHrYGDD=AE}d&t zM9Y0-k4q>00w!ZOZ=`Ict=mjALN*I+4NYxGnz5JW?q}tShf@}LPVM3*^x*_w&sUc) z**h>(Fm6e+Key6fd*uC&iLbxQ8&lbu<^)QT*zPK^Csu+rMZSX-%YCq=r)Fns=u*m) fR_vH=;HKrB^YvDRZ7;M>(a+zX*b7kuxuN@C6?`l1 literal 0 HcmV?d00001 diff --git a/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/CMakeLists.txt new file mode 100644 index 0000000..1b91236 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject new file mode 100644 index 0000000..dc03cec --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project new file mode 100644 index 0000000..b9351c9 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_pingpong_freertos_example_imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/hardware_init.c new file mode 100644 index 0000000..aa69475 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/pingpong_freertos.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/pingpong_freertos/pingpong_freertos.c new file mode 100644 index 0000000..6d0c03d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/CMakeLists.txt new file mode 100644 index 0000000..eae2fa5 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject new file mode 100644 index 0000000..473cbf9 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project new file mode 100644 index 0000000..4fdae98 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_str_echo_bm_example_imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/hardware_init.c new file mode 100644 index 0000000..aa69475 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/str_echo_bm.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_bm/str_echo_bm.c new file mode 100644 index 0000000..c96d505 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/FreeRTOSConfig.h new file mode 100644 index 0000000..c57902e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/CMakeLists.txt new file mode 100644 index 0000000..19eeddc --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject new file mode 100644 index 0000000..03dce1e --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project new file mode 100644 index 0000000..1ca4bf9 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/ds5/.project @@ -0,0 +1,86 @@ + + + rpmsg_str_echo_freertos_example_imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/hardware_init.c new file mode 100644 index 0000000..aa69475 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/str_echo_freertos.c b/examples/imx7_smarc_m4/demo_apps/rpmsg/str_echo_freertos/str_echo_freertos.c new file mode 100644 index 0000000..b34b3d7 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/FreeRTOSConfig.h b/examples/imx7_smarc_m4/demo_apps/sema4_demo/FreeRTOSConfig.h new file mode 100644 index 0000000..bd4ca6f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/CMakeLists.txt new file mode 100644 index 0000000..517dd77 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_all.bat b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_all.sh b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_debug.bat b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_debug.sh b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_release.bat b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_release.sh b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/clean.bat b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/clean.sh b/examples/imx7_smarc_m4/demo_apps/sema4_demo/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.cproject b/examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.cproject new file mode 100644 index 0000000..106b6fd --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.project b/examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.project new file mode 100644 index 0000000..4ed37d3 --- /dev/null +++ b/examples/imx7_smarc_m4/demo_apps/sema4_demo/ds5/.project @@ -0,0 +1,86 @@ + + + sema4_demo_imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/hardware_init.c b/examples/imx7_smarc_m4/demo_apps/sema4_demo/hardware_init.c new file mode 100644 index 0000000..0cd686a --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/main.c b/examples/imx7_smarc_m4/demo_apps/sema4_demo/main.c new file mode 100644 index 0000000..d24111f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/sema4_mutex.c b/examples/imx7_smarc_m4/demo_apps/sema4_demo/sema4_mutex.c new file mode 100644 index 0000000..a52cfba --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/demo_apps/sema4_demo/sema4_mutex.h b/examples/imx7_smarc_m4/demo_apps/sema4_demo/sema4_mutex.h new file mode 100644 index 0000000..b380111 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/CMakeLists.txt new file mode 100644 index 0000000..ea6ba4d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.cproject new file mode 100644 index 0000000..e4aef99 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.project b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.project new file mode 100644 index 0000000..d1ef978 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/ds5/.project @@ -0,0 +1,86 @@ + + + adc_imx7d_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/hardware_init.c new file mode 100644 index 0000000..52fcabc --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/adc_imx7d/main.c b/examples/imx7_smarc_m4/driver_examples/adc_imx7d/main.c new file mode 100644 index 0000000..42bb2e1 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/CMakeLists.txt new file mode 100644 index 0000000..4137c6e --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/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(ecspi_interrupt_master_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/ecspi.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/ecspi.h" + "${ProjDirPath}/../../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(ecspi_interrupt_master_example PROPERTIES OUTPUT_NAME "ecspi_interrupt_master_example.elf") + +TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example m) +TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example c) +TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example gcc) +TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example nosys) +TARGET_LINK_LIBRARIES(ecspi_interrupt_master_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/ecspi_interrupt_master_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/ecspi_interrupt_master_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET ecspi_interrupt_master_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.hex) +ADD_CUSTOM_COMMAND(TARGET ecspi_interrupt_master_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_master_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.bat new file mode 100644 index 0000000..1939438 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.sh new file mode 100755 index 0000000..8c5f621 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.bat new file mode 100644 index 0000000..4950fc9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.sh new file mode 100755 index 0000000..a3a7820 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.bat new file mode 100644 index 0000000..9ec4b80 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.sh new file mode 100755 index 0000000..204a7a1 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.cproject new file mode 100644 index 0000000..0880801 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.project b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.project new file mode 100644 index 0000000..fc41bad --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/ds5/.project @@ -0,0 +1,86 @@ + + + ecspi_interrupt_master_example_imx7_smarc_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-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-7-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-7-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-7-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-7-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-5-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-5-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-5-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-5-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-5-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-5-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/ecspi.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ecspi.cdriver2virtual:/virtualdriver/ecspi.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ecspi.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/hardware_init.c new file mode 100644 index 0000000..8916b5b --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/hardware_init.c @@ -0,0 +1,56 @@ +/* + * 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 ECSPI */ + RDC_SetPdapAccess(RDC, BOARD_ECSPI_MASTER_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + /* Select board ecspi clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_ECSPI_MASTER_CCM_ROOT, ccmRootmuxEcspiOsc24m, 0, 0); + /* Enable ecspi clock gate */ + CCM_EnableRoot(CCM, BOARD_ECSPI_MASTER_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_ECSPI_MASTER_CCM_CCGR, ccmClockNeededRunWait); + /* Configure ecspi pin IOMUX */ + configure_ecspi_pins(BOARD_ECSPI_MASTER_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/main.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/main.c new file mode 100644 index 0000000..b6904ac --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/master/main.c @@ -0,0 +1,288 @@ +/* + * 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 "uart_imx.h" +#include "debug_console_imx.h" +#include "ecspi.h" +#include "clock_freq.h" + +/* define ECSPI master mode parameters configuration. */ +#define ECSPI_MASTER_BURSTLENGTH (7) +#define ECSPI_MASTER_STARTMODE (0) + +typedef struct EcspiState +{ + uint8_t* txBuffPtr; /* Pointer to ECSPI Transmit Buffer */ + uint8_t txSize; /* The remaining number of bytes to be transmitted */ + uint8_t* rxBuffPtr; /* Pointer to ECSPI Receive Buffer */ + uint8_t rxSize; /* The remaining number of bytes to be received */ + volatile bool isBusy; /* True if there is a active transfer */ +} ecspi_state_t; + +/* ECSPI runtime state structure */ +static ecspi_state_t ecspiState; + +/* ECSPI master configure */ +static void ECSPI_MasterConfig(ecspi_init_config_t* initConfig); +/* ECSPI data transfer */ +static bool ECSPI_MasterTransfer(uint8_t* txBuffer, uint8_t* rxBuffer, uint32_t transferSize); +static bool ECSPI_MasterReceiveBurst(void); +static bool ECSPI_MasterTransmitBurst(void); +/* ECSPI transfer status */ +static bool ECSPI_MasterGetTransferStatus(void); + +/* Transferred data */ +static uint8_t txData[1] = {0}; +static uint8_t rxData[1] = {0}; + +int main(void) +{ + uint8_t control_char; + uint8_t i; + + ecspi_init_config_t ecspiMasterInitConfig = { + .baudRate = 500000, + .mode = ecspiMasterMode, + .burstLength = ECSPI_MASTER_BURSTLENGTH, + .channelSelect = BOARD_ECSPI_MASTER_CHANNEL, + .clockPhase = ecspiClockPhaseSecondEdge, + .clockPolarity = ecspiClockPolarityActiveHigh, + .ecspiAutoStart = ECSPI_MASTER_STARTMODE + }; + + /* Hardware initialize, include RDC, CLOCK, IOMUX, ENABLE MODULE */ + hardware_init(); + + /* Update clock frequency of this module */ + ecspiMasterInitConfig.clockRate = get_ecspi_clock_freq(BOARD_ECSPI_MASTER_BASEADDR); + + PRINTF("\n-------------- ECSPI master driver example --------------\n\n\r"); + PRINTF("This example application demonstrates usage of SPI driver in master mode.\n\r"); + PRINTF("It transfers data to/from remote MCU in SPI slave mode.\n\r"); + + /* Ecspi module initialize, include configure parameters */ + ECSPI_MasterConfig(&ecspiMasterInitConfig); + + /* Wait slave ready, then press 's' to start communication. */ + while(true) + { + PRINTF("Press \"s\" when spi slave is ready.\n\r"); + control_char = GETCHAR(); + if((control_char == 's') || (control_char == 'S')) + break; + } + + /* Send 1~20 to slave and receive data from slave */ + for(i = 0; i < 20; i++) + { + txData[0]++; + ECSPI_MasterTransfer((uint8_t*)txData, (uint8_t*)rxData, 1); + while(ECSPI_MasterGetTransferStatus()); + PRINTF("MASTER: Transmited data: %d \n\r", txData[0]); + PRINTF(" : Received data: %d \n\n\r", rxData[0]); + } + while(1); +} + +/****************************************************************************** +* +* Function Name: ECSPI_MasterTransmitBurst +* Comments: Fill the TXFIFO. +* +******************************************************************************/ +static bool ECSPI_MasterTransmitBurst(void) +{ + uint8_t bytes; + uint32_t data; + uint8_t i; + + /* Fill the TXFIFO */ + while((ecspiState.txSize > 0) && (ECSPI_GetStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoFull) == 0)) + { + bytes = ecspiState.txSize & 0x3; /* first get unaligned part transmitted */ + bytes = bytes ? bytes : 4; /* if aligned, then must be 4 */ + + if(!(ecspiState.txBuffPtr)) + { + data = 0xFFFFFFFF; /* half-duplex receive data */ + } + else + { + data = 0; + for(i = 0; i < bytes; i++) + data = (data << 8) | *(ecspiState.txBuffPtr)++; + } + + ECSPI_SendData(BOARD_ECSPI_MASTER_BASEADDR, data); + ecspiState.txSize -= bytes; + ecspiState.rxSize += bytes; + } + /* start transmission */ + ECSPI_StartBurst(BOARD_ECSPI_MASTER_BASEADDR); + /* set transfer flag */ + ecspiState.isBusy = true; + return true; +} + +/****************************************************************************** +* +* Function Name: ECSPI_MasterReceiveBurst +* Comments: Receive data from RXFIFO +* +******************************************************************************/ +static bool ECSPI_MasterReceiveBurst(void) +{ + uint32_t data; + uint32_t bytes; + uint32_t i; + + while ((ecspiState.rxSize > 0) && (ECSPI_GetStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagRxfifoReady) != 0)) + { + data = ECSPI_ReceiveData(BOARD_ECSPI_MASTER_BASEADDR); /* read data from register */ + bytes = ecspiState.rxSize & 0x3; /* first get unaligned part received */ + bytes = bytes ? bytes : 4; /* if aligned, then must be 4 */ + + if(ecspiState.rxBuffPtr) /* not half-duplex transmit */ + { + for(i = bytes; i > 0; i--) + { + *(ecspiState.rxBuffPtr + i - 1) = data & 0xFF; + data >>= 8; + } + ecspiState.rxBuffPtr += bytes; + } + ecspiState.rxSize -= bytes; + } + return true; +} + +/****************************************************************************** +* +* Function Name: ECSPI_MasterTransfer +* Comments: Transmit and Receive an amount of data in no-blocking mode with +* interrupt. +* +******************************************************************************/ +static bool ECSPI_MasterTransfer(uint8_t* txBuffer, uint8_t* rxBuffer, uint32_t transferSize) +{ + uint32_t len; + + if((ecspiState.isBusy) || (transferSize == 0)) + { + return false; + } + + /* Update the burst length to real size */ + len = (uint32_t)(transferSize * 8 - 1); + ECSPI_SetBurstLength(BOARD_ECSPI_MASTER_BASEADDR, len); + + /* Configure the transfer */ + ecspiState.txBuffPtr = txBuffer; + ecspiState.rxBuffPtr = rxBuffer; + ecspiState.txSize = transferSize; + ecspiState.rxSize = 0; + + /* Fill the TXFIFO */ + ECSPI_MasterTransmitBurst(); + /* Enable interrupts */ + ECSPI_SetIntCmd(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoEmpty, true); + return true; +} + +/****************************************************************************** +* +* Function Name: ECSPI_MasterGetTransferStatus +* Comments: Get transfer status. +* +******************************************************************************/ +static bool ECSPI_MasterGetTransferStatus(void) +{ + return ecspiState.isBusy; +} + +/****************************************************************************** +* +* Function Name: ECSPI_MasterConfig +* Comments: ECSPI module initialize +* +******************************************************************************/ +static void ECSPI_MasterConfig(ecspi_init_config_t* initConfig) +{ + /* Initialize ECSPI transfer state. */ + ecspiState.isBusy = false; + + /* Initialize ECSPI, parameter configure */ + ECSPI_Init(BOARD_ECSPI_MASTER_BASEADDR, initConfig); + + /* Call core API to enable the IRQ. */ + NVIC_EnableIRQ(BOARD_ECSPI_MASTER_IRQ_NUM); +} + +/****************************************************************************** +* +* Function Name: BOARD_ECSPI_MASTER_HANDLER +* Comments: The interrupt service routine triggered by ECSPI interrupt +* +******************************************************************************/ +void BOARD_ECSPI_MASTER_HANDLER(void) +{ + /* Receive data from RXFIFO */ + ECSPI_MasterReceiveBurst(); + + /* Push data left */ + if(ecspiState.txSize) + { + ECSPI_MasterTransmitBurst(); + return; + } + + /* No data left to push, but still waiting for rx data, enable receive data available interrupt. */ + if(ecspiState.rxSize) + { + ECSPI_SetIntCmd(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagRxfifoReady, true); + return; + } + + /* Disable interrupt */ + ECSPI_SetIntCmd(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoEmpty, false); + ECSPI_SetIntCmd(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagRxfifoReady, false); + + /* Clear the status */ + ECSPI_ClearStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoTc); + ECSPI_ClearStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagRxfifoOverflow); + + ecspiState.isBusy = false; +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/CMakeLists.txt new file mode 100644 index 0000000..2ef3fcb --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/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(ecspi_interrupt_slave_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/ecspi.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/ecspi.h" + "${ProjDirPath}/../../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(ecspi_interrupt_slave_example PROPERTIES OUTPUT_NAME "ecspi_interrupt_slave_example.elf") + +TARGET_LINK_LIBRARIES(ecspi_interrupt_slave_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(ecspi_interrupt_slave_example m) +TARGET_LINK_LIBRARIES(ecspi_interrupt_slave_example c) +TARGET_LINK_LIBRARIES(ecspi_interrupt_slave_example gcc) +TARGET_LINK_LIBRARIES(ecspi_interrupt_slave_example nosys) +TARGET_LINK_LIBRARIES(ecspi_interrupt_slave_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/ecspi_interrupt_slave_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/ecspi_interrupt_slave_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET ecspi_interrupt_slave_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_slave_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_slave_example.hex) +ADD_CUSTOM_COMMAND(TARGET ecspi_interrupt_slave_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_slave_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_interrupt_slave_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.bat new file mode 100644 index 0000000..1939438 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.sh new file mode 100755 index 0000000..8c5f621 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.bat new file mode 100644 index 0000000..4950fc9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.sh new file mode 100755 index 0000000..a3a7820 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.bat new file mode 100644 index 0000000..9ec4b80 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.sh new file mode 100755 index 0000000..204a7a1 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.cproject new file mode 100644 index 0000000..691c87b --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.project b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.project new file mode 100644 index 0000000..e2c4397 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/ds5/.project @@ -0,0 +1,86 @@ + + + ecspi_interrupt_slave_example_imx7_smarc_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-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-7-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-7-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-7-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-7-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-5-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-5-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-5-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-5-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-5-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-5-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/ecspi.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ecspi.cdriver2virtual:/virtualdriver/ecspi.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ecspi.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/hardware_init.c new file mode 100644 index 0000000..1788b10 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/hardware_init.c @@ -0,0 +1,56 @@ +/* + * 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 ECSPI */ + RDC_SetPdapAccess(RDC, BOARD_ECSPI_SLAVE_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + /* Select board ecspi clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_ECSPI_SLAVE_CCM_ROOT, ccmRootmuxEcspiOsc24m, 0, 0); + /* Enable ecspi clock gate */ + CCM_EnableRoot(CCM, BOARD_ECSPI_SLAVE_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_ECSPI_SLAVE_CCM_CCGR, ccmClockNeededRunWait); + /* Configure ecspi pin IOMUX */ + configure_ecspi_slave_pins(BOARD_ECSPI_SLAVE_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/main.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/main.c new file mode 100644 index 0000000..938cbd0 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_interrupt/slave/main.c @@ -0,0 +1,175 @@ +/* + * 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 "uart_imx.h" +#include "debug_console_imx.h" +#include "ecspi.h" + +/* define ECSPI slave mode burst length */ +#define ECSPI_SLAVE_BURSTLENGTH (7) +#define FIRST_DATA 0xFF + +/* ECSPI module slave mode configure */ +static void ECSPI_SlaveConfig(ecspi_init_config_t* initConfig); +/* ECSPI slave mode transfer Status */ +static bool ECSPI_SlaveGetTransferStatus(void); + +static volatile uint8_t txData; +static volatile uint8_t rxData; +static uint8_t txBuffer[20]; +static uint8_t rxBuffer[20]; +static volatile bool isBusy; + +int main(void) +{ + uint8_t i; + + ecspi_init_config_t ecspiSlaveInitConfig = { + .clockRate = 0, + .baudRate = 0, + .mode = ecspiSlaveMode, + .burstLength = ECSPI_SLAVE_BURSTLENGTH, + .channelSelect = BOARD_ECSPI_SLAVE_CHANNEL, + .clockPhase = ecspiClockPhaseSecondEdge, + .clockPolarity = ecspiClockPolarityActiveHigh, + .ecspiAutoStart = 0 + }; + + /* Hardware initialiize, include RDC, CLOCK, IOMUX, ENABLE MODULE */ + hardware_init(); + + PRINTF("\n-------------- ECSPI slave driver example --------------\n\n\r"); + PRINTF("This example application demonstrates usage of ECSPI slave driver.\n\r"); + PRINTF("It responding to master via SPI bus.\n\n\r"); + + /* Ecspi slave initialize, include configure parameters */ + txData = FIRST_DATA; + ECSPI_SlaveConfig(&ecspiSlaveInitConfig); + + PRINTF("SLAVE: Initial transmit data: %d\n\n\r", txData); + + /* Send data to master and receive data from master */ + txData = 0; + for(i = 0; i < 20; i++) + { + /* Wait for transfer */ + while(ECSPI_SlaveGetTransferStatus()); + txBuffer[i] = txData; + rxBuffer[i] = rxData; + txData = txData + 1; + /* Set transfer status */ + isBusy = true; + } + + for(i = 0; i < 20; i++) + { + PRINTF("SLAVE: Next step transmit data: %d\n\r", txBuffer[i]); + PRINTF(" : Currently received data: %d\n\n\r", rxBuffer[i]); + } + + /* Disable ecspi slave module */ + ECSPI_Disable(BOARD_ECSPI_SLAVE_BASEADDR); + while(1); +} + +/****************************************************************************** +* +* Function Name: ECSPI_SlaveGetTransferStatus +* Comments: Get Slave transfer status. +* +******************************************************************************/ +static bool ECSPI_SlaveGetTransferStatus(void) +{ + return isBusy; +} + +/****************************************************************************** +* +* Function Name: ECSPI_SlaveConfig +* Comments: ECSPI slave initialize +* +******************************************************************************/ +static void ECSPI_SlaveConfig(ecspi_init_config_t* initConfig) +{ + /* Initialize ECSPI, parameter configure */ + ECSPI_Init(BOARD_ECSPI_SLAVE_BASEADDR, initConfig); + + /* Move first data to tx data register to be ready for first transmition. */ + ECSPI_SendData(BOARD_ECSPI_SLAVE_BASEADDR, txData); + + /* Call core API to enable the IRQ. */ + NVIC_EnableIRQ(BOARD_ECSPI_SLAVE_IRQ_NUM); + + /* Clear ECSPI status register */ + ECSPI_ClearStatusFlag(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagTxfifoTc); + ECSPI_ClearStatusFlag(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagRxfifoOverflow); + + /* Enable RXFIFO Ready Interrupt.*/ + ECSPI_SetIntCmd(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagRxfifoReady, true); + + /* Set ECSPI transfer state. */ + isBusy = true; +} + +/****************************************************************************** +* +* Function Name : BOARD_ECSPI_SLAVE_HANDLER +* Returned Value : none +* Comments : +* ECSPI slave IRQ handler. +* Copy txData to tx data register (will be send in next step) and received +* data to rxData. +* +******************************************************************************/ +void BOARD_ECSPI_SLAVE_HANDLER(void) +{ + /* Are one word or more in RX FIFO */ + if(ECSPI_GetStatusFlag(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagRxfifoReady) != 0) + { + /* Read byte from rx data register */ + rxData = ECSPI_ReceiveData(BOARD_ECSPI_SLAVE_BASEADDR); + + /* Store tx data to tx data register for next transmition */ + ECSPI_SendData(BOARD_ECSPI_SLAVE_BASEADDR, txData); + + /* Clear the status */ + ECSPI_ClearStatusFlag(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagTxfifoTc); + ECSPI_ClearStatusFlag(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagRxfifoOverflow); + + /* Set transfer status */ + isBusy = false; + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/CMakeLists.txt new file mode 100644 index 0000000..4f7d875 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/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(ecspi_polling_master_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/ecspi.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/ecspi.h" + "${ProjDirPath}/../../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(ecspi_polling_master_example PROPERTIES OUTPUT_NAME "ecspi_polling_master_example.elf") + +TARGET_LINK_LIBRARIES(ecspi_polling_master_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(ecspi_polling_master_example m) +TARGET_LINK_LIBRARIES(ecspi_polling_master_example c) +TARGET_LINK_LIBRARIES(ecspi_polling_master_example gcc) +TARGET_LINK_LIBRARIES(ecspi_polling_master_example nosys) +TARGET_LINK_LIBRARIES(ecspi_polling_master_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/ecspi_polling_master_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/ecspi_polling_master_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET ecspi_polling_master_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_master_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_master_example.hex) +ADD_CUSTOM_COMMAND(TARGET ecspi_polling_master_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_master_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_master_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.bat new file mode 100644 index 0000000..1939438 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.sh new file mode 100755 index 0000000..8c5f621 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.bat new file mode 100644 index 0000000..4950fc9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.sh new file mode 100755 index 0000000..a3a7820 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.bat new file mode 100644 index 0000000..9ec4b80 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.sh new file mode 100755 index 0000000..204a7a1 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.cproject new file mode 100644 index 0000000..ad056bc --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.project b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.project new file mode 100644 index 0000000..fbeb096 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/ds5/.project @@ -0,0 +1,86 @@ + + + ecspi_polling_master_example_imx7_smarc_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-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-7-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-7-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-7-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-7-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-5-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-5-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-5-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-5-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-5-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-5-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/ecspi.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ecspi.cdriver2virtual:/virtualdriver/ecspi.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ecspi.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/hardware_init.c new file mode 100644 index 0000000..8916b5b --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/hardware_init.c @@ -0,0 +1,56 @@ +/* + * 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 ECSPI */ + RDC_SetPdapAccess(RDC, BOARD_ECSPI_MASTER_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + /* Select board ecspi clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_ECSPI_MASTER_CCM_ROOT, ccmRootmuxEcspiOsc24m, 0, 0); + /* Enable ecspi clock gate */ + CCM_EnableRoot(CCM, BOARD_ECSPI_MASTER_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_ECSPI_MASTER_CCM_CCGR, ccmClockNeededRunWait); + /* Configure ecspi pin IOMUX */ + configure_ecspi_pins(BOARD_ECSPI_MASTER_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/main.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/main.c new file mode 100644 index 0000000..a933b96 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/master/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 +#include "board.h" +#include "debug_console_imx.h" +#include "ecspi.h" +#include "clock_freq.h" + +/* define ECSPI master mode parameters configuration. */ +#define ECSPI_MASTER_BURSTLENGTH (7) +#define ECSPI_MASTER_STARTMODE (0) +#define BURST_LENGTH_IN_BYTES(x) ((8 * x) - 1) + +/* ECSPI data transfer */ +static bool ECSPI_MasterTransfer(uint8_t* txBuffer, uint8_t* rxBuffer, uint32_t transferSize); + +int main(void) +{ + uint8_t txData = 0; + uint8_t rxData = 0; + uint8_t control_char; + + ecspi_init_config_t initConfig = { + .baudRate = 500000, + .mode = ecspiMasterMode, + .burstLength = ECSPI_MASTER_BURSTLENGTH, + .channelSelect = BOARD_ECSPI_MASTER_CHANNEL, + .clockPhase = ecspiClockPhaseSecondEdge, + .clockPolarity = ecspiClockPolarityActiveHigh, + .ecspiAutoStart = ECSPI_MASTER_STARTMODE + }; + + /* Hardware initialize, include RDC, CLOCK, IOMUX, ENABLE MODULE */ + hardware_init(); + + /* Update clock frequency of this module */ + initConfig.clockRate = get_ecspi_clock_freq(BOARD_ECSPI_MASTER_BASEADDR); + + PRINTF("\n-------------- ECSPI master driver example --------------\n\n\r"); + PRINTF("This example application demonstrates usage of SPI driver in master mode.\n\r"); + PRINTF("It transfers data to/from remote MCU in SPI slave mode.\n\r"); + + /* Ecspi module initialize, include configure parameters */ + ECSPI_Init(BOARD_ECSPI_MASTER_BASEADDR, &initConfig); + + /* Wait slave ready, then press 's' to start communication. */ + while (true) + { + PRINTF("Press \"s\" when SPI slave is ready.\n\r"); + control_char = GETCHAR(); + if ((control_char == 's') || (control_char == 'S')) + break; + } + + /* Send 1~20 to slave and receive data from slave */ + for (uint8_t i = 0; i < 20; i++) + { + txData++; + ECSPI_MasterTransfer(&txData, &rxData, 1); + PRINTF("MASTER: Transmited data: %d \n\r", txData); + PRINTF(" : Received data: %d \n\r", rxData); + } + + PRINTF("Example finish!!!\n\r"); + while (1) + __WFI(); +} + +/****************************************************************************** +* +* Function Name: ECSPI_MasterTransfer +* Comments: Transmit and Receive an amount of data in no-blocking mode with +* interrupt. +* +******************************************************************************/ +static bool ECSPI_MasterTransfer(uint8_t* txBuffer, uint8_t* rxBuffer, uint32_t transferSize) +{ + if (0 == transferSize) + return false; + + /* Set the burst length to one byte(8 bits) */ + ECSPI_SetBurstLength(BOARD_ECSPI_MASTER_BASEADDR, BURST_LENGTH_IN_BYTES(1)); + + while (transferSize) + { + /* Fill the TXFIFO */ + ECSPI_SendData(BOARD_ECSPI_MASTER_BASEADDR, *txBuffer++); + + /* start transmission */ + ECSPI_StartBurst(BOARD_ECSPI_MASTER_BASEADDR); + + /* Wait transmission finish */ + while (!ECSPI_GetStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoTc)); + ECSPI_ClearStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoTc); + + /* Fill the RXFIFO */ + *rxBuffer = ECSPI_ReceiveData(BOARD_ECSPI_MASTER_BASEADDR); + + transferSize--; + } + + return true; +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/CMakeLists.txt new file mode 100644 index 0000000..9416d9f --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/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(ecspi_polling_slave_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/ecspi.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/ecspi.h" + "${ProjDirPath}/../../../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(ecspi_polling_slave_example PROPERTIES OUTPUT_NAME "ecspi_polling_slave_example.elf") + +TARGET_LINK_LIBRARIES(ecspi_polling_slave_example -Wl,--start-group) +# LIBRARIES +IF(CMAKE_BUILD_TYPE MATCHES Debug) +ELSEIF(CMAKE_BUILD_TYPE MATCHES Release) +ENDIF() + +# SYSTEM LIBRARIES +TARGET_LINK_LIBRARIES(ecspi_polling_slave_example m) +TARGET_LINK_LIBRARIES(ecspi_polling_slave_example c) +TARGET_LINK_LIBRARIES(ecspi_polling_slave_example gcc) +TARGET_LINK_LIBRARIES(ecspi_polling_slave_example nosys) +TARGET_LINK_LIBRARIES(ecspi_polling_slave_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/ecspi_polling_slave_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/ecspi_polling_slave_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET ecspi_polling_slave_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_slave_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_slave_example.hex) +ADD_CUSTOM_COMMAND(TARGET ecspi_polling_slave_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_slave_example.elf ${EXECUTABLE_OUTPUT_PATH}/ecspi_polling_slave_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.bat new file mode 100644 index 0000000..1939438 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.sh new file mode 100755 index 0000000..8c5f621 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.bat new file mode 100644 index 0000000..4950fc9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.sh new file mode 100755 index 0000000..a3a7820 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.bat new file mode 100644 index 0000000..9ec4b80 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.sh new file mode 100755 index 0000000..204a7a1 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.cproject new file mode 100644 index 0000000..9ffa28f --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.project b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.project new file mode 100644 index 0000000..a729a08 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/ds5/.project @@ -0,0 +1,86 @@ + + + ecspi_polling_slave_example_imx7_smarc_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-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/arm/startup_MCIMX7D_M4.sutilities2virtual:/virtualutilities/debug_console_imx.c1PARENT-7-PROJECT_LOC/platform/utilities/src/debug_console_imx.cutilities2virtual:/virtualutilities/debug_console_imx.h1PARENT-7-PROJECT_LOC/platform/utilities/inc/debug_console_imx.hutilities2virtual:/virtualutilities/print_scan.c1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.cutilities2virtual:/virtualutilities/print_scan.h1PARENT-7-PROJECT_LOC/platform/utilities/src/print_scan.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_analog_imx7d.hsystem2virtual:/virtualsystem/ccm_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ccm_imx7d.hsystem2virtual:/virtualsystem/lmem.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/lmem.hsystem2virtual:/virtualsystem/rdc.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc.hsystem2virtual:/virtualsystem/rdc_defs_imx7d.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/rdc_defs_imx7d.hsystem2virtual:/virtualsystem/wdog_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/wdog_imx.hsystem2virtual:/virtualsystem/ccm_analog_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_analog_imx7d.csystem2virtual:/virtualsystem/ccm_imx7d.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ccm_imx7d.csystem2virtual:/virtualsystem/lmem.c1PARENT-7-PROJECT_LOC/platform/drivers/src/lmem.csystem2virtual:/virtualsystem/rdc.c1PARENT-7-PROJECT_LOC/platform/drivers/src/rdc.csystem2virtual:/virtualsystem/wdog_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/wdog_imx.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.c1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.cstartup2virtual:/virtualstartup/system_MCIMX7D_M4.h1PARENT-7-PROJECT_LOC/platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.hboard2virtual:/virtualboard/pin_mux.c1PARENT-5-PROJECT_LOC/pin_mux.cboard2virtual:/virtualboard/pin_mux.h1PARENT-5-PROJECT_LOC/pin_mux.hboard2virtual:/virtualboard/board.c1PARENT-5-PROJECT_LOC/board.cboard2virtual:/virtualboard/board.h1PARENT-5-PROJECT_LOC/board.hboard2virtual:/virtualboard/clock_freq.c1PARENT-5-PROJECT_LOC/clock_freq.cboard2virtual:/virtualboard/clock_freq.h1PARENT-5-PROJECT_LOC/clock_freq.hboard2virtual:/virtualboard/hardware_init.c1PARENT-1-PROJECT_LOC/hardware_init.csource2virtual:/virtualsource/main.c1PARENT-1-PROJECT_LOC/main.cdriver2virtual:/virtualdriver/ecspi.c1PARENT-7-PROJECT_LOC/platform/drivers/src/ecspi.cdriver2virtual:/virtualdriver/ecspi.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/ecspi.hdriver2virtual:/virtualdriver/uart_imx.c1PARENT-7-PROJECT_LOC/platform/drivers/src/uart_imx.cdriver2virtual:/virtualdriver/uart_imx.h1PARENT-7-PROJECT_LOC/platform/drivers/inc/uart_imx.h + + + diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/hardware_init.c new file mode 100644 index 0000000..1788b10 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/hardware_init.c @@ -0,0 +1,56 @@ +/* + * 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 ECSPI */ + RDC_SetPdapAccess(RDC, BOARD_ECSPI_SLAVE_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false); + /* Select board ecspi clock derived from OSC clock(24M) */ + CCM_UpdateRoot(CCM, BOARD_ECSPI_SLAVE_CCM_ROOT, ccmRootmuxEcspiOsc24m, 0, 0); + /* Enable ecspi clock gate */ + CCM_EnableRoot(CCM, BOARD_ECSPI_SLAVE_CCM_ROOT); + CCM_ControlGate(CCM, BOARD_ECSPI_SLAVE_CCM_CCGR, ccmClockNeededRunWait); + /* Configure ecspi pin IOMUX */ + configure_ecspi_slave_pins(BOARD_ECSPI_SLAVE_BASEADDR); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/main.c b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/main.c new file mode 100644 index 0000000..67785c7 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/ecspi/ecspi_polling/slave/main.c @@ -0,0 +1,99 @@ +/* + * 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 "ecspi.h" + +/* define ECSPI slave mode burst length */ +#define ECSPI_SLAVE_BURSTLENGTH (7) +#define FIRST_DATA 0xFF + +int main(void) +{ + uint8_t txBuffer[20] = {0}; + uint8_t rxBuffer[20] = {0}; + uint8_t txData = FIRST_DATA; + + ecspi_init_config_t initConfig = { + .clockRate = 0, + .baudRate = 0, + .mode = ecspiSlaveMode, + .burstLength = ECSPI_SLAVE_BURSTLENGTH, + .channelSelect = BOARD_ECSPI_SLAVE_CHANNEL, + .clockPhase = ecspiClockPhaseSecondEdge, + .clockPolarity = ecspiClockPolarityActiveHigh, + .ecspiAutoStart = 0 + }; + + /* Hardware initialize, include RDC, CLOCK, IOMUX, ENABLE MODULE */ + hardware_init(); + + PRINTF("\n-------------- ECSPI slave driver example --------------\n\n\r"); + PRINTF("This example application demonstrates usage of ECSPI slave driver.\n\r"); + PRINTF("It responding to master via SPI bus.\n\n\r"); + + /* Initialize ECSPI, parameter configure */ + ECSPI_Init(BOARD_ECSPI_SLAVE_BASEADDR, &initConfig); + + PRINTF("SLAVE: Initial transmit data: %d\n\n\r", FIRST_DATA); + /* Move first data to tx data register to be ready for first transmission. */ + ECSPI_SendData(BOARD_ECSPI_SLAVE_BASEADDR, txData); + + /* Send data to master and receive data from master */ + txData = 0; + + for(uint8_t i = 0; i < 20; i++) + { + /* Wait for data received */ + while(!ECSPI_GetStatusFlag(BOARD_ECSPI_SLAVE_BASEADDR, ecspiFlagRxfifoReady)); + /* Fill rxBuffer */ + rxBuffer[i] = ECSPI_ReceiveData(BOARD_ECSPI_SLAVE_BASEADDR); + /* Store tx data to tx data register for next transmission */ + ECSPI_SendData(BOARD_ECSPI_SLAVE_BASEADDR, txData); + txBuffer[i] = txData; + txData++; + } + + for(uint8_t i = 0; i < 20; i++) + { + PRINTF("SLAVE: Next step transmit data: %d\n\r", txBuffer[i]); + PRINTF(" : Currently received data: %d\n\n\r", rxBuffer[i]); + } + + PRINTF("Example finish!!!\n\r"); + while(1) + __WFI(); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/CMakeLists.txt new file mode 100644 index 0000000..75c6836 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject new file mode 100644 index 0000000..7ffa060 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project new file mode 100644 index 0000000..756fee7 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/ds5/.project @@ -0,0 +1,86 @@ + + + flexcan_loopback_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/hardware_init.c new file mode 100644 index 0000000..ad34e0e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/main.c b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_loopback/main.c new file mode 100644 index 0000000..980e8ea --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/CMakeLists.txt new file mode 100644 index 0000000..a504059 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject new file mode 100644 index 0000000..731fb4b --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.project b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.project new file mode 100644 index 0000000..95a2cb9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/ds5/.project @@ -0,0 +1,86 @@ + + + flexcan_network_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/hardware_init.c new file mode 100644 index 0000000..ad34e0e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/main.c b/examples/imx7_smarc_m4/driver_examples/flexcan/flexcan_network/main.c new file mode 100644 index 0000000..2332019 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/CMakeLists.txt new file mode 100644 index 0000000..f2620f9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/CMakeLists.txt @@ -0,0 +1,140 @@ +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_bank2_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/src/rdc_semaphore.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/rdc_semaphore.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}/../../../../../platform/drivers/src/gpio_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/gpio_imx.h" + "${ProjDirPath}/../../../pin_mux.c" + "${ProjDirPath}/../../../pin_mux.h" + "${ProjDirPath}/../../../board.c" + "${ProjDirPath}/../../../board.h" + "${ProjDirPath}/../../../clock_freq.c" + "${ProjDirPath}/../../../clock_freq.h" + "${ProjDirPath}/../hardware_init.c" + "${ProjDirPath}/../../../gpio_pins.c" + "${ProjDirPath}/../../../gpio_pins.h" + "${ProjDirPath}/../gpio_ctrl.c" + "${ProjDirPath}/../gpio_ctrl.h" + "${ProjDirPath}/../main.c" + "${ProjDirPath}/../../../../../platform/drivers/src/uart_imx.c" + "${ProjDirPath}/../../../../../platform/drivers/inc/uart_imx.h" +) +SET_TARGET_PROPERTIES(gpio_bank2_imx_example PROPERTIES OUTPUT_NAME "gpio_bank2_imx_example.elf") + +TARGET_LINK_LIBRARIES(gpio_bank2_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_bank2_imx_example m) +TARGET_LINK_LIBRARIES(gpio_bank2_imx_example c) +TARGET_LINK_LIBRARIES(gpio_bank2_imx_example gcc) +TARGET_LINK_LIBRARIES(gpio_bank2_imx_example nosys) +TARGET_LINK_LIBRARIES(gpio_bank2_imx_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/gpio_bank2_imx_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/gpio_bank2_imx_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET gpio_bank2_imx_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/gpio_bank2_imx_example.elf ${EXECUTABLE_OUTPUT_PATH}/gpio_bank2_imx_example.hex) +ADD_CUSTOM_COMMAND(TARGET gpio_bank2_imx_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/gpio_bank2_imx_example.elf ${EXECUTABLE_OUTPUT_PATH}/gpio_bank2_imx_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.cproject new file mode 100644 index 0000000..0dd0722 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.project b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.project new file mode 100644 index 0000000..106d872 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/ds5/.project @@ -0,0 +1,86 @@ + + + gpio_imx_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.c b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.c new file mode 100644 index 0000000..f3d1eed --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.c @@ -0,0 +1,214 @@ +/* + * 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 "gpio_pins.h" +#include "board.h" +#include "gpio_ctrl.h" +#include "gpio_imx.h" +#include "rdc_semaphore.h" +#include "debug_console_imx.h" + +#define GPIO_DEBOUNCE_DELAY (100000) + + +void GPIO_Ctrl_InitSwitch1Pin() +{ +#ifdef BOARD_GPIO_SWITCH1_CONFIG + /* Acquire RDC semaphore before access GPIO to avoid conflict, it's + * necessary when GPIO RDC is configured as Semaphore Required */ + RDC_SEMAPHORE_Lock(BOARD_GPIO_SWITCH1_RDC_PDAP); + GPIO_Init(BOARD_GPIO_SWITCH1_CONFIG->base, &Switch1); + RDC_SEMAPHORE_Unlock(BOARD_GPIO_SWITCH1_RDC_PDAP); +#endif +} + +void GPIO_Ctrl_InitLed1Pin() +{ +#ifdef BOARD_GPIO_LED1_CONFIG + /* Acquire RDC semaphore before access GPIO to avoid conflict, it's + * necessary when GPIO RDC is configured as Semaphore Required */ + RDC_SEMAPHORE_Lock(BOARD_GPIO_LED1_RDC_PDAP); + GPIO_Init(BOARD_GPIO_LED1_CONFIG->base, &Led1); + RDC_SEMAPHORE_Unlock(BOARD_GPIO_LED1_RDC_PDAP); +#endif +} + +void GPIO_Ctrl_InitSwitch2Pin() +{ +#ifdef BOARD_GPIO_SWITCH2_CONFIG + /* Acquire RDC semaphore before access GPIO to avoid conflict, it's + * necessary when GPIO RDC is configured as Semaphore Required */ + RDC_SEMAPHORE_Lock(BOARD_GPIO_SWITCH2_RDC_PDAP); + GPIO_Init(BOARD_GPIO_SWITCH2_CONFIG->base, &Switch2); + RDC_SEMAPHORE_Unlock(BOARD_GPIO_SWITCH2_RDC_PDAP); +#endif +} + +void GPIO_Ctrl_InitLed2Pin() +{ +#ifdef BOARD_GPIO_LED2_CONFIG + /* Acquire RDC semaphore before access GPIO to avoid conflict, it's + * necessary when GPIO RDC is configured as Semaphore Required */ + RDC_SEMAPHORE_Lock(BOARD_GPIO_LED2_RDC_PDAP); + GPIO_Init(BOARD_GPIO_LED2_CONFIG->base, &Led2); + RDC_SEMAPHORE_Unlock(BOARD_GPIO_LED2_RDC_PDAP); +#endif +} + +void GPIO_Ctrl_Init() +{ + GPIO_Ctrl_InitSwitch1Pin(); + GPIO_Ctrl_InitLed1Pin(); + GPIO_Ctrl_InitSwitch2Pin(); + GPIO_Ctrl_InitLed2Pin(); +} + +void GPIO_Ctrl_ToggleLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc) +{ + static bool onLed0 = 0; + onLed0 = GPIO_ReadPinOutput(boardGpioConfig->base, boardGpioConfig->pin); + if(onLed0 == 0) + { + RDC_SEMAPHORE_Lock(boardGpioRdc); + GPIO_WritePinOutput(boardGpioConfig->base, + boardGpioConfig->pin, gpioPinSet); + RDC_SEMAPHORE_Unlock(boardGpioRdc); + } + else + { + RDC_SEMAPHORE_Lock(boardGpioRdc); + GPIO_WritePinOutput(boardGpioConfig->base, + boardGpioConfig->pin, gpioPinClear); + RDC_SEMAPHORE_Unlock(boardGpioRdc); + } +} + +void GPIO_Ctrl_ClearLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc) +{ + RDC_SEMAPHORE_Lock(boardGpioRdc); + GPIO_WritePinOutput(boardGpioConfig->base, + boardGpioConfig->pin, gpioPinClear); + RDC_SEMAPHORE_Unlock(boardGpioRdc); +} + +void GPIO_Ctrl_SetLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc) +{ + + RDC_SEMAPHORE_Lock(boardGpioRdc); + GPIO_WritePinOutput(boardGpioConfig->base, + boardGpioConfig->pin, gpioPinSet); + RDC_SEMAPHORE_Unlock(boardGpioRdc); +} + +void GPIO_Ctrl_WriteLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc, uint32_t value) +{ + RDC_SEMAPHORE_Lock(boardGpioRdc); + GPIO_WritePinOutput(boardGpioConfig->base, + boardGpioConfig->pin, value); + RDC_SEMAPHORE_Unlock(boardGpioRdc); +} + + +uint32_t GPIO_Ctrl_GetKey(gpio_config_t *boardGpioConfig) +{ + return GPIO_ReadPinInput(boardGpioConfig->base, boardGpioConfig->pin); +} + +void GPIO_WaitKeyPressed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc) +{ + uint32_t i, j, debounce; + /* Wait for Key Released. */ + do + { + debounce = 0; + while (0 == GPIO_ReadPinInput(boardGpioConfig->base, boardGpioConfig->pin)); + + for (i = 0; i < 3; i++) + { + /* Delay to wait key value stable. The cycle number should be changed + * according to M4 Core clock frequncy. + */ + for (j = 0 ; j < GPIO_DEBOUNCE_DELAY; j++) + { + __NOP(); + } + + if (1 == GPIO_ReadPinInput(boardGpioConfig->base, boardGpioConfig->pin)) + { + debounce++; + } + } + + if (debounce > 2) + { + break; + } + } + while (1); +} +#ifdef BOARD_GPIO_KEY_CONFIG +void BOARD_GPIO_KEY_HANDLER() +{ + + + /* When user input captured, we disable GPIO interrupt */ + NVIC_DisableIRQ(BOARD_GPIO_KEY_IRQ_NUM); + + RDC_SEMAPHORE_Lock(BOARD_GPIO_KEY_RDC_PDAP); + + /* Disable GPIO pin interrupt */ + GPIO_SetPinIntMode(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin, false); + /* Clear the interrupt state */ + GPIO_ClearStatusFlag(BOARD_GPIO_KEY_CONFIG->base, BOARD_GPIO_KEY_CONFIG->pin); + + RDC_SEMAPHORE_Unlock(BOARD_GPIO_KEY_RDC_PDAP); + +#ifdef xSemaphoreGiveFromISR + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + /* Unlock the task to process the event. */ + xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken); + + /* Perform a context switch to wake the higher priority task. */ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +#endif +} +#endif + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.h b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.h new file mode 100644 index 0000000..4b20ce1 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/gpio_ctrl.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015, Freescale Semiconductor, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * o Neither the name of Freescale Semiconductor, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __GPIO_CTRL_H__ +#define __GPIO_CTRL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * @brief Initialize GPIO controller. + */ +void GPIO_Ctrl_Init(void); + +/*! + * @brief Toggle LED on/off status + */ +void GPIO_Ctrl_ToggleLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc); +/*! + * @brief Clear LED on/off status + */ +void GPIO_Ctrl_ClearLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc); +/*! + * @brief Set LED on/off status + */ +void GPIO_Ctrl_SetLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc); +/*! + * @brief write LED on/off status + */ +void GPIO_Ctrl_WriteLed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc, uint32_t value); +/*! + * @brief Get Key on/off status + */ +uint32_t GPIO_Ctrl_GetKey(gpio_config_t *boardGpioConfig); + +/*! + * @brief Get Key on/off status + */ +void GPIO_WaitKeyPressed(gpio_config_t *boardGpioConfig, uint32_t boardGpioRdc); + +#ifdef __cplusplus +} +#endif + +#endif /* __GPIO_CTRL_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/hardware_init.c new file mode 100644 index 0000000..c0be651 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_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, we can set sreq argument to true + * when the peer core could also access GPIO with RDC_SEMAPHORE, or the peer + * core doesn't access the GPIO at all */ + RDC_SetPdapAccess(RDC, rdcPdapGpio2, 0xFF, false/*true*/, false); + + /* Enable gpio clock gate */ + // CCM_ControlGate(CCM, BOARD_GPIO_KEY_CCM_CCGR, ccmClockNeededRunWait); +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/main.c b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/main.c new file mode 100644 index 0000000..c130c31 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_bank2_imx/main.c @@ -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. + */ + +#include +#include "board.h" +#include "gpio_pins.h" +#include "gpio_imx.h" +#include "gpio_ctrl.h" +#include "debug_console_imx.h" + + +/* button relevent variables */ +static uint8_t keyPressCount; +static uint8_t keyPressCountOld; + + +/****************************************************************************** +* +* Function Name: main +* Comments: Hello World Example with GPIO. +* This example include: +* Configure BUTTON1 as GPIO functionality +* and check the button's state(pressed or released). According to the Button +* status, copy it to the LED +* +******************************************************************************/ +int main(void) +{ + /* hardware initialiize, include RDC, IOMUX, Uart debug initialize */ + hardware_init(); + PRINTF("\n\r\n\r\n\r"); + PRINTF("=======================================================\n\r"); + PRINTF("================= GPIO Bank 2 Example =================\n\r"); + PRINTF("===== Change the Led Status according to the Key ======\n\r"); + PRINTF("=======================================================\n\r"); + + /* GPIO module initialize, configure "LED" as output and button as interrupt mode. */ + GPIO_Ctrl_Init(); + + keyPressCount = 0; + keyPressCountOld = 0; + + /* Initialize enviroments and led status */ + keyPressCount = GPIO_Ctrl_GetKey(BOARD_GPIO_SWITCH1_CONFIG); + keyPressCountOld = keyPressCount; + GPIO_Ctrl_WriteLed(BOARD_GPIO_LED1_CONFIG, BOARD_GPIO_LED1_RDC_PDAP, keyPressCount); + + PRINTF("================== Hello World GPIO ===================\n\r"); + + while(true) + { + /* wait for user change button leve */ + keyPressCount = GPIO_Ctrl_GetKey(BOARD_GPIO_SWITCH1_CONFIG); + /* If button change, than print and update LED */ + if(keyPressCount != keyPressCountOld) + { + keyPressCountOld = keyPressCount; + GPIO_Ctrl_WriteLed(BOARD_GPIO_LED1_CONFIG, BOARD_GPIO_LED1_RDC_PDAP, keyPressCount); + PRINTF("================== keyPressCount = %d ==================\n\r", keyPressCount); + } + } +} + + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/CMakeLists.txt new file mode 100644 index 0000000..af034fb --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/gpio_imx/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.cproject new file mode 100644 index 0000000..0dd0722 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.project b/examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.project new file mode 100644 index 0000000..106d872 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpio_imx/ds5/.project @@ -0,0 +1,86 @@ + + + gpio_imx_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/gpio_imx/hardware_init.c new file mode 100644 index 0000000..3c5b0e1 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpio_imx/main.c b/examples/imx7_smarc_m4/driver_examples/gpio_imx/main.c new file mode 100644 index 0000000..f062aef --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/CMakeLists.txt new file mode 100644 index 0000000..eaa052e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/gpt/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/gpt/ds5/.cproject new file mode 100644 index 0000000..5de9d82 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpt/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/gpt/ds5/.project b/examples/imx7_smarc_m4/driver_examples/gpt/ds5/.project new file mode 100644 index 0000000..084bff2 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/gpt/ds5/.project @@ -0,0 +1,86 @@ + + + gpt_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/gpt/hardware_init.c new file mode 100644 index 0000000..b43ffbb --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/gpt/main.c b/examples/imx7_smarc_m4/driver_examples/gpt/main.c new file mode 100644 index 0000000..edf299c --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/CMakeLists.txt new file mode 100644 index 0000000..75ed945 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/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(i2c_imx_interrupt_eeprom_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_eeprom_example PROPERTIES OUTPUT_NAME "i2c_imx_interrupt_eeprom_example.elf") + +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_eeprom_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_eeprom_example m) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_eeprom_example c) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_eeprom_example gcc) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_eeprom_example nosys) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_eeprom_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/i2c_imx_interrupt_eeprom_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/i2c_imx_interrupt_eeprom_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET i2c_imx_interrupt_eeprom_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_eeprom_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_eeprom_example.hex) +ADD_CUSTOM_COMMAND(TARGET i2c_imx_interrupt_eeprom_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_eeprom_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_eeprom_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.cproject new file mode 100644 index 0000000..eb1e5e3 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.project b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.project new file mode 100644 index 0000000..6a8d6ce --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/ds5/.project @@ -0,0 +1,86 @@ + + + i2c_imx_interrupt_eeprom_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/hardware_init.c new file mode 100644 index 0000000..3ffd205 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/main.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/main.c new file mode 100644 index 0000000..2de3c14 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_eeprom/main.c @@ -0,0 +1,390 @@ +/* + * 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 EEPROM_ADDRESS (0x50) + +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 bool compare(uint8_t* bufA, uint8_t* bufB, uint32_t length); + +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 + }; + uint8_t txBuffer[5]; + uint8_t rxBuffer[5]; + uint8_t cmdBuffer[5]; + + /* 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 Driven Example +++++++++++++++++\n\r"); + PRINTF("This example will write data to on board EEPROM through I2C Bus\n\r"); + PRINTF("and read them back to see if the EEPROM is programmed successfully. \n\r\n\r"); + + PRINTF("[1].Initialize the I2C module with initialize structure. \n\r"); + I2C_XFER_Config(&i2cInitConfig); + + PRINTF("[2].Launch a I2C write action to 0x0000 address. \n\r"); + cmdBuffer[0] = EEPROM_ADDRESS << 1; + cmdBuffer[1] = 0x00; + cmdBuffer[2] = 0x00; + + PRINTF("[3].Prepare Data for Sending. \n\r"); + txBuffer[0] = 0x11; + txBuffer[1] = 0x22; + txBuffer[2] = 0x33; + txBuffer[3] = 0x44; + txBuffer[4] = 0x55; + + PRINTF("[4].Write data to EEPROM. \n\r"); + I2C_XFER_Write(cmdBuffer, 3, txBuffer, 5); + PRINTF("[5].Wait until transmission is finished. \n\r"); + while(I2C_XFER_IsBusy()); + + PRINTF("[6].Launch a I2C read action from 0x0000 address. \n\r"); + cmdBuffer[0] = EEPROM_ADDRESS << 1; + cmdBuffer[1] = 0x00; + cmdBuffer[2] = 0x00; + cmdBuffer[3] = (EEPROM_ADDRESS << 1) + 1; + + PRINTF("[7].Read data from EEPROM. \n\r"); + I2C_XFER_Read(cmdBuffer, 4, rxBuffer, 5); + PRINTF("[8].Wait until transmission is finished. \n\r"); + while (I2C_XFER_IsBusy()); + + PRINTF("[9].Compare data between txBuf and rxBuf: \n\r"); + if (compare(txBuffer, rxBuffer, 5)) + PRINTF(" txBuf and rxBuf are same, example passed!!!\n\r"); + else + PRINTF(" txBuf and rxBuf are different, example failed!!! \n\r"); + + while (true); +} + +static bool compare(uint8_t* bufA, uint8_t* bufB, uint32_t length) +{ + for (uint32_t i = 0; i < length; i++) + { + if (bufA[i] != bufB[i]) + return false; + } + + return true; +} + +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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/CMakeLists.txt new file mode 100644 index 0000000..77065a3 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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_sensor_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_sensor_imx7d_example PROPERTIES OUTPUT_NAME "i2c_imx_interrupt_sensor_imx7d_example.elf") + +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_sensor_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_sensor_imx7d_example m) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_sensor_imx7d_example c) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_sensor_imx7d_example gcc) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_sensor_imx7d_example nosys) +TARGET_LINK_LIBRARIES(i2c_imx_interrupt_sensor_imx7d_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/i2c_imx_interrupt_sensor_imx7d_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/i2c_imx_interrupt_sensor_imx7d_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET i2c_imx_interrupt_sensor_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_sensor_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_sensor_imx7d_example.hex) +ADD_CUSTOM_COMMAND(TARGET i2c_imx_interrupt_sensor_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_sensor_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_interrupt_sensor_imx7d_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.cproject new file mode 100644 index 0000000..8078e53 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.project b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.project new file mode 100644 index 0000000..598d999 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/ds5/.project @@ -0,0 +1,86 @@ + + + i2c_imx_interrupt_sensor_imx7d_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/hardware_init.c new file mode 100644 index 0000000..3ffd205 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/main.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/main.c new file mode 100644 index 0000000..bcb365e --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_interrupt_sensor_imx7d/main.c @@ -0,0 +1,431 @@ +/* + * 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" + +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_abs(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) +{ + uint8_t i; + + /* 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 accelerometer through I2C Bus\n\r"); + PRINTF("and read 10 samples back to see if the accelerometer is configured successfully. \n\r\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].Set on-board Acc sensor range to 2G\n\r"); + // Place FXOS8700 into standby + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x2A; + txBuffer[0] = 0x00; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while(I2C_XFER_IsBusy()); + + // Disable FXOS8700's magnetometer only + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x5B; + txBuffer[0] = 0x00; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while(I2C_XFER_IsBusy()); + + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x5C; + txBuffer[0] = 0x00; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while(I2C_XFER_IsBusy()); + + // Set accelerometer range to 2G + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x0E; + txBuffer[0] = 0x00; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while(I2C_XFER_IsBusy()); + + // Set accelerometer for high resolution (maximum over sampling) + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x2B; + txBuffer[0] = 0x02; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while(I2C_XFER_IsBusy()); + + PRINTF("[3].Set on-board Acc sensor working at fast read and active mode\n\r"); + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x2A; + txBuffer[0] = 0x09; + I2C_XFER_Write(cmdBuffer, 2, txBuffer, 1); + while(I2C_XFER_IsBusy()); + + PRINTF("[4].Acc sensor WHO_AM_I check... "); + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x0D; + cmdBuffer[2] = (BOARD_I2C_FXOS8700_ADDR << 1) + 1; + I2C_XFER_Read(cmdBuffer, 3, rxBuffer, 1); + while (I2C_XFER_IsBusy()); + if (0xC7 == rxBuffer[0]) + PRINTF("OK\n\r"); + else + PRINTF("ERROR\n\r"); + + PRINTF("[5].Acquire 10 samples from Acc sensor\n\r"); + for (i = 0; i < 10; i++) + report_abs(); + + PRINTF("\n\rExample finished!!!\n\r"); + while (true) + __WFI(); +} + +static void report_abs(void) +{ + int16_t x, y, z; + float Ax, Ay, Az; + + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x01; + cmdBuffer[2] = (BOARD_I2C_FXOS8700_ADDR << 1) + 1; + I2C_XFER_Read(cmdBuffer, 3, rxBuffer, 6); + while (I2C_XFER_IsBusy()); + + x = ((rxBuffer[0] << 8) & 0xff00) | rxBuffer[1]; + y = ((rxBuffer[2] << 8) & 0xff00) | rxBuffer[3]; + z = ((rxBuffer[4] << 8) & 0xff00) | rxBuffer[5]; + x = (int16_t)(x) >> 2; + y = (int16_t)(y) >> 2; + z = (int16_t)(z) >> 2; + + Ax = x / (4.0 * 1024); //For full scale range 2g mode. + Ay = y / (4.0 * 1024); + Az = z / (4.0 * 1024); + PRINTF("2G MODE: X=%6.3fg Y=%6.3fg Z=%6.3fg\n\r",Ax, Ay, Az); +} + +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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/CMakeLists.txt new file mode 100644 index 0000000..fa17877 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/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(i2c_imx_polling_eeprom_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_eeprom_example PROPERTIES OUTPUT_NAME "i2c_imx_polling_eeprom_example.elf") + +TARGET_LINK_LIBRARIES(i2c_imx_polling_eeprom_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_eeprom_example m) +TARGET_LINK_LIBRARIES(i2c_imx_polling_eeprom_example c) +TARGET_LINK_LIBRARIES(i2c_imx_polling_eeprom_example gcc) +TARGET_LINK_LIBRARIES(i2c_imx_polling_eeprom_example nosys) +TARGET_LINK_LIBRARIES(i2c_imx_polling_eeprom_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/i2c_imx_polling_eeprom_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/i2c_imx_polling_eeprom_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET i2c_imx_polling_eeprom_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_eeprom_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_eeprom_example.hex) +ADD_CUSTOM_COMMAND(TARGET i2c_imx_polling_eeprom_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_eeprom_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_eeprom_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.bat @@ -0,0 +1,5 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_all.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_debug.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.bat @@ -0,0 +1,3 @@ +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release . +mingw32-make -j4 +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/build_release.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cmake -DCMAKE_TOOLCHAIN_FILE="../../../../../../tools/cmake_toolchain_files/armgcc.cmake" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release . +make -j4 diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.bat @@ -0,0 +1,3 @@ +RD /s /Q Debug Release CMakeFiles +DEL /s /Q /F Makefile cmake_install.cmake CMakeCache.txt +pause diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/armgcc/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf debug release CMakeFiles +rm -rf Makefile cmake_install.cmake CMakeCache.txt diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.cproject new file mode 100644 index 0000000..0ef4678 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.project b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.project new file mode 100644 index 0000000..a7f12e8 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/ds5/.project @@ -0,0 +1,86 @@ + + + i2c_imx_polling_eeprom_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/hardware_init.c new file mode 100644 index 0000000..3ffd205 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/main.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/main.c new file mode 100644 index 0000000..459e702 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_eeprom/main.c @@ -0,0 +1,310 @@ +/* + * 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 EEPROM_ADDRESS (0x50) + +static bool compare(uint8_t* bufA, uint8_t* bufB, uint32_t length); + +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 + }; + uint8_t txBuffer[5]; + uint8_t rxBuffer[5]; + uint8_t cmdBuffer[5]; + + /* 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 write data to on board EEPROM through I2C Bus\n\r"); + PRINTF("and read them back to see if the EEPROM is programmed successfully. \n\r\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].Launch a I2C write action to 0x0000 address. \n\r"); + cmdBuffer[0] = EEPROM_ADDRESS << 1; + cmdBuffer[1] = 0x00; + cmdBuffer[2] = 0x00; + + PRINTF("[3].Prepare Data for Sending. \n\r"); + txBuffer[0] = 0x11; + txBuffer[1] = 0x22; + txBuffer[2] = 0x33; + txBuffer[3] = 0x44; + txBuffer[4] = 0x55; + + PRINTF("[4].Write data to EEPROM and wait until transmission finished. \n\r"); + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 3, txBuffer, 5); + + PRINTF("[5].Launch a I2C read action from 0x0000 address. \n\r"); + cmdBuffer[0] = EEPROM_ADDRESS << 1; + cmdBuffer[1] = 0x00; + cmdBuffer[2] = 0x00; + cmdBuffer[3] = (EEPROM_ADDRESS << 1) + 1; + + PRINTF("[6].Read data from EEPROM and wait until transmission finished. \n\r"); + I2C_MasterReceiveDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 4, rxBuffer, 5); + + PRINTF("[7].Compare data between txBuf and rxBuf: \n\r"); + if (compare(txBuffer, rxBuffer, 5)) + PRINTF(" txBuf and rxBuf are same, example passed!!!\n\r"); + else + PRINTF(" txBuf and rxBuf are different, example failed!!! \n\r"); + + while (true) + __WFI(); +} + +static bool compare(uint8_t* bufA, uint8_t* bufB, uint32_t length) +{ + for (uint32_t i = 0; i < length; i++) + { + if (bufA[i] != bufB[i]) + return false; + } + + return true; +} + +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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/CMakeLists.txt new file mode 100644 index 0000000..da26472 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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_sensor_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_sensor_imx7d_example PROPERTIES OUTPUT_NAME "i2c_imx_polling_sensor_imx7d_example.elf") + +TARGET_LINK_LIBRARIES(i2c_imx_polling_sensor_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_sensor_imx7d_example m) +TARGET_LINK_LIBRARIES(i2c_imx_polling_sensor_imx7d_example c) +TARGET_LINK_LIBRARIES(i2c_imx_polling_sensor_imx7d_example gcc) +TARGET_LINK_LIBRARIES(i2c_imx_polling_sensor_imx7d_example nosys) +TARGET_LINK_LIBRARIES(i2c_imx_polling_sensor_imx7d_example -Wl,--end-group) + +# MAP FILE +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Xlinker -Map=debug/i2c_imx_polling_sensor_imx7d_example.map") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Xlinker -Map=release/i2c_imx_polling_sensor_imx7d_example.map") + +# BIN AND HEX +ADD_CUSTOM_COMMAND(TARGET i2c_imx_polling_sensor_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_sensor_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_sensor_imx7d_example.hex) +ADD_CUSTOM_COMMAND(TARGET i2c_imx_polling_sensor_imx7d_example POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_sensor_imx7d_example.elf ${EXECUTABLE_OUTPUT_PATH}/i2c_imx_polling_sensor_imx7d_example.bin) diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.cproject new file mode 100644 index 0000000..a915cc9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.project b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.project new file mode 100644 index 0000000..ee72cd2 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/ds5/.project @@ -0,0 +1,86 @@ + + + i2c_imx_polling_sensor_imx7d_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/hardware_init.c new file mode 100644 index 0000000..3ffd205 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_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/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/main.c b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/main.c new file mode 100644 index 0000000..d2977a1 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/i2c_imx/i2c_polling_sensor_imx7d/main.c @@ -0,0 +1,343 @@ +/* + * 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" + +static uint8_t txBuffer[5]; +static uint8_t rxBuffer[7]; +static uint8_t cmdBuffer[5]; + +static void report_abs(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) +{ + uint8_t i; + + /* 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 accelerometer through I2C Bus\n\r"); + PRINTF("and read 10 samples back to see if the accelerometer 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].Set on-board Acc sensor range to 2G\n\r"); + // Place FXOS8700 into standby + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x2A; + txBuffer[0] = 0x00; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + + // Disable FXOS8700's magnetometer only + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x5B; + txBuffer[0] = 0x00; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x5C; + txBuffer[0] = 0x00; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + + // Set accelerometer range to 2G + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x0E; + txBuffer[0] = 0x00; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + + // Set accelerometer for high resolution (maximum over sampling) + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x2B; + txBuffer[0] = 0x02; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + + PRINTF("[3].Set on-board Acc sensor working at active mode\n\r"); + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x2A; + txBuffer[0] = 0x09; + I2C_MasterSendDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 2, txBuffer, 1); + + PRINTF("[4].Acc sensor WHO_AM_I check... "); + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x0D; + cmdBuffer[2] = (BOARD_I2C_FXOS8700_ADDR << 1) + 1; + I2C_MasterReceiveDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 3, rxBuffer, 1); + if (0xC7 == rxBuffer[0]) + PRINTF("OK\n\r"); + else + PRINTF("ERROR\n\r"); + + PRINTF("[5].Acquire 10 samples from Acc sensor\n\r"); + for (i = 0; i < 10; i++) + report_abs(); + + PRINTF("\n\rExample finished!!!\n\r"); + while (true) + __WFI(); +} + +static void report_abs(void) +{ + int16_t x, y, z; + float Ax, Ay, Az; + + cmdBuffer[0] = BOARD_I2C_FXOS8700_ADDR << 1; + cmdBuffer[1] = 0x01; + cmdBuffer[2] = (BOARD_I2C_FXOS8700_ADDR << 1) + 1; + I2C_MasterReceiveDataPolling(BOARD_I2C_BASEADDR, cmdBuffer, 3, rxBuffer, 6); + + x = ((rxBuffer[0] << 8) & 0xff00) | rxBuffer[1]; + y = ((rxBuffer[2] << 8) & 0xff00) | rxBuffer[3]; + z = ((rxBuffer[4] << 8) & 0xff00) | rxBuffer[5]; + x = (int16_t)(x) >> 2; + y = (int16_t)(y) >> 2; + z = (int16_t)(z) >> 2; + + Ax = x / (4.0 * 1024); //For full scale range 2g mode. + Ay = y / (4.0 * 1024); + Az = z / (4.0 * 1024); + PRINTF("2G MODE: X=%6.3fg Y=%6.3fg Z=%6.3fg\n\r",Ax, Ay, Az); +} + +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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/CMakeLists.txt new file mode 100644 index 0000000..a9a2980 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject new file mode 100644 index 0000000..7eed1b9 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project new file mode 100644 index 0000000..41007bd --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/ds5/.project @@ -0,0 +1,86 @@ + + + uart_imx_interrupt_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/hardware_init.c new file mode 100644 index 0000000..b9efeaf --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/main.c b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_interrupt/main.c new file mode 100644 index 0000000..9b22f1f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/CMakeLists.txt new file mode 100644 index 0000000..97d1f98 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.bat new file mode 100644 index 0000000..0cf721f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_all.sh new file mode 100755 index 0000000..3827529 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.bat new file mode 100644 index 0000000..e9ccfdd --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_debug.sh new file mode 100755 index 0000000..effd076 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.bat new file mode 100644 index 0000000..0759349 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/build_release.sh new file mode 100755 index 0000000..a12067d --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject new file mode 100644 index 0000000..781f810 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.project b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.project new file mode 100644 index 0000000..7225d85 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/ds5/.project @@ -0,0 +1,86 @@ + + + uart_imx_polling_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/hardware_init.c new file mode 100644 index 0000000..b9efeaf --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/main.c b/examples/imx7_smarc_m4/driver_examples/uart_imx/uart_polling/main.c new file mode 100644 index 0000000..5888f6f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/CMakeLists.txt b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/CMakeLists.txt new file mode 100644 index 0000000..cda6351 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_all.bat b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_all.bat new file mode 100644 index 0000000..6d41d86 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_all.sh b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_all.sh new file mode 100755 index 0000000..ebb0c25 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_debug.bat b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_debug.bat new file mode 100644 index 0000000..bf3b902 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_debug.sh b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_debug.sh new file mode 100755 index 0000000..571868b --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_release.bat b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_release.bat new file mode 100644 index 0000000..e229a83 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_release.sh b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/build_release.sh new file mode 100755 index 0000000..035ce4e --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/clean.bat b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/clean.bat new file mode 100644 index 0000000..ffea088 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/clean.sh b/examples/imx7_smarc_m4/driver_examples/wdog_imx/armgcc/clean.sh new file mode 100755 index 0000000..795ad87 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.cproject b/examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.cproject new file mode 100644 index 0000000..438fecf --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.cproject @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.project b/examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.project new file mode 100644 index 0000000..8f79ab4 --- /dev/null +++ b/examples/imx7_smarc_m4/driver_examples/wdog_imx/ds5/.project @@ -0,0 +1,86 @@ + + + wdog_imx_example_imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/hardware_init.c b/examples/imx7_smarc_m4/driver_examples/wdog_imx/hardware_init.c new file mode 100644 index 0000000..8f0d50f --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/driver_examples/wdog_imx/main.c b/examples/imx7_smarc_m4/driver_examples/wdog_imx/main.c new file mode 100644 index 0000000..af29975 --- /dev/null +++ b/examples/imx7_smarc_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/imx7_smarc_m4/gpio_pins.c b/examples/imx7_smarc_m4/gpio_pins.c new file mode 100644 index 0000000..3da0f07 --- /dev/null +++ b/examples/imx7_smarc_m4/gpio_pins.c @@ -0,0 +1,172 @@ +/* + * 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" +#include "board.h" +#include "gpio_imx.h" + +gpio_config_t gpioLed = { + "GPIO5", /* name */ + &IOMUXC_LPSR_SW_MUX_CTL_PAD_GPIO1_IO01, /* muxReg */ + 0, /* muxConfig */ + &IOMUXC_LPSR_SW_PAD_CTL_PAD_GPIO1_IO01, /* padReg */ + 0, /* padConfig */ + GPIO1, /* base */ + 1 /* pin */ +}; + +gpio_config_t gpioKeyFunc1 = { + "FUNC1", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_DATA05, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05_HYS_MASK, + GPIO2, /* base */ + 5 /* pin */ +}; + +gpio_config_t gpioKeyFunc2 = { + "FUNC2", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_DATA02, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02_HYS_MASK, + GPIO2, /* base */ + 2 /* pin */ +}; + +/* The Embedian example using input and output as well as interrupt mode. The Embedian example uses GPIO6 and GPIO8 for button/keys, GPIO2 and GPIO4 for LEDs. On EVK-STD-CARRIER-S20 evaluation carrier, you can use header GPIO to connect the SMARC signals to a button or LED respectively. */ + +/* Switch 1 (GPIO6) + * Golden Finger BALL NAME GPIO ALT + * P114 EPDC_DATA05 GPIO2_07 5 + */ +gpio_config_t gpioSwitch1 = { + "GPIO6", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_DATA05, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA05_HYS_MASK, + GPIO2, /* base */ + 5 /* pin */ +}; + +gpio_init_config_t Switch1 = { + .pin = 5, //pin number + .direction = gpioDigitalInput, + .interruptMode = gpioNoIntmode +}; + +/* LED 1 (GPIO2) + * Golden Finger BALL NAME GPIO ALT + * P110 EPDC_DATA02 GPIO2_02 5 + */ + +gpio_config_t gpioLed1 = { + "GPIO2", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_DATA02, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA02_HYS_MASK, + GPIO2, /* base */ + 2 /* pin */ +}; + +gpio_init_config_t Led1 = { + .pin = 2, //pin number + .direction = gpioDigitalOutput, + .interruptMode = gpioNoIntmode +}; + +/* Switch 2 (GPIO8) + * Golden Finger BALL NAME GPIO ALT + * P116 EPDC_DATA06 GPIO2_06 5 + */ +gpio_config_t gpioSwitch2 = { + "GPIO8", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_DATA06, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA06, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA06_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA06_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA06_HYS_MASK, + GPIO2, /* base */ + 6 /* pin */ +}; + +gpio_init_config_t Switch2 = { + .pin = 6, //pin number + .direction = gpioDigitalInput, + .interruptMode = gpioNoIntmode +}; + +/* LED 2 (GPIO4) + * Golden Finger BALL NAME GPIO ALT + * P112 EPDC_DATA04 GPIO2_04 5 + */ + +gpio_config_t gpioLed2 = { + "GPIO4", /* name */ + &IOMUXC_SW_MUX_CTL_PAD_EPDC_DATA04, /* muxReg */ + 5, /* muxConfig */ + &IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA04, /* padReg */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA04_PS(2) | /* padConfig */ + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA04_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_EPDC_DATA04_HYS_MASK, + GPIO2, /* base */ + 4 /* pin */ +}; + +gpio_init_config_t Led2 = { + .pin = 4, //pin number + .direction = gpioDigitalOutput, + .interruptMode = gpioNoIntmode +}; + +void configure_gpio_pin(gpio_config_t *config) +{ + assert(config); + + *(config->muxReg) = config->muxConfig; + *(config->padReg) = config->padConfig; +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/gpio_pins.h b/examples/imx7_smarc_m4/gpio_pins.h new file mode 100644 index 0000000..c314c68 --- /dev/null +++ b/examples/imx7_smarc_m4/gpio_pins.h @@ -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. + */ + +#ifndef __GPIO_PINS_H__ +#define __GPIO_PINS_H__ + +#include "device_imx.h" +#include "gpio_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 gpioKeyFunc1; +extern gpio_config_t gpioKeyFunc2; + +extern gpio_config_t gpioSwitch1; +extern gpio_config_t gpioLed1; +extern gpio_config_t gpioSwitch2; +extern gpio_config_t gpioLed2; + +extern gpio_init_config_t Switch1; +extern gpio_init_config_t Led1; +extern gpio_init_config_t Switch2; +extern gpio_init_config_t Led2; + +/*! @brief Configure specific GPIO pin */ +void configure_gpio_pin(gpio_config_t *config); + +#endif /* __GPIO_PINS_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/pin_mux.c b/examples/imx7_smarc_m4/pin_mux.c new file mode 100644 index 0000000..b1e7bd1 --- /dev/null +++ b/examples/imx7_smarc_m4/pin_mux.c @@ -0,0 +1,297 @@ +/* + * 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_TX + IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO13 = IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO13_MUX_MODE(3); + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO13 = IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO13_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO13_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO13_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO13_HYS_MASK; + + // CAN1_RX + IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO12 = IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO12_MUX_MODE(3); + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO12 = IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO12_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO12_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO12_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO12_HYS_MASK; + break; + case CAN2_BASE: + // CAN2_TX + IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO15 = IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO15_MUX_MODE(3); + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO15 = IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO15_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO15_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO15_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO15_HYS_MASK; + + // CAN2_RX + IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO14 = IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO14_MUX_MODE(3); + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO14 = IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO14_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO14_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO14_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO14_HYS_MASK; + break; + } +} + +void configure_i2c_pins(I2C_Type* base) +{ + switch((uint32_t)base) + { + case I2C1_BASE: + // I2C1 (I2C_PM) 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 (I2C_GP) 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 (I2C_LCD) iomux configuration + IOMUXC_SW_MUX_CTL_PAD_I2C3_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C3_SCL_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C3_SCL_SION_MASK; + IOMUXC_SW_MUX_CTL_PAD_I2C3_SDA = IOMUXC_SW_MUX_CTL_PAD_I2C3_SDA_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C3_SDA_SION_MASK; + + IOMUXC_I2C3_SCL_SELECT_INPUT = IOMUXC_I2C3_SCL_SELECT_INPUT_DAISY(2); + IOMUXC_I2C3_SDA_SELECT_INPUT = IOMUXC_I2C3_SDA_SELECT_INPUT_DAISY(2); + + 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; + + 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; + break; + case I2C4_BASE: + // I2C4 (I2C_CAM) iomux configuration + IOMUXC_SW_MUX_CTL_PAD_I2C4_SCL = IOMUXC_SW_MUX_CTL_PAD_I2C4_SCL_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C4_SCL_SION_MASK; + IOMUXC_SW_MUX_CTL_PAD_I2C4_SDA = IOMUXC_SW_MUX_CTL_PAD_I2C4_SDA_MUX_MODE(0) | + IOMUXC_SW_MUX_CTL_PAD_I2C4_SDA_SION_MASK; + + IOMUXC_I2C4_SCL_SELECT_INPUT = IOMUXC_I2C4_SCL_SELECT_INPUT_DAISY(2); + IOMUXC_I2C4_SDA_SELECT_INPUT = IOMUXC_I2C4_SDA_SELECT_INPUT_DAISY(2); + + IOMUXC_SW_PAD_CTL_PAD_I2C3_SCL = IOMUXC_SW_PAD_CTL_PAD_I2C4_SCL_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C4_SCL_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C4_SCL_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C4_SCL_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_I2C4_SDA = IOMUXC_SW_PAD_CTL_PAD_I2C4_SDA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_I2C4_SDA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_I2C4_SDA_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_I2C4_SDA_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_UART2_RX_DATA = IOMUXC_SW_MUX_CTL_PAD_UART2_RX_DATA_MUX_MODE(0); + IOMUXC_SW_MUX_CTL_PAD_UART2_TX_DATA = IOMUXC_SW_MUX_CTL_PAD_UART2_TX_DATA_MUX_MODE(0); + IOMUXC_SW_PAD_CTL_PAD_UART2_RX_DATA = IOMUXC_SW_PAD_CTL_PAD_UART2_RX_DATA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART2_RX_DATA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_UART2_RX_DATA_HYS_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART2_RX_DATA_DSE(0); + IOMUXC_SW_PAD_CTL_PAD_UART2_TX_DATA = IOMUXC_SW_PAD_CTL_PAD_UART2_TX_DATA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART2_TX_DATA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_UART2_RX_DATA_HYS_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART2_TX_DATA_DSE(0); + IOMUXC_UART2_RX_DATA_SELECT_INPUT = IOMUXC_UART2_RX_DATA_SELECT_INPUT_DAISY(2); + break; + case UART3_BASE: + // UART3 iomux configuration + IOMUXC_SW_MUX_CTL_PAD_UART3_RX_DATA = IOMUXC_SW_MUX_CTL_PAD_UART3_RX_DATA_MUX_MODE(0); + IOMUXC_SW_MUX_CTL_PAD_UART3_TX_DATA = IOMUXC_SW_MUX_CTL_PAD_UART3_TX_DATA_MUX_MODE(0); + IOMUXC_SW_PAD_CTL_PAD_UART3_RX_DATA = IOMUXC_SW_PAD_CTL_PAD_UART3_RX_DATA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART3_RX_DATA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_UART3_RX_DATA_HYS_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART3_RX_DATA_DSE(0); + IOMUXC_SW_PAD_CTL_PAD_UART3_TX_DATA = IOMUXC_SW_PAD_CTL_PAD_UART3_TX_DATA_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART3_TX_DATA_PS(3) | + IOMUXC_SW_PAD_CTL_PAD_UART3_RX_DATA_HYS_MASK | + IOMUXC_SW_PAD_CTL_PAD_UART3_TX_DATA_DSE(0); + IOMUXC_UART3_RX_DATA_SELECT_INPUT = IOMUXC_UART3_RX_DATA_SELECT_INPUT_DAISY(2); + break; + default: + break; + } +} + +void configure_ecspi_pins(ECSPI_Type* base) +{ + switch((uint32_t)base) + { + case ECSPI1_BASE: + // ECSPI1 iomux configuration + /* daisy chain selection */ + IOMUXC_ECSPI1_MISO_SELECT_INPUT = 1; + + /* iomux */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI1_SCLK = IOMUXC_SW_MUX_CTL_PAD_ECSPI1_SCLK_MUX_MODE(0); /* ECSPI SLK */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI1_MOSI = IOMUXC_SW_MUX_CTL_PAD_ECSPI1_MOSI_MUX_MODE(0); /* ECSPI MOSI */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI1_MISO = IOMUXC_SW_MUX_CTL_PAD_ECSPI1_MISO_MUX_MODE(0); /* ECSPI MISO */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI1_SS0 = IOMUXC_SW_MUX_CTL_PAD_ECSPI1_SS0_MUX_MODE(0); /* ECSPI SS0 */ + + /* pad control */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SCLK = IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SCLK_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SCLK_PS(0) | /* pull down */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SCLK_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SCLK_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_MOSI = IOMUXC_SW_PAD_CTL_PAD_ECSPI1_MOSI_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_MOSI_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_MISO = IOMUXC_SW_PAD_CTL_PAD_ECSPI1_MISO_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SS0 = IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SS0_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SS0_PS(3) | /* pull up */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SS0_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI1_SS0_HYS_MASK; + break; + case ECSPI2_BASE: + // ECSPI1 iomux configuration + /* daisy chain selection */ + IOMUXC_ECSPI2_MISO_SELECT_INPUT = 0; + + /* iomux */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SCLK = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SCLK_MUX_MODE(0); /* ECSPI SLK */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MOSI = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MOSI_MUX_MODE(0); /* ECSPI MOSI */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MISO = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MISO_MUX_MODE(0); /* ECSPI MISO */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SS0 = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SS0_MUX_MODE(0); /* ECSPI SS0 */ + + /* pad control */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK_PS(0) | /* pull down */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MOSI = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MOSI_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MISO = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MISO_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MISO_HYS_MASK; + + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0 = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0_PE_MASK | + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0_PS(3) | /* pull up */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0_HYS_MASK; + break; + default: + break; + } +} + +void configure_ecspi_slave_pins(ECSPI_Type* base) +{ + switch((uint32_t)base) + { + case ECSPI2_BASE: + /* daisy chain selection */ + IOMUXC_ECSPI2_SCLK_SELECT_INPUT = 0; + IOMUXC_ECSPI2_MOSI_SELECT_INPUT = 0; + IOMUXC_ECSPI2_SS0_B_SELECT_INPUT = 0; + + /* iomux */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SCLK = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SCLK_MUX_MODE(0); /* ECSPI SLK */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MOSI = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MOSI_MUX_MODE(0); /* ECSPI MOSI */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MISO = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_MISO_MUX_MODE(0); /* ECSPI MISO */ + IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SS0 = IOMUXC_SW_MUX_CTL_PAD_ECSPI2_SS0_MUX_MODE(0); /* ECSPI SS0 */ + + /* pad control */ + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SCLK_HYS_MASK; + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MOSI = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MOSI_HYS_MASK; + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MISO = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MISO_DSE(0) | + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_MISO_HYS_MASK; + IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0 = IOMUXC_SW_PAD_CTL_PAD_ECSPI2_SS0_HYS_MASK; + break; + default: + break; + } +} + +/******************************************************************************* + * EOF + ******************************************************************************/ diff --git a/examples/imx7_smarc_m4/pin_mux.h b/examples/imx7_smarc_m4/pin_mux.h new file mode 100644 index 0000000..25ea4c0 --- /dev/null +++ b/examples/imx7_smarc_m4/pin_mux.h @@ -0,0 +1,124 @@ +/* + * 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); + +/* +** =================================================================== +** Method : pin_mux_ECSPI (component PinSettings) +*/ +/*! +** @brief +** ECSPI method sets registers according routing settings. Call +** this method code to route desired pins into: +** ECSPI1,ECSPI2,ECSPI3,ECSPI4 peripherals. +** @param +** ECSPI_Type* base - ECSPI base address 1..4 +*/ +/* ===================================================================*/ +void configure_ecspi_pins(ECSPI_Type* base); + +/* +** =================================================================== +** Method : pin_mux_slave_ECSPI (component PinSettings) +*/ +/*! +** @brief +** ECSPI method sets registers according routing settings. Call +** this method code to route desired pins into: +** ECSPI1,ECSPI2,ECSPI3,ECSPI4 peripherals. +** @param +** ECSPI_Type* base - ECSPI base address 1..4 +*/ +/* ===================================================================*/ +void configure_ecspi_slave_pins(ECSPI_Type* base); + +#endif /* __PIN_MUX_H__ */ +/******************************************************************************* + * EOF + ******************************************************************************/ -- 1.9.1