diff --git a/.github/workflows/example_tester.yml b/.github/workflows/example_tester.yml new file mode 100644 index 0000000000..854c1c83f4 --- /dev/null +++ b/.github/workflows/example_tester.yml @@ -0,0 +1,100 @@ +############################################################################### +# +# Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by +# Analog Devices, Inc.), +# Copyright (C) 2023-2024 Analog Devices, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + +name: Basic Examples Test + +# Cancels workflows in progress that are in the same PR +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + pull_request: + branches: + - main + paths-ignore: + # Any files in a docs directory anywhere in the repository. + - "**/docs/**" + - "**/Documentation/**" + # Any README.md file anywhere in the repository. + - "**/README.md" + # Any .pdf file anywhere in the repository. + - "**/*.pdf" + # Any .yml file anywhere in the repository. + # can comment this out when testing changes to THIS yml file + - "**/*.yml" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + +env: + MAXIM_PATH: '' + +jobs: + Example_Tests: + # The type of runner that the job will run on + runs-on: [self-hosted] + if: github.event.pull_request.draft == false + + + steps: + + - uses: actions/checkout@v4 + with: + submodules: false + repository: analogdevicesinc/msdk + fetch-depth: 0 + + - name: Set MAXIM_PATH + run: | + echo "MAXIM_PATH=$(pwd)" >> $GITHUB_ENV + printenv + + - name: Lock Boards + uses: Analog-Devices-MSDK/btm-ci-scripts/actions/lock-board@v1.1 + with: + boards: | + max32690_board_ex + lock: true + timeout: 900 # Attempt to lock for an hour + + - name: run_example_test + run: | + bash .github/workflows/scripts/example_tester.sh max32690_board_ex + + - name: Unlock Boards + if: always() + uses: Analog-Devices-MSDK/btm-ci-scripts/actions/lock-board@v1.1 + with: + lock: false + all_owned: true + + + + + + + + + + diff --git a/.github/workflows/scripts/example_tester.sh b/.github/workflows/scripts/example_tester.sh new file mode 100644 index 0000000000..2d3211d263 --- /dev/null +++ b/.github/workflows/scripts/example_tester.sh @@ -0,0 +1,515 @@ +#! /usr/bin/bash + +<<"CONFIGURATION" +The following is the configuration for hardware (max32690): +remove JP7(RX_EN) and install JP8(TX_EN) headers +Install headers JP9 and JP10 to SDA and SCL respectively. +You must connect P1.8->P2.8 (SCL) and P1.7->P2.7 (SCL). +Connect pins P2.12->P1.9 for UART test +connect MISO (P2.27) and MOSI (P2.28) pins +Apply an input voltage between 0 and 1.25V to pin labeled 0 of the JH6 (Analog) header. for ADC +CONFIGURATION + + +# variable for configuration +baudRate=115200 +timeLimit=5 +timeLimitICC=30 #ICC needs around 20s to finish the test +boardVersion=max32690 +#boardName=max32690-1 +boardName=$1 +uartPort=$(resource_manager -g $boardName.console_port) +target_uc=$(resource_manager -g $boardName.target) +#MAXIM_PATH=/home/jcai/Workspace/msdk +Path=$MAXIM_PATH/Examples/$target_uc + +# variable for testing purpose +tempFile=.temp.txt +result_UART_INTERRUPT='not tested' +result_UART_DMA='not tested' +result_HelloWorld='not tested' +result_HelloWorld_Cpp='not tested' +result_TRNG='not tested' +result_I2C='not tested' +result_SPI_POLLING='not tested' +result_SPI_INTERRUPT='not tested' +result_SPI_DMA='not tested' +result_SPI_V2_POLLING='not tested' #this is only for max32690 +result_SPI_V2_INTERRUPT='not tested' #this is only for max32690 +result_SPI_V2_DMA='not tested' #this is only for max32690 +result_ICC='not tested' +result_Hash='not tested' +result_DMA='not tested' +result_CRC='not tested' +result_ADC_POLLING='not tested' +result_ADC_INTERRUPT='not tested' +result_ADC_DMA='not tested' +result_Lib_Gen='not tested' +result_Lib_Use='not tested' + +function init() { + # print the testcase + echo "-------------------------------------------------------------------" + echo "Start testing $1 Example:" + # clean the temp file + rm -rf $tempFile + sleep 2 + + # do initialization, compiler and flash the code + testName=$1 + if [[ $testName != Library_Use ]] + then + make -C $Path/$testName distclean + + if [[ $1 = "SPI" || $1 = "SPI_v2" || $1 = "ADC" || $1 = "UART" ]]; + then + make -C $Path/$testName METHOD=$2 + else + make -C $Path/$testName + fi + fi + + if [[ $testName != Library_Generate && $testName != Library_Use ]] + then + stty -F $uartPort $baudRate + ocdflash $boardName $Path/$testName/build/$boardVersion.elf + if [[ $testName = ICC ]] + then + timeout $timeLimitICC cat $uartPort > $tempFile + else + timeout $timeLimit cat $uartPort > $tempFile + fi + fi +} + +function test_Hello_World() { + init Hello_World + + # start testing the output + grep "Hello World!" $tempFile + if [[ $? -eq 0 ]]; + then + result_HelloWorld='pass' + else + result_HelloWorld='fail' + fi + + printf "Test result for Hello_World: $result_HelloWorld\n" + +} + +function test_Hello_World_Cpp() { + init Hello_World_Cpp + + # start testing the output + grep "C++ Hello World Example" $tempFile + if [[ $? -eq 0 ]]; + then + result_HelloWorld_Cpp='pass' + else + result_HelloWorld_Cpp='fail' + fi + + printf "Test result for Hello_World_Cpp: $result_HelloWorld_Cpp\n" + +} + +function test_UART() { + init UART INTERRUPT + + # start testing the output + grep "Example Succeeded" $tempFile + if [[ $? -eq 0 ]]; + then + result_UART_INTERRUPT='pass' + else + result_UART_INTERRUPT='fail' + fi + + printf "Test result for UART_INTERRUPT: $result_UART_INTERRUPT\n" +: ' + init UART DMA + + # start testing the output + grep "Example Succeeded" $tempFile + if [[ $? -eq 0 ]]; + then + result_UART_DMA='pass' + else + result_UART_DMA='fail' + fi + + printf "Test result for UART_DMA: $result_UART_DMA\n" +' +} + +function test_TRNG() { + init TRNG + + # start testing the output + grep "Test Complete" $tempFile + if [[ $? -eq 0 ]]; + then + result_TRNG='pass' + else + result_TRNG='fail' + fi + + printf "Test result for TRNG: $result_TRNG\n" + +} + + +function test_I2C() { + init I2C + + # start testing the output + grep "I2C Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_I2C='pass' + else + result_I2C='fail' + fi + + printf "Test result for I2C: $result_I2C\n" + +} + +function test_SPI() { + init SPI MASTERSYNC + + # start testing the output + grep "16 Bits Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_SPI_POLLING='pass' + else + result_SPI_POLLING='fail' + fi + + printf "Test result for SPI_POLLING: $result_SPI_POLLING\n" + + init SPI MASTERASYNC + + # start testing the output + grep "16 Bits Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_SPI_INTERRUPT='pass' + else + result_SPI_INTERRUPT='fail' + fi + + printf "Test result for SPI_INTERRUPT: $result_SPI_INTERRUPT\n" + + init SPI MASTERDMA + + # start testing the output + grep "16 Bits Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_SPI_DMA='pass' + else + result_SPI_DMA='fail' + fi + + printf "Test result for SPI_DMA: $result_SPI_DMA\n" + +} + +function test_SPI_V2() { + init SPI_v2 CONTROLLER_SYNC + + # start testing the output + grep "16 Bits Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_SPI_V2_POLLING='pass' + else + result_SPI_V2_POLLING='fail' + fi + + printf "Test result for SPI_v2_POLLING: $result_SPI_V2_POLLING\n" + + init SPI_v2 CONTROLLER_ASYNC + + # start testing the output + grep "16 Bits Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_SPI_V2_INTERRUPT='pass' + else + result_SPI_V2_INTERRUPT='fail' + fi + + printf "Test result for SPI_v2_INTERRUPT: $result_SPI_V2_INTERRUPT\n" + + init SPI_v2 CONTROLLER_DMA + + # start testing the output + grep "16 Bits Transaction Successful" $tempFile + if [[ $? -eq 0 ]]; + then + result_SPI_V2_DMA='pass' + else + result_SPI_V2_DMA='fail' + fi + + printf "Test result for SPI_v2_DMA: $result_SPI_V2_DMA\n" + +} +function test_ICC() { + init ICC + + # start testing the output + grep "Example Succeeded" $tempFile + if [[ $? -eq 0 ]]; + then + result_ICC='pass' + else + result_ICC='fail' + fi + + printf "Test result for ICC: $result_ICC\n" + +} + +function test_Hash() { + init Hash + + # start testing the output + grep "Example Succeeded" $tempFile + if [[ $? -eq 0 ]]; + then + result_Hash='pass' + else + result_Hash='fail' + fi + + printf "Test result for Hash: $result_Hash\n" + +} + +function test_DMA() { + init DMA + + # start testing the output + grep "Example Succeeded" $tempFile + if [[ $? -eq 0 ]]; + then + result_DMA='pass' + else + result_DMA='fail' + fi + + printf "Test result for DMA: $result_DMA\n" + +} + +function test_CRC() { + init CRC + + # start testing the output + grep "Example Succeeded" $tempFile + if [[ $? -eq 0 ]]; + then + result_CRC='pass' + else + result_CRC='fail' + fi + + printf "Test result for CRC: $result_CRC\n" + +} + + +function test_ADC() { + + init ADC POLLING + + # start testing the output + result_ADC_POLLING='pass' + grep "Running Single Channel Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_POLLING='fail' + fi + + grep "Running Temperature Sensor Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_POLLING='fail' + fi + + grep "Running Multi Channel Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_POLLING='fail' + fi + printf "Test result for ADC_POLLING: $result_ADC_POLLING\n" + + init ADC INTERRUPT + + # start testing the output + result_ADC_INTERRUPT='pass' + grep "Running Single Channel Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_INTERRUPT='fail' + fi + + grep "Running Temperature Sensor Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_INTERRUPT='fail' + fi + + grep "Running Multi Channel Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_INTERRUPT='fail' + fi + printf "Test result for ADC_INTERRUPT: $result_ADC_INTERRUPT\n" + + init ADC DMA + + # start testing the output + result_ADC_DMA='pass' + grep "Running Single Channel Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_DMA='fail' + fi + + grep "Running Temperature Sensor Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_DMA='fail' + fi + + grep "Running Multi Channel Example" $tempFile + if [[ $? -ne 0 ]]; + then + result_ADC_DMA='fail' + fi + printf "Test result for ADC_DMA: $result_ADC_DMA\n" +} + +function test_Lib_Gen() { + init Library_Generate + + # start testing the output + find $Path/$testName/build/$boardVersion.a + if [[ $? -eq 0 ]]; + then + result_Lib_Gen='pass' + else + result_Lib_Gen='fail' + fi + + printf "Test result for Library_Generate: $result_Lib_Gen\n" + +} + +function test_Lib_Use() { + init Library_Use + + # start testing the output + make -C $Path/$testName distclean + make -C $Path/$testName + if [[ $? -eq 0 ]]; + then + result_Lib_Use='pass' + else + result_Lib_Use='fail' + fi + + printf "Test result for Library_Use: $result_Lib_Use\n" + +} + +function summary() { + printf "*************************Result Summary****************************\n" + printf "Test result for Hello_World: $result_HelloWorld\n" + printf "Test result for Hello_World_Cpp: $result_HelloWorld_Cpp\n" + printf "Test result for UART_INTERRUPT: $result_UART_INTERRUPT\n" + printf "Test result for UART_DMA: $result_UART_DMA\n" + printf "Test result for TRNG: $result_TRNG\n" + printf "Test result for I2C: $result_I2C\n" + printf "Test result for SPI_POLLING: $result_SPI_POLLING\n" + printf "Test result for SPI_INTERRUPT: $result_SPI_INTERRUPT\n" + printf "Test result for SPI_DMA: $result_SPI_DMA\n" + if [[ $boardVersion = max32690 ]] + then + printf "Test result for SPI_v2_POLLING: $result_SPI_V2_POLLING\n" + printf "Test result for SPI_v2_INTERRUPT: $result_SPI_V2_INTERRUPT\n" + printf "Test result for SPI_v2_DMA: $result_SPI_V2_DMA\n" + fi + printf "Test result for ICC: $result_ICC\n" + printf "Test result for Hash: $result_Hash\n" + printf "Test result for DMA: $result_DMA\n" + printf "Test result for CRC: $result_CRC\n" + printf "Test result for ADC_POLLING: $result_ADC_POLLING\n" + printf "Test result for ADC_INTERRUPT: $result_ADC_INTERRUPT\n" + printf "Test result for ADC_DMA: $result_ADC_DMA\n" + printf "Test result for Library_Generate: $result_Lib_Gen\n" + printf "Test result for Library_Use: $result_Lib_Use\n" + +} + +function main() { + test_UART + if [[ $result_UART_INTERRUPT = 'fail' ]] + then + printf "Since UART INTERRUPT test fails, example test stops. " + return + fi + test_Hello_World + test_Hello_World_Cpp + test_TRNG + #test_I2C + test_SPI + if [[ $boardVersion = max32690 ]] + then + test_SPI_V2 + fi + test_Hash + test_DMA + test_CRC + test_ADC + test_ICC + test_Lib_Gen + test_Lib_Use + + summary + # clean the temp file + rm -rf $tempFile +} + +main +if [[ $result_UART_INTERRUPT = "fail" || + $result_UART_DMA = "fail" || + $result_HelloWorld = "fail" || + $result_HelloWorld_Cpp = "fail" || + $result_TRNG = "fail" || + $result_I2C = "fail" || + $result_SPI_POLLING = "fail" || + $result_SPI_INTERRUPT = "fail" || + $result_SPI_DMA = "fail" || + $result_SPI_V2_POLLING = "fail" || # Only for max32690 + $result_SPI_V2_INTERRUPT = "fail" || # Only for max32690 + $result_SPI_V2_DMA = "fail" || # Only for max32690 + $result_ICC = "fail" || + $result_Hash = "fail" || + $result_DMA = "fail" || + $result_CRC = "fail" || + $result_ADC_POLLING = "fail" || + $result_ADC_INTERRUPT = "fail" || + $result_ADC_DMA = "fail" || + $result_Lib_Gen = "fail" || + $result_Lib_Use = "fail" ]]; then + exit 2 + else + exit 0 +fi diff --git a/Examples/MAX32690/ADC/main.c b/Examples/MAX32690/ADC/main.c index d25f5be923..47a0a4ad96 100644 --- a/Examples/MAX32690/ADC/main.c +++ b/Examples/MAX32690/ADC/main.c @@ -35,10 +35,10 @@ #include "fcr_regs.h" #include "led.h" #include "tmr.h" - +#include "nvic_table.h" /***** Definitions *****/ -#define POLLING // Uncomment to perform ADC conversions using blocking/polling method +//#define POLLING // Uncomment to perform ADC conversions using blocking/polling method // #define INTERRUPT // Uncomment to perform ADC conversions using interrupt driven method // #define DMA // Uncomment to perform ADC conversions using DMA driven method. diff --git a/Examples/MAX32690/ADC/project.mk b/Examples/MAX32690/ADC/project.mk index 96eb02eae1..4cc4eee9c3 100644 --- a/Examples/MAX32690/ADC/project.mk +++ b/Examples/MAX32690/ADC/project.mk @@ -13,3 +13,6 @@ # For more information on how sing process works, see # https://www.analog.com/en/education/education-library/videos/6313214207112.html SBT=0 + +METHOD ?= POLLING +PROJ_CFLAGS += -D$(METHOD) \ No newline at end of file diff --git a/Examples/MAX32690/Bluetooth/BLE_otas/dats_main.c b/Examples/MAX32690/Bluetooth/BLE_otas/dats_main.c index d1d6ccff59..6c8ebd4e8b 100644 --- a/Examples/MAX32690/Bluetooth/BLE_otas/dats_main.c +++ b/Examples/MAX32690/Bluetooth/BLE_otas/dats_main.c @@ -450,7 +450,11 @@ static void datsSetup(dmEvt_t *pMsg) { /* Initialize control information */ datsCb.restoringResList = FALSE; - memcpy(&datsScanDataDisc[2], deviceName, sizeof(deviceName)); + < < < < < < < < < + Temporary merge branch 1 memcpy(&datsScanDataDisc[2], deviceName, sizeof(deviceName)); + datsScanDataDisc[0] = sizeof(deviceName); + datsScanDataDisc[1] = DM_ADV_TYPE_LOCAL_NAME; + == == == == = memcpy(&datsScanDataDisc[2], deviceName, sizeof(deviceName)); datsScanDataDisc[0] = sizeof(deviceName); datsScanDataDisc[1] = DM_ADV_TYPE_LOCAL_NAME; diff --git a/Examples/MAX32690/SPI/main.c b/Examples/MAX32690/SPI/main.c index 31d31ebe22..0d24956774 100644 --- a/Examples/MAX32690/SPI/main.c +++ b/Examples/MAX32690/SPI/main.c @@ -41,16 +41,12 @@ #include "led.h" /***** Preprocessors *****/ -#define MASTERSYNC 1 -#define MASTERASYNC 0 -#define MASTERDMA 0 +//#define MASTERSYNC 1 +//#define MASTERASYNC 0 +//#define MASTERDMA 0 +// define three METHOD above in project.mk +// MASTERSYNC is default -#if (!(MASTERSYNC || MASTERASYNC || MASTERDMA)) -#error "You must set either MASTERSYNC or MASTERASYNC or MASTERDMA to 1." -#endif -#if ((MASTERSYNC && MASTERASYNC) || (MASTERASYNC && MASTERDMA) || (MASTERDMA && MASTERSYNC)) -#error "You must select either MASTERSYNC or MASTERASYNC or MASTERDMA, not all 3." -#endif /***** Definitions *****/ #define DATA_LEN 100 // Words #define DATA_VALUE 0xA5A5 // This is for master mode only... @@ -153,11 +149,11 @@ int main(void) return retVal; } -#if MASTERSYNC +#ifdef MASTERSYNC MXC_SPI_MasterTransaction(&req); #endif -#if MASTERASYNC +#ifdef MASTERASYNC MXC_NVIC_SetVector(SPI_IRQ, SPI_IRQHandler); NVIC_EnableIRQ(SPI_IRQ); MXC_SPI_MasterTransactionAsync(&req); @@ -166,7 +162,7 @@ int main(void) #endif -#if MASTERDMA +#ifdef MASTERDMA MXC_DMA_ReleaseChannel(0); MXC_DMA_ReleaseChannel(1); diff --git a/Examples/MAX32690/SPI/project.mk b/Examples/MAX32690/SPI/project.mk index 96eb02eae1..f5d5f71759 100644 --- a/Examples/MAX32690/SPI/project.mk +++ b/Examples/MAX32690/SPI/project.mk @@ -13,3 +13,7 @@ # For more information on how sing process works, see # https://www.analog.com/en/education/education-library/videos/6313214207112.html SBT=0 + + +METHOD ?= MASTERSYNC +PROJ_CFLAGS += -D$(METHOD) \ No newline at end of file diff --git a/Examples/MAX32690/SPI_v2/main.c b/Examples/MAX32690/SPI_v2/main.c index 282032c1bb..2f7c674e46 100644 --- a/Examples/MAX32690/SPI_v2/main.c +++ b/Examples/MAX32690/SPI_v2/main.c @@ -37,18 +37,11 @@ #include "led.h" /***** Preprocessors *****/ -#define CONTROLLER_SYNC 1 -#define CONTROLLER_ASYNC 0 -#define CONTROLLER_DMA 0 - -// Preprocessor Error Checking -#if (!(CONTROLLER_SYNC || CONTROLLER_ASYNC || CONTROLLER_DMA)) -#error "You must set either CONTROLLER_SYNC or CONTROLLER_ASYNC or CONTROLLER_DMA to 1." -#endif -#if ((CONTROLLER_SYNC && CONTROLLER_ASYNC) || (CONTROLLER_ASYNC && CONTROLLER_DMA) || \ - (CONTROLLER_DMA && CONTROLLER_SYNC)) -#error "You must select either CONTROLLER_SYNC or CONTROLLER_ASYNC or CONTROLLER_DMA, not all 3." -#endif +//#define CONTROLLER_SYNC +//#define CONTROLLER_ASYNC +//#define CONTROLLER_DMA +// define three METHOD above in project.mk +// CONTROLLER_SYNC is default /***** Definitions *****/ #define DATA_LEN 100 // Words diff --git a/Examples/MAX32690/SPI_v2/project.mk b/Examples/MAX32690/SPI_v2/project.mk index a607748507..2a6864ac9f 100644 --- a/Examples/MAX32690/SPI_v2/project.mk +++ b/Examples/MAX32690/SPI_v2/project.mk @@ -11,3 +11,7 @@ # Build SPI v2 library for example. MXC_SPI_VERSION = v2 + + +METHOD ?= CONTROLLER_SYNC +PROJ_CFLAGS += -D$(METHOD) \ No newline at end of file diff --git a/Examples/MAX32690/UART/main.c b/Examples/MAX32690/UART/main.c index 8823637331..c361715285 100644 --- a/Examples/MAX32690/UART/main.c +++ b/Examples/MAX32690/UART/main.c @@ -37,7 +37,8 @@ #include "nvic_table.h" /***** Definitions *****/ -// #define DMA +// to enable DMA, define in project.mk +// INTERRUPT is default in project.mk #define UART_BAUD 115200 #define BUFF_SIZE 1024 diff --git a/Examples/MAX32690/UART/project.mk b/Examples/MAX32690/UART/project.mk index 42b5536113..fa98fb50d7 100644 --- a/Examples/MAX32690/UART/project.mk +++ b/Examples/MAX32690/UART/project.mk @@ -17,3 +17,7 @@ SBT=0 ifeq ($(BOARD),FTHR) $(error ERR_NOTSUPPORTED: This project is not supported for the FTHR board) endif + + +METHOD ?= INTERRUPT +PROJ_CFLAGS += -D$(METHOD) diff --git a/Libraries/libs.mk b/Libraries/libs.mk index 4211fc967c..884925a849 100644 --- a/Libraries/libs.mk +++ b/Libraries/libs.mk @@ -86,6 +86,7 @@ endif # for CHIP_REVISION b *************************************************** else ifeq ($(CHIP_REVISION),b) + ifeq ($(RISCV_CORE),) ifeq ($(MFLOAT_ABI),hard) @@ -101,6 +102,9 @@ endif endif +#********************************************************************* + + ifeq ($(CODED_PHY_DEMO),1) PROJ_CFLAGS += -DAPP_CODED_PHY_DEMO=1 else