samples: boards: mimxrt11xx_cm7: Magic addr sample
Add magic address sample to show how to use flexram magic address using memc flexram driver. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
parent
2d1fdb5586
commit
31eb944fcd
5 changed files with 101 additions and 0 deletions
10
samples/boards/mimxrt1170_evk_cm7/magic_addr/CMakeLists.txt
Normal file
10
samples/boards/mimxrt1170_evk_cm7/magic_addr/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(magic_addr)
|
||||
|
||||
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers/memc)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
18
samples/boards/mimxrt1170_evk_cm7/magic_addr/README.rst
Normal file
18
samples/boards/mimxrt1170_evk_cm7/magic_addr/README.rst
Normal file
|
@ -0,0 +1,18 @@
|
|||
.. _flexram_magic_addr:
|
||||
|
||||
FLEXRAM Magic Addr
|
||||
##################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
A sample that shows how to use RT11XX FLEXRAM Magic Addr functionality
|
||||
|
||||
Magic Addr is a feature of FlexRAM that allows user to configure an interrupt
|
||||
on an arbitrary RAM/TCM address access. This sample shows how to use the custom
|
||||
API for the flexram in zephyr to use this unique feature.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
see board documentation
|
3
samples/boards/mimxrt1170_evk_cm7/magic_addr/prj.conf
Normal file
3
samples/boards/mimxrt1170_evk_cm7/magic_addr/prj.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API=y
|
||||
CONFIG_CONSOLE_SUBSYS=y
|
||||
CONFIG_CONSOLE_GETCHAR=y
|
12
samples/boards/mimxrt1170_evk_cm7/magic_addr/sample.yaml
Normal file
12
samples/boards/mimxrt1170_evk_cm7/magic_addr/sample.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
sample:
|
||||
description: RT1170 FLEXRAM Magic Addr example
|
||||
name: magic addr
|
||||
common:
|
||||
integration_platforms:
|
||||
- mimxrt1170_evk_cm7
|
||||
- mimxrt1160_evk_cm7
|
||||
tests:
|
||||
sample.boards.mimxrt1170_evk.magic_addr:
|
||||
platform_allow:
|
||||
- mimxrt1170_evk_cm7
|
||||
- mimxrt1160_evk_cm7
|
58
samples/boards/mimxrt1170_evk_cm7/magic_addr/src/main.c
Normal file
58
samples/boards/mimxrt1170_evk_cm7/magic_addr/src/main.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2023 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <zephyr/linker/section_tags.h>
|
||||
#include "memc_nxp_flexram.h"
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/console/console.h>
|
||||
#include <zephyr/cache.h>
|
||||
|
||||
K_SEM_DEFINE(dtcm_magic, 0, 1);
|
||||
|
||||
__dtcm_bss_section uint8_t var;
|
||||
int cnt;
|
||||
|
||||
void flexram_magic_addr_isr_cb(enum memc_flexram_interrupt_cause cause,
|
||||
void *data)
|
||||
{
|
||||
ARG_UNUSED(data);
|
||||
|
||||
if (cause == flexram_dtcm_magic_addr) {
|
||||
printf("Magic DTCM address accessed %d times\n", ++cnt);
|
||||
k_sem_give(&dtcm_magic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
memc_flexram_register_callback(flexram_magic_addr_isr_cb, NULL);
|
||||
|
||||
console_init();
|
||||
|
||||
printf("%s is opening spellbook...\n", CONFIG_BOARD);
|
||||
printf("Cast some characters:\n");
|
||||
|
||||
uint32_t dtcm_addr = (uint32_t)&var;
|
||||
|
||||
memc_flexram_set_dtcm_magic_addr(dtcm_addr);
|
||||
|
||||
uint8_t tmp;
|
||||
|
||||
while (1) {
|
||||
printf("\n");
|
||||
tmp = console_getchar();
|
||||
printf("Writing %c to magic addr...\n", tmp);
|
||||
var = tmp;
|
||||
k_sem_take(&dtcm_magic, K_FOREVER);
|
||||
printf("Reading from magic addr...\n");
|
||||
printf("Magic variable got: %c\n", var);
|
||||
k_sem_take(&dtcm_magic, K_FOREVER);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue