diff --git a/LPC55S69_manifest_v3_10.xml b/LPC55S69_manifest_v3_10.xml index c7aed9536..8b5d20d03 100644 --- a/LPC55S69_manifest_v3_10.xml +++ b/LPC55S69_manifest_v3_10.xml @@ -1,16 +1,15 @@ - - - + + + - + - @@ -39,7 +38,6 @@ - @@ -944,6 +942,11 @@ ${load} + + + + + @@ -1159,11 +1162,6 @@ ${load} - - - - - @@ -1516,122 +1514,6 @@ ${load} - - LPCXpresso Development Board for LPC55S6x family of MCUs with USB Type-C Host Shield Board Gen 2 with Display Port Alt Mode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LPCXpresso Development Board for LPC55S6x family of MCUs with Sensor Toolbox Development Boards for a 9-Axis Solution using FXAS21002C and FXOS8700CQ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1732,72 +1614,6 @@ ${load} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -27718,17 +27532,6 @@ ${load} - - - - - - - - - - - @@ -30351,7 +30154,7 @@ ${load} - + @@ -30370,7 +30173,10 @@ ${load} - + + + + @@ -30378,7 +30184,7 @@ ${load} - + @@ -30501,7 +30307,7 @@ ${load} - + @@ -30539,7 +30345,7 @@ ${load} - + @@ -41848,7 +41654,7 @@ ${load} - + @@ -41862,7 +41668,7 @@ ${load} - + @@ -41924,7 +41730,7 @@ ${load} - + @@ -41944,7 +41750,7 @@ ${load} - + @@ -42476,7 +42282,7 @@ ${load} - + @@ -42503,7 +42309,7 @@ ${load} - + @@ -42528,7 +42334,7 @@ ${load} - + @@ -43245,7 +43051,7 @@ ${load} - + @@ -43269,11 +43075,11 @@ ${load} - + - - + + @@ -43283,11 +43089,11 @@ ${load} - + - + @@ -43813,7 +43619,7 @@ ${load} - + @@ -43831,9 +43637,13 @@ ${load} - + - + + + + + @@ -43866,12 +43676,16 @@ ${load} - + - + + + + + @@ -43887,9 +43701,12 @@ ${load} - + - + + + + @@ -43962,6 +43779,24 @@ ${load} + + + + + + + + + + + + + + + + + + @@ -43977,7 +43812,7 @@ ${load} - + @@ -43991,7 +43826,7 @@ ${load} - + @@ -44013,7 +43848,7 @@ ${load} - + @@ -44058,7 +43893,7 @@ ${load} - + @@ -44511,7 +44346,7 @@ ${load} - + @@ -44532,7 +44367,7 @@ ${load} - + @@ -44550,7 +44385,7 @@ ${load} - + @@ -44568,7 +44403,7 @@ ${load} - + @@ -44586,7 +44421,7 @@ ${load} - + @@ -44604,7 +44439,7 @@ ${load} - + @@ -44622,7 +44457,7 @@ ${load} - + @@ -44643,7 +44478,7 @@ ${load} - + @@ -44679,7 +44514,7 @@ ${load} - + @@ -44724,7 +44559,7 @@ ${load} - + @@ -44742,7 +44577,7 @@ ${load} - + @@ -44760,7 +44595,7 @@ ${load} - + @@ -44778,7 +44613,7 @@ ${load} - + @@ -44796,7 +44631,7 @@ ${load} - + @@ -44814,7 +44649,7 @@ ${load} - + @@ -53314,95 +53149,6 @@ ${load} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -56283,7 +56029,7 @@ ${load} - + @@ -56304,7 +56050,7 @@ ${load} - + @@ -56985,143 +56731,6 @@ ${load} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SW-Content-Register.txt b/SW-Content-Register.txt index 9606e0d3f..267e729d2 100644 --- a/SW-Content-Register.txt +++ b/SW-Content-Register.txt @@ -1,5 +1,5 @@ Release Name: MCUXpresso Software Development Kit (SDK) -Release Version: 2.13.0 +Release Version: 2.13.1 Package License: LA_OPT_NXP_Software_License.txt v39 August 2022- Additional Distribution License granted, license in Section 2.3 applies SDK_Peripheral_Driver Name: SDK Peripheral Driver @@ -271,29 +271,6 @@ lvgl Name: LVGL Origin: Gabor Kiss-Vamosi Url: https://github.com/lvgl/lvgl -safety_iec60730b Name: safety iec60730b - Version: 4.2 - Outgoing License: LA_OPT_NXP_Software_License.txt - v39 August 2022 - Additional distribution license - granted - License in Section 2.3 applies - License File: LA_OPT_NXP_Software_License.txt - Format: source code & object code & header files - Description: Safety IEC60730b Example - Location: middleware/safety_iec60730b - Origin: NXP - -srecord Name: SRecord 1.64 For Windows - Version: 1.64 - Outgoing License: GPL-3.0 - License File: - tool/srecord/srecord-1.64.zip/srecord-1.64/LICENSE - Format: source code & binary - Description: Utility for manipulating EPROM load - files, is used for postbuild CRC calculation. - Location: tools/srecord - Origin: Peter Miller - Url: http://srecord.sourceforge.net/index.html - maestro Name: Maestro Audio Framework Version: 1.5.0 Outgoing License: LA_OPT_NXP_Software_License.txt diff --git a/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.c b/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.c index a4ed287f5..326d3fa01 100644 --- a/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.c +++ b/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.c @@ -11,7 +11,7 @@ #include #include -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC // @formatter:off LVM_EQNB_BandDef_t EQNB_BandDefs_UserEq1_internal[LVM_EQNB_MAX_BANDS_NBR] = { {-15, 50, 50}, // gain(dB), freq(Hz) , Qfactor *100 @@ -217,7 +217,7 @@ eap_att_control_t att_control = {.attVersion = 4, .volume = 75, .seek_time = 0, -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC .controlParam = &ControlParamSet_internal, .instParams = &InstParams_internal, .headroomParams = &HeadroomParams_internal, @@ -232,7 +232,7 @@ eap_att_control_t *get_eap_att_control(void) void eap_att_process(void) { -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC if (attProcessIterator++ == 0) { LVM_VersionInfo_st eapVersionInfo; @@ -271,7 +271,6 @@ void eap_att_process(void) } att_control.status = kAttRunning; - att_control.logme("[EAP_ATT] Playback started for %s\r\n", att_control.input); break; @@ -308,7 +307,7 @@ void eap_att_process(void) case kAttCmdSeek: att_control.lastError = seek_wrapper(att_control.seek_time); break; -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC case kAttCmdSetConfig: { att_control.logme("[EAP_ATT] Set config\r\n"); @@ -355,10 +354,15 @@ void eap_att_process(void) att_control.logme("[EAP_ATT] Error occurred %d for command %d\r\n", att_control.lastError, att_control.command); if (att_control.status == kAttRunning) { - att_control.logme("[EAP_ATT] Error occurred, trying to stop...\r\n"); stop_wrapper(); + att_control.logme("[EAP_ATT] Error occurred, playback stopped\r\n"); + att_control.lastError = kEapAttCodeOk; + att_control.status = kAttIdle; + } + else + { + att_control.status = kAttError; } - att_control.status = kAttError; } att_control.command = kAttCmdNone; @@ -449,7 +453,7 @@ eap_att_code_t set_volume(int value) return kEapAttCodeOk; // let implementation on user if needed } -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC static eap_att_code_t update_wrapper(void) { diff --git a/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.h b/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.h index 493f877d7..d253356f9 100644 --- a/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.h +++ b/boards/lpcxpresso55s69/audio_examples/common/att/eap_att.h @@ -45,10 +45,12 @@ #ifndef _EAP_ATT_H_ #define _EAP_ATT_H_ -#if defined EAP_PROC -#include -#elif defined EAP32_PROC +#ifdef EAP_PROC +#ifdef MULTICHANNEL_EXAMPLE #include +#else +#include +#endif #endif #include @@ -61,7 +63,7 @@ extern "C" { #endif #ifndef MAX_FILE_NAME_LENGTH -#define MAX_FILE_NAME_LENGTH 32 +#define MAX_FILE_NAME_LENGTH 64 #endif enum @@ -145,7 +147,7 @@ typedef struct _eap_att_control eap_att_code_t (*update)(void); /* This is called when EAP config structures were changed by the tool. */ int (*logme)(const char *fmt_s, ...); /* This function is mapped to stdio::printf() by default. */ -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC eap_att_code_t (*normalize_params)(void); /* Normalizes params definition structures i.e. bands elements count. */ // EAP references @@ -169,7 +171,7 @@ eap_att_control_t *get_eap_att_control(void); */ void eap_att_process(void); -#if (defined EAP_PROC || defined EAP32_PROC) +#ifdef EAP_PROC /* * Register the LVM handle into EAP ATT control structure when this handle will be available. * Be sure that handle is registered at least immediately after eap_att_control_t.play() handler will be called. diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_data.h b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_data.h index 0ae085a83..2e92c68f1 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_data.h +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_data.h @@ -23,6 +23,9 @@ typedef struct _app_data int lastPreset; // buffer for last active preset selection int logEnabled; // enable log to increase debug verbosity ext_proc_args eap_args; +#ifdef MULTICHANNEL_EXAMPLE + uint8_t num_channels; // number of channels set with cli +#endif } app_data_t; app_data_t *get_app_data(); diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.c b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.c index 3cc355820..c5e4f0591 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.c @@ -12,6 +12,7 @@ #include "app_data.h" #include "app_streamer.h" #include "streamer_pcm_app.h" +#include "app_definitions.h" #include "main.h" #include "maestro_logging.h" @@ -194,7 +195,92 @@ void STREAMER_Stop(streamer_handle_t *handle) ringbuf_clear(audioBuffer); } } +#ifdef MULTICHANNEL_EXAMPLE +status_t STREAMER_PCM_Create(char *filename, int volume) +{ + STREAMER_CREATE_PARAM params; + osa_task_def_t thread_attr; + ELEMENT_PROPERTY_T prop; + int ret; + eap_att_control_t *control = get_eap_att_control(); + + /* Create message process thread */ + thread_attr.tpriority = OSA_PRIORITY_HIGH; + thread_attr.tname = (uint8_t *)STREAMER_MESSAGE_TASK_NAME; + thread_attr.pthread = &STREAMER_MessageTask; + thread_attr.stacksize = STREAMER_MESSAGE_TASK_STACK_SIZE; + ret = OSA_TaskCreate(&msg_thread, &thread_attr, (void *)control); + if (KOSA_StatusSuccess != ret) + { + return kStatus_Fail; + } + + /* Create streamer */ + strcpy(params.out_mq_name, APP_STREAMER_MSG_QUEUE); + params.stack_size = STREAMER_TASK_STACK_SIZE; + params.task_name = STREAMER_TASK_NAME; +#ifdef EAP_PROC + if (get_app_data()->num_channels == 2) + { + params.pipeline_type = STREAM_PIPELINE_PCM_AUDIO_PROC_AUDIO; + } + else + { + params.pipeline_type = STREAM_PIPELINE_PCM_AUDIO; + } +#else + params.pipeline_type = STREAM_PIPELINE_PCM_AUDIO; +#endif /* EAP_PROC */ + params.task_name = STREAMER_TASK_NAME; + params.in_dev_name = ""; + params.out_dev_name = ""; + + streamer = streamer_create(¶ms); + if (!streamer) + { + return kStatus_Fail; + } + + prop.prop = PROP_FILESRC_SET_LOCATION; + prop.val = (uintptr_t)filename; + + streamer_set_property(streamer, prop, true); + + prop.prop = PROP_FILESRC_SET_SAMPLE_RATE; + prop.val = DEMO_SAMPLE_RATE; + + streamer_set_property(streamer, prop, true); + + prop.prop = PROP_FILESRC_SET_NUM_CHANNELS; + prop.val = get_app_data()->num_channels; + + streamer_set_property(streamer, prop, true); + + prop.prop = PROP_FILESRC_SET_BIT_WIDTH; + prop.val = DEMO_BIT_WIDTH; + + streamer_set_property(streamer, prop, true); + + prop.prop = PROP_FILESRC_SET_CHUNK_SIZE; + prop.val = get_app_data()->num_channels * DEMO_BYTE_WIDTH * DEMO_SAMPLE_RATE / 100; + + streamer_set_property(streamer, prop, true); + + prop.prop = PROP_AUDIOSINK_SET_VOLUME; + prop.val = volume; + streamer_set_property(streamer, prop, true); + +#ifdef EAP_PROC + if (get_app_data()->num_channels == 2) + { + register_post_process(streamer); + } +#endif + + return kStatus_Success; +} +#else status_t STREAMER_file_Create(char *filename, int volume) { STREAMER_CREATE_PARAM params; @@ -217,15 +303,15 @@ status_t STREAMER_file_Create(char *filename, int volume) /* Create streamer */ strcpy(params.out_mq_name, APP_STREAMER_MSG_QUEUE); - params.stack_size = STREAMER_TASK_STACK_SIZE; + params.stack_size = STREAMER_TASK_STACK_SIZE; #ifdef EAP_PROC params.pipeline_type = STREAM_PIPELINE_AUDIO_PROC; #else params.pipeline_type = STREAM_PIPELINE_FILESYSTEM; #endif - params.task_name = STREAMER_TASK_NAME; - params.in_dev_name = ""; - params.out_dev_name = ""; + params.task_name = STREAMER_TASK_NAME; + params.in_dev_name = ""; + params.out_dev_name = ""; streamer = streamer_create(¶ms); if (!streamer) @@ -245,7 +331,7 @@ status_t STREAMER_file_Create(char *filename, int volume) return kStatus_Success; } - +#endif /* EAP Audio Tuning Tool control integration - START */ /* this functions should not be called internally to prevent possible issues caused by broken state machine */ eap_att_code_t play() @@ -257,9 +343,12 @@ eap_att_code_t play() // set_debug_level(LOGLVL_DEBUG); // get_debug_state(); streamer_pcm_init(); - +#ifdef MULTICHANNEL_EXAMPLE + if (STREAMER_PCM_Create((char *)get_eap_att_control()->input, DEMO_VOLUME) == kStatus_Success) +#else if (STREAMER_file_Create((char *)get_eap_att_control()->input, (int)get_eap_att_control()->volume) == kStatus_Success) +#endif { if (streamer_set_state(streamer, 0, STATE_PLAYING, true) == 0) { diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.h b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.h index f8f662e55..d136aac66 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.h +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/app_streamer.h @@ -51,6 +51,20 @@ extern "C" { */ void STREAMER_Init(void); +#ifdef MULTICHANNEL_EXAMPLE +/*! + * @brief Create an Maestro streamer interface handle + * + * This function creates an Maestro streamer interface and starts a task for + * handling pcm files + * + * @param handle Pointer to input handle + * @param out sink type + * @return kStatus_Success on success, otherwise an error. + */ + +status_t STREAMER_PCM_Create(char *filename, int volume); +#else /*! * @brief Create an Maestro streamer interface handle * @@ -63,6 +77,7 @@ void STREAMER_Init(void); */ status_t STREAMER_file_Create(char *filename, int volume); +#endif /*! * @brief Destroy an Maestro streamer interface handle diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/CMakeLists.txt b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/CMakeLists.txt index 4579d1878..14df15a45 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/CMakeLists.txt +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/CMakeLists.txt @@ -80,9 +80,9 @@ set(CMAKE_MODULE_PATH ${SdkRootDirPath}/components/i2c ${SdkRootDirPath}/middleware/sdmmc ${SdkRootDirPath}/devices/LPC55S69/utilities + ${SdkRootDirPath}/middleware/EAP ${SdkRootDirPath}/middleware/maestro ${SdkRootDirPath}/middleware/fatfs - ${SdkRootDirPath}/middleware/EAP ${SdkRootDirPath}/middleware/maestro/mcu-audio/opus ${SdkRootDirPath}/middleware/maestro/mcu-audio/opusfile ${SdkRootDirPath}/middleware/maestro/mcu-audio/ogg @@ -134,6 +134,8 @@ include(driver_lpc_dma_LPC55S69_cm33_core0) include(driver_flexcomm_i2s_dma_LPC55S69_cm33_core0) +include(middleware_eap_arm_lib_LPC55S69_cm33_core0) + include(middleware_freertos-kernel_heap_4_LPC55S69_cm33_core0) include(middleware_maestro_framework_LPC55S69_cm33_core0) @@ -144,8 +146,6 @@ include(middleware_fatfs_sd_LPC55S69_cm33_core0) include(middleware_eap_LPC55S69_cm33_core0) -include(middleware_eap_arm_lib_LPC55S69_cm33_core0) - include(middleware_maestro_framework_opus_LPC55S69_cm33_core0) include(middleware_maestro_framework_opusfile_LPC55S69_cm33_core0) @@ -190,13 +190,13 @@ include(component_osa_free_rtos_LPC55S69_cm33_core0) include(driver_sdif_LPC55S69_cm33_core0) -include(middleware_maestro_framework_doc_LPC55S69_cm33_core0) - -include(middleware_maestro_framework_streamer_LPC55S69_cm33_core0) +include(middleware_eap16_header_LPC55S69_cm33_core0) include(middleware_eap_exapp_LPC55S69_cm33_core0) -include(middleware_eap16_header_LPC55S69_cm33_core0) +include(middleware_maestro_framework_doc_LPC55S69_cm33_core0) + +include(middleware_maestro_framework_streamer_LPC55S69_cm33_core0) include(utilities_misc_utilities_LPC55S69_cm33_core0) @@ -211,6 +211,10 @@ TARGET_LINK_LIBRARIES(${MCUX_SDK_PROJECT_NAME} PRIVATE -Wl,--start-group) target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${TARGET_LINK_SYSTEM_LIBRARIES}) +if(CMAKE_BUILD_TYPE STREQUAL debug) + target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/EAP/EAP_Library/libEAP16_3_0_12_FP2_CM33.a) +endif(CMAKE_BUILD_TYPE STREQUAL debug) + if(CMAKE_BUILD_TYPE STREQUAL debug) target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/maestro/libs/cm33f/armgcc/release/libmp3.a) endif(CMAKE_BUILD_TYPE STREQUAL debug) @@ -227,9 +231,9 @@ if(CMAKE_BUILD_TYPE STREQUAL debug) target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/maestro/libs/cm33f/armgcc/release/libflac.a) endif(CMAKE_BUILD_TYPE STREQUAL debug) -if(CMAKE_BUILD_TYPE STREQUAL debug) +if(CMAKE_BUILD_TYPE STREQUAL release) target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/EAP/EAP_Library/libEAP16_3_0_12_FP2_CM33.a) -endif(CMAKE_BUILD_TYPE STREQUAL debug) +endif(CMAKE_BUILD_TYPE STREQUAL release) if(CMAKE_BUILD_TYPE STREQUAL release) target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/maestro/libs/cm33f/armgcc/release/libmp3.a) @@ -247,10 +251,6 @@ if(CMAKE_BUILD_TYPE STREQUAL release) target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/maestro/libs/cm33f/armgcc/release/libflac.a) endif(CMAKE_BUILD_TYPE STREQUAL release) -if(CMAKE_BUILD_TYPE STREQUAL release) - target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../../middleware/EAP/EAP_Library/libEAP16_3_0_12_FP2_CM33.a) -endif(CMAKE_BUILD_TYPE STREQUAL release) - TARGET_LINK_LIBRARIES(${MCUX_SDK_PROJECT_NAME} PRIVATE -Wl,--end-group) diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/flags.cmake b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/flags.cmake index e04762166..7f018431c 100755 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/flags.cmake +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/armgcc/flags.cmake @@ -43,9 +43,9 @@ SET(CMAKE_C_FLAGS_DEBUG " \ -DALGORITHM_LIMP=1 \ -DALGORITHM_LIMR=1 \ -DCPU_LPC55S69JBD100_cm33_core0 \ + -DEAP_PROC \ -DSTREAMER_ENABLE_AUDIO_PROC \ -DSTREAMER_ENABLE_VIT_SINK \ - -DEAP_PROC \ -DPRINTF_ADVANCED_ENABLE=1 \ -DPRINTF_FLOAT_ENABLE=1 \ -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING \ @@ -102,9 +102,9 @@ SET(CMAKE_C_FLAGS_RELEASE " \ -DALGORITHM_LIMP=1 \ -DALGORITHM_LIMR=1 \ -DCPU_LPC55S69JBD100_cm33_core0 \ + -DEAP_PROC \ -DSTREAMER_ENABLE_AUDIO_PROC \ -DSTREAMER_ENABLE_VIT_SINK \ - -DEAP_PROC \ -DPRINTF_ADVANCED_ENABLE=1 \ -DPRINTF_FLOAT_ENABLE=1 \ -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING \ diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/cmd.c b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/cmd.c index 82f927ad5..a3038dccd 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/cmd.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/cmd.c @@ -15,6 +15,7 @@ #include "fsl_shell.h" #include "ff.h" +#include "app_definitions.h" #include "app_streamer.h" #include "eap_att.h" @@ -49,17 +50,25 @@ SHELL_COMMAND_DEFINE( file, "\r\n\"file\": Perform audio file decode and playback\r\n" "\r\n" - " USAGE: file [start|stop|pause|seek|volume|" + " USAGE: file [start|stop|pause|volume|" +#ifndef MULTICHANNEL_EXAMPLE + "seek|" +#endif #ifdef EAP_PROC "update|set|get|" #endif "track|list|info]\r\n" - " start Play default (first found) or specified audio track file.\r\n" +#ifdef MULTICHANNEL_EXAMPLE + " start Play default (first found) file with default (8) channels.\r\n" +#else + " start Play default (first found) or specified audio track file.\r\n" +#endif " stop Stops actual playback.\r\n" " pause Pause actual track or resume if already paused.\r\n" - " seek= Seek currently paused track. Seek time is absolute time in milliseconds.\r\n" " volume= Set volume. The volume can be set from 0 to 100.\r\n" - +#ifndef MULTICHANNEL_EXAMPLE + " seek= Seek currently paused track. Seek time is absolute time in milliseconds.\r\n" +#endif #ifdef EAP_PROC " update= Apply current EAP parameters without attribute value\r\n" " or switch to preset 1-"TO_STR(EAP_MAX_PRESET)"\r\n" @@ -68,16 +77,29 @@ SHELL_COMMAND_DEFINE( " get Sync actual EAP parameters from library to ATT config structures.\r\n" #endif - " track= Select audio track to play.\r\n" +#ifdef MULTICHANNEL_EXAMPLE + " track [num_channels] Select audio track to play. Select 2 or 8 channels. \r\n" + " - If channel number not specified, default 8 is used. \r\n" +#else + " track= Select audio track to play.\r\n" +#endif " list List audio files available on mounted SD card.\r\n" - " info Prints playback info.\r\n", - + " info Prints playback info.\r\n" +#ifdef MULTICHANNEL_EXAMPLE + " NOTE: Selected audio track must always meet the following parameters:\r\n" + " - Sample rate: 96 kHz\r\n" + " - Width: 32 bit\r\n" + " - Number of channels: Depending on the [num_channels] parameter\r\n" +#ifdef EAP_PROC + " NOTE: Only when 2 channels are selected EAP can be applied to the audio track." +#endif +#endif +, shellFile, SHELL_IGNORE_PARAMETER_COUNT); SDK_ALIGN(static uint8_t s_shellHandleBuffer[SHELL_HANDLE_SIZE], 4); static shell_handle_t s_shellHandle; - extern serial_handle_t g_serialHandle; extern app_handle_t app; streamer_handle_t streamerHandle; @@ -155,7 +177,9 @@ static shell_status_t shellEcho(shell_handle_t shellHandle, int32_t argc, char * static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char **argv) { char *dot; - +#ifdef MULTICHANNEL_EXAMPLE + uint8_t num_channels = DEMO_CHANNEL_NUM; // default number of channels is 8 +#endif shell_status_t retVal = kStatus_SHELL_Success; if (!app.sdcardInserted) @@ -166,10 +190,15 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * // lock ATT mutex if needed, but based on major usecase it is not necessary // be sure that this routine is as short as possible without any complex logic +#ifdef MULTICHANNEL_EXAMPLE if (argc >= 2) { +#endif if (strcmp(argv[1], "start") == 0) { +#ifdef MULTICHANNEL_EXAMPLE + get_app_data()->num_channels = DEMO_CHANNEL_NUM; // set default channel number = 8 +#endif get_eap_att_control()->command = kAttCmdStart; } else if (strcmp(argv[1], "stop") == 0) @@ -180,6 +209,7 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * { get_eap_att_control()->command = kAttCmdPause; } +#ifndef MULTICHANNEL_EXAMPLE else if (strcmp(argv[1], "seek") == 0) { if ((get_eap_att_control()->status != kAttPaused) && (get_eap_att_control()->status != kAttRunning)) @@ -223,6 +253,7 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * } } } +#endif #if defined(EAP_PROC) && (ALGORITHM_XO == 1) else if (strcmp(argv[1], "xo") == 0) // this option is good for testing but could be removed for production { @@ -290,10 +321,10 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * if (argc == 3) { int preset = abs(atoi((argv[2]))); - if (preset < 0 || preset > EAP_MAX_PRESET) + if (preset <= 0 || preset > EAP_MAX_PRESET) { PRINTF("[CMD] EAP preset number out of range, setting EAP all effects OFF.\r\n"); - preset = 0; + preset = 1; } get_eap_att_control()->eapPreset = preset; } @@ -314,19 +345,24 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * { dot = strrchr(argv[2], '.'); if ( +#ifdef MULTICHANNEL_EXAMPLE + (dot && strncmp(dot + 1, "pcm", 4) == 0) +#else #if (OGG_OPUS_DEC == 1) - (dot && strncmp(dot + 1, "opus", 4) == 0) || (dot && strncmp(dot + 1, "ogg", 3) == 0) || + (dot && strncmp(dot + 1, "opus", 4) == 0) || (dot && strncmp(dot + 1, "ogg", 3) == 0) || #endif #if (AAC_DEC == 1) - (dot && strncmp(dot + 1, "aac", 3) == 0) || + (dot && strncmp(dot + 1, "aac", 3) == 0) || #endif #if (WAV_DEC == 1) - (dot && strncmp(dot + 1, "wav", 3) == 0) || + (dot && strncmp(dot + 1, "wav", 3) == 0) || #endif #if (FLAC_DEC == 1) - (dot && strncmp(dot + 1, "flac", 3) == 0) || + (dot && strncmp(dot + 1, "flac", 3) == 0) || #endif - (dot && strncmp(dot + 1, "mp3", 3) == 0)) + (dot && strncmp(dot + 1, "mp3", 3) == 0) +#endif + ) { strcpy(get_eap_att_control()->input, argv[2]); get_eap_att_control()->command = kAttCmdStart; @@ -334,22 +370,47 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * else { PRINTF( - "[CMD] Input audio file name has to match one of the .mp3" + "[CMD] Input audio file name has to match one of the" +#ifdef MULTICHANNEL_EXAMPLE + " .pcm" +#else + " .mp3" #if (OGG_OPUS_DEC == 1) - "|.opus|.ogg" + "|.opus|.ogg" #endif #if (AAC_DEC == 1) - "|.aac" + "|.aac" #endif #if (WAV_DEC == 1) - "|.wav" + "|.wav" #endif #if (FLAC_DEC == 1) - "|.flac" + "|.flac" #endif - " formats.\r\n"); +#endif + " format.\r\n"); + retVal = kStatus_SHELL_Error; } +#ifdef MULTICHANNEL_EXAMPLE + if (argc == 4) + { + num_channels = abs(atoi((argv[3]))); + if (num_channels == 2 || num_channels == 8) + { + get_app_data()->num_channels = num_channels; + } + else + { + PRINTF("Number of channels not allowed (2 or 8 allowed).\r\n"); + retVal = kStatus_SHELL_Error; + } + } + else + { + get_app_data()->num_channels = num_channels; + } +#endif } else { @@ -387,12 +448,14 @@ static shell_status_t shellFile(shell_handle_t shellHandle, int32_t argc, char * PRINTF("[CMD] Undefined att command option. \r\n"); retVal = kStatus_SHELL_Error; } +#ifdef MULTICHANNEL_EXAMPLE } else { PRINTF("[CMD] Enter correct command option. \r\n"); retVal = kStatus_SHELL_Error; } +#endif // unlock APP mutex return retVal; } diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.c b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.c index 22c658f9e..8c026e5c7 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.c @@ -324,14 +324,14 @@ int EAP_Init(void *arg) int EAP_Execute(void *arg, void *inputBuffer, int size) { - StreamBuffer *buf = (StreamBuffer *)inputBuffer; - int8_t *pkt_hdr_size = arg; - AudioPacketHeader *data_packet = NULL; - int8_t *data_ptr = NULL; - int8_t num_channel = 0; - int8_t byte_width = 0; - int8_t *outBuffer[NUM_OUT_BUFFES] = {NULL, NULL}; - LVM_ReturnStatus_en LVM_Status = LVM_SUCCESS; + StreamBuffer *buf = (StreamBuffer *)inputBuffer; + int8_t *pkt_hdr_size = arg; + AudioPacketHeader *data_packet = NULL; + int8_t *data_ptr = NULL; + int8_t num_channel = 0; + int8_t byte_width = 0; + int8_t *outBuffer[NUM_OUT_BUFFERS] = {NULL, NULL}; + LVM_ReturnStatus_en LVM_Status = LVM_SUCCESS; if ((buf == NULL) || (pkt_hdr_size == NULL)) { @@ -382,7 +382,7 @@ int EAP_Execute(void *arg, void *inputBuffer, int size) } eap_xo_out_buf_size = (uint16_t)size; - eap_xo_out_buffer = (int8_t *)OSA_MemoryAllocate(size * NUM_OUT_BUFFES + *pkt_hdr_size); + eap_xo_out_buffer = (int8_t *)OSA_MemoryAllocate(size * NUM_OUT_BUFFERS + *pkt_hdr_size); if (eap_xo_out_buffer == NULL) { return LVM_NULLADDRESS; @@ -398,11 +398,16 @@ int EAP_Execute(void *arg, void *inputBuffer, int size) EAP_AudioTime += LVM_FRAME_SIZE_MS; - LVM_Status = LVM_Process(EAP_hInstance, /* Instance handle */ + LVM_Status = LVM_Process(EAP_hInstance, /* Instance handle */ +#ifdef MULTICHANNEL_EXAMPLE + (LVM_INT32 *)data_ptr, /* Input buffer */ + (LVM_INT32 **)outBuffer, /* Output buffer */ +#else (LVM_INT16 *)data_ptr, /* Input buffer */ (LVM_INT16 **)outBuffer, /* Output buffer */ - size / num_channel, /* Number of samples to process */ - EAP_AudioTime); /* Audio Time*/ +#endif + size / num_channel, /* Number of samples to process */ + EAP_AudioTime); /* Audio Time*/ #if (ALGORITHM_XO == 1) @@ -516,9 +521,11 @@ LVM_ReturnStatus_en EAP_SetFSandChannels(ext_proc_args *args) case 48000: control->controlParam->SampleRate = LVM_FS_48000; break; + case 96000: + control->controlParam->SampleRate = LVM_FS_96000; + break; case 64000: case 88200: - case 96000: case 128000: case 176400: case 192000: diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.h b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.h index 379064288..2c07876ab 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.h +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/eap_proc.h @@ -8,8 +8,13 @@ #ifndef _EAP_PROC_H_ #define _EAP_PROC_H_ +#ifdef MULTICHANNEL_EXAMPLE +#include "EAP32.h" // EAP library +#else #include "EAP16.h" // EAP library +#endif #include "eap_att.h" +#include "app_definitions.h" #define LVM_FRAME_SIZE_MS (10) @@ -17,9 +22,13 @@ #define MAX_SAMPLE_SIZE (1024) #endif -#define NUM_OUT_BUFFES (2) -// #define XO_USE_FULL_STEREO /* Define for the full output range of the EAP crossover options when applied to a stereo -// audio input file */ +#define NUM_OUT_BUFFERS (2) + +/* Define for the full output range of the EAP crossover options when applied to a stereo audio input file */ +// #define XO_USE_FULL_STEREO +#if (defined(XO_USE_FULL_STEREO) && (DEMO_CODEC_CS42448 != 1)) +#error "When full stereo mode is enabled, the CS42448 codec must also be enabled" +#endif int EAP_Init(void *arg); int EAP_Execute(void *arg, void *inputBuffer, int size); diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/maestro_playback_v3_10.xml b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/maestro_playback_v3_10.xml index 2eda4032a..ce824ec54 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/maestro_playback_v3_10.xml +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/maestro_playback_v3_10.xml @@ -21,12 +21,12 @@ + - @@ -49,10 +49,10 @@ + + - - @@ -61,7 +61,7 @@ - + @@ -82,9 +82,9 @@ ALGORITHM_LIMP=1 ALGORITHM_LIMR=1 CPU_LPC55S69JBD100_cm33_core0 + EAP_PROC STREAMER_ENABLE_AUDIO_PROC STREAMER_ENABLE_VIT_SINK - EAP_PROC PRINTF_ADVANCED_ENABLE=1 PRINTF_FLOAT_ENABLE=1 DEBUG_CONSOLE_TRANSFER_NON_BLOCKING diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.c b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.c index 02ddd2da5..1038087ab 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.c @@ -151,6 +151,9 @@ status_t list_files(bool autoInput) /* Check file for supported audio extension */ dot = strrchr(fileInformation.fname, '.'); if ( +#ifdef MULTICHANNEL_EXAMPLE + (dot && strncmp(dot + 1, "pcm", 4) == 0) +#else #if (OGG_OPUS_DEC == 1) (dot && strncmp(dot + 1, "opus", 4) == 0) || (dot && strncmp(dot + 1, "ogg", 3) == 0) || #endif @@ -163,12 +166,15 @@ status_t list_files(bool autoInput) #if (FLAC_DEC == 1) (dot && strncmp(dot + 1, "flac", 3) == 0) || #endif - (dot && strncmp(dot + 1, "mp3", 3) == 0)) + (dot && strncmp(dot + 1, "mp3", 3) == 0) +#endif + ) { if (count < MAX_FILES_LIST) { - strcpy(get_eap_att_control()->availableInputs[count], fileInformation.fname); - PRINTF(" %s\r\n", fileInformation.fname); + strncpy(get_eap_att_control()->availableInputs[count], fileInformation.fname, + sizeof(get_eap_att_control()->availableInputs[count])); + PRINTF(" %s\r\n", get_eap_att_control()->availableInputs[count]); count++; } else diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.h b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.h index 29e15269e..b54a38fcc 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.h +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/main.h @@ -24,6 +24,9 @@ /******************************************************************************* * Definitions ******************************************************************************/ +#if defined(AAC_DEC) && defined(__ICCARM__) +#error "AAC decoder is not enabled in IAR." +#endif typedef struct _app_handle { diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/readme.txt b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/readme.txt index 9a9c79440..08e356bef 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/readme.txt +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/readme.txt @@ -7,6 +7,7 @@ Depending on target platform there are different features of the demo enabled. - File decoding and playback - EAP effects during file playback + - Multi-channel playback The application is controlled by commands from a shell interface using serial console. @@ -84,6 +85,7 @@ There is limited RAM on this platform, which brings following limitations: - To enable FLAC decoding and playback it is necessary to disable EAP: 1. Define FLAC_DEC=1 in the project settings 2. Undefine EAP_PROC in the project settings + - When playing FLAC audio files with too small frame size (block size), the audio output may be distorted because the board is not fast enough. - The AAC decoder is only supported in MCUXpresso and ARMGCC. Running the demo ================ @@ -100,3 +102,7 @@ Copyright 2022 NXP [APP_Shell_Task] start >> [APP_SDCARD_Task] SD card drive mounted + +Known issues + +1. MP3 decoder has issues with some of the files. One of the channels can be sometimes distorted or missing parts of the signal. diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/streamer_pcm.c b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/streamer_pcm.c index 011d36420..0cf330587 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/streamer_pcm.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_playback/cm33_core0/streamer_pcm.c @@ -72,25 +72,39 @@ int streamer_pcm_write(pcm_rtos_t *pcm, uint8_t *data, uint32_t size) { /* Ensure write size is a multiple of 32, otherwise EDMA will assert * failure. Round down for the last chunk of a file/stream. */ - pcm->i2sTxTransfer.dataSize = size - (size % 32); - pcm->i2sTxTransfer.data = data; + int32_t local_size = size - (size % 32); + uint32_t offset = 0; + uint16_t dataSize = 0; - /* Start the consecutive transfer */ - while (I2S_TxTransferSendDMA(DEMO_I2S_TX, &pcm->i2sTxHandle, pcm->i2sTxTransfer) == kStatus_I2S_Busy) + while (local_size > 0) { - /* Wait for transfer to finish */ - if (xSemaphoreTake(pcm->semaphoreTX, portMAX_DELAY) != pdTRUE) + /* Make sure the data size is not larger than 2048 bytes for a oneChannel configuration, as the I2S EDMA driver + * does not allow this yet. */ + dataSize = + ((pcm->num_channels == 1) && (local_size > 2048)) ? ((local_size - 2048) > 1024 ? 2048 : 1024) : local_size; + pcm->i2sTxTransfer.dataSize = pcm->isFirstTx ? (dataSize / 2) : dataSize; + pcm->i2sTxTransfer.data = data + offset; + local_size -= dataSize; + offset += dataSize; + + /* Start the consecutive transfer */ + while (I2S_TxTransferSendDMA(DEMO_I2S_TX, &pcm->i2sTxHandle, pcm->i2sTxTransfer) == kStatus_I2S_Busy) { - return -1; + /* Wait for transfer to finish */ + if (xSemaphoreTake(pcm->semaphoreTX, portMAX_DELAY) != pdTRUE) + { + return -1; + } } - } - if (pcm->isFirstTx) - { - /* Need to queue two transmit buffers so when the first one - * finishes transfer, the other immediatelly starts */ - I2S_TxTransferSendDMA(DEMO_I2S_TX, &pcm->i2sTxHandle, pcm->i2sTxTransfer); - pcm->isFirstTx = 0; + if (pcm->isFirstTx) + { + pcm->i2sTxTransfer.data += pcm->i2sTxTransfer.dataSize; + /* Need to queue two transmit buffers so when the first one + * finishes transfer, the other immediatelly starts */ + I2S_TxTransferSendDMA(DEMO_I2S_TX, &pcm->i2sTxHandle, pcm->i2sTxTransfer); + pcm->isFirstTx = 0; + } } return 0; diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/FreeRTOSConfig.h b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/FreeRTOSConfig.h index a86314298..69edabb62 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/FreeRTOSConfig.h +++ b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/FreeRTOSConfig.h @@ -71,7 +71,7 @@ #define configSUPPORT_STATIC_ALLOCATION 0 #define configSUPPORT_DYNAMIC_ALLOCATION 1 #if ((defined(MIMXRT1051_SERIES) || defined(MIMXRT1052_SERIES) || defined(MIMXRT1041_SERIES) || defined(MIMXRT1042_SERIES)) && defined(VIT_PROC)) -#define configTOTAL_HEAP_SIZE ((size_t) (478 * 1024)) +#define configTOTAL_HEAP_SIZE ((size_t) (446 * 1024)) #elif ((defined(MIMXRT1051_SERIES) || defined(MIMXRT1052_SERIES) || defined(MIMXRT1041_SERIES) || defined(MIMXRT1042_SERIES)) && !defined(VIT_PROC)) #define configTOTAL_HEAP_SIZE ((size_t) (252 * 1024)) #elif (defined(LPC55S69_cm33_core0_SERIES) || defined(RW610_SERIES)) diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/app_streamer.c b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/app_streamer.c index b4068df88..b2f537d65 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/app_streamer.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/app_streamer.c @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 NXP + * Copyright 2020-2023 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -257,6 +257,17 @@ status_t STREAMER_mic_Create(streamer_handle_t *handle, out_sink_t out_sink, cha } #endif // VIT_PROC +#if (defined(PLATFORM_RT1170) || defined(PLATFORM_RT1160) || DEMO_CODEC_CS42448) +#ifndef VOICE_SEEKER_PROC + if (params.pipeline_type == STREAM_PIPELINE_VIT) + { + PRINTF( + "[STREAMER] Please enable VoiceSeeker, it must be used if more than one channel is used and VIT is " + "enabled.\r\n"); + return kStatus_Fail; + } +#endif + #if (defined(PLATFORM_RT1170) || defined(PLATFORM_RT1160)) prop.prop = PROP_AUDIOSRC_SET_FRAME_MS; prop.val = 30; @@ -265,21 +276,19 @@ status_t STREAMER_mic_Create(streamer_handle_t *handle, out_sink_t out_sink, cha prop.prop = PROP_AUDIOSRC_SET_NUM_CHANNELS; prop.val = 2; streamer_set_property(handle->streamer, prop, true); - - prop.prop = PROP_AUDIOSRC_SET_BITS_PER_SAMPLE; - prop.val = 32; - streamer_set_property(handle->streamer, prop, true); #endif #if DEMO_CODEC_CS42448 prop.prop = PROP_AUDIOSRC_SET_NUM_CHANNELS; prop.val = 8; streamer_set_property(handle->streamer, prop, true); +#endif prop.prop = PROP_AUDIOSRC_SET_BITS_PER_SAMPLE; prop.val = 32; streamer_set_property(handle->streamer, prop, true); #endif + prop.prop = PROP_AUDIOSRC_SET_SAMPLE_RATE; prop.val = 16000; streamer_set_property(handle->streamer, prop, true); diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/armgcc/flags.cmake b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/armgcc/flags.cmake index 4fbeb78dd..251f9aca6 100755 --- a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/armgcc/flags.cmake +++ b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/armgcc/flags.cmake @@ -32,6 +32,7 @@ SET(CMAKE_C_FLAGS_DEBUG " \ -DCPU_LPC55S69JBD100_cm33_core0 \ -DSTREAMER_ENABLE_AUDIO_PROC \ -DSTREAMER_ENABLE_VIT_SINK \ + -DI2S_NUM_BUFFERS=3 \ -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING \ -DOSA_USED \ -DSHELL_TASK_STACK_SIZE=4000 \ @@ -42,7 +43,6 @@ SET(CMAKE_C_FLAGS_DEBUG " \ -DDEBUG_CONSOLE_RX_ENABLE=0 \ -DPRINTF_ADVANCED_ENABLE=1 \ -DPRINTF_FLOAT_ENABLE=1 \ - -DI2S_NUM_BUFFERS=2 \ -DSERIAL_PORT_TYPE_UART=1 \ -DSDK_OS_FREE_RTOS \ -DCASCFG_PLATFORM_FREERTOS \ @@ -76,6 +76,7 @@ SET(CMAKE_C_FLAGS_RELEASE " \ -DCPU_LPC55S69JBD100_cm33_core0 \ -DSTREAMER_ENABLE_AUDIO_PROC \ -DSTREAMER_ENABLE_VIT_SINK \ + -DI2S_NUM_BUFFERS=3 \ -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING \ -DOSA_USED \ -DSHELL_TASK_STACK_SIZE=4000 \ @@ -86,7 +87,6 @@ SET(CMAKE_C_FLAGS_RELEASE " \ -DDEBUG_CONSOLE_RX_ENABLE=0 \ -DPRINTF_ADVANCED_ENABLE=1 \ -DPRINTF_FLOAT_ENABLE=1 \ - -DI2S_NUM_BUFFERS=2 \ -DSERIAL_PORT_TYPE_UART=1 \ -DSDK_OS_FREE_RTOS \ -DCASCFG_PLATFORM_FREERTOS \ diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/maestro_record_v3_10.xml b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/maestro_record_v3_10.xml index fac88abc0..21e30475d 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/maestro_record_v3_10.xml +++ b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/maestro_record_v3_10.xml @@ -64,6 +64,7 @@ CPU_LPC55S69JBD100_cm33_core0 STREAMER_ENABLE_AUDIO_PROC STREAMER_ENABLE_VIT_SINK + I2S_NUM_BUFFERS=3 DEBUG_CONSOLE_TRANSFER_NON_BLOCKING OSA_USED SHELL_TASK_STACK_SIZE=4000 @@ -74,7 +75,6 @@ DEBUG_CONSOLE_RX_ENABLE=0 PRINTF_ADVANCED_ENABLE=1 PRINTF_FLOAT_ENABLE=1 - I2S_NUM_BUFFERS=2 SERIAL_PORT_TYPE_UART=1 SDK_OS_FREE_RTOS CASCFG_PLATFORM_FREERTOS diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/readme.txt b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/readme.txt index 0b76543eb..24866977c 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/readme.txt +++ b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/readme.txt @@ -40,6 +40,10 @@ Type "help" to see the command list. Similar description will be displayed on se For custom VIT model generation (defining own wake words and voice commands) please use https://vit.nxp.com/ +Note: + - If more than one channel is used and VIT is enabled, please enable VoiceSeeker. + - The VoiceSeeker that combines multiple channels into one must be used, as VIT can only work with one channel. + Toolchain supported =================== diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/streamer_pcm.c b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/streamer_pcm.c index 8b152345f..471699ffb 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/streamer_pcm.c +++ b/boards/lpcxpresso55s69/audio_examples/maestro_record/cm33_core0/streamer_pcm.c @@ -60,6 +60,10 @@ void streamer_pcm_start(pcm_rtos_t *pcm) { /* Interrupts already enabled - nothing to do. * App/streamer can begin writing data to SAI. */ + if (pcm->isFirstTx == 1) + { + I2S_Enable(DEMO_I2S_TX); + } } void streamer_pcm_close(pcm_rtos_t *pcm) @@ -129,7 +133,9 @@ int streamer_pcm_read(pcm_rtos_t *pcm, uint8_t *data, uint32_t size) { /* Wait for the previous transfer to finish */ if (xSemaphoreTake(pcm->semaphoreRX, portMAX_DELAY) != pdTRUE) + { return -1; + } } /* Start the consecutive transfer */ @@ -232,7 +238,7 @@ int streamer_pcm_setparams( I2S_TxInit(DEMO_I2S_TX, &pcmHandle.tx_config); } } - ret = CODEC_SetMute(&codecHandle, kCODEC_PlayChannelHeadphoneLeft | kCODEC_PlayChannelHeadphoneRight, true); + ret = streamer_pcm_set_volume(pcm, 0); if (ret != kStatus_Success) { diff --git a/boards/lpcxpresso55s69/audio_examples/maestro_usb_mic/cm33_core0/readme.txt b/boards/lpcxpresso55s69/audio_examples/maestro_usb_mic/cm33_core0/readme.txt index 6e7d46b5d..2f840e7f2 100644 --- a/boards/lpcxpresso55s69/audio_examples/maestro_usb_mic/cm33_core0/readme.txt +++ b/boards/lpcxpresso55s69/audio_examples/maestro_usb_mic/cm33_core0/readme.txt @@ -28,13 +28,9 @@ After running the "usb_mic" command, the USB device will be enumerated on your h User will see the volume levels obtained from the USB host as in the example below. This is just an example application. To leverage the values, the demo has to be modified. -Note -1. When connected to MacBook, change the PCM format from (0x02,0x00,) to (0x01,0x00, ) in - g_config_descriptor[CONFIG_DESC_SIZE] in the usb_descriptor.c. Otherwise, it can't be enumerated and - noise is present when recording with the QuickTime player because the sampling frequency and bit resolution - do not match. -2. When device functionality is changed, please uninstall the previous PC driver to make sure the device with changed functionality can run normally. -3. If you're having audio problems on Windows 10 for recorder, please disable signal enhancement as the following if it is enabled and have a try again. +Notes +1. When device functionality is changed, please uninstall the previous PC driver to make sure the device with changed functionality can run normally. +2. If you're having audio problems on Windows 10 for recorder, please disable signal enhancement as the following if it is enabled and have a try again. Toolchain supported diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/GUI/safety.pmp b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/GUI/safety.pmp deleted file mode 100644 index 52a83467f..000000000 Binary files a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/GUI/safety.pmp and /dev/null differ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/freemaster_cfg.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/freemaster_cfg.h deleted file mode 100644 index 173556a56..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/freemaster_cfg.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2007-2015 Freescale Semiconductor, Inc. - * Copyright 2018-2019 NXP - * - * SPDX-License-Identifier: BSD-3-Clause - * - * FreeMASTER Communication Driver - User Configuration File - */ - -#ifndef FREEMASTER_CFG_H -#define FREEMASTER_CFG_H - -//////////////////////////////////////////////////////////////////////////////// -// Definitions -//////////////////////////////////////////////////////////////////////////////// - -#define FMSTR_PLATFORM_CORTEX_M 1 /* Cortex-M platform (see freemaster.h for list of all supported platforms) */ - -//! Set the demo configuration -#define FMSTR_DEMO_ENOUGH_ROM 1 /* Platform has enough ROM to show most of the FreeMASTER features */ -#define FMSTR_DEMO_LARGE_ROM \ - 1 /* Platform has large ROM enough to store the extended data structures used in FreeMASTER demo */ -#define FMSTR_DEMO_SUPPORT_I64 1 /* support for long long type */ -#define FMSTR_DEMO_SUPPORT_FLT 1 /* support for float type */ -#define FMSTR_DEMO_SUPPORT_DBL 1 /* support for double type */ - -//! Enable/Disable FreeMASTER functionalities -#define FMSTR_DISABLE 0 //!< To disable all FreeMASTER functionalities - -//! Select interrupt or poll-driven serial communication -#define FMSTR_LONG_INTR 0 //!< Complete message processing in interrupt -#define FMSTR_SHORT_INTR 0 //!< Queuing done in interrupt -#define FMSTR_POLL_DRIVEN 1 //!< No interrupt needed, polling only - -//! Select communication interface - -//! List of implemented standard FreeMASTER transports and its drivers -//!< FMSTR_SERIAL - Standard serial transport protocol (Used by various types of UART peripherals as USB CDC -//!< implementation) -//!< FMSTR_SERIAL_MCUX_UART - MCUXSDK driver for UART peripheral -//!< FMSTR_SERIAL_MCUX_LPUART - MCUXSDK driver for LPUART peripheral -//!< FMSTR_SERIAL_MCUX_USART - MCUXSDK driver for USART peripheral -//!< FMSTR_SERIAL_MCUX_MINIUSART -MCUXSDK driver for MINIUSART peripheral -//!< FMSTR_SERIAL_MCUX_USB - MCUXSDK driver for USB peripheral with CDC class -//!< FMSTR_CAN - Standard CAN transport protocol (Used by various types of CAN peripherals) -//!< FMSTR_CAN_MCUX_FLEXCAN - MCUXSDK driver for FlexCAN peripheral -//!< FMSTR_CAN_MCUX_MCAN - MCUXSDK driver for MCAN peripheral -//!< FMSTR_CAN_MCUX_MSCAN - MCUXSDK driver for msCAN peripheral -//!< FMSTR_PDBDM - Packet Driven BDM (Background debug memory access using JTAG, SWD or BDM debug probes). This -//!< transport does not use low-level driver. - -#define FMSTR_TRANSPORT FMSTR_SERIAL //!< Use serial transport layer */ -#define FMSTR_SERIAL_DRV FMSTR_SERIAL_MCUX_USART //!< Use serial driver for USART */ - -//! Define communication interface base address or leave undefined for runtime setting -// #undef FMSTR_SERIAL_BASE //!< Serial base will be assigned in runtime (when FMSTR_USE_UART) -// #undef FMSTR_CAN_BASE //!< CAN base will be assigned in runtime (when FMSTR_USE_FLEXCAN) - -//! FlexCAN-specific, communication message buffers -#define FMSTR_FLEXCAN_TXMB 0 -#define FMSTR_FLEXCAN_RXMB 1 - -//! Input/output communication buffer size -#define FMSTR_COMM_BUFFER_SIZE 0 //!< Set to 0 for "automatic" - -//! Receive FIFO queue size (use with FMSTR_SHORT_INTR only) -#define FMSTR_COMM_RQUEUE_SIZE 32 //!< Set to 0 for "default" - -//! Support for Application Commands -#define FMSTR_USE_APPCMD 1 //!< Enable/disable App.Commands support -#define FMSTR_APPCMD_BUFF_SIZE 32 //!< App.Command data buffer size -#define FMSTR_MAX_APPCMD_CALLS 4 //!< How many app.cmd callbacks? (0=disable) - -//! Oscilloscope support -#define FMSTR_USE_SCOPE 2 //!< Specify number of supported oscilloscopes -#define FMSTR_MAX_SCOPE_VARS 8 //!< Specify maximum number of scope variables per one oscilloscope - -//! Recorder support -#define FMSTR_USE_RECORDER 2 //!< Specify number of supported recorders - -//! Built-in recorder buffer -#define FMSTR_REC_BUFF_SIZE 1024 //!< Built-in buffer size. Set to zero to disable using embedded buffer for recorder 0. - -//! Recorder time base, specifies how often the recorder is called in the user app. -#define FMSTR_REC_TIMEBASE FMSTR_REC_BASE_MILLISEC(0) //!< 0 = "unknown" -#define FMSTR_REC_FLOAT_TRIG 1 //!< Enable/disable floating point triggering - -//!< Target-side address translation (TSA) -#define FMSTR_USE_TSA 0 //!< Enable TSA functionality -#define FMSTR_USE_TSA_INROM 1 //!< TSA tables declared as const (put to ROM) -#define FMSTR_USE_TSA_SAFETY 1 //!< Enable/Disable TSA memory protection -#define FMSTR_USE_TSA_DYNAMIC 1 //!< Enable/Disable TSA entries to be added also in runtime - -//!< Pipes as data streaming over FreeMASTER protocol -#define FMSTR_USE_PIPES 3 //!< Specify number of supported pipe objects - -//!< Enable/Disable read/write memory commands -#define FMSTR_USE_READMEM 1 //!< Enable read memory commands -#define FMSTR_USE_WRITEMEM 1 //!< Enable write memory commands -#define FMSTR_USE_WRITEMEMMASK 1 //!< Enable write memory bits commands - -// Define password for access levels to protect them. AVOID SHORT PASSWORDS in production version. -// Passwords should be at least 20 characters long to prevent dictionary attacks. -// #define FMSTR_RESTRICTED_ACCESS_RWF_PASSWORD "rwf" -// #define FMSTR_RESTRICTED_ACCESS_RW_PASSWORD "rw" -// #define FMSTR_RESTRICTED_ACCESS_R_PASSWORD "r" - -// Storing cleartext passwords in Flash memory is not safe, consider storing their SHA1 hash instead -// Even with this option, the hash must be generated from reasonably complex password to prevent dictionary attack. -#define FMSTR_USE_HASHED_PASSWORDS \ - 0 //!< When non-zero, the passwords above are specified as a pointer to 20-byte SHA1 hash of password text - -#endif /* FREEMASTER_CFG_H */ - -//////////////////////////////////////////////////////////////////////////////// -// EOF -//////////////////////////////////////////////////////////////////////////////// diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/isr.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/isr.h deleted file mode 100644 index bc490b315..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/isr.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _ISR_H_ -#define _ISR_H_ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#undef VECTOR_015 -#define VECTOR_015 SYSTICK_Isr - -/******************************************************************************* - * API - ******************************************************************************/ -extern void SYSTICK_Isr(void); - -#endif /* _ISR_H_ */ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/main.c b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/main.c deleted file mode 100644 index 24be5a630..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/main.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "safety_config.h" -#if FMSTR_SERIAL_ENABLE -#include "freemaster.h" -#endif - - -/******************************************************************************* - * Prototypes - ******************************************************************************/ -void SYSTICK_Isr(void); -void safety_dio_runtime(void); - -/******************************************************************************* - * Variables - ******************************************************************************/ -/* Start and end addresses for March test applied to Stack area */ -extern const uint32_t c_stackTestFirstAddress; /* defined in safety_*.c */ -extern const uint32_t c_stackTestSecondAddress; /* defined in safety_*.c */ - -/* Test variable */ -volatile uint32_t counter = 0; - -#if defined(__IAR_SYSTEMS_ICC__) /* IAR */ - #pragma section = ".safety_ram" - #pragma section = ".pctest" - - wd_test_t g_sSafetyWdTest @ ".safety_ram"; - safety_common_t g_sSafetyCommon @ ".safety_ram"; - fs_flash_runtime_test_parameters_t g_sFlashCrc @ ".safety_ram"; - fs_flash_configuration_parameters_t g_sFlashConfig @ ".safety_ram"; - fs_ram_test_t g_sSafetyRamTest @ ".safety_ram"; - fs_ram_test_t g_sSafetyRamStackTest @ ".safety_ram"; - fs_clock_test_t g_sSafetyClockTest @ ".safety_ram"; - -#elif (defined(__GNUC__) && ( __ARMCC_VERSION >= 6010050)) /* KEIL */ - #include "linker_config.h" - - /* The safety-related RAM border marker. */ - extern uint32_t Image$$SafetyRam_region$$Limit; - - uint32_t stack_pointer_addr = (uint32_t)__BOOT_STACK_ADDRESS; - - uint16_t crcPostbuild; /* Checksum result calculated by srec_cat.exe in post-build phase */ - - wd_test_t g_sSafetyWdTest __attribute__((section(".safety_ram"))); - safety_common_t g_sSafetyCommon __attribute__((section(".safety_ram"))); - fs_clock_test_t g_sSafetyClockTest __attribute__((section(".safety_ram"))); - fs_ram_test_t g_sSafetyRamTest __attribute__((section(".safety_ram"))); - fs_ram_test_t g_sSafetyRamStackTest __attribute__((section(".safety_ram"))); - fs_flash_runtime_test_parameters_t g_sFlashCrc __attribute__((section(".safety_ram"))); - fs_flash_configuration_parameters_t g_sFlashConfig __attribute__((section(".safety_ram"))); - -#else /* MCUXpresso */ - - uint16_t crcPostbuild; /* Checksum result calculated by srec_cat.exe in post-build phase */ - - extern uint32_t __BOOT_STACK_ADDRESS; /* from Linker command file */ - uint32_t stack_pointer_addr = (uint32_t)&__BOOT_STACK_ADDRESS; - - extern uint32_t m_sec_fs_ram_start; /* from Linker command file */ - uint32_t pui32SafetyRamSectionStart = (uint32_t)&m_sec_fs_ram_start; - - extern uint32_t m_sec_fs_ram_end; /* from Linker command file */ - uint32_t pui32SafetyRamSectionEnd = (uint32_t)&m_sec_fs_ram_end; - - wd_test_t g_sSafetyWdTest __attribute__((section(".safety_ram"))); - safety_common_t g_sSafetyCommon __attribute__((section(".safety_ram"))); - fs_clock_test_t g_sSafetyClockTest __attribute__((section(".safety_ram"))); - fs_ram_test_t g_sSafetyRamTest __attribute__((section(".safety_ram"))); - fs_ram_test_t g_sSafetyRamStackTest __attribute__((section(".safety_ram"))); - fs_flash_runtime_test_parameters_t g_sFlashCrc __attribute__((section(".safety_ram"))); - fs_flash_configuration_parameters_t g_sFlashConfig __attribute__((section(".safety_ram"))); -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ -/*! - * @brief main function - * - * @param void - * - * @return None - */ -int32_t main(void) -{ -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - /* Clock initialization */ - ClockInit(); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - /* Pin initialization */ - BOARD_InitBootPins(); - - /* Watchdog test */ - SafetyWatchdogTest(&g_sSafetyCommon, &g_sSafetyWdTest); - - g_sSafetyCommon.safetyErrors = 0; /* clear the variable that records safety error codes */ - g_sSafetyCommon.fastIsrSafetySwitch = 0; - -#if defined(__IAR_SYSTEMS_ICC__) /* IAR */ - uint32_t *safetyRamStart = __section_begin(".safety_ram"); - uint32_t *safetyRamEnd = __section_end(".safety_ram"); - -#elif (defined(__GNUC__) && (__ARMCC_VERSION >= 6010050)) /* KEIL */ - uint32_t *safetyRamStart = (uint32_t *)m_safety_ram_start; - uint32_t *safetyRamEnd = (uint32_t *)&Image$$SafetyRam_region$$Limit; - -#else /* MCUXpresso */ - uint32_t *safetyRamStart = (uint32_t *)pui32SafetyRamSectionStart; - uint32_t *safetyRamEnd = (uint32_t *)pui32SafetyRamSectionEnd; -#endif - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - -#if FMSTR_SERIAL_ENABLE - SerialInit(); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - FMSTR_Init();/* initialize freemaster */ -#endif /* FMSTR_SERIAL_ENABLE */ - - /* Flash test init */ - SafetyFlashTestInit(&g_sFlashCrc, &g_sFlashConfig); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - -#if FLASH_TEST_ENABLED - /* After-reset flash test */ - SafetyFlashAfterResetTest(&g_sSafetyCommon, &g_sFlashConfig); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif -#endif /* FLASH_TEST_ENABLED */ - - /* Ram test init for Safety related RAM space */ - SafetyRamTestInit(&g_sSafetyRamTest, safetyRamStart, safetyRamEnd); - - /* Ram test init for Stack memory */ - SafetyRamTestInit(&g_sSafetyRamStackTest, (uint32_t *)c_stackTestFirstAddress, - (uint32_t *)c_stackTestSecondAddress); - - /* Ram after-reset test for safety related memory*/ - SafetyRamAfterResetTest(&g_sSafetyCommon, &g_sSafetyRamTest); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - /* Ram after-reset test for Stack area */ - SafetyRamAfterResetTest(&g_sSafetyCommon, &g_sSafetyRamStackTest); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - -#if PC_TEST_ENABLED - /* Program Counter test */ - SafetyPcTest(&g_sSafetyCommon, PC_TEST_PATTERN); -#endif - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - /* CPU test after */ - SafetyCpuAfterResetTest(&g_sSafetyCommon); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - /* initialize Stack test */ - SafetyStackTestInit(); - - /* Stack overflow and underflow test */ - SafetyStackTest(&g_sSafetyCommon); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - -#if ADC_TEST_ENABLED - AdcInit(); - - #if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ - #endif - - /* After-reset ADC test */ - for (uint8_t i = 0; i < 6; i++) /* each odd iteration is init phase */ - { - for (uint8_t y = 0; y < 40; y++) - __asm("nop"); /* delay because of conversion time */ - SafetyAnalogTest(&g_sSafetyCommon); - - #if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ - #endif - } -#endif /* ADC_TEST_ENABLED */ - -#if DIO_TEST_ENABLED - /* Digital I/O test */ - - for (int i = 0; g_dio_safety_test_items[i] != 0; i++) - { - -#ifndef _MIMXRT1189_CM33_H_ - SafetyDigitalOutputTest(&g_sSafetyCommon, g_dio_safety_test_items[i]); -#endif - - SafetyDigitalInputOutput_ShortSupplyTest(&g_sSafetyCommon, g_dio_safety_test_items[i], DIO_SHORT_TO_GND_TEST); - SafetyDigitalInputOutput_ShortSupplyTest(&g_sSafetyCommon, g_dio_safety_test_items[i], DIO_SHORT_TO_VDD_TEST); - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - } - - SafetyDigitalInputOutput_ShortAdjTest(&g_sSafetyCommon, g_dio_safety_test_items[0], g_dio_safety_test_items[1], - LOGICAL_ONE); - SafetyDigitalInputOutput_ShortAdjTest(&g_sSafetyCommon, g_dio_safety_test_items[0], g_dio_safety_test_items[1], - LOGICAL_ZERO); -#endif /* DIO_TEST_ENABLED */ - -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - -#if CLOCK_TEST_ENABLED - /* Initialize Clock test */ - SafetyClockTestInit(&g_sSafetyCommon, &g_sSafetyClockTest); -#endif - - /* Initialize SysTick */ - SystickInit(SYSTICK_RELOAD_VALUE); - - /* Enable interrupts */ - __asm("CPSIE i"); - - while (1) - { - /* Interruptable CPU registers test */ - SafetyCpuBackgroundTest(&g_sSafetyCommon); - - /* safety test of CPU CONTROL register, it cannot be placed in interrupt, thus interrupts must be disabled for a - * while */ - /* - see IEC60730 library documentation for CPU errors handling ! */ - __asm("CPSID i"); -#if (defined(_LPC55S69_CM33_CORE0_H_) || defined(_LPC55S06_H_) || defined(_MIMXRT1189_CM33_H_)) /* If device supports TrustZone */ - g_sSafetyCommon.CPU_control_s_test_result = FS_CM33_CPU_Control_S(); -#else - g_sSafetyCommon.CPU_control_s_test_result = FS_CM33_CPU_Control(); -#endif /* If device supports TrustZone */ - __asm("CPSIE i"); - if (g_sSafetyCommon.CPU_control_s_test_result == FS_FAIL_CPU_CONTROL) - { - g_sSafetyCommon.safetyErrors |= CPU_CONTROL_ERROR; - SafetyErrorHandling(&g_sSafetyCommon); - } - - /* safety test of CPU SP_PROCESS register, it cannot be placed in interrupt, thus interrupts must be disabled - * for a while */ - /* - see IEC60730 library documentation for CPU errors handling ! */ - __asm("CPSID i"); - FS_CM33_CPU_SPprocess_S(); - __asm("CPSIE i"); - -#if FLASH_TEST_ENABLED - /* Runtime Flash test */ - SafetyFlashRuntimeTest(&g_sSafetyCommon, &g_sFlashCrc, &g_sFlashConfig); -#endif - -#if CLOCK_TEST_ENABLED - /* Runtime Clock test */ - SafetyClockTestCheck(&g_sSafetyCommon, &g_sSafetyClockTest); -#endif - - /* Stack overflow and underflow test */ - SafetyStackTest(&g_sSafetyCommon); - -#if ADC_TEST_ENABLED - /* Runtime ADC test */ - SafetyAnalogTest(&g_sSafetyCommon); -#endif - -#if DIO_TEST_ENABLED - /* Digital I/O test */ - safety_dio_runtime(); -#endif - -#if FMSTR_SERIAL_ENABLE - - FMSTR_Poll(); /* Freemaster cummunication */ -#endif /* FMSTR_SERIAL_ENABLE */ - - development_test_terminate(); /* For example validation during development */ - } -} - -void safety_dio_runtime(void) -{ - /* Static variable for indexing in items array */ - static uint8_t dio_cnt_number = 0; - - if (g_dio_safety_test_items[dio_cnt_number] != NULL) - { - #ifndef _MIMXRT1189_CM33_H_ - SafetyDigitalOutputTest(&g_sSafetyCommon, g_dio_safety_test_items[dio_cnt_number]); - #endif - SafetyDigitalInputOutput_ShortSupplyTest(&g_sSafetyCommon, g_dio_safety_test_items[dio_cnt_number], - DIO_SHORT_TO_GND_TEST); - SafetyDigitalInputOutput_ShortSupplyTest(&g_sSafetyCommon, g_dio_safety_test_items[dio_cnt_number], - DIO_SHORT_TO_VDD_TEST); - - /* In next call, test next DIO channel */ - dio_cnt_number++; - } - else - { - dio_cnt_number = 0; - } -} - -/*! - * @brief Systick interrupt function - * - * @param void - * - * @return None - */ -void SYSTICK_Isr(void) -{ - counter++; - -#if CLOCK_TEST_ENABLED - /* Clock test function */ - SafetyClockTestIsr(&g_sSafetyClockTest); -#endif - - /* Safety tests which cannot be interrupted */ - SafetyIsrFunction(&g_sSafetyCommon, &g_sSafetyRamTest, &g_sSafetyRamStackTest); - - /* Refreshing the watchdog. For short period of interrupts, choose higher refresh ratio parameter */ - SafetyWatchdogRuntimeRefresh(&g_sSafetyWdTest); -} diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/mcux/linker/lpcxpresso55s69_safety.ld b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/mcux/linker/lpcxpresso55s69_safety.ld deleted file mode 100644 index b16c05a48..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/mcux/linker/lpcxpresso55s69_safety.ld +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * Processors: LPC55S69JBD100_cm33_core0 - * LPC55S69JBD64_cm33_core0 - * LPC55S69JEV98_cm33_core0 - */ - -/******************************************************************************/ -/****************** LIBRARY *******************************************/ -/******************************************************************************/ -GROUP ( - "libcr_semihost_nf.a" - "libcr_c.a" - "libcr_eabihelpers.a" - "libgcc.a" -) - -/******************************************************************************/ -/****************** USER CONFIGURATION PART ***************************/ -/******************************************************************************/ -/* FLASH memory boundaries. */ -__ROM_start__ = 0x00000000; -__ROM_end__ = 0x00071FFF; - -/* RAM memory boundaries. */ -__RAM_start__ = 0x20000000; -__RAM_end__ = 0x200317FF; - -/* Sizes of objects in RAM. */ -__size_cstack__ = 0x0400; /* Stack size. */ -stack_test_block_size = 0x10; /* Safety stack test pattern. */ -ram_test_backup_size = 0x20; /* Safety RAM test backup size. */ -wd_test_backup_size = 0x20; /* Safety WDOG test data size. */ - -/* Sizes of objects in FLASH. */ -__vector_table_size__ = 0x130; -__PC_test_size = 0x20; -__size_flash_crc__ = 0x10; -__flash_cfg_size = 0x10; - -__VECTOR_TABLE = __ROM_start__; -__size_heap__ = 0x40; /* 2x heap and heap2stackfill */ - -/******************************************************************************/ -/****************** SYMBOLS *******************************************/ -/******************************************************************************/ -/* Assemble RAM addresses. */ -m_ram_test_backup = (__RAM_end__ - ram_test_backup_size + 0x1); -m_wd_test_backup = (m_ram_test_backup - wd_test_backup_size); -m_pc_test_flag = (m_wd_test_backup - 0x4); -m_safety_error_code = (m_pc_test_flag - 0x4); -m_stack_test_p_4 = (m_safety_error_code - 0x4); -m_stack_test_p_3 = (m_stack_test_p_4 - stack_test_block_size +0x4); -__BOOT_STACK_ADDRESS = (m_stack_test_p_3 - 0x4); -m_stack_test_p_2 = (__BOOT_STACK_ADDRESS - __size_cstack__); -m_stack_test_p_1 = (m_stack_test_p_2 - stack_test_block_size + 0x4); - -m_safety_ram_start = __RAM_start__; - -/* Assemble FLASH addresses. */ -m_intvec_table_start = (__ROM_start__); -m_intvec_table_end = (m_intvec_table_start + __vector_table_size__ - 0x1); -__PC_test_start__ = (m_intvec_table_end + 0x1); -__PC_test_end__ = (__PC_test_start__ + __PC_test_size - 0x1); -m_flash_start = (__PC_test_end__ + 0x1); - -m_fs_flash_crc_end = (__ROM_end__); -m_fs_flash_crc_start = (m_fs_flash_crc_end - __size_flash_crc__ + 0x1); -m_flash_end = (m_fs_flash_crc_start - 0x1); - -MEMORY -{ - /* Define each memory region */ - MEM_FLASH (rx) : ORIGIN = __ROM_start__, LENGTH = (__ROM_end__ - __ROM_start__ + 1) - MEM_RAM (rwx) : ORIGIN = __RAM_start__, LENGTH = (__RAM_end__ - __RAM_start__ + 1) -} - -/******************************************************************************/ -/****************** PLACING *******************************************/ -/******************************************************************************/ -ENTRY(ResetISR) - -SECTIONS -{ - /* Safety-related code and read-only data section. */ - .SEC_FS_ROM : ALIGN(4) - { - FILL(0xff) - - /* The interrupt vector table. */ - . = m_intvec_table_start; - KEEP(*(.intvec*)) - - /* PC test object. */ - . = __PC_test_start__; - KEEP(*iec60730b_cm33_pc_object.o(.text*)) - - /* Safety-related FLASH code and RO data. */ - . = m_flash_start; - *(.rodata*) - . = . + 1; - . = ALIGN(4); - } >MEM_FLASH - - /* The safety-related RAM. */ - .SEC_FS_RAM m_safety_ram_start : AT (ADDR(.SEC_FS_ROM) + SIZEOF(.SEC_FS_ROM)) - { - m_sec_fs_ram_load_start = LOADADDR(.SEC_FS_RAM); - m_sec_fs_ram_start = .; - *(.safety_ram*) - *main.o(.data*) - *safety_test_items.o(.data*) - . = . + 1; - . = ALIGN(4); - m_sec_fs_ram_load_end = LOADADDR (.SEC_FS_RAM) + SIZEOF(.SEC_FS_RAM); - m_sec_fs_ram_end = .; - - /* The end of safety-related FLASH memory. */ - m_safety_flash_end = LOADADDR (.SEC_FS_RAM) + SIZEOF(.SEC_FS_RAM); - } >MEM_RAM - - - /* The non-safety RW data. */ - .SEC_RWRAM m_sec_fs_ram_end : AT (m_safety_flash_end) - { - m_sec_rwram_load_start = LOADADDR(.SEC_RWRAM); - m_sec_rwram_start = .; - *(.data*) - . = . + 1; - . = ALIGN(4); - m_sec_rwram_load_end = LOADADDR(.SEC_RWRAM) + SIZEOF(.SEC_RWRAM); - m_sec_rwram_end = .; - } >MEM_RAM - - /* The non-safety code and RO data. */ - .SEC_ROM m_sec_rwram_load_end : ALIGN(4) - { - FILL(0xff) - *(.text*) - KEEP(*(.rodata .rodata.* .constdata .constdata.*)) - . = . + 1; - . = ALIGN(4); - } >MEM_FLASH - - /* The safety FLASH CRC. */ - .SEC_CRC m_fs_flash_crc_start : ALIGN(4) - { - FILL(0xff) - KEEP(*(.flshcrc*)) - } >MEM_FLASH - - /* Stack memory. */ - stack (__BOOT_STACK_ADDRESS - __size_cstack__) : ALIGN(4) - { - . = ALIGN(4); - } > MEM_RAM - - /* The zero-initialized RW data. */ - .SEC_BSS m_sec_rwram_end : ALIGN(4) - { - m_sec_bss_start = .; - *(.bss*) - *(COMMON) - . = . + 1; - . = ALIGN(4); - m_sec_bss_end = .; - } >MEM_RAM - - /* Reserve and place Heap within memory map */ - _HeapSize = __size_heap__; - .heap : ALIGN(4) - { - _pvHeapStart = .; - . += _HeapSize; - . = ALIGN(4); - _pvHeapLimit = .; - } > MEM_RAM -} diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/pin_mux.c b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/pin_mux.c deleted file mode 100644 index 305361bf1..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/pin_mux.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/*********************************************************************************************************************** - * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file - * will be overwritten if the respective MCUXpresso Config Tools is used to update this file. - **********************************************************************************************************************/ - -/* clang-format off */ -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -!!GlobalInfo -product: Pins v8.0 -processor: LPC55S69 -package_id: LPC55S69JBD100 -mcu_data: ksdk2_0 -processor_version: 8.0.0 - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ -/* clang-format on */ - -#include "fsl_common.h" -#include "fsl_iocon.h" -#include "pin_mux.h" - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitBootPins - * Description : Calls initialization functions. - * - * END ****************************************************************************************************************/ -void BOARD_InitBootPins(void) -{ - BOARD_InitPins(); -} - -/* clang-format off */ -/* - * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* -BOARD_InitPins: -- options: {callFromInitBoot: 'true', coreID: cm33_core0, enableClock: 'true'} -- pin_list: - - {pin_num: '92', peripheral: FLEXCOMM0, signal: RXD_SDA_MOSI_DATA, pin_signal: PIO0_29/FC0_RXD_SDA_MOSI_DATA/SD1_D2/CTIMER2_MAT3/SCT0_OUT8/CMP0_OUT/PLU_OUT2/SECURE_GPIO0_29, - mode: inactive, slew_rate: standard, invert: disabled, open_drain: disabled} - - {pin_num: '94', peripheral: FLEXCOMM0, signal: TXD_SCL_MISO_WS, pin_signal: PIO0_30/FC0_TXD_SCL_MISO_WS/SD1_D3/CTIMER0_MAT0/SCT0_OUT9/SECURE_GPIO0_30, mode: inactive, - slew_rate: standard, invert: disabled, open_drain: disabled} - * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** - */ -/* clang-format on */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitPins - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -/* Function assigned for the Cortex-M33 (Core #0) */ -void BOARD_InitPins(void) -{ - /* Enables the clock for the I/O controller.: Enable Clock. */ - CLOCK_EnableClock(kCLOCK_Iocon); - - const uint32_t port0_pin29_config = (/* Pin is configured as FC0_RXD_SDA_MOSI_DATA */ - IOCON_PIO_FUNC1 | - /* No addition pin function */ - IOCON_PIO_MODE_INACT | - /* Standard mode, output slew rate control is enabled */ - IOCON_PIO_SLEW_STANDARD | - /* Input function is not inverted */ - IOCON_PIO_INV_DI | - /* Enables digital function */ - IOCON_PIO_DIGITAL_EN | - /* Open drain is disabled */ - IOCON_PIO_OPENDRAIN_DI); - /* PORT0 PIN29 (coords: 92) is configured as FC0_RXD_SDA_MOSI_DATA */ - IOCON_PinMuxSet(IOCON, 0U, 29U, port0_pin29_config); - - const uint32_t port0_pin30_config = (/* Pin is configured as FC0_TXD_SCL_MISO_WS */ - IOCON_PIO_FUNC1 | - /* No addition pin function */ - IOCON_PIO_MODE_INACT | - /* Standard mode, output slew rate control is enabled */ - IOCON_PIO_SLEW_STANDARD | - /* Input function is not inverted */ - IOCON_PIO_INV_DI | - /* Enables digital function */ - IOCON_PIO_DIGITAL_EN | - /* Open drain is disabled */ - IOCON_PIO_OPENDRAIN_DI); - /* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */ - IOCON_PinMuxSet(IOCON, 0U, 30U, port0_pin30_config); -} -/*********************************************************************************************************************** - * EOF - **********************************************************************************************************************/ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/pin_mux.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/pin_mux.h deleted file mode 100644 index dce5aa71c..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/pin_mux.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/*********************************************************************************************************************** - * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file - * will be overwritten if the respective MCUXpresso Config Tools is used to update this file. - **********************************************************************************************************************/ - -#ifndef _PIN_MUX_H_ -#define _PIN_MUX_H_ - -/*! - * @addtogroup pin_mux - * @{ - */ - -/*********************************************************************************************************************** - * API - **********************************************************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! - * @brief Calls initialization functions. - * - */ -void BOARD_InitBootPins(void); - -#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */ -#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */ -#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */ -#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */ -#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */ -#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */ - -/*! - * @brief Configures pin routing and optionally pin electrical features. - * - */ -void BOARD_InitPins(void); /* Function assigned for the Cortex-M33 (Core #0) */ - -#if defined(__cplusplus) -} -#endif - -/*! - * @} - */ -#endif /* _PIN_MUX_H_ */ - -/*********************************************************************************************************************** - * EOF - **********************************************************************************************************************/ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/project_setup_lpcxpresso55s69.c b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/project_setup_lpcxpresso55s69.c deleted file mode 100644 index b391b9fde..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/project_setup_lpcxpresso55s69.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "project_setup_lpcxpresso55s69.h" -#include "board.h" - -#include "fsl_lpadc.h" -#include "fsl_power.h" -#include "fsl_power.h" -#include "fsl_clock.h" -#include "fsl_usart.h" -#include "fsl_iocon.h" -#include "freemaster.h" -#include "freemaster_serial.h" -#include "freemaster_serial_usart.h" - -/******************************************************************************* - * Code - ******************************************************************************/ -/*! - * @brief Watchdog configuration function - * - * Enables the watchdog. Also in Wait and Stop mode. Updates are allowed - * - * @param wd_setup_value //watchdog setup value for timeout - * - * @return None - */ -void WatchdogEnable(uint32_t wd_setup_value) -{ - SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_FRO1MHZ_CLK_ENA_MASK; /* Enable FRO_1MHz */ - SYSCON->WDTCLKDIV = 0; /* WD clock 1MHz */ - SYSCON->AHBCLKCTRL.AHBCLKCTRL0 |= SYSCON_AHBCLKCTRL0_WWDT_MASK; /* Enable clock to WDT */ - - uint32_t bitMask = 0x400000; - - /* reset register is in SYSCON */ - /* set bit */ - SYSCON->PRESETCTRLSET[0] = bitMask; - /* wait until it reads 0b1 */ - while (0u == (SYSCON->PRESETCTRLX[0] & bitMask)) - { - } - - /* clear bit */ - SYSCON->PRESETCTRLCLR[0] = bitMask; - /* wait until it reads 0b0 */ - while (bitMask == (SYSCON->PRESETCTRLX[0] & bitMask)) - { - } - - USED_WDOG->TC = WWDT_TC_COUNT(wd_setup_value); /* refresh value */ - USED_WDOG->MOD = WWDT_MOD_WDRESET(1) | WWDT_MOD_WDEN(1); - USED_WDOG->WINDOW = 0xFFFFFF; /* Disable Window mode */ - - __asm("CPSID i"); - USED_WDOG->FEED = 0xAA; /* Start WDOG */ - USED_WDOG->FEED = 0x55; - __asm("CPSIE i"); -} - -/*! - * @brief Watchdog disabling function - * - * @param *WDOGx - pointer to the base address of the periphery - * - * @return None - */ -void WatchdogDisable(void) -{ - /* Wdog is disabled on LPCdisabled after reset by default */ -} - -/*! - * @brief Initialization of Systick timer - * - * This function configures the Systick as a source of interrupt - * - * @param reload_value - defines the period of counter refresh - * - * @return None - */ -void SystickInit(uint32_t reload_value) -{ - // SYSCON->SYSTICKCLKSEL.SYSTICKCLKSEL0 = 0; /*Main clock select */ - // SYSCON->SYSTICKCLKDIV0 &= ~(SYSCON_SYSTICKCLKDIV0_DIV_MASK); /*0 = div 1 */ - - SysTick->VAL = 0; - SysTick->LOAD = reload_value; - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk; -} - -/* Second timer for CLOCK TEST */ -void second_timer_inicialization(void) -{ - SYSCON->AHBCLKCTRL.AHBCLKCTRL0 |= SYSCON_AHBCLKCTRL0_RTC_MASK; - - SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_FRO1MHZ_CLK_ENA_MASK; - - SYSCON->CTIMERCLKSEL.CTIMERCLKSEL0 = 0x4; /* OSCILATOR 1MHZ */ - SYSCON->AHBCLKCTRL.AHBCLKCTRL1 |= SYSCON_AHBCLKCTRL1_TIMER0_MASK; /*Enable clock to Ctimer0*/ - - SYSCON->PRESETCTRL.PRESETCTRL0 &= ~(SYSCON_PRESETCTRL1_TIMER0_RST_MASK); // Reset the CTIMER0 - SYSCON->PRESETCTRL.PRESETCTRL0 |= (SYSCON_PRESETCTRL1_TIMER0_RST_MASK); - - CTIMER0->CTCR &= ~(CTIMER_CTCR_CTMODE_MASK); - CTIMER0->TCR |= CTIMER_TCR_CEN_MASK; /*Enable counter*/ - CTIMER0->TCR |= CTIMER_TCR_CRST_MASK; /*Counter reset*/ - CTIMER0->TCR &= ~(CTIMER_TCR_CRST_MASK); /*Counter stop reset*/ -} - -/*! - * @brief Setup of clock - * - * @param void - * - * @return None - * - * - */ -void ClockInit(void) -{ - BOARD_BootClockPLL150M(); -} - -/*! - * @brief Initialization of CTIMER - * - * This function initializes the CTIMER. CTIMER is used for After reset WDog test. - * - * @param void - * - * @return None - */ -void CTIMER_initialisation(void) -{ - POWER_DisablePD(kPDRUNCFG_PD_FRO1M); /*!< Ensure FRO is on */ - - SYSCON->CTIMERCLKSEL.CTIMERCLKSEL0 = 0x3; /* 96MHZ HF FRO CLOCK */ - SYSCON->AHBCLKCTRL.AHBCLKCTRL1 |= SYSCON_AHBCLKCTRL1_TIMER0_MASK; /* Enable clock to Ctimer0 */ - - SYSCON->PRESETCTRL.PRESETCTRL0 &= ~(SYSCON_PRESETCTRL1_TIMER0_RST_MASK); - SYSCON->PRESETCTRL.PRESETCTRL0 |= (SYSCON_PRESETCTRL1_TIMER0_RST_MASK); - - CTIMER0->CTCR &= ~(CTIMER_CTCR_CTMODE_MASK); - - CTIMER0->TCR |= CTIMER_TCR_CEN_MASK; /* Enable counter */ - CTIMER0->TCR |= CTIMER_TCR_CRST_MASK; /* Counter reset */ - CTIMER0->TCR &= ~(CTIMER_TCR_CRST_MASK); /* Counter stop reset */ -} -/*! - * @brief Sets port direction and mux - * - * @param - * - * @return None - */ -void PortSetup(uint8_t *pByte, - uint32_t *pDir, - uint32_t *pIocon, - uint32_t pinDir, - uint32_t pinNum, - uint32_t pull, - uint32_t clock_enable_shift) -{ - /* Enable clock to GPIO module */ - SYSCON->AHBCLKCTRL.AHBCLKCTRL0 |= (1 << clock_enable_shift); - - *pIocon |= IOCON_PIO_DIGIMODE(1); /*Enable Digi mode*/ - *pIocon &= ~(IOCON_PIO_MODE_MASK); /*Clear PULL setting*/ - *pIocon |= IOCON_PIO_MODE(pull); /*Set pullup*/ - - if (pinDir == PIN_DIRECTION_OUT) - { - *pDir |= (1 << pinNum); /* PINx = 1 = output */ - } - else if (pinDir == PIN_DIRECTION_IN) - { - *pDir &= ~(1 << pinNum); /* PINx = 0 = input */ - } -} - -/*! - * @brief Initialization of ADC0 - * - * 8 MHz System Oscillator Bus Clock is the source clock. - * single-ended 16-bit conversion - * - * @param void - * - * @return None - */ -void AdcInit(void) -{ - /* Analog pin setup - GPIO_0_23, P19_4 on board */ - IOCON->PIO[0][23] = (0x400 | 0x10); - - lpadc_config_t configStruct; - lpadc_conv_command_config_t commandConfigStruct; - lpadc_conv_trigger_config_t triggerConfigStruct; - - /* Enable clock to ADC */ - CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 16U, true); - CLOCK_AttachClk(kMAIN_CLK_to_ADC_CLK); - - /* Disable LDOGPADC power down */ - POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC); - - /* Configure ADC module */ - LPADC_GetDefaultConfig(&configStruct); - configStruct.enableAnalogPreliminary = true; - configStruct.referenceVoltageSource = kLPADC_ReferenceVoltageAlt2; - configStruct.conversionAverageMode = kLPADC_ConversionAverage128; - configStruct.powerLevelMode = kLPADC_PowerLevelAlt4; - LPADC_Init(ADC0, &configStruct); - - /* Request offset calibration */ - // LPADC_DoOffsetCalibration(ADC0); // uncomment for auto calibration (must feed watchdog during calibration) - ADC0->OFSTRIM = 0x10003; // manual calibration - - /* Request gain calibration. */ - // LPADC_DoAutoCalibration(ADC0); // uncomment for auto calibration (must feed watchdog during calibration) - ADC0->GCR[0] = 0x00011AE; // manual calibration - ADC0->GCR[1] = 0x0001138; // manual calibration - - /************************************/ - /* Set conversion CMD configuration */ - /************************************/ - LPADC_GetDefaultConvCommandConfig(&commandConfigStruct); - commandConfigStruct.conversionResolutionMode = kLPADC_ConversionResolutionHigh; - - /* 3V3 */ - commandConfigStruct.channelNumber = 12U; /* 3V3 channel */ - LPADC_SetConvCommandConfig(ADC0, 1U, &commandConfigStruct); /* Command ID = 1 (idx 0) */ - - /* 1V */ - commandConfigStruct.channelNumber = 13U; /* 1V channel */ - LPADC_SetConvCommandConfig(ADC0, 2U, &commandConfigStruct); /* Command ID = 2 (idx 1) */ - - /* EXTERNAL PIN GPIO_0_23 (P19,4 on board) */ - commandConfigStruct.channelNumber = 0; /* external pin channel */ - LPADC_SetConvCommandConfig(ADC0, 3U, &commandConfigStruct); /* Command ID = 3 (idx 2) */ - - /*****************************/ - /* Set trigger configuration */ - /*****************************/ - LPADC_GetDefaultConvTriggerConfig(&triggerConfigStruct); - triggerConfigStruct.enableHardwareTrigger = false; - - /* 3V3 */ - triggerConfigStruct.targetCommandId = 1U; - LPADC_SetConvTriggerConfig(ADC0, 0U, &triggerConfigStruct); /* Trigger ID = 0 */ - - /* 1V */ - triggerConfigStruct.targetCommandId = 2U; - LPADC_SetConvTriggerConfig(ADC0, 1U, &triggerConfigStruct); /* Trigger ID = 1 */ - - /* EXTERNAL PIN */ - triggerConfigStruct.targetCommandId = 3U; - LPADC_SetConvTriggerConfig(ADC0, 2U, &triggerConfigStruct); /* Trigger ID = 2 */ -} - -/************************************************/ -void SerialInit(void) -{ - /* Init board hardware. */ - /* attach main clock divide to FLEXCOMM0 (debug console) 12MHz */ - CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0); - - /* FreeMASTER communication layer initialization */ - /* Enables the clock for the I/O controller.: Enable Clock. */ - CLOCK_EnableClock(kCLOCK_Iocon); - - const uint32_t port0_pin29_config = (/* Pin is configured as FC0_RXD_SDA_MOSI_DATA */ - 0x01u | - /* No addition pin function */ - 0x00u | - /* Standard mode, output slew rate control is enabled */ - 0x00u | - /* Input function is not inverted */ - 0x00u | - /* Enables digital function */ - 0x0100u | - /* Open drain is disabled */ - 0x00u); - /* PORT0 PIN29 (coords: 92) is configured as FC0_RXD_SDA_MOSI_DATA */ - IOCON_PinMuxSet(IOCON, 0U, 29U, port0_pin29_config); - - const uint32_t port0_pin30_config = (/* Pin is configured as FC0_TXD_SCL_MISO_WS */ - 0x01u | - /* No addition pin function */ - 0x00u | - /* Standard mode, output slew rate control is enabled */ - 0x00u | - /* Input function is not inverted */ - 0x00u | - /* Enables digital function */ - 0x0100u | - /* Open drain is disabled */ - 0x00u); - /* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */ - IOCON_PinMuxSet(IOCON, 0U, 30U, port0_pin30_config); - - usart_config_t config; - /* - * usartConfig->baudRate_Bps = UART_BAUD_RATE; - * usartConfig->parityMode = kUSART_ParityDisabled; - * usartConfig->stopBitCount = kUSART_OneStopBit; - * usartConfig->bitCountPerChar = kUSART_8BitsPerChar; - * usartConfig->loopback = false; - * usartConfig->enableTx = false; - * usartConfig->enableRx = false; - */ - USART_GetDefaultConfig(&config); - /* Override the Default configuration to satisfy FreeMASTER needs */ - config.baudRate_Bps = UART_BAUD_RATE; - config.enableTx = true; - config.enableRx = true; - - USART_Init((USART_Type *)BOARD_DEBUG_UART_BASEADDR, &config, BOARD_DEBUG_UART_CLK_FREQ); - -#if FMSTR_SERIAL_ENABLE - /* Register communication module used by FreeMASTER driver. */ - FMSTR_SerialSetBaseAddress((USART_Type *)BOARD_DEBUG_UART_BASEADDR); - -#if FMSTR_SHORT_INTR || FMSTR_LONG_INTR - /* Enable UART interrupts. */ - EnableIRQ(BOARD_UART_IRQ); - EnableGlobalIRQ(0); -#endif -#endif //FMSTR_SERIAL_ENABLE -} diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/project_setup_lpcxpresso55s69.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/project_setup_lpcxpresso55s69.h deleted file mode 100644 index 5a182dd5a..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/project_setup_lpcxpresso55s69.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _PROJECT_SETUP_H_ -#define _PROJECT_SETUP_H_ - -#include "safety_config.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -#define BACKUP 0 -#define RESTORE 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * @name Project setup functions - * @{ - */ -/******************************************************************************* - * API - ******************************************************************************/ -void WatchdogEnable(uint32_t wd_setup_value); -void WatchdogDisable(void); -void CTIMER_initialisation(void); -void second_timer_inicialization(void); /* Second timer for CLOKC TEST */ -void SystickInit(uint32_t reload_value); -void ClockInit(void); -void PortSetup(uint8_t *pByte, - uint32_t *pDir, - uint32_t *pIocon, - uint32_t pinDir, - uint32_t pinNum, - uint32_t pull, - uint32_t clock_enable_shift); -void AdcInit(void); -void Tsi0SetupSelfCap(void); -void Tsi0SetupMutualCap(void); -void SerialInit(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _PROJECT_SETUP_H_ */ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/readme.txt b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/readme.txt deleted file mode 100644 index a0e787fdd..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/readme.txt +++ /dev/null @@ -1,12 +0,0 @@ -Overview -======== -This application demonstrates use of certified NXP Safety Library 4.1 which meets the IEC60730 class B standard. - -More information -================ -- All important documents (library/application user's guide, release note and certificate) are in SDK install folder\docs\safety\. -- For more information see webpage: www.nxp.com/iec60730. - -Running the demo -================ -- Follow Safety example user's guide \docs\safety\IEC60730BLPC55SXXUG.pdf. diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_cm33_lpc.c b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_cm33_lpc.c deleted file mode 100644 index cde421a2a..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_cm33_lpc.c +++ /dev/null @@ -1,1112 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "safety_cm33_lpc.h" -#include "freemaster.h" - -#if (defined(__GNUC__) && ( __ARMCC_VERSION >= 6010050)) /* KEIL */ - #include "linker_config.h" -#endif - -#if defined(__IAR_SYSTEMS_ICC__) /* IAR */ - #pragma section = ".safety_ram" - #pragma section = ".checksum" - #pragma location = ".checksum" -#endif - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#ifndef CRC_BASE - #define CRC_BASE 0x0u /*Function API for HW and SW CRC is the same, due to this reason, we must define this symbol, even though it is not used */ -#endif - -/******************************************************************************* - * Variables - ******************************************************************************/ -#if (defined(__GNUC__) && ( __ARMCC_VERSION >= 6010050)) /* KEIL */ - extern uint16_t crcPostbuild; /* defined in main.c */ - const uint32_t c_wdBackupAddress = (uint32_t)m_wd_test_backup; - #define WATCHDOG_TEST_VARIABLES ((fs_wdog_test_t *) c_wdBackupAddress) - - const uint32_t c_programCounterTestFlag = (uint32_t)m_pc_test_flag; - #define PC_TEST_FLAG ((uint32_t *) c_programCounterTestFlag) - - const uint32_t c_safetyErrorCodeAddress = (uint32_t)m_safety_error_code; - #define SAFETY_ERROR_CODE ((uint32_t *) c_safetyErrorCodeAddress) - - const uint32_t c_backupAddress = (uint32_t)m_ram_test_backup; - - /* put values from extern symbols to const variables */ - const uint32_t c_stackTestFirstAddress = (uint32_t)m_stack_test_p_2; - const uint32_t c_stackTestSecondAddress = (uint32_t)m_stack_test_p_3; - - /* The safety-related FLASH end border marker. */ - extern uint32_t Load$$ER_IROM3$$Limit; - - /* The safety-related FLASH CRC value. */ - fs_crc_t c_sfsCRC __attribute__((used, section(".flshcrc"))) = - { - .ui16Start = 0xA55AU, - .ui32FlashStart = (uint32_t)__ROM_start__, - .ui32FlashEnd = (uint32_t)&Load$$ER_IROM3$$Limit, - .ui32CRC = (uint32_t)FS_CFG_FLASH_TST_CRC, - .ui16End = 0x5AA5U - }; - - -#else /* IAR + MCUXpresso */ - extern uint32_t m_wd_test_backup; /* from Linker configuration file */ - const uint32_t c_wdBackupAddress = (uint32_t)&m_wd_test_backup; - #define WATCHDOG_TEST_VARIABLES ((fs_wdog_test_t *) c_wdBackupAddress) - - extern uint32_t m_ram_test_backup; /* symbol from Linker configuration file */ - const uint32_t c_backupAddress = (uint32_t)&m_ram_test_backup; - - extern uint32_t m_pc_test_flag; /* from Linker configuration file */ - const uint32_t programCounterTestFlag = (uint32_t)&m_pc_test_flag; - #define PC_TEST_FLAG ((uint32_t *) programCounterTestFlag) - - extern uint32_t m_safety_error_code; /* from Linker configuration file */ - const uint32_t c_safetyErrorCodeAddress = (uint32_t)&m_safety_error_code; - #define SAFETY_ERROR_CODE ((uint32_t *) c_safetyErrorCodeAddress) - - extern uint32_t m_stack_test_p_2; /* symbol from Linker configuration file */ - extern uint32_t m_stack_test_p_3; /* symbol from Linker configuration file */ - /* put values from extern symbols to const variables */ - const uint32_t c_stackTestFirstAddress = (uint32_t)&m_stack_test_p_2; - const uint32_t c_stackTestSecondAddress = (uint32_t)&m_stack_test_p_3; - - #if defined(__IAR_SYSTEMS_ICC__) /* IAR */ - extern const uint32_t __checksum; /* calculated by Linker */ - const uint32_t c_checksumStart @ "checksum_start_mark"; - const uint32_t c_checksumEnd @ "checksum_end_mark"; - - #else /* MCUXpresso */ - extern uint16_t crcPostbuild; /* defined in main.c */ - extern uint32_t stack_test_block_size; /* from Linker command file */ - #define STACK_TEST_BLOCK_SIZE (uint32_t)&stack_test_block_size - extern uint32_t ram_test_backup_size; /* from Linker command file */ - #define RAM_TEST_BACKUP_SIZE (uint32_t)&ram_test_backup_size - - extern uint32_t __ROM_start__; /* symbol from Linker command file */ - extern uint32_t m_safety_flash_end; /* symbol from Linker command file */ - - /* The safety-related FLASH CRC value. */ - fs_crc_t c_sfsCRC __attribute__((used, section(".flshcrc"))) = - { - .ui16Start = 0xA55AU, - .ui32FlashStart = (uint32_t) &__ROM_start__, - .ui32FlashEnd = (uint32_t) &m_safety_flash_end, - .ui32CRC = (uint32_t)FS_CFG_FLASH_TST_CRC, - .ui16End = 0x5AA5U - }; - - - #endif -#endif - -/** This variable is used as flag for automatic "run" test during example development, -these test have a 3 return value: -1. All tests pass - wait until all after/reset and runtime test passed -2. Safety errror - return from SafetyErrorHandling() function -3. timeout - if case of that all tests are not finished until setted timeout */ -#define CLOCK_PASSED (1 << 0) -#define INVARIABLE_RUNTIME_PASSED (1 << 1) -#define VARIABLE_RUNTIME_PASSED (1 << 2) -#define ALL_RUNTIME_PASSED 0x07 - -/*************************************************** - * BIT MASK - * b.0 - Clock test - * b.1 - Invariable memory RunTime - * b.2 - Variable memory Runtime - ***************************************************/ -uint32_t runtime_test_finish_flag = 0; /* no test performed */ - -/* This function is only for development validation - - * indicate that runtime test run at leaset one. */ -static void test_end(void); -/******************************************************************************* - * Code - ******************************************************************************/ -/*! - * @brief Safety watchdog test. - * - * This function is used to test the Watchdog. - * Sets up LPTMR for the test. - * Calculates limit values for watchdog timeout. - * Performs the watchdog test. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psSafetyWdTest - The pointer of the Safety Watchdog test structure - * @param peClockFreq - The pointer of the clock name enumeration - * - * @return None - */ -void SafetyWatchdogTest(safety_common_t *psSafetyCommon, wd_test_t *psSafetyWdTest) -{ -#if WATCHDOG_ENABLED - uint32_t counterLimitHigh; - uint32_t counterLimitLow; - uint32_t runTestCondition; - uint32_t checkTestCondition; - - /* calculate counter limit values */ - psSafetyWdTest->wdTestTemp1 = ((uint64_t)WATCHDOG_TIMEOUT_VALUE * (uint64_t)WD_REF_TIMER_CLOCK_FREQUENCY); - psSafetyWdTest->wdTestExpected = psSafetyWdTest->wdTestTemp1 / (uint32_t)WATCHDOG_CLOCK; - psSafetyWdTest->wdTestTolerance = (psSafetyWdTest->wdTestExpected * (uint32_t)WD_TEST_TOLERANCE) / (uint32_t)100; - psSafetyWdTest->wdTestLimitHigh = psSafetyWdTest->wdTestExpected + psSafetyWdTest->wdTestTolerance; - psSafetyWdTest->wdTestLimitLow = psSafetyWdTest->wdTestExpected - psSafetyWdTest->wdTestTolerance; - counterLimitHigh = psSafetyWdTest->wdTestLimitHigh; - counterLimitLow = psSafetyWdTest->wdTestLimitLow; - - /* Safety library structure initialization */ - WATCHDOG_TEST_VARIABLES->RefTimerBase = (uint32_t)WDOG_REF_TIMER_BASE; - WATCHDOG_TEST_VARIABLES->WdogBase = (uint32_t)USED_WDOG; - WATCHDOG_TEST_VARIABLES->pResetDetectRegister = (uint32_t)(RESET_DETECT_REGISTER); - WATCHDOG_TEST_VARIABLES->ResetDetectMask = (uint32_t)RESET_DETECT_MASK; - - /* Conditions */ - runTestCondition = WD_RUN_TEST_CONDITION; - checkTestCondition = WD_CHECK_TEST_CONDITION; - - /* CTIMER initialization (96MHz) */ - CTIMER_initialisation(); - - if (*(RESET_DETECT_REGISTER)&runTestCondition) /* if non WD reset --- because of debugging--- in real it must be - only after POR reset */ - { - *SAFETY_ERROR_CODE = 0; /* clean the safety error code flag */ - FS_WDOG_Setup_WWDT_LPC(WATCHDOG_TEST_VARIABLES); - } - - if (*(RESET_DETECT_REGISTER)&checkTestCondition) - { - psSafetyCommon->WDOG_test_result = FS_WDOG_Check_WWDT_LPC55SXX( - counterLimitHigh, counterLimitLow, WATCHDOG_RESETS_LIMIT, ENDLESS_LOOP_ENABLE, WATCHDOG_TEST_VARIABLES); - if (psSafetyCommon->WDOG_test_result != FS_PASS) /* WDOG can return more error messages */ - { - psSafetyCommon->safetyErrors |= WDOG_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - } - - psSafetyWdTest->watchdogResets = WATCHDOG_TEST_VARIABLES->resets; - psSafetyWdTest->watchdogTimeoutCheck = WATCHDOG_TEST_VARIABLES->counter; - psSafetyWdTest->watchdogRefreshRatio = 0U; - -#endif /* WATCHDOG_ENABLED */ -} - -/*! - * @brief Safety watchdog refresh. - * - * This function is used for adjusting of the watchdog refresh when using in fast interrupt. - * - * @param psSafetyWdTest The pointer of the Safety Watchdog test structure - * - * @return None - */ -void SafetyWatchdogRuntimeRefresh(wd_test_t *psSafetyWdTest) -{ - psSafetyWdTest->watchdogRefreshRatio++; - if (psSafetyWdTest->watchdogRefreshRatio == WATCHDOG_REFRESH_RATIO) - { -#if WATCHDOG_ENABLED - Watchdog_refresh; /* refreshing the watchdog */ -#endif - - psSafetyWdTest->watchdogRefreshRatio = 0; - } -} - -/*! - * @brief Initialization of Safety clock test. - * - * Complete Initialization of the clock test. - * Function calculates limit values. - * Cals clock test init function from the IEC60730B library. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psSafetyClockTest - The pointer of the Safety Clock test structure - * @param peClockFreq - The pointer of the clock name enumeration - * - * @return None - */ -void SafetyClockTestInit(safety_common_t *psSafetyCommon, fs_clock_test_t *psSafetyClockTest) -{ - psSafetyCommon->mcgirclkFreq = REF_TIMER_CLOCK_FREQUENCY; - -#if USE_WKT - psSafetyClockTest->clockTestTolerance = CLOCK_TEST_TOLERANCE; - psSafetyClockTest->clockTestExpected = START_VALUE - (psSafetyCommon->mcgirclkFreq / (uint32_t)ISR_FREQUENCY); - psSafetyClockTest->clockTestLimitHigh = - psSafetyClockTest->clockTestExpected + ((psSafetyCommon->mcgirclkFreq / (uint32_t)ISR_FREQUENCY) * 0.5); - psSafetyClockTest->clockTestLimitLow = - psSafetyClockTest->clockTestExpected - ((psSafetyCommon->mcgirclkFreq / (uint32_t)ISR_FREQUENCY) * 2); -#else /*USE CTIMER*/ - psSafetyClockTest->clockTestExpected = (psSafetyCommon->mcgirclkFreq / (uint32_t)ISR_FREQUENCY); - psSafetyClockTest->clockTestTolerance = - (psSafetyClockTest->clockTestExpected * (uint32_t)CLOCK_TEST_TOLERANCE) / (uint32_t)100; - psSafetyClockTest->clockTestLimitHigh = - psSafetyClockTest->clockTestExpected + psSafetyClockTest->clockTestTolerance; - psSafetyClockTest->clockTestLimitLow = psSafetyClockTest->clockTestExpected - psSafetyClockTest->clockTestTolerance; - -#endif - psSafetyClockTest->clockTestStart = 0; /* clock test result will be processed after the first interrupt occurs */ - - FS_CLK_Init((uint32_t *)&psSafetyClockTest->clockTestContext); - - /* Initialize the reference timer */ - CTIMER_initialisation(); -} - -/*! - * @brief Clock test function, called from interrupt. - * - * This function calls clock test function from the IEC60730B library and enable the test evaluation. - * It must be called in the Systick interrupt to catch the value of LPTMR counter. - * - * @param psSafetyClockTest - The pointer of the Safety Clock test structure - * - * @return None - */ -void SafetyClockTestIsr(fs_clock_test_t *psSafetyClockTest) -{ -#if USE_WKT - FS_CLK_WKT_LPC((fs_wkt_t *)REF_TIMER_USED, (uint32_t *)&psSafetyClockTest->clockTestContext, START_VALUE); -#else - FS_CLK_CTIMER_LPC((fs_ctimer_t *)REF_TIMER_USED, (uint32_t *)&psSafetyClockTest->clockTestContext); -#endif - psSafetyClockTest->clockTestStart |= 1; /* to prevent checking of result before execution */ -} - -/*! - * @brief Clock test check function. - * - * This function can be called from any place of application. - * It calls the FS_CLK_Check function from the IEC60730 library - * In case of incorrect clock test result, it updates the safetyErrors variable accordingly. - * A node of program flow check is placed here. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psSafetyClockTest - The pointer of the Safety Clock test structure - * @param psSafetyProgramFlowTest - The pointer of the Program flow test structure - * - * @return None - */ -void SafetyClockTestCheck(safety_common_t *psSafetyCommon, fs_clock_test_t *psSafetyClockTest) -{ - if (psSafetyClockTest->clockTestStart) /* condition is valid after the first Systick interrupt */ - { - psSafetyCommon->CLOCK_test_result = - FS_CLK_Check(psSafetyClockTest->clockTestContext, psSafetyClockTest->clockTestLimitLow, - psSafetyClockTest->clockTestLimitHigh); - if (psSafetyCommon->CLOCK_test_result == FS_FAIL_CLK) - { - psSafetyCommon->safetyErrors |= CLOCK_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - runtime_test_finish_flag |= CLOCK_PASSED; /*Variable for development run test, useless for final application */ - } -} - -/*! - * @brief Initialization of Safety Flash test. - * - * Enable clock for HW CRC module. - * Inits the Flash test variables - * - * @param psFlashCrc - The pointer of the Flash CRC structure. - * @param psFlashConfig - The pointer of the Safety Flash test configuration structure. - * - * @return None - */ -void SafetyFlashTestInit(fs_flash_runtime_test_parameters_t *psFlashCrc, - fs_flash_configuration_parameters_t *psFlashConfig) -{ -#if HW_FLASH_TEST - /* Enable clock to CRC module */ - SYSCON->AHBCLKCTRLSET[0] = (1U << 21U); -#endif - -#if defined(__IAR_SYSTEMS_ICC__) /* IAR */ - psFlashConfig->startAddress = (uint32_t)&c_checksumStart; - psFlashConfig->endAddress = - 4 + (uint32_t)&c_checksumEnd; /* We must test also last adress, due to this reason +4 in IAR */ - psFlashConfig->checksum = __checksum; - -#else /* KEIL + MCUXpresso */ - psFlashConfig->startAddress = c_sfsCRC.ui32FlashStart; - psFlashConfig->endAddress = c_sfsCRC.ui32FlashEnd; - psFlashConfig->checksum = c_sfsCRC.ui32CRC; -#endif - - psFlashConfig->size = psFlashConfig->endAddress - psFlashConfig->startAddress ; - psFlashConfig->blockSize = FLASH_TEST_BLOCK_SIZE; - psFlashConfig->startConditionSeed = (uint32_t)FLASH_TEST_CONDITION_SEED; - - psFlashCrc->actualAddress = psFlashConfig->startAddress; /* start address */ - psFlashCrc->partCrc = psFlashConfig->startConditionSeed; /* initial seed */ - psFlashCrc->blockSize = - (psFlashConfig->size < psFlashConfig->blockSize) ? psFlashConfig->size : psFlashConfig->blockSize; -} - -/*! - * @brief After-reset Flash test. - * - * This function calls the flash test function from IEC60730 library. - * Safety-related part of the flash is tested at once. - * In case of incorrect flash test result, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psFlashConfig - The pointer of the Safety Flash test configuration structure. - * - * @return None - */ -void SafetyFlashAfterResetTest(safety_common_t *psSafetyCommon, fs_flash_configuration_parameters_t *psFlashConfig) -{ -#if HW_FLASH_TEST - #ifdef _LPC55S36_H_ - uint16_t after_reset_crc = psFlashConfig->startConditionSeed; - - psSafetyCommon->FLASH_test_result = FS_FLASH_C_HW16_K(psFlashConfig->startAddress, psFlashConfig->size, CRC_BASE, - &after_reset_crc); - if (((uint32_t)after_reset_crc != psFlashConfig->checksum) || (psSafetyCommon->FLASH_test_result != FS_PASS)) - { - psSafetyCommon->safetyErrors |= FLASH_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - #else - psSafetyCommon->FLASH_test_result = FS_CM33_FLASH_HW16(psFlashConfig->startAddress, psFlashConfig->size, CRC_BASE, - psFlashConfig->startConditionSeed); - - if ((uint32_t)psSafetyCommon->FLASH_test_result != psFlashConfig->checksum) - { - psSafetyCommon->safetyErrors |= FLASH_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - #endif - -#else - psSafetyCommon->FLASH_test_result = FS_CM33_FLASH_SW16(psFlashConfig->startAddress, psFlashConfig->size, (uint32_t)CRC_BASE, - psFlashConfig->startConditionSeed); - - if ((uint32_t)psSafetyCommon->FLASH_test_result != psFlashConfig->checksum) - { - psSafetyCommon->safetyErrors |= FLASH_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - -#endif - -} - -/*! - * @brief Runtime Flash test. - * - * This function calls the flash test function from IEC60730 library. - * Safety-related part of the flash is tested in sequence. - * Calls SafetyFlashTestHandling function. - * In case of incorrect flash test result, it updates the safetyErrors variable accordingly. - * A node of program flow check is placed here. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psFlashCrc - The pointer of the Flash CRC structure. - * @param psFlashConfig - The pointer of the Safety Flash test configuration structure. - * @param psSafetyProgramFlowTest - The pointer of the Program flow test structure - * - * @return None - */ -void SafetyFlashRuntimeTest(safety_common_t *psSafetyCommon, - fs_flash_runtime_test_parameters_t *psFlashCrc, - fs_flash_configuration_parameters_t *psFlashConfig) -{ - /* CRC calculation for a given block of Flash memory */ -#if HW_FLASH_TEST - #ifdef _LPC55S36_H_ - psSafetyCommon->FLASH_test_result = FS_FLASH_C_HW16_K(psFlashCrc->actualAddress, psFlashCrc->blockSize, CRC_BASE, (uint16_t *)&psFlashCrc->partCrc); - #else - psFlashCrc->partCrc = FS_CM33_FLASH_HW16(psFlashCrc->actualAddress, psFlashCrc->blockSize, CRC_BASE, psFlashCrc->partCrc); - #endif - -#else - psFlashCrc->partCrc = - FS_CM33_FLASH_SW16(psFlashCrc->actualAddress, psFlashCrc->blockSize, (uint32_t)CRC_BASE, psFlashCrc->partCrc); -#endif - - if (FS_FLASH_FAIL == SafetyFlashTestHandling(psFlashCrc, psFlashConfig)) - { - psSafetyCommon->safetyErrors |= FLASH_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -} - -/*! - * @brief Handling of flash test when used in runtime. - * - * The function updates the flash test variables, when flash is tested in sequence. - * - * @param __checksum - Constant that is calculated by Linker and stored in Flash. - * @param psFlashCrc - The pointer of the Flash CRC structure. - * @param psFlashConfig - The pointer of the Safety Flash test configuration structure. - * - * @return Result of the flash test: FS_ST_FLASH_FAIL or FS_ST_FLASH_PASS - */ -uint32_t SafetyFlashTestHandling(fs_flash_runtime_test_parameters_t *psFlashCrc, - fs_flash_configuration_parameters_t *psFlashConfig) -{ - psFlashCrc->actualAddress += psFlashCrc->blockSize; /* set the actual address for testing */ - if (psFlashCrc->actualAddress == psFlashConfig->endAddress) /* if all the addresses were tested... */ - { - if ((uint32_t)psFlashCrc->partCrc == - psFlashConfig->checksum) /* checksum must be same as calculated in linker */ - { - psFlashCrc->finalCrc = (uint32_t)psFlashCrc->partCrc; /* Store final CRC value */ - - psFlashCrc->partCrc = psFlashConfig->startConditionSeed; /* set start seed as input for CRC calculation */ - psFlashCrc->actualAddress = psFlashConfig->startAddress; /* set start address */ - psFlashCrc->blockSize = psFlashConfig->blockSize; /* size of block for CRC testing */ - - runtime_test_finish_flag |= - INVARIABLE_RUNTIME_PASSED; /*Variable for development run test, useless for final application */ - - return FS_FLASH_PASS; - } - else - { - return FS_FLASH_FAIL; - } - } - else - { - if (psFlashConfig->endAddress - psFlashCrc->actualAddress < - psFlashConfig->blockSize) /* set size of last block */ - { - psFlashCrc->blockSize = - psFlashConfig->endAddress - psFlashCrc->actualAddress; /* arrange the block size for remaining memory */ - } - return FS_FLASH_PASS; - } -} - -/*! - * @brief Initialization of Safety RAM test. - * - * Inits the RAM test variables - * - * @param psSafetyRamTest - The pointer of the RAM test structure. - * @param pSafetyRamStart - The pointer of the RAM test start address. - * @param pSafetyRamEnd - The pointer of the RAM test end address. - * - * @return None - */ -void SafetyRamTestInit(fs_ram_test_t *psSafetyRamTest, uint32_t *pSafetyRamStart, uint32_t *pSafetyRamEnd) -{ - psSafetyRamTest->ramTestStartAddress = (uint32_t)pSafetyRamStart; - psSafetyRamTest->ramTestEndAddress = (uint32_t)pSafetyRamEnd; - psSafetyRamTest->defaultBlockSize = RAM_TEST_BACKUP_SIZE; - psSafetyRamTest->blockSize = RAM_TEST_BLOCK_SIZE; - psSafetyRamTest->actualAddress = psSafetyRamTest->ramTestStartAddress; - -#if (defined(__GNUC__) && (__ARMCC_VERSION >= 6010050)) /* KEIL */ - psSafetyRamTest->backupAddress = (uint32_t)m_ram_test_backup; -#else /* IAR + MCUXpresso */ - psSafetyRamTest->backupAddress = (uint32_t)&m_ram_test_backup; -#endif -} - -/*! - * @brief After-reset RAM test. - * - * This function calls the RAM test function from IEC60730 library. - * Safety-related part of the RAM is tested at once. - * In case of incorrect RAM test result, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psSafetyRamTest - The pointer of the Safety RAM test structure. - * - * @return None - */ -void SafetyRamAfterResetTest(safety_common_t *psSafetyCommon, fs_ram_test_t *psSafetyRamTest) -{ - psSafetyCommon->RAM_test_result = FS_CM33_RAM_AfterReset( - psSafetyRamTest->ramTestStartAddress, psSafetyRamTest->ramTestEndAddress, psSafetyRamTest->defaultBlockSize, - psSafetyRamTest->backupAddress, FS_CM33_RAM_SegmentMarchC); - - if (psSafetyCommon->RAM_test_result == FS_FAIL_RAM) - { - psSafetyCommon->safetyErrors |= RAM_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -} - -/*! - * @brief Runtime RAM test. - * - * This function calls the RAM test function from IEC60730 library. - * Safety-related part of the RAM is tested in sequence. - * Calls SafetyFlashTestHandling function. - * In case of incorrect RAM test result, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psSafetyRamTest - The pointer of the Safety RAM test structure. - * - * @return None - */ -void SafetyRamRuntimeTest(safety_common_t *psSafetyCommon, fs_ram_test_t *psSafetyRamTest) -{ - psSafetyCommon->RAM_test_result = - FS_CM33_RAM_Runtime(psSafetyRamTest->ramTestStartAddress, psSafetyRamTest->ramTestEndAddress, - (uint32_t *)&psSafetyRamTest->actualAddress, psSafetyRamTest->blockSize, - psSafetyRamTest->backupAddress, FS_CM33_RAM_SegmentMarchX); - - if (psSafetyCommon->RAM_test_result == FS_FAIL_RAM) - { - psSafetyCommon->safetyErrors |= RAM_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - /* Test if whole RAM was tested, only for example validation */ - if (psSafetyRamTest->ramTestStartAddress == psSafetyRamTest->actualAddress) - runtime_test_finish_flag |= - VARIABLE_RUNTIME_PASSED; /*Variable for development run test, useless for final application */ -} - -/*! - * @brief Program counter test. - * - * This function uses two addresses: first is defined in linker file (fs_cm0_pc_object.o), - * second address comes as function argument (must be RAM address). - * Both addresses must be defined by the developer and suitable to test all of the possible PC bits. - * This test cannot be interrupted. - * In case of incorrect PC test result, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param pattern - RAM address, it can vary with multiple function calls - * - * @return None - */ -void SafetyPcTest(safety_common_t *psSafetyCommon, uint32_t pattern) -{ - psSafetyCommon->PC_test_result = FS_CM33_PC_Test(pattern, FS_PC_Object, (uint32_t *)PC_TEST_FLAG); - if (psSafetyCommon->PC_test_result == FS_FAIL_PC) - { - psSafetyCommon->safetyErrors |= PC_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -} - -/*! - * @brief After-reset CPU registers test. - * - * This function calls the CPU test functions from IEC60730 library. - * All the registers are tested at once. - * In case of incorrect flash test result, it updates the safetyErrors variable accordingly. - * See IEC60730 library documentation for CPU errors handling ! - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * - * @return None - */ -void SafetyCpuAfterResetTest(safety_common_t *psSafetyCommon) -{ - /* stacked CPU registers */ - psSafetyCommon->CPU_reg_test_result = FS_CM33_CPU_Register(); - if (psSafetyCommon->CPU_reg_test_result == FS_FAIL_CPU_REGISTER) - { - psSafetyCommon->safetyErrors |= CPU_REGISTERS_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - /* non-stacked CPU registers */ - psSafetyCommon->CPU_non_stacked_test_result = FS_CM33_CPU_NonStackedRegister(); - if (psSafetyCommon->CPU_non_stacked_test_result == FS_FAIL_CPU_NONSTACKED_REGISTER) - { - psSafetyCommon->safetyErrors |= CPU_NONSTACKED_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - /* SP main Secure */ - FS_CM33_CPU_SPmain_S(); - - /* SP main limit Secure */ - FS_CM33_CPU_SPmain_Limit_S(); - - /* SP process Secure */ - FS_CM33_CPU_SPprocess_S(); - - /* SP process limit Secure */ - FS_CM33_CPU_SPprocess_Limit_S(); - - /* PRIMASK Secure */ - psSafetyCommon->CPU_primask_s_test_result = FS_CM33_CPU_Primask_S(); - if (psSafetyCommon->CPU_primask_s_test_result == FS_FAIL_CPU_PRIMASK) - { - psSafetyCommon->safetyErrors |= CPU_PRIMASK_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - /* Special Secure */ - psSafetyCommon->CPU_special_s_test_result = FS_CM33_CPU_Special8PriorityLevels_S(); - if (psSafetyCommon->CPU_special_s_test_result == FS_FAIL_CPU_SPECIAL) - { - psSafetyCommon->safetyErrors |= CPU_SPECIAL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - -#if (defined(_LPC55S69_CM33_CORE0_H_) || defined(_LPC55S06_H_)) /* If device supports TrustZone */ - /* CONTROL Secure */ - psSafetyCommon->CPU_control_s_test_result = FS_CM33_CPU_Control_S(); - if (psSafetyCommon->CPU_control_s_test_result == FS_FAIL_CPU_CONTROL) - { - psSafetyCommon->safetyErrors |= CPU_CONTROL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - /* CONTROL Non-Secure */ - psSafetyCommon->CPU_control_ns_test_result = FS_CM33_CPU_Control_NS(); - if (psSafetyCommon->CPU_control_ns_test_result == FS_FAIL_CPU_CONTROL) - { - psSafetyCommon->safetyErrors |= CPU_CONTROL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - /* SP main Non-Secure */ - FS_CM33_CPU_SPmain_NS(); - - /* SP main limit Non-Secure */ - FS_CM33_CPU_SPmain_Limit_NS(); - - /* SP process Non-Secure */ - FS_CM33_CPU_SPprocess_NS(); - - /* SP process limit Non-Secure */ - FS_CM33_CPU_SPprocess_Limit_NS(); - - /* PRIMASK Non-Secure */ - psSafetyCommon->CPU_primask_ns_test_result = FS_CM33_CPU_Primask_NS(); - if (psSafetyCommon->CPU_primask_ns_test_result == FS_FAIL_CPU_PRIMASK) - { - psSafetyCommon->safetyErrors |= CPU_PRIMASK_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - /* Special Non-Secure */ - psSafetyCommon->CPU_special_ns_test_result = FS_CM33_CPU_Special8PriorityLevels_NS(); - if (psSafetyCommon->CPU_special_ns_test_result == FS_FAIL_CPU_SPECIAL) - { - psSafetyCommon->safetyErrors |= CPU_SPECIAL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -#else - /* CONTROL */ - psSafetyCommon->CPU_control_s_test_result = FS_CM33_CPU_Control(); - if (psSafetyCommon->CPU_control_s_test_result == FS_FAIL_CPU_CONTROL) - { - psSafetyCommon->safetyErrors |= CPU_CONTROL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -#endif /* If device supports TrustZone */ - -#if __FPU_PRESENT - psSafetyCommon->CPU_fpu_test_result = FS_CM33_CPU_Float1(); - if (psSafetyCommon->CPU_fpu_test_result == FS_FAIL_CPU_FLOAT_1) - { - psSafetyCommon->safetyErrors |= CPU_FLOAT_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - psSafetyCommon->CPU_fpu_test_result = FS_CM33_CPU_Float2(); - if (psSafetyCommon->CPU_fpu_test_result == FS_FAIL_CPU_FLOAT_2) - { - psSafetyCommon->safetyErrors |= CPU_FLOAT_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -#endif -} - -/*! - * @brief Uninterruptible test of CPU registers. - * - * This function calls the CPU test functions from IEC60730 library. - * The function must be called from an interrupt with highest priority. - * In case of incorrect flash test result, it updates the safetyErrors variable accordingly. - * See IEC60730 library documentation for CPU errors handling ! - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * - * @return None - */ -void SafetyCpuIsrTest(safety_common_t *psSafetyCommon) -{ - /* PRIMASK Secure */ - psSafetyCommon->CPU_primask_s_test_result = FS_CM33_CPU_Primask_S(); - if (psSafetyCommon->CPU_primask_s_test_result == FS_FAIL_CPU_PRIMASK) - { - psSafetyCommon->safetyErrors |= CPU_PRIMASK_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - /* Special Secure */ - psSafetyCommon->CPU_special_s_test_result = FS_CM33_CPU_Special8PriorityLevels_S(); - if (psSafetyCommon->CPU_special_s_test_result == FS_FAIL_CPU_SPECIAL) - { - psSafetyCommon->safetyErrors |= CPU_SPECIAL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - /* SP main Secure */ - FS_CM33_CPU_SPmain_S(); - - /* SP main limit Secure */ - FS_CM33_CPU_SPmain_Limit_S(); - -#if (defined(_LPC55S69_CM33_CORE0_H_) || defined(_LPC55S06_H_)) /* If device supports TrustZone */ - /* PRIMASK Non-Secure */ - psSafetyCommon->CPU_primask_ns_test_result = FS_CM33_CPU_Primask_NS(); - if (psSafetyCommon->CPU_primask_ns_test_result == FS_FAIL_CPU_PRIMASK) - { - psSafetyCommon->safetyErrors |= CPU_PRIMASK_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - /* Special Non-Secure */ - psSafetyCommon->CPU_special_ns_test_result = FS_CM33_CPU_Special8PriorityLevels_NS(); - if (psSafetyCommon->CPU_special_ns_test_result == FS_FAIL_CPU_SPECIAL) - { - psSafetyCommon->safetyErrors |= CPU_SPECIAL_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -#endif /* If device supports TrustZone */ -} - -/*! - * @brief Interruptible test of CPU registers. - * - * This function calls the CPU test functions from IEC60730 library. - * The function can be called from the background loop. - * In case of incorrect flash test result, it updates the safetyErrors variable accordingly. - * See IEC60730 library documentation for CPU errors handling ! - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * - * @return None - */ -void SafetyCpuBackgroundTest(safety_common_t *psSafetyCommon) -{ - psSafetyCommon->CPU_reg_test_result = FS_CM33_CPU_Register(); - if (psSafetyCommon->CPU_reg_test_result == FS_FAIL_CPU_REGISTER) - { - psSafetyCommon->safetyErrors |= CPU_REGISTERS_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - psSafetyCommon->CPU_non_stacked_test_result = FS_CM33_CPU_NonStackedRegister(); - if (psSafetyCommon->CPU_non_stacked_test_result == FS_FAIL_CPU_NONSTACKED_REGISTER) - { - psSafetyCommon->safetyErrors |= CPU_NONSTACKED_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -} - -/*! - * @brief Initialization of Stack test. - * - * This function calls FS_CM33_STACK_Init function from IEC60730 library. - * - * @param void - macros from header files define the parameters - * - * @return None - */ -void SafetyStackTestInit(void) -{ - FS_CM33_STACK_Init(STACK_TEST_PATTERN, c_stackTestFirstAddress, c_stackTestSecondAddress, STACK_TEST_BLOCK_SIZE); -} - -/*! - * @brief Stack test. - * - * This function calls the STACK test function from IEC60730 library - * Stack is tested for underflow and overflow condition. - * In case of incorrect Stack test result, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * - * @return None - */ -void SafetyStackTest(safety_common_t *psSafetyCommon) -{ - psSafetyCommon->STACK_test_result = FS_CM33_STACK_Test(STACK_TEST_PATTERN, c_stackTestFirstAddress, - c_stackTestSecondAddress, STACK_TEST_BLOCK_SIZE); - if (psSafetyCommon->STACK_test_result == FS_FAIL_STACK) - { - psSafetyCommon->safetyErrors |= STACK_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } -} - -/*! - * @brief SafetyDIOTestInit - * - * Check if every item of input array has valid pin definition. - * It also fills the pcr variable with appropriate address (pin control register address), which is used in DIO - * test. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param *pTestItems - Array of pointers to the DIO test items (pin definitions) - * - * @return None - */ -void SafetyDIOTestInit(safety_common_t *psSafetyCommon, fs_dio_test_lpc_t *pTestItems[]) -{ - /* Nothing to do here, just because of compatibility */ -} - -/*! - * @brief Digital Input/Output test. - * - * This function calls output test functions from IEC60730 library - * In case of incorrect test result, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param pTestedPin - The pointer to the DIO test item structure (pin definition) - * - * @return None - */ -void SafetyDigitalOutputTest(safety_common_t *psSafetyCommon, fs_dio_test_lpc_t *pTestedPin) -{ - PortSetup(pTestedPin->pPort_byte, pTestedPin->pPort_dir, pTestedPin->pPort_Iocon, PIN_DIRECTION_OUT, - pTestedPin->pinNum, PIN_PULL_UP, pTestedPin->gpio_clkc_shift); - - psSafetyCommon->DIO_output_test_result = FS_DIO_Output_LPC(pTestedPin, DIO_WAIT_CYCLE); - - if ((psSafetyCommon->DIO_output_test_result) != FS_PASS) - { - psSafetyCommon->safetyErrors |= DIO_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - PortSetup(pTestedPin->pPort_byte, pTestedPin->pPort_dir, pTestedPin->pPort_Iocon, PIN_DIRECTION_OUT, - pTestedPin->pinNum, PIN_PULL_UP, pTestedPin->gpio_clkc_shift); -} - -/*! - * @brief Digital Input/Output Short to Adjacent pins test - * - * This function calls digital io short test SET and GET functions from IEC60730 library - * In case of incorrect test conditions, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param *pTestedPin - The pointer to the DIO test item structure (pin definition) - * @param *pAdjPin - The pointer of the DIO test item structure for Adjacent pin (pin definition) - * @param pinValue - logical 1 or logical 0 will be set on the tested pin - * - * @return None - */ -void SafetyDigitalInputOutput_ShortAdjTest(safety_common_t *psSafetyCommon, - fs_dio_test_lpc_t *pTestedPin, - fs_dio_test_lpc_t *pAdjPin, - uint32_t pinValue) -{ - PortSetup(pTestedPin->pPort_byte, pTestedPin->pPort_dir, pTestedPin->pPort_Iocon, PIN_DIRECTION_IN, - pTestedPin->pinNum, PIN_PULL_UP, pTestedPin->gpio_clkc_shift); - PortSetup(pAdjPin->pPort_byte, pAdjPin->pPort_dir, pAdjPin->pPort_Iocon, PIN_DIRECTION_OUT, pAdjPin->pinNum, - PIN_PULL_UP, pAdjPin->gpio_clkc_shift); - - psSafetyCommon->DIO_short_test_result = FS_DIO_ShortToAdjSet_LPC(pTestedPin, pAdjPin, pinValue, DIO_BACKUP); - if ((psSafetyCommon->DIO_short_test_result) != FS_PASS) - { - psSafetyCommon->safetyErrors |= DIO_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - /* if needed, place some delay loop here */ - for (int i = 0; i < 200; i++) - { - __asm("nop"); - } - - psSafetyCommon->DIO_input_test_result = FS_DIO_InputExt_LPC(pTestedPin, pAdjPin, pinValue, DIO_BACKUP); - if ((psSafetyCommon->DIO_input_test_result) != FS_PASS) - { - psSafetyCommon->safetyErrors |= DIO_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - PortSetup(pTestedPin->pPort_byte, pTestedPin->pPort_dir, pTestedPin->pPort_Iocon, PIN_DIRECTION_OUT, - pTestedPin->pinNum, PIN_PULL_UP, pTestedPin->gpio_clkc_shift); - PortSetup(pAdjPin->pPort_byte, pAdjPin->pPort_dir, pAdjPin->pPort_Iocon, PIN_DIRECTION_OUT, pAdjPin->pinNum, - PIN_PULL_UP, pAdjPin->gpio_clkc_shift); -} - -/*! - * @brief Digital Input/Output Short to Supply test. - * - * This function calls digital io short test SET and GET functions from IEC60730 library - * In case of incorrect test conditions, it updates the safetyErrors variable accordingly. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param *pTestedPin - The pointer to the DIO test item structure (pin definition) - * @param polarity - macro DIO_SHORT_TO_VDD_TEST or DIO_SHORT_TO_GND_TEST - * - * @return None - */ -void SafetyDigitalInputOutput_ShortSupplyTest(safety_common_t *psSafetyCommon, - fs_dio_test_lpc_t *pTestedPin, - uint8_t polarity) -{ - PortSetup(pTestedPin->pPort_byte, pTestedPin->pPort_dir, pTestedPin->pPort_Iocon, PIN_DIRECTION_OUT, - pTestedPin->pinNum, PIN_PULL_UP, pTestedPin->gpio_clkc_shift); - - psSafetyCommon->DIO_short_test_result = FS_DIO_ShortToSupplySet_LPC(pTestedPin, polarity, DIO_BACKUP); - if ((psSafetyCommon->DIO_short_test_result) != FS_PASS) - { - SafetyErrorHandling(psSafetyCommon); - } - - /* if needed, place some delay loop here */ - for (int i = 0; i < 200; i++) - { - __asm("nop"); - } - - psSafetyCommon->DIO_input_test_result = FS_DIO_InputExt_LPC(pTestedPin, pTestedPin, polarity, DIO_BACKUP); - if ((psSafetyCommon->DIO_input_test_result) != FS_PASS) - { - psSafetyCommon->safetyErrors |= DIO_TEST_ERROR; - SafetyErrorHandling(psSafetyCommon); - } - - PortSetup(pTestedPin->pPort_byte, pTestedPin->pPort_dir, pTestedPin->pPort_Iocon, PIN_DIRECTION_OUT, - pTestedPin->pinNum, PIN_PULL_UP, pTestedPin->gpio_clkc_shift); -} - -/*! - * @brief ADC test. - * - * This function calls functions from IEC60730 library to perform ADC test. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * - * @return None - */ -void SafetyAnalogTest(safety_common_t *psSafetyCommon) -{ - static int index = 0; /* Iteration variable for going through all ADC test items */ - - /* If state is FS_AIO_SCAN_COMPLETE, check limits, otherwise function has not effect */ - psSafetyCommon->AIO_test_result = FS_AIO_LimitCheck(g_aio_safety_test_items[index]->RawResult, &(g_aio_safety_test_items[index]->Limits), &(g_aio_safety_test_items[index]->state)); - - switch (psSafetyCommon->AIO_test_result) - { - case FS_AIO_INIT: - FS_AIO_InputSet_A1(g_aio_safety_test_items[index], (fs_aio_a1_t *)TESTED_ADC); - break; - case FS_AIO_PROGRESS: - FS_AIO_ReadResult_A1(g_aio_safety_test_items[index], (fs_aio_a1_t *)TESTED_ADC); - break; - case FS_PASS: /* successfull execution of test, call the trigger function again */ - if( g_aio_safety_test_items[++index] == NULL) - { - index = 0; /* again first channel*/ - } - g_aio_safety_test_items[index]->state = FS_AIO_INIT; - break; - case FS_FAIL_AIO: - SafetyErrorHandling(psSafetyCommon); - break; - default: - __asm("NOP"); - break; - } -} - -/*! - * @brief Handling of the safety functions that must be called in interrupt routine. - * - * This function switches between safety functions that are called in interrupt - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * @param psSafetyRamTest - The pointer of the Safety RAM test structure. - * @param psSafetyRamStackTest - The pointer of the Safety RAM test structure for Stack area. - * - * @return None - */ -void SafetyIsrFunction(safety_common_t *psSafetyCommon, - fs_ram_test_t *psSafetyRamTest, - fs_ram_test_t *psSafetyRamStackTest) -{ - switch (psSafetyCommon->fastIsrSafetySwitch) - { - case 0: /* CPU registers test that cannot be interrupted */ - SafetyCpuIsrTest(psSafetyCommon); - break; - case 1: /* Program counter test */ -#if PC_TEST_ENABLED - SafetyPcTest(psSafetyCommon, PC_TEST_PATTERN); -#endif - break; - case 2: /* RAM March test for safety related RAM space */ - SafetyRamRuntimeTest(psSafetyCommon, psSafetyRamTest); - break; - case 3: /* RAM March test for memory occupied by the Stack */ - SafetyRamRuntimeTest(psSafetyCommon, psSafetyRamStackTest); - break; - default: - __asm("nop"); - break; - } - - psSafetyCommon->fastIsrSafetySwitch++; - if (psSafetyCommon->fastIsrSafetySwitch == 4) - psSafetyCommon->fastIsrSafetySwitch = 0; -} - -/* Function for example validation during development */ -void development_test_terminate(void) -{ - static uint8_t runtime_counter = 0; - if (runtime_test_finish_flag == ALL_RUNTIME_PASSED) - { - runtime_test_finish_flag = 0; - runtime_counter++; - if (runtime_counter == 10) - { - test_end(); /* Mark that runtime test run */ - } - } -} -/* This function is only for example validation during development */ -static void test_end(void) -{ - __asm("nop"); -} - -/*! - * @brief Handling with a safety error. - * - * This function stores the code of recognized safety error into the dedicated RAM memory that is deleted only - * after POR. If SAFETY_ERROR_ACTION macro is defined, interrupts are disabled and function waits for watchdog reset. - * - * @param psSafetyCommon - The pointer of the Common Safety structure - * - * @return None - */ -void SafetyErrorHandling(safety_common_t *psSafetyCommon) -{ - *SAFETY_ERROR_CODE = psSafetyCommon->safetyErrors; - test_end(); /* Only for example validation. Indicate that some error occured and test can be stoped */ -#if SAFETY_ERROR_ACTION - __asm("CPSID i"); /* disable interrupts */ - while (1) - { -#if FMSTR_SERIAL_ENABLE - - FMSTR_Poll(); /* Freemaster cummunication */ -#endif - - } - -#endif -} diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_cm33_lpc.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_cm33_lpc.h deleted file mode 100644 index c3320022c..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_cm33_lpc.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _SAFETY_CM33_LPC_H_ -#define _SAFETY_CM33_LPC_H_ - -#include "safety_config.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define CPU_TEST_ERROR 0x1 /* CPU test fault flag */ -#define FLASH_TEST_ERROR 0x2 /* Flash test fault flag */ -#define RAM_TEST_ERROR 0x4 /* RAM test fault flag */ -#define STACK_TEST_ERROR 0x8 /* Stack test fault flag */ -#define CLOCK_TEST_ERROR 0x10 /* Clock test fault flag */ -#define PC_TEST_ERROR 0x20 /* Program counter test fault flag */ -#define CPU_PRIMASK_ERROR 0x40 /* PRIMASK test fault flag */ -#define CPU_REGISTERS_ERROR 0x80 /* CPU registers test fault flag */ -#define CPU_NONSTACKED_ERROR 0x100 /* non-stacked CPU test fault flag */ -#define CPU_CONTROL_ERROR 0x200 /* CONTROL register test fault flag */ -#define CPU_SPECIAL_ERROR 0x400 /* BASEPRI and FAULTMASK test fault flag */ -#define CPU_FLOAT_ERROR 0x800 /* FLOAT test fault flag */ -#define DIO_TEST_ERROR 0x1000 /* DIO test fault flag */ -#define AIO_TEST_ERROR 0x2000 /* AIO test fault flag */ -#define TSI_TEST_ERROR 0x4000 /* TSI test fault flag */ -#define WDOG_TEST_ERROR 0x8000 /* WDOG test fault flag */ - -#define FS_FLASH_PASS 0x0 /* Flash test pass return */ -#define FS_FLASH_FAIL 0x00000301 /* Flash test fail return */ -#define FS_FLASH_PROGRESS 0x00000302 - -#define SAFETY_CFG_PC_ADDR0 0x1FFFFFF8 /* #1 test address for Program counter test */ -#define SAFETY_CFG_PC_ADDR1 0x20000006 /* #2 test address for Program counter test */ - -/*! @brief Safety tests */ -typedef struct _safety_common -{ - uint32_t fastIsrSafetySwitch; - uint32_t safetyErrors; - uint32_t CLOCK_test_result; - uint32_t FLASH_test_result; - uint32_t RAM_test_result; - uint32_t PC_test_result; - uint32_t CPU_primask_s_test_result; - uint32_t CPU_primask_ns_test_result; - uint32_t CPU_special_s_test_result; - uint32_t CPU_special_ns_test_result; - uint32_t CPU_reg_test_result; - uint32_t CPU_non_stacked_test_result; - uint32_t CPU_control_s_test_result; - uint32_t CPU_control_ns_test_result; - uint32_t CPU_fpu_test_result; - uint32_t STACK_test_result; - uint32_t DIO_input_test_result; - uint32_t DIO_output_test_result; - uint32_t DIO_short_test_result; - uint32_t AIO_test_result; - uint32_t TSI_test_result; - uint32_t WDOG_test_result; - uint32_t cpuClkFreq; - uint32_t mcgirclkFreq; - uint32_t lpoFreq; -} safety_common_t; - -/*! @brief Safety Watchdog test */ -typedef struct _wd_test -{ - uint64_t wdTestTemp1; - uint32_t wdTestExpected; - uint32_t wdTestTolerance; - uint32_t wdTestLptmrCnt; - uint32_t wdTestLimitHigh; - uint32_t wdTestLimitLow; - uint32_t watchdogResets; - uint32_t watchdogTimeoutCheck; - uint16_t watchdogRefreshRatio; -} wd_test_t; - -/*! @brief Safety Clock test */ -typedef struct _clock_test -{ - uint32_t clockTestContext; - uint32_t clockTestTolerance; - uint32_t clockTestExpected; - uint32_t clockTestLimitHigh; - uint32_t clockTestLimitLow; - uint32_t systickReloadValue; - uint16_t clockTestStart; -} fs_clock_test_t; - -/*! @brief Safety RAM test */ -typedef struct _ram_test -{ - uint32_t ramTestStartAddress; - uint32_t ramTestEndAddress; - uint32_t blockSize; - uint32_t actualAddress; - uint32_t defaultBlockSize; - uint32_t backupAddress; -} fs_ram_test_t; - -/*! @brief Safety Flash test runtime */ -typedef struct _flash_runtime_test_parameters -{ - uint32_t blockSize; /* size of tested block */ - uint32_t actualAddress; /* actual start address for crc module */ - uint32_t partCrc; /* seed in begin, particular crc result in process, crc result in final*/ - uint32_t finalCrc; /* CRC value after all blocsk is calculated */ -} fs_flash_runtime_test_parameters_t; - -/*! @brief Safety Flash test parameters */ -typedef struct _flash_configuration_parameters -{ - uint32_t startConditionSeed; - uint32_t startAddress; - uint32_t endAddress; - uint32_t size; - uint32_t blockSize; - uint32_t checksum; -} fs_flash_configuration_parameters_t; - -/* CRC structure containing information for the offline CRC calculation. */ -typedef struct _fs_crc -{ - uint16_t ui16Start; - uint32_t ui32FlashStart __attribute__((packed)); - uint32_t ui32FlashEnd __attribute__((packed)); - uint32_t ui32CRC __attribute__((packed)); - uint16_t ui16End __attribute__((packed)); -} fs_crc_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * @name Safety Class B tests handling functions - * @{ - */ - -/******************************************************************************* - * API - ******************************************************************************/ -void SafetyWatchdogTest(safety_common_t *psSafetyCommon, wd_test_t *psSafetyWdTest); -void SafetyWatchdogRuntimeRefresh(wd_test_t *psSafetyWdTest); -void SafetyClockTestInit(safety_common_t *psSafetyCommon, fs_clock_test_t *psSafetyClockTest); -void SafetyClockTestIsr(fs_clock_test_t *psSafetyClockTest); -void SafetyClockTestCheck(safety_common_t *psSafetyCommon, fs_clock_test_t *psSafetyClockTest); -void SafetyFlashTestInit(fs_flash_runtime_test_parameters_t *psFlashCrc, - fs_flash_configuration_parameters_t *psFlashConfig); -void SafetyFlashAfterResetTest(safety_common_t *psSafetyCommon, fs_flash_configuration_parameters_t *psFlashConfig); -void SafetyFlashRuntimeTest(safety_common_t *psSafetyCommon, - fs_flash_runtime_test_parameters_t *psFlashCrc, - fs_flash_configuration_parameters_t *psFlashConfig); -uint32_t SafetyFlashTestHandling(fs_flash_runtime_test_parameters_t *psFlashCrc, - fs_flash_configuration_parameters_t *psFlashConfig); -void SafetyRamTestInit(fs_ram_test_t *psSafetyRamTest, uint32_t *pSafetyRamStart, uint32_t *pSafetyRamEnd); -void SafetyRamAfterResetTest(safety_common_t *psSafetyCommon, fs_ram_test_t *psSafetyRamTest); -void SafetyRamRuntimeTest(safety_common_t *psSafetyCommon, fs_ram_test_t *psSafetyRamTest); -void SafetyPcTest(safety_common_t *psSafetyCommon, uint32_t pattern); -void SafetyCpuAfterResetTest(safety_common_t *psSafetyCommon); -void SafetyCpuIsrTest(safety_common_t *psSafetyCommon); -void SafetyCpuBackgroundTest(safety_common_t *psSafetyCommon); -void SafetyStackTestInit(void); -void SafetyStackTest(safety_common_t *psSafetyCommon); - -void SafetyDIOTestInit(safety_common_t *psSafetyCommon, fs_dio_test_lpc_t *pTestItems[]); -void SafetyDigitalOutputTest(safety_common_t *psSafetyCommon, fs_dio_test_lpc_t *pTestedPin); -void SafetyDigitalInputOutput_ShortSupplyTest(safety_common_t *psSafetyCommon, - fs_dio_test_lpc_t *pTestedPin, - uint8_t polarity); -void SafetyDigitalInputOutput_ShortAdjTest(safety_common_t *psSafetyCommon, - fs_dio_test_lpc_t *pTestedPin, - fs_dio_test_lpc_t *pAdjPin, - uint32_t PinValue); - -void SafetyAnalogTest(safety_common_t *psSafetyCommon); - -void SafetyIsrFunction(safety_common_t *psSafetyCommon, - fs_ram_test_t *psSafetyRamTest, - fs_ram_test_t *psSafetyRamStackTest); - -void development_test_terminate(void); -void SafetyErrorHandling(safety_common_t *psSafetyCommon); - -#ifdef __cplusplus -} -#endif - -#endif /* _SAFETY_CM33_LPC_H_ */ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_config.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_config.h deleted file mode 100644 index 0907c33c6..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_config.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _SAFETY_CONFIG_H_ -#define _SAFETY_CONFIG_H_ - -#include "LPC55S69_cm33_core0.h" -#include "iec60730b.h" -#include "iec60730b_core.h" -#include "safety_test_items.h" -#include "project_setup_lpcxpresso55s69.h" -#include "safety_cm33_lpc.h" -#include "pin_mux.h" - -#ifndef NULL -#ifdef __cplusplus -#define NULL (0) -#else -#define NULL ((void *)0) -#endif -#endif - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/* This macro enables infinity while loop in SafetyErrorHandling() function */ -#define SAFETY_ERROR_ACTION 1 - -/* TEST SWITCHES - for debugging it is better to turn the flash test and watchdog OFF */ -#define ADC_TEST_ENABLED 0 -#define CLOCK_TEST_ENABLED 1 -#define DIO_TEST_ENABLED 1 -#define FLASH_TEST_ENABLED 1 -#define RAM_TEST_ENABLED 1 -#define PC_TEST_ENABLED 1 -#define WATCHDOG_ENABLED 0 -#define FMSTR_SERIAL_ENABLE 1 - -/* CLOCK test */ -#define USE_WKT 0 /*USE CTIMER = 0 USE WKT = 1 */ -#define CLOCK_ERROR_HANDLING 1 -#define REF_TIMER_USED CTIMER0 -#define REF_TIMER_CLOCK_FREQUENCY 96e06 -#define SYSTICK_RELOAD_VALUE 150000 -#define ISR_FREQUENCY 1000 /* Hz */ -#define CLOCK_TEST_TOLERANCE 20 /* % */ - -/********* Watchdog *********/ -#define WDOG_REF_TIMER_BASE CTIMER0 -#define RESET_DETECT_REGISTER &(PMC->AOREG1) -#define RESET_DETECT_MASK 0x10U -#define REG_WIDE FS_WDOG_SRS_WIDE_32b - -#define Watchdog_refresh \ - WWDT->FEED = 0xAA; \ - WWDT->FEED = 0x55 -#define USED_WDOG WWDT - -#define ENDLESS_LOOP_ENABLE 1 /* set 1 or 0 */ -#define WATCHDOG_RESETS_LIMIT 1000 -#define WATCHDOG_REFRESH_RATIO 1 -#define WATCHDOG_TIMEOUT_VALUE 500 /* 2ms refresh period (500 / 250kHz) */ -#define WD_REF_TIMER_CLOCK_FREQUENCY 96e06 -#define WATCHDOG_CLOCK 250000 -#define WD_TEST_TOLERANCE 40 /* % */ - -#define WD_RUN_TEST_CONDITION \ - (PMC_AOREG1_POR_MASK | PMC_AOREG1_PADRESET_MASK | PMC_AOREG1_BODRESET_MASK | PMC_AOREG1_SYSTEMRESET_MASK | \ - PMC_AOREG1_DPDRESET_WAKEUPIO_MASK | PMC_AOREG1_DPDRESET_RTC_MASK | PMC_AOREG1_DPDRESET_OSTIMER_MASK) -#define WD_CHECK_TEST_CONDITION PMC_AOREG1_WDTRESET_MASK -/********* Watchdog END *********/ - -/* GPIO macros */ -#define PIN_DIRECTION_IN 0 -#define PIN_DIRECTION_OUT 1 - -#define PIN_PULL_DISABLE 0 -#define PIN_PULL_DOWN 1 -#define PIN_PULL_UP 2 - -#define LOGICAL_ONE 1 -#define LOGICAL_ZERO 0 - -/* Dio port settings */ -#define DIO_EXPECTED_VALUE 0 - -#define DIO_WAIT_CYCLE 75 - -#define DIO_BACKUP_ENABLE 1 -#define DIO_BACKUP_DISABLE 0 -#define DIO_BACKUP DIO_BACKUP_ENABLE - -#define DIO_SHORT_TO_GND_TEST 1 -#define DIO_SHORT_TO_VDD_TEST 0 - -/* Program Counter TEST */ -#define PC_TEST_PATTERN 0x20001000 /* test address for Program counter test (in RAM region) */ - -/* UART macros */ -#define UART_BAUD_RATE 9600 - -/* FLASH TEST MACROS */ -#define HW_FLASH_TEST 1 /* Use HW = 1 SW = 0 flash TEST*/ -#define FLASH_TEST_BLOCK_SIZE 0x20 -#define CRC_BASE CRC_ENGINE_BASE -#define FLASH_TEST_CONDITION_SEED 0x0000 /* 0xFFFFFFFF CRC32, 0x0000 CRC16 */ - -#if defined(__GNUC__) || defined(__ARMCC_VERSION) -/*! @note The following flash test settings must be in consistence with - "User AFTER BUILD = srec_cat!*/ -/* The CRC16 of safety-related FLASH memory. */ -#define FS_CFG_FLASH_TST_CRC (0xFFFFU) -#endif - -#define RAM_TEST_BLOCK_SIZE 0x4 /* size of block for runtime testing */ - -#if defined(__IAR_SYSTEMS_ICC__) || (defined(__GNUC__) && (__ARMCC_VERSION >= 6010050)) /* IAR + KEIL */ -#define RAM_TEST_BACKUP_SIZE 0x20 /* must fit with the setup from linker configuration file */ -#define STACK_TEST_BLOCK_SIZE 0x10 /* must fit with the setup from linker configuration file */ -#endif - -#define STACK_TEST_PATTERN 0x77777777 - -#define TESTED_ADC ADC0 /*which ADC is use for AIO test*/ -#define ADC_RESOLUTION 16 -#define ADC_REFERENCE 3.3 -#define ADC_BANDGAP_LEVEL 1.65 /* depends on power supply configuration */ -#define ADC_DEVIATION_PERCENT 20 - - -#endif /* _SAFETY_CONFIG_H_ */ diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_iec60730b_core0_v3_10.xml b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_iec60730b_core0_v3_10.xml deleted file mode 100644 index 321175cc6..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_iec60730b_core0_v3_10.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - arm-none-eabi-objcopy -v -O ihex "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.hex"; ${ProjDirPath}/crc_hex.bat -${ConfigName}/${BuildArtifactFileBaseName}.hex -${ConfigName}/${BuildArtifactFileBaseName}_crc.hex -tools\\srecord\\srec_cat.exe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_test_items.c b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_test_items.c deleted file mode 100644 index 96d850f30..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_test_items.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "safety_config.h" - -#if defined(__IAR_SYSTEMS_ICC__) -#pragma location = ".safety_ram" -#endif - -/******************************************************************************* - * * - * STRUCTURE FOR DIO Initialization and TEST * - * * - *******************************************************************************/ - -fs_dio_test_lpc_t dio_safety_test_item_0 = /* P1_8 */ - {.iocon_mode_shift = IOCON_PIO_MODE_SHIFT, /*Device depend*/ - .pPort_byte = (uint8_t *)&(GPIO->B[1][8]), /*adress of byte register in GPIO*/ - .pPort_dir = (uint32_t *)&(GPIO->DIR[1]), /* asress of dir1 register*/ - .pPort_Iocon = (uint32_t *)&(IOCON->PIO[1][8]), /* Adress of concrete IOCON register*/ - .pinNum = 8, /*Position in DIR registor*/ - .gpio_clkc_shift = SYSCON_AHBCLKCTRL0_GPIO1_SHIFT}; - -fs_dio_test_lpc_t dio_safety_test_item_1 = /* P1_9 */ - {.iocon_mode_shift = IOCON_PIO_MODE_SHIFT, /* Device depend */ - .pPort_byte = (uint8_t *)&(GPIO->B[1][9]), /*adress of byte register in GPIO*/ - .pPort_dir = (uint32_t *)&(GPIO->DIR[1]), /* asress of dir1 register*/ - .pPort_Iocon = (uint32_t *)&(IOCON->PIO[1][9]), /* Adress of concrete IOCON register*/ - - .pinNum = 9, /*Position in DIR registor*/ - .gpio_clkc_shift = SYSCON_AHBCLKCTRL0_GPIO1_SHIFT}; - -/* NULL terminated array of pointers to dio_test_t items for safety DIO test */ -fs_dio_test_lpc_t *g_dio_safety_test_items[] = {&dio_safety_test_item_0, &dio_safety_test_item_1, NULL}; - -/******************************************************************************* - * * - * STRUCTURE FOR AIO TEST * - * * - *******************************************************************************/ -#define ADC_MAX ((1 << (ADC_RESOLUTION)) - 1) -#define ADC_BANDGAP_LEVEL_RAW (((ADC_BANDGAP_LEVEL) * (ADC_MAX)) / (ADC_REFERENCE)) -#define ADC_MIN_LIMIT(val) (uint16_t)(((val) * (100 - ADC_DEVIATION_PERCENT)) / 100) -#define ADC_MAX_LIMIT(val) (uint16_t)(((val) * (100 + ADC_DEVIATION_PERCENT)) / 100) - -fs_aio_test_a1_t aio_safety_test_item_VL = -{ - .AdcChannel = 0, - .commandBuffer = 1, - .SideSelect = 0,/* 0 = A side, 1 = B side*/ - .softwareTriggerEvent = 0, /* write to the SWTRIG register select between 0 - 3, SWTRIG[SWT0] is associated with TCTRL0 */ - .Limits.low = (uint32_t)ADC_MIN_LIMIT(0), - .Limits.high = (uint32_t)ADC_MAX_LIMIT(60), - .state = FS_AIO_INIT -}; - -fs_aio_test_a1_t aio_safety_test_item_VH = -{ - .AdcChannel = 1, - .commandBuffer = 1, - .SideSelect = 0,/* 0 = A side, 1 = B side*/ - .softwareTriggerEvent = 0, /* write to the SWTRIG register select between 0 - 3, SWTRIG[SWT0] is associated with TCTRL0 */ - .Limits.low = (uint32_t)ADC_MIN_LIMIT(ADC_MAX), - .Limits.high = (uint32_t)ADC_MAX_LIMIT(ADC_MAX), - .state = FS_AIO_INIT -}; - -fs_aio_test_a1_t aio_safety_test_item_BG = -{ - .AdcChannel = 2, - .commandBuffer = 1, - .SideSelect = 0,/* 0 = A side, 1 = B side*/ - .softwareTriggerEvent = 0, /* write to the SWTRIG register select between 0 - 3, SWTRIG[SWT0] is associated with TCTRL0 */ - .Limits.low = (uint32_t)ADC_MIN_LIMIT(ADC_BANDGAP_LEVEL_RAW), - .Limits.high = (uint32_t)ADC_MAX_LIMIT(ADC_BANDGAP_LEVEL_RAW), - .state = FS_AIO_INIT -}; - -/* NULL terminated array of pointers to fs_aio_test_a2346_t items for safety AIO test */ -fs_aio_test_a1_t *g_aio_safety_test_items[] = {&aio_safety_test_item_VL, - &aio_safety_test_item_VH, - &aio_safety_test_item_BG, - NULL}; diff --git a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_test_items.h b/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_test_items.h deleted file mode 100644 index 09e653118..000000000 --- a/boards/lpcxpresso55s69/demo_apps/safety_iec60730b/cm33_core0/safety_test_items.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2021 NXP. - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _SAFETY_TEST_ITEMS_H_ -#define _SAFETY_TEST_ITEMS_H_ - -/* NULL terminated array of pointers to fs_dio_test_lpc_t items for safety DIO test */ -extern fs_dio_test_lpc_t *g_dio_safety_test_items[]; - -/* NULL terminated array of pointers to aio_test_t items for safety AIO test */ -extern fs_aio_test_a1_t *g_aio_safety_test_items[]; - -#endif diff --git a/boards/lpcxpresso55s69/demo_apps/shell/cm33_core0/shell.bin b/boards/lpcxpresso55s69/demo_apps/shell/cm33_core0/shell.bin index aeeb0faa8..906cb0bbe 100755 Binary files a/boards/lpcxpresso55s69/demo_apps/shell/cm33_core0/shell.bin and b/boards/lpcxpresso55s69/demo_apps/shell/cm33_core0/shell.bin differ diff --git a/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout.bin b/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout.bin new file mode 100755 index 000000000..318d58e15 Binary files /dev/null and b/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout.bin differ diff --git a/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout_v3_10.xml b/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout_v3_10.xml index 0fd2dae05..43540f1d4 100644 --- a/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout_v3_10.xml +++ b/boards/lpcxpresso55s69/driver_examples/clockout/cm33_core0/clockout_v3_10.xml @@ -111,7 +111,7 @@