From e7384abb326313333d41b31e86db50f12c2922b1 Mon Sep 17 00:00:00 2001 From: karaanil Date: Tue, 28 Feb 2023 10:52:05 +0300 Subject: [PATCH 1/5] Add MAX32662 FTHR Board in MSDK --- .../Boards/MAX32662/EvKit_V1/Include/board.h | 7 + .../Boards/MAX32662/FTHR/Include/board.h | 98 +++++++ Libraries/Boards/MAX32662/FTHR/Source/board.c | 115 +++++++++ .../Boards/MAX32662/FTHR/Source/rom_stub.c | 82 ++++++ Libraries/Boards/MAX32662/FTHR/Source/stdio.c | 240 ++++++++++++++++++ Libraries/Boards/MAX32662/FTHR/adapters.txt | 2 + Libraries/Boards/MAX32662/FTHR/board.mk | 52 ++++ Libraries/Boards/MAX32662/FTHR/examples.txt | 43 ++++ Libraries/Boards/MAX32662/FTHR/target.txt | 1 + 9 files changed, 640 insertions(+) create mode 100644 Libraries/Boards/MAX32662/FTHR/Include/board.h create mode 100644 Libraries/Boards/MAX32662/FTHR/Source/board.c create mode 100644 Libraries/Boards/MAX32662/FTHR/Source/rom_stub.c create mode 100644 Libraries/Boards/MAX32662/FTHR/Source/stdio.c create mode 100644 Libraries/Boards/MAX32662/FTHR/adapters.txt create mode 100644 Libraries/Boards/MAX32662/FTHR/board.mk create mode 100644 Libraries/Boards/MAX32662/FTHR/examples.txt create mode 100644 Libraries/Boards/MAX32662/FTHR/target.txt diff --git a/Libraries/Boards/MAX32662/EvKit_V1/Include/board.h b/Libraries/Boards/MAX32662/EvKit_V1/Include/board.h index af72dd0084a..db90ee8dafa 100644 --- a/Libraries/Boards/MAX32662/EvKit_V1/Include/board.h +++ b/Libraries/Boards/MAX32662/EvKit_V1/Include/board.h @@ -45,6 +45,13 @@ extern "C" { #endif +/* + Define board name: + Use as #if defined(BOARD_EVKIT_V1) + Not as #if BOARD_EVKIT_V1 +*/ +#define BOARD_EVKIT_V1 1 + #ifndef CONSOLE_UART #define CONSOLE_UART 0 /// UART instance to use for console #endif diff --git a/Libraries/Boards/MAX32662/FTHR/Include/board.h b/Libraries/Boards/MAX32662/FTHR/Include/board.h new file mode 100644 index 00000000000..64ba855a874 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/Include/board.h @@ -0,0 +1,98 @@ +/****************************************************************************** + * Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +/** + * @file board.h + * @brief Board support package API. + */ + +#include + +#ifndef LIBRARIES_BOARDS_MAX32662_EVKIT_V1_INCLUDE_BOARD_H_ +#define LIBRARIES_BOARDS_MAX32662_EVKIT_V1_INCLUDE_BOARD_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + Define board name: + Use as #if defined(BOARD_FTHR) + Not as #if BOARD_FTHR +*/ +#define BOARD_FTHR 1 + +#ifndef CONSOLE_UART +#define CONSOLE_UART 0 /// UART instance to use for console +#endif + +#ifndef CONSOLE_BAUD +#define CONSOLE_BAUD 115200 /// Console baud rate +#endif + +#define LED_OFF 1 /// Inactive state of LEDs +#define LED_ON 0 /// Active state of LEDs + +#define LED1 0 +#define LED2 1 + +/** + * \brief Initialize the BSP and board interfaces. + * \returns #E_NO_ERROR if everything is successful + */ +int Board_Init(void); + +/** + * \brief Initialize or reinitialize the console. This may be necessary if the + * system clock rate is changed. + * \returns #E_NO_ERROR if everything is successful + */ +int Console_Init(void); + +/** + * \brief Shutdown the console. + * \returns #E_NO_ERROR if everything is successful + */ +int Console_Shutdown(void); + +/** + * \brief Attempt to prepare the console for sleep. + * \returns #E_NO_ERROR if ready to sleep, #E_BUSY if not ready for sleep. + */ +int Console_PrepForSleep(void); + +#ifdef __cplusplus +} +#endif + +#endif // LIBRARIES_BOARDS_MAX32662_EVKIT_V1_INCLUDE_BOARD_H_ diff --git a/Libraries/Boards/MAX32662/FTHR/Source/board.c b/Libraries/Boards/MAX32662/FTHR/Source/board.c new file mode 100644 index 00000000000..870878b5814 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/Source/board.c @@ -0,0 +1,115 @@ +/****************************************************************************** + * Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +#include +#include "mxc_device.h" +#include "mxc_sys.h" +#include "mxc_errors.h" +#include "mxc_assert.h" +#include "board.h" +#include "uart.h" +#include "gpio.h" +#include "mxc_pins.h" +#include "led.h" +#include "pb.h" + +/***** Global Variables *****/ +mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(CONSOLE_UART); +extern uint32_t SystemCoreClock; + +const mxc_gpio_cfg_t pb_pin[] = { { MXC_GPIO0, MXC_GPIO_PIN_6, MXC_GPIO_FUNC_IN, + MXC_GPIO_PAD_PULL_UP, MXC_GPIO_VSSEL_VDDIOH } }; +const unsigned int num_pbs = (sizeof(pb_pin) / sizeof(mxc_gpio_cfg_t)); + +const mxc_gpio_cfg_t led_pin[] = { { MXC_GPIO0, MXC_GPIO_PIN_14, MXC_GPIO_FUNC_OUT, + MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO } }; +const unsigned int num_leds = (sizeof(led_pin) / sizeof(mxc_gpio_cfg_t)); + +/***** File Scope Variables *****/ + +/******************************************************************************/ +void mxc_assert(const char *expr, const char *file, int line) +{ + printf("MXC_ASSERT %s #%d: (%s)\n", file, line, expr); + while (1) {} +} + +/******************************************************************************/ +int Board_Init(void) +{ + int err; + + if ((err = Console_Init()) < E_NO_ERROR) { + return err; + } + + if ((err = PB_Init()) != E_NO_ERROR) { + MXC_ASSERT_FAIL(); + return err; + } + + if ((err = LED_Init()) != E_NO_ERROR) { + MXC_ASSERT_FAIL(); + return err; + } + + return E_NO_ERROR; +} + +/******************************************************************************/ +int Console_Init(void) +{ + int err; + + if ((err = MXC_UART_Init(ConsoleUart, CONSOLE_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { + return err; + } + + return E_NO_ERROR; +} + +int Console_Shutdown(void) +{ + int err; + + if ((err = MXC_UART_Shutdown(ConsoleUart)) != E_NO_ERROR) { + return err; + } + + return E_NO_ERROR; +} +/******************************************************************************/ +void NMI_Handler(void) +{ + __NOP(); +} diff --git a/Libraries/Boards/MAX32662/FTHR/Source/rom_stub.c b/Libraries/Boards/MAX32662/FTHR/Source/rom_stub.c new file mode 100644 index 00000000000..8d05fe7b996 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/Source/rom_stub.c @@ -0,0 +1,82 @@ +/****************************************************************************** + * Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +#include "max32662.h" + +/* The stack address is defined by the linker + * It is typed as a function here to avoid compiler warnings + */ +extern void __StackTop(void); + +void Reset_Handler(void); +void NMI_Handler_ROM(void); +void HardFault_Handler_ROM(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +/* Create a vector table to locate at zero in the ROM for handling reset and startup */ +__attribute__((section(".rom_vector"))) void (*const rom_vector[])(void) = { + __StackTop, /* Top of Stack */ + Reset_Handler, /* Reset Handler */ + NMI_Handler_ROM, /* NMI Handler */ + HardFault_Handler_ROM, /* Hard Fault Handler */ + MemManage_Handler, /* MPU Fault Handler */ + BusFault_Handler, /* Bus Fault Handler */ + UsageFault_Handler, /* Usage Fault Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + SVC_Handler, /* SVCall Handler */ + DebugMon_Handler, /* Debug Monitor Handler */ + 0, /* Reserved */ + PendSV_Handler, /* PendSV Handler */ + SysTick_Handler, /* SysTick Handler */ +}; + +/* This is needed to handle the NMI at POR */ +__attribute__((section(".rom_handlers"))) void NMI_Handler_ROM(void) +{ + __NOP(); +} + +/* This is needed to handle the fault after initial programming */ +__attribute__((section(".rom_handlers"))) void HardFault_Handler_ROM(void) +{ + NVIC_SystemReset(); +} diff --git a/Libraries/Boards/MAX32662/FTHR/Source/stdio.c b/Libraries/Boards/MAX32662/FTHR/Source/stdio.c new file mode 100644 index 00000000000..58247875040 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/Source/stdio.c @@ -0,0 +1,240 @@ +/****************************************************************************** + * Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +#include +#include +#include +#include +#include + +#if defined(__GNUC__) +#include +#include +#endif /* __GNUC__ */ + +#if defined(__CC_ARM) +#include +#pragma import(__use_no_semihosting_swi) + +struct __FILE { + int handle; +}; +FILE __stdout; +FILE __stdin; +/** + * Integer to store the last character read from the FILE using fgetc(). + * Only valid if fgetc() was the last function called on the stream. + */ +int g_lastChar = 0; +/** + * Global variable set to TRUE if fgetc() was previously called, false otherwise. + * This variable is necessary for implementing __backspace(FILE *f) in the MDK microlib. + */ +int g_readChar = 0; + +#endif /* __CC_ARM */ + +/* Defines - Compiler Specific */ +#if defined(__ICCARM__) +#define STDIN_FILENO 0 // Defines that are not included in the DLIB. +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#define EBADF -1 +#endif /* __ICCARM__ */ + +#include "mxc_device.h" +#include "mxc_sys.h" +#include "board.h" +#include "uart.h" + +#define MXC_UARTn MXC_UART_GET_UART(CONSOLE_UART) +#define UART_FIFO MXC_UART_GET_FIFO(CONSOLE_UART) +/* The following libc stub functions are required for a proper link with printf(). + * These can be tailored for a complete stdio implementation. + * GNUC requires all functions below. IAR & KEIL only use read and write. + */ +#if defined(__GNUC__) +int _open(const char *name, int flags, int mode) +{ + return -1; +} +int _close(int file) +{ + return -1; +} +int _isatty(int file) +{ + return -1; +} +int _lseek(int file, off_t offset, int whence) +{ + return -1; +} +int _fstat(int file, struct stat *st) +{ + return -1; +} +#endif /* __GNUC__ */ + +/* Handle IAR and ARM/Keil Compilers for _read/_write. Keil uses fputc and + fgetc for stdio */ +#if defined(__ICCARM__) || defined(__GNUC__) + +#if defined(__GNUC__) // GNUC _read function prototype +int _read(int file, char *ptr, int len) +{ + int n; +#elif defined(__ICCARM__) // IAR Compiler _read function prototype +int __read(int file, unsigned char *ptr, size_t len) +{ + size_t n; +#endif /* */ + + int num = 0; // count of number received. + + switch (file) { + case STDIN_FILENO: + for (n = 0; n < len; n++) { + *ptr = MXC_UART_ReadCharacter(MXC_UARTn); // read a byte. + MXC_UART_WriteCharacter(MXC_UARTn, *ptr); // echo the byte. + if (*ptr == '\r') { // check for end of line. + *ptr = '\n'; + num++; + ptr++; + + break; + } else { + ptr++; + num++; + } + } + + break; + default: + errno = EBADF; + return -1; + } + return num; +} + +/* newlib/libc printf() will eventually call write() to get the data to the stdout */ +#if defined(__GNUC__) +// GNUC _write function prototype +int _write(int file, char *ptr, int len) +{ + int n; +#elif defined(__ICCARM__) // IAR Compiler _read function prototype +// IAR EW _write function prototype +int __write(int file, const unsigned char *ptr, size_t len) +{ + size_t n; +#endif /* __GNUC__ */ + + switch (file) { + case STDOUT_FILENO: + case STDERR_FILENO: + // This function should be as fast as possible + // So we'll forgo the UART driver for now + for (n = 0; n < len; n++) { + if (*ptr == '\n') { + // Wait until there's room in the FIFO + while (MXC_UARTn->status & MXC_F_UART_STATUS_TX_FULL) {} + MXC_UARTn->fifo = '\r'; + } + // Wait until there's room in the FIFO + while (MXC_UARTn->status & MXC_F_UART_STATUS_TX_FULL) {} + MXC_UARTn->fifo = *ptr++; + } + break; + default: + errno = EBADF; + return -1; + } + + return len; +} + +#endif /* ( __ICCARM__ ) || ( __GNUC__ ) */ + +/* Handle Keil/ARM Compiler which uses fputc and fgetc for stdio */ +#if defined(__CC_ARM) +int fputc(int c, FILE *f) +{ + if (c != '\n') { + MXC_UART_WriteCharacter(MXC_UARTn, c); + } else { + MXC_UART_WriteCharacter(MXC_UARTn, '\r'); + MXC_UART_WriteCharacter(MXC_UARTn, '\n'); + } + + return 0; +} + +int __backspace(FILE *f) +{ + if (g_readChar) + return g_lastChar; + else + return EOF; +} + +int fgetc(FILE *f) +{ + g_lastChar = (int)MXC_UART_ReadCharacter( + MXC_UARTn); /* Read the byte and save it to global for backspace */ + g_readChar = 1; /* set global to indicate g_lastChar is valid. */ + return g_lastChar; +} + +int ferror(FILE *f) +{ + g_readChar = 0; + return EOF; +} + +void _ttywrch(int c) +{ + if (c != '\n') { + MXC_UART_WriteCharacter(MXC_UARTn, c); + } else { + MXC_UART_WriteCharacter(MXC_UARTn, '\r'); + MXC_UART_WriteCharacter(MXC_UARTn, '\n'); + } +} + +void _sys_exit(int return_code) +{ + while (1) {} +} + +#endif /* __CC_ARM */ diff --git a/Libraries/Boards/MAX32662/FTHR/adapters.txt b/Libraries/Boards/MAX32662/FTHR/adapters.txt new file mode 100644 index 00000000000..9ee4ed2a720 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/adapters.txt @@ -0,0 +1,2 @@ +CMSIS-DAP, interface/cmsis-dap.cfg +MAX32625_PICO, interface/cmsis-dap.cfg \ No newline at end of file diff --git a/Libraries/Boards/MAX32662/FTHR/board.mk b/Libraries/Boards/MAX32662/FTHR/board.mk new file mode 100644 index 00000000000..06c166d1ce8 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/board.mk @@ -0,0 +1,52 @@ +################################################################################ + # Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + # + # Permission is hereby granted, free of charge, to any person obtaining a + # copy of this software and associated documentation files (the "Software"), + # to deal in the Software without restriction, including without limitation + # the rights to use, copy, modify, merge, publish, distribute, sublicense, + # and/or sell copies of the Software, and to permit persons to whom the + # Software is furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included + # in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + # + # Except as contained in this notice, the name of Maxim Integrated + # Products, Inc. shall not be used except as stated in the Maxim Integrated + # Products, Inc. Branding Policy. + # + # The mere transfer of this software does not imply any licenses + # of trade secrets, proprietary technology, copyrights, patents, + # trademarks, maskwork rights, or any other form of intellectual + # property whatsoever. Maxim Integrated Products, Inc. retains all + # ownership rights. + # + ############################################################################### + +ifeq "$(BOARD_DIR)" "" +$(error BOARD_DIR must be set) +endif + +# Source files for this test (add path to VPATH below) +SRCS += board.c +SRCS += stdio.c +SRCS += led.c +SRCS += pb.c +SRCS += rom_stub.c + + +# Where to find BSP source files +VPATH += $(BOARD_DIR)/Source +VPATH += $(BOARD_DIR)/../Source + +# Where to find BSP header files +IPATH += $(BOARD_DIR)/Include +IPATH += $(BOARD_DIR)/../Include \ No newline at end of file diff --git a/Libraries/Boards/MAX32662/FTHR/examples.txt b/Libraries/Boards/MAX32662/FTHR/examples.txt new file mode 100644 index 00000000000..9effebff154 --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/examples.txt @@ -0,0 +1,43 @@ +ADC +ARM-DSP/arm_bayes_example +ARM-DSP/arm_class_marks_example +ARM-DSP/arm_convolution_example +ARM-DSP/arm_dotproduct_example_f32 +ARM-DSP/arm_fft_bin_example +ARM-DSP/arm_fir_example +ARM-DSP/arm_graphic_equalizer_example +ARM-DSP/arm_linear_interp_example +ARM-DSP/arm_matrix_example +ARM-DSP/arm_signal_converge_example +ARM-DSP/arm_sin_cos_example +ARM-DSP/arm_svm_example +ARM-DSP/arm_variance_example +Bootloader_Host +CAN +Coremark +DMA +EEPROM_Emulator +Flash +Flash_CLI +GPIO +Hello_World +I2C +I2C_MNGR +I2C_SCAN +I2C_Sensor +I2S +ICC +Info_Block_Usecase +LP +RTC +RTC_Backup +SCPA_OTP_Dump +SPI +SPI_MasterSlave +Temp_Monitor +TMR +TRNG +UART +UART_Wakeup +Watchdog +WearLeveling diff --git a/Libraries/Boards/MAX32662/FTHR/target.txt b/Libraries/Boards/MAX32662/FTHR/target.txt new file mode 100644 index 00000000000..0d87c762b9d --- /dev/null +++ b/Libraries/Boards/MAX32662/FTHR/target.txt @@ -0,0 +1 @@ +max32662.cfg \ No newline at end of file From adb4c58fc0b71b09a934af04fcb7db281637cabe Mon Sep 17 00:00:00 2001 From: karaanil Date: Mon, 6 Mar 2023 10:49:09 +0300 Subject: [PATCH 2/5] [MSDK-1054] I2C example description and verifyData fix --- Examples/MAX32662/I2C/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Examples/MAX32662/I2C/main.c b/Examples/MAX32662/I2C/main.c index 7945582b3d5..20ee187d9e0 100644 --- a/Examples/MAX32662/I2C/main.c +++ b/Examples/MAX32662/I2C/main.c @@ -53,6 +53,7 @@ #include "nvic_table.h" #include "i2c.h" #include "dma.h" +#include "board.h" /***** Definitions *****/ //#define MASTERDMA //Comment this line out if standard I2C transaction is required @@ -199,9 +200,17 @@ int main() printf("read and write to another I2C which acts as a slave.\n"); printf("\nYou will need to connect P0.12->P0.6 (SCL) and\n"); - printf("P0.13->P0.9 (SDA). As well jumper JP1 (VREF) needs\n"); + printf("P0.13->P0.9 (SDA)."); +#if defined(BOARD_EVKIT_V1) + printf("As well jumper JP1 (VREF) needs\n"); printf("to be removed.\n"); +#else + printf("\nTo have pull up resistor\n"); + printf("Either connect SLAVE_SCL to P0.12 and SLAVE_SDA to P0.13\n"); + printf("Or use breadboard and connect P0.12 to 3.3V with 4.7k \n"); + printf("and P0.13 to 3.3V with 4.7k\n"); +#endif int error, i = 0; //Setup the I2CM @@ -277,7 +286,7 @@ int main() printf("\n-->Result: \n"); printData(); printf("\n"); - if (verifyData()) { + if (!verifyData()) { printf("\n-->I2C Transaction Successful\n"); } else { printf("\n-->I2C Transaction Failed\n"); From 735f2eee1fa14aee747a59302e79b6df1cad339a Mon Sep 17 00:00:00 2001 From: karaanil Date: Fri, 3 Mar 2023 10:16:28 +0300 Subject: [PATCH 3/5] UART example FTHR fix --- Examples/MAX32662/UART/main.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Examples/MAX32662/UART/main.c b/Examples/MAX32662/UART/main.c index 7b7cffecfd1..2337b332b9e 100644 --- a/Examples/MAX32662/UART/main.c +++ b/Examples/MAX32662/UART/main.c @@ -54,10 +54,18 @@ #define UART_BAUD 115200 #define BUFF_SIZE 1024 -#define READING_UART MXC_UART0 -#define READ_IDX MXC_UART_GET_IDX(MXC_UART0) -#define WRITING_UART MXC_UART1 -#define WRITE_IDX MXC_UART_GET_IDX(MXC_UART1) + +#if defined(BOARD_EVKIT_V1) + #define READING_UART MXC_UART0 + #define READ_IDX MXC_UART_GET_IDX(MXC_UART0) + #define WRITING_UART MXC_UART1 + #define WRITE_IDX MXC_UART_GET_IDX(MXC_UART1) +#else + #define READING_UART MXC_UART1 + #define READ_IDX MXC_UART_GET_IDX(MXC_UART1) + #define WRITING_UART MXC_UART0 + #define WRITE_IDX MXC_UART_GET_IDX(MXC_UART0) +#endif /***** Globals *****/ volatile int READ_FLAG; @@ -100,7 +108,11 @@ int main(void) printf("\n\n**************** UART Example ******************\n"); printf("This example shows a loopback test between the 2 UARTs on the MAX32662.\n"); - printf("\nConnect UART0 to UART1 (P0.11 (AIN2) -> P0.2) for this example.\n"); +#if defined(BOARD_EVKIT_V1) + printf("\nConnect UART0A RX to UART1A TX (P0.11 (AIN2) -> P0.2) for this example.\n"); +#else + printf("\nConnect UART0B TX to UART1A RX (P0.8 -> P0.3) for this example.\n"); +#endif printf("The LEDs are used to indicate the success of the test.\nBlinking->Success, " "Solid->Failure\n"); @@ -133,7 +145,11 @@ int main(void) MXC_Delay(MXC_DELAY_SEC(1)); // Initialize the UART +#if defined(BOARD_EVKIT_V1) if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { +#else + if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_B)) != E_NO_ERROR) { +#endif Shutdown_UARTS(); Console_Init(); printf("-->Error initializing UART: %d\n", error); @@ -141,7 +157,11 @@ int main(void) return error; } +#if defined(BOARD_EVKIT_V1) if ((error = MXC_UART_Init(READING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { +#else + if ((error = MXC_UART_Init(READING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { +#endif Shutdown_UARTS(); Console_Init(); printf("-->Error initializing UART: %d\n", error); From 8e6813b3fd6f649d16d9b2c5749f0b04733f3c24 Mon Sep 17 00:00:00 2001 From: karaanil Date: Mon, 6 Mar 2023 12:00:41 +0300 Subject: [PATCH 4/5] clang-format-run --- Examples/MAX32662/UART/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/MAX32662/UART/main.c b/Examples/MAX32662/UART/main.c index 2337b332b9e..d5401b259f8 100644 --- a/Examples/MAX32662/UART/main.c +++ b/Examples/MAX32662/UART/main.c @@ -56,15 +56,15 @@ #define BUFF_SIZE 1024 #if defined(BOARD_EVKIT_V1) - #define READING_UART MXC_UART0 - #define READ_IDX MXC_UART_GET_IDX(MXC_UART0) - #define WRITING_UART MXC_UART1 - #define WRITE_IDX MXC_UART_GET_IDX(MXC_UART1) +#define READING_UART MXC_UART0 +#define READ_IDX MXC_UART_GET_IDX(MXC_UART0) +#define WRITING_UART MXC_UART1 +#define WRITE_IDX MXC_UART_GET_IDX(MXC_UART1) #else - #define READING_UART MXC_UART1 - #define READ_IDX MXC_UART_GET_IDX(MXC_UART1) - #define WRITING_UART MXC_UART0 - #define WRITE_IDX MXC_UART_GET_IDX(MXC_UART0) +#define READING_UART MXC_UART1 +#define READ_IDX MXC_UART_GET_IDX(MXC_UART1) +#define WRITING_UART MXC_UART0 +#define WRITE_IDX MXC_UART_GET_IDX(MXC_UART0) #endif /***** Globals *****/ From 5ce180a728a6c44526e22e57b962197214ff1450 Mon Sep 17 00:00:00 2001 From: karaanil Date: Tue, 7 Mar 2023 10:42:51 +0300 Subject: [PATCH 5/5] [MSDK-1066] MAX32662 FTHR Pull Request Changes --- Examples/MAX32662/UART/main.c | 19 ------------------- .../Boards/MAX32662/FTHR/Include/board.h | 6 +++--- Libraries/Boards/MAX32662/FTHR/examples.txt | 2 -- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/Examples/MAX32662/UART/main.c b/Examples/MAX32662/UART/main.c index d5401b259f8..e6b84b3eaa2 100644 --- a/Examples/MAX32662/UART/main.c +++ b/Examples/MAX32662/UART/main.c @@ -55,17 +55,10 @@ #define UART_BAUD 115200 #define BUFF_SIZE 1024 -#if defined(BOARD_EVKIT_V1) -#define READING_UART MXC_UART0 -#define READ_IDX MXC_UART_GET_IDX(MXC_UART0) -#define WRITING_UART MXC_UART1 -#define WRITE_IDX MXC_UART_GET_IDX(MXC_UART1) -#else #define READING_UART MXC_UART1 #define READ_IDX MXC_UART_GET_IDX(MXC_UART1) #define WRITING_UART MXC_UART0 #define WRITE_IDX MXC_UART_GET_IDX(MXC_UART0) -#endif /***** Globals *****/ volatile int READ_FLAG; @@ -108,11 +101,7 @@ int main(void) printf("\n\n**************** UART Example ******************\n"); printf("This example shows a loopback test between the 2 UARTs on the MAX32662.\n"); -#if defined(BOARD_EVKIT_V1) - printf("\nConnect UART0A RX to UART1A TX (P0.11 (AIN2) -> P0.2) for this example.\n"); -#else printf("\nConnect UART0B TX to UART1A RX (P0.8 -> P0.3) for this example.\n"); -#endif printf("The LEDs are used to indicate the success of the test.\nBlinking->Success, " "Solid->Failure\n"); @@ -145,11 +134,7 @@ int main(void) MXC_Delay(MXC_DELAY_SEC(1)); // Initialize the UART -#if defined(BOARD_EVKIT_V1) - if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { -#else if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_B)) != E_NO_ERROR) { -#endif Shutdown_UARTS(); Console_Init(); printf("-->Error initializing UART: %d\n", error); @@ -157,11 +142,7 @@ int main(void) return error; } -#if defined(BOARD_EVKIT_V1) - if ((error = MXC_UART_Init(READING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { -#else if ((error = MXC_UART_Init(READING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) { -#endif Shutdown_UARTS(); Console_Init(); printf("-->Error initializing UART: %d\n", error); diff --git a/Libraries/Boards/MAX32662/FTHR/Include/board.h b/Libraries/Boards/MAX32662/FTHR/Include/board.h index 64ba855a874..0dd890aa210 100644 --- a/Libraries/Boards/MAX32662/FTHR/Include/board.h +++ b/Libraries/Boards/MAX32662/FTHR/Include/board.h @@ -38,8 +38,8 @@ #include -#ifndef LIBRARIES_BOARDS_MAX32662_EVKIT_V1_INCLUDE_BOARD_H_ -#define LIBRARIES_BOARDS_MAX32662_EVKIT_V1_INCLUDE_BOARD_H_ +#ifndef LIBRARIES_BOARDS_MAX32662_FTHR_INCLUDE_BOARD_H_ +#define LIBRARIES_BOARDS_MAX32662_FTHR_INCLUDE_BOARD_H_ #ifdef __cplusplus extern "C" { @@ -95,4 +95,4 @@ int Console_PrepForSleep(void); } #endif -#endif // LIBRARIES_BOARDS_MAX32662_EVKIT_V1_INCLUDE_BOARD_H_ +#endif // LIBRARIES_BOARDS_MAX32662_FTHR_INCLUDE_BOARD_H_ diff --git a/Libraries/Boards/MAX32662/FTHR/examples.txt b/Libraries/Boards/MAX32662/FTHR/examples.txt index 9effebff154..b33c093af86 100644 --- a/Libraries/Boards/MAX32662/FTHR/examples.txt +++ b/Libraries/Boards/MAX32662/FTHR/examples.txt @@ -12,11 +12,9 @@ ARM-DSP/arm_signal_converge_example ARM-DSP/arm_sin_cos_example ARM-DSP/arm_svm_example ARM-DSP/arm_variance_example -Bootloader_Host CAN Coremark DMA -EEPROM_Emulator Flash Flash_CLI GPIO