mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
MAX32650/1/2 Support
Added support for the MAX32650/1/2 series parts - MAX32650FTHR, MAX32650EvKit, MAX32651EvKit - Added special flash rule for MAX32651 due to signing required - Added depencies to flash-msdk rules for executable
This commit is contained in:
parent
61beb6316d
commit
0c37f93bc8
149
hw/bsp/max32650/FreeRTOSConfig/FreeRTOSConfig.h
Normal file
149
hw/bsp/max32650/FreeRTOSConfig/FreeRTOSConfig.h
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.0.0
|
||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. 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. If you wish to use our Amazon
|
||||
* FreeRTOS name, please do so in a fair use way that does not cause confusion.
|
||||
*
|
||||
* 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 THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
// skip if included from IAR assembler
|
||||
#ifndef __IASMARM__
|
||||
#include "mxc_device.h"
|
||||
#endif
|
||||
|
||||
/* Cortex M23/M33 port configuration. */
|
||||
#define configENABLE_MPU 0
|
||||
#define configENABLE_FPU 1
|
||||
#define configENABLE_TRUSTZONE 0
|
||||
#define configMINIMAL_SECURE_STACK_SIZE (1024)
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||
#define configCPU_CLOCK_HZ SystemCoreClock
|
||||
#define configTICK_RATE_HZ ( 1000 )
|
||||
#define configMAX_PRIORITIES ( 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( 128 )
|
||||
#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
|
||||
#define configMAX_TASK_NAME_LEN 16
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 4
|
||||
#define configUSE_QUEUE_SETS 0
|
||||
#define configUSE_TIME_SLICING 0
|
||||
#define configUSE_NEWLIB_REENTRANT 0
|
||||
#define configENABLE_BACKWARD_COMPATIBILITY 1
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 0
|
||||
|
||||
/* Hook function related definitions. */
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configCHECK_HANDLER_INSTALLATION 0
|
||||
|
||||
/* Run time and task stats gathering related definitions. */
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
#define configUSE_TRACE_FACILITY 1 // legacy trace
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES 2
|
||||
|
||||
/* Software timer related definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
|
||||
#define configTIMER_QUEUE_LENGTH 32
|
||||
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
|
||||
/* Optional functions - most linkers will remove unused functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 0
|
||||
#define INCLUDE_uxTaskPriorityGet 0
|
||||
#define INCLUDE_vTaskDelete 0
|
||||
#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
|
||||
#define INCLUDE_xResumeFromISR 0
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 0
|
||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 0
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 0
|
||||
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
|
||||
#define INCLUDE_pcTaskGetTaskName 0
|
||||
#define INCLUDE_eTaskGetState 0
|
||||
#define INCLUDE_xEventGroupSetBitFromISR 0
|
||||
#define INCLUDE_xTimerPendFunctionCall 0
|
||||
|
||||
/* FreeRTOS hooks to NVIC vectors */
|
||||
#define xPortPendSVHandler PendSV_Handler
|
||||
#define xPortSysTickHandler SysTick_Handler
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Interrupt nesting behavior configuration.
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
|
||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
#endif
|
1
hw/bsp/max32650/boards/max32650evkit/board.cmake
Normal file
1
hw/bsp/max32650/boards/max32650evkit/board.cmake
Normal file
@ -0,0 +1 @@
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld)
|
56
hw/bsp/max32650/boards/max32650evkit/board.h
Normal file
56
hw/bsp/max32650/boards/max32650evkit/board.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
|
||||
*
|
||||
* 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 THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LED
|
||||
#define LED_PORT MXC_GPIO2
|
||||
#define LED_PIN MXC_GPIO_PIN_25
|
||||
#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// Button
|
||||
#define BUTTON_PORT MXC_GPIO2
|
||||
#define BUTTON_PIN MXC_GPIO_PIN_28
|
||||
#define BUTTON_PULL MXC_GPIO_PAD_WEAK_PULL_UP
|
||||
#define BUTTON_STATE_ACTIVE 0
|
||||
|
||||
// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
|
||||
#define UART_NUM 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H_ */
|
17
hw/bsp/max32650/boards/max32650evkit/board.mk
Normal file
17
hw/bsp/max32650/boards/max32650evkit/board.mk
Normal file
@ -0,0 +1,17 @@
|
||||
LD_FILE = $(BOARD_PATH)/max32650.ld
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = max32650
|
||||
|
||||
# flash target using Jlik
|
||||
flash: flash-jlink
|
||||
|
||||
# Optional flash option when running within an installed MSDK to use OpenOCD
|
||||
# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated.
|
||||
# If the MSDK is installed, flash-msdk can be run to utilize the the modified
|
||||
# openocd with the algorithms
|
||||
MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
|
||||
flash-msdk: $(BUILD)/$(PROJECT).elf
|
||||
$(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
|
||||
-f interface/cmsis-dap.cfg -f target/max32650.cfg \
|
||||
-c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
|
119
hw/bsp/max32650/boards/max32650evkit/max32650.ld
Normal file
119
hw/bsp/max32650/boards/max32650evkit/max32650.ld
Normal file
@ -0,0 +1,119 @@
|
||||
MEMORY {
|
||||
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 /* 64kB ROM */
|
||||
FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00300000 /* 3MB flash */
|
||||
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000 /* 1MB SRAM */
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*) /* program code */
|
||||
*(.rodata*) /* read-only data: "const" */
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
/* C++ Exception handling */
|
||||
KEEP(*(.eh_frame*))
|
||||
_etext = .;
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
/* it's used for C++ exception handling */
|
||||
/* we need to keep this to avoid overlapping */
|
||||
.ARM.exidx :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} > FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
_data = ALIGN(., 4);
|
||||
*(vtable)
|
||||
*(.data*) /*read-write initialized data: initialized global variable*/
|
||||
*(.spix_config*) /* SPIX configuration functions need to be run from SRAM */
|
||||
*(.flashprog*) /* Flash program */
|
||||
|
||||
|
||||
/* These array sections are used by __libc_init_array to call static C++ constructors */
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
_edata = ALIGN(., 4);
|
||||
} > SRAM AT>FLASH
|
||||
__load_data = LOADADDR(.data);
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_bss = .;
|
||||
*(.bss*) /*read-write zero initialized data: uninitialzed global variable*/
|
||||
*(COMMON)
|
||||
_ebss = ALIGN(., 4);
|
||||
} > SRAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > SRAM
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
*(.heap*)
|
||||
__HeapLimit = ABSOLUTE(__StackLimit);
|
||||
} > SRAM
|
||||
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
|
||||
}
|
1
hw/bsp/max32650/boards/max32650fthr/board.cmake
Normal file
1
hw/bsp/max32650/boards/max32650fthr/board.cmake
Normal file
@ -0,0 +1 @@
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld)
|
57
hw/bsp/max32650/boards/max32650fthr/board.h
Normal file
57
hw/bsp/max32650/boards/max32650fthr/board.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
|
||||
*
|
||||
* 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 THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LED
|
||||
#define LED_PORT MXC_GPIO1
|
||||
#define LED_PIN MXC_GPIO_PIN_14
|
||||
#define LED_VDDIO MXC_GPIO_VSSEL_VDDIO
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// Button
|
||||
#define BUTTON_PORT MXC_GPIO1
|
||||
#define BUTTON_PIN MXC_GPIO_PIN_19
|
||||
#define BUTTON_PULL MXC_GPIO_PAD_WEAK_PULL_UP
|
||||
#define BUTTON_STATE_ACTIVE 0
|
||||
|
||||
// UART Enable for SWD UART Pins. Pin Mux handled by the HAL
|
||||
#define UART_NUM 0
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H_ */
|
17
hw/bsp/max32650/boards/max32650fthr/board.mk
Normal file
17
hw/bsp/max32650/boards/max32650fthr/board.mk
Normal file
@ -0,0 +1,17 @@
|
||||
LD_FILE = $(BOARD_PATH)/max32650.ld
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = max32650
|
||||
|
||||
# flash target using Jlik
|
||||
flash: flash-jlink
|
||||
|
||||
# Optional flash option when running within an installed MSDK to use OpenOCD
|
||||
# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated.
|
||||
# If the MSDK is installed, flash-msdk can be run to utilize the the modified
|
||||
# openocd with the algorithms
|
||||
MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
|
||||
flash-msdk: $(BUILD)/$(PROJECT).elf
|
||||
$(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
|
||||
-f interface/cmsis-dap.cfg -f target/max32650.cfg \
|
||||
-c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
|
119
hw/bsp/max32650/boards/max32650fthr/max32650.ld
Normal file
119
hw/bsp/max32650/boards/max32650fthr/max32650.ld
Normal file
@ -0,0 +1,119 @@
|
||||
MEMORY {
|
||||
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 /* 64kB ROM */
|
||||
FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00300000 /* 3MB flash */
|
||||
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000 /* 1MB SRAM */
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*) /* program code */
|
||||
*(.rodata*) /* read-only data: "const" */
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
/* C++ Exception handling */
|
||||
KEEP(*(.eh_frame*))
|
||||
_etext = .;
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
/* it's used for C++ exception handling */
|
||||
/* we need to keep this to avoid overlapping */
|
||||
.ARM.exidx :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} > FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
_data = ALIGN(., 4);
|
||||
*(vtable)
|
||||
*(.data*) /*read-write initialized data: initialized global variable*/
|
||||
*(.spix_config*) /* SPIX configuration functions need to be run from SRAM */
|
||||
*(.flashprog*) /* Flash program */
|
||||
|
||||
|
||||
/* These array sections are used by __libc_init_array to call static C++ constructors */
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
_edata = ALIGN(., 4);
|
||||
} > SRAM AT>FLASH
|
||||
__load_data = LOADADDR(.data);
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_bss = .;
|
||||
*(.bss*) /*read-write zero initialized data: uninitialzed global variable*/
|
||||
*(COMMON)
|
||||
_ebss = ALIGN(., 4);
|
||||
} > SRAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > SRAM
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
*(.heap*)
|
||||
__HeapLimit = ABSOLUTE(__StackLimit);
|
||||
} > SRAM
|
||||
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
|
||||
}
|
1
hw/bsp/max32650/boards/max32651evkit/board.cmake
Normal file
1
hw/bsp/max32650/boards/max32651evkit/board.cmake
Normal file
@ -0,0 +1 @@
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32651.ld)
|
56
hw/bsp/max32650/boards/max32651evkit/board.h
Normal file
56
hw/bsp/max32650/boards/max32651evkit/board.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
|
||||
*
|
||||
* 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 THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LED
|
||||
#define LED_PORT MXC_GPIO2
|
||||
#define LED_PIN MXC_GPIO_PIN_25
|
||||
#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// Button
|
||||
#define BUTTON_PORT MXC_GPIO2
|
||||
#define BUTTON_PIN MXC_GPIO_PIN_28
|
||||
#define BUTTON_PULL MXC_GPIO_PAD_WEAK_PULL_UP
|
||||
#define BUTTON_STATE_ACTIVE 0
|
||||
|
||||
// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
|
||||
#define UART_NUM 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H_ */
|
42
hw/bsp/max32650/boards/max32651evkit/board.mk
Normal file
42
hw/bsp/max32650/boards/max32651evkit/board.mk
Normal file
@ -0,0 +1,42 @@
|
||||
LD_FILE = $(BOARD_PATH)/max32651.ld
|
||||
CFLAGS += -D__SLA_FWK__
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = max32650
|
||||
|
||||
# flash target using MSDK signing the image
|
||||
flash: flash-msdk-signed
|
||||
|
||||
|
||||
MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
|
||||
|
||||
# The MAX32651EVKIT is pin for pin identical to the MAX32650EVKIT, however the
|
||||
# MAX32651 has a secure bootloader which requires the image to be signed before
|
||||
# loading into flash. All MAX32651EVKIT's have the same key for evaluation
|
||||
# purposes, so create a special flash rule to sign the binary and flash using
|
||||
# the MSDK.
|
||||
# For the MAX32650, the regular flash, flash-jlink and flash-msdk are sufficient
|
||||
MCU_PATH = $(TOP)/hw/mcu/analog/max32/
|
||||
# Assume no extension for sign utility
|
||||
SIGN_EXE = sign_app
|
||||
ifeq ($(OS), Windows_NT)
|
||||
# Must use .exe extension on Windows, since the binaries
|
||||
# for Linux may live in the same place.
|
||||
SIGN_EXE := sign_app.exe
|
||||
else
|
||||
UNAME = $(shell uname -s)
|
||||
ifneq ($(findstring MSYS_NT,$(UNAME)),)
|
||||
# Must also use .exe extension for MSYS2
|
||||
SIGN_EXE := sign_app.exe
|
||||
endif
|
||||
endif
|
||||
|
||||
flash-msdk-signed: $(BUILD)/$(PROJECT).elf
|
||||
$(OBJCOPY) $(BUILD)/$(PROJECT).elf -R .sig -O binary $(BUILD)/$(PROJECT).bin
|
||||
$(MCU_PATH)/Tools/SBT/bin/$(SIGN_EXE) -c MAX32651 key_file="$(MCU_PATH)/Tools/SBT/devices/MAX32651/keys/maximtestcrk.key" \
|
||||
ca=$(BUILD)/$(PROJECT).bin sca=$(BUILD)/$(PROJECT).sbin
|
||||
$(OBJCOPY) $(BUILD)/$(PROJECT).elf --update-section .sig=$(BUILD)/$(PROJECT).sig
|
||||
$(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
|
||||
-f interface/cmsis-dap.cfg -f target/max32650.cfg \
|
||||
-c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
|
||||
|
132
hw/bsp/max32650/boards/max32651evkit/max32651.ld
Normal file
132
hw/bsp/max32650/boards/max32651evkit/max32651.ld
Normal file
@ -0,0 +1,132 @@
|
||||
MEMORY {
|
||||
HEADER (rx): ORIGIN = 0x10000000, LENGTH = 0x200
|
||||
FLASH (rx) : ORIGIN = 0x10000200, LENGTH = 0x002FFE00 /* 3MB flash */
|
||||
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000 /* 1MB SRAM */
|
||||
}
|
||||
|
||||
/* Added Oct 9, 2018 to go to correct reset vector. */
|
||||
ENTRY(Reset_Handler)
|
||||
PROVIDE( _start_SWAP = (((Reset_Handler) >> 24) | (((Reset_Handler) & 0x00FF0000) >> 8) | (((Reset_Handler) & 0x0000FF00) << 8) | ((Reset_Handler) << 24)));
|
||||
PROVIDE_HIDDEN( _SLA_Size = _endimage - __end_header );
|
||||
PROVIDE( _SLA_Size_SWAP = (((_SLA_Size) >> 24) | (((_SLA_Size) & 0x00FF0000) >> 8) | (((_SLA_Size) & 0x0000FF00) << 8) | ((_SLA_Size) << 24)));
|
||||
|
||||
/* Sections Definitions */
|
||||
SECTIONS {
|
||||
.sb_sla_header : ALIGN(4)
|
||||
{
|
||||
FILL(0xFF)
|
||||
KEEP(*(.sb_sla_header)) /* Header for ROM code */
|
||||
__end_header = . ;
|
||||
. = ALIGN(512);
|
||||
} > HEADER
|
||||
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*) /* program code */
|
||||
*(.rodata*) /* read-only data: "const" */
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* C++ Exception handling */
|
||||
KEEP(*(.eh_frame*))
|
||||
_etext = .;
|
||||
} > FLASH
|
||||
|
||||
/* it's used for C++ exception handling */
|
||||
/* we need to keep this to avoid overlapping */
|
||||
.ARM.exidx :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
_data = ALIGN(., 4);
|
||||
*(.data*) /*read-write initialized data: initialized global variable*/
|
||||
*(.spix_config*) /* SPIX configuration functions need to be run from SRAM */
|
||||
*(.flashprog*) /* Flash program */
|
||||
|
||||
|
||||
/* These array sections are used by __libc_init_array to call static C++ constructors */
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
_edata = ALIGN(., 4);
|
||||
} > SRAM AT>FLASH
|
||||
__load_data = LOADADDR(.data);
|
||||
_enddata = LOADADDR(.data)+SIZEOF(.data);
|
||||
|
||||
.sb_sla_trailer : AT(_enddata)
|
||||
{
|
||||
KEEP(*(.sb_sla_trailer))
|
||||
/* Align image with 16 byte boundary to conform to flash encryption block size. */
|
||||
FILL(0xDEADC0DE);
|
||||
/* NOTE: The FILL and ALIGN will not work unless something is written to the section. So, we use LONG. */
|
||||
LONG(0xDEADC0DE);
|
||||
. = ALIGN(16);
|
||||
} > FLASH
|
||||
_endimage = LOADADDR(.sb_sla_trailer)+SIZEOF(.sb_sla_trailer);
|
||||
.sig :
|
||||
{
|
||||
KEEP(*(.sig))
|
||||
LONG(0xDEADBEEF);
|
||||
|
||||
} > FLASH
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_bss = .;
|
||||
*(.bss*) /*read-write zero initialized data: uninitialzed global variable*/
|
||||
*(COMMON)
|
||||
_ebss = ALIGN(., 4);
|
||||
} > SRAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > SRAM
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
*(.heap*)
|
||||
__HeapLimit = ABSOLUTE(__StackLimit);
|
||||
} > SRAM
|
||||
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
|
||||
}
|
160
hw/bsp/max32650/family.c
Normal file
160
hw/bsp/max32650/family.c
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024 Brent Kowal (Analog Devices, Inc)
|
||||
*
|
||||
* 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 THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "gpio.h"
|
||||
#include "mxc_device.h"
|
||||
#include "uart.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM
|
||||
//--------------------------------------------------------------------+
|
||||
mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(UART_NUM);
|
||||
|
||||
void board_init(void) {
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
// 1ms tick timer
|
||||
SysTick_Config(SystemCoreClock / 1000);
|
||||
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
||||
NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
|
||||
#endif
|
||||
mxc_gpio_cfg_t gpioConfig;
|
||||
|
||||
// LED
|
||||
gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
|
||||
gpioConfig.func = MXC_GPIO_FUNC_OUT;
|
||||
gpioConfig.mask = LED_PIN;
|
||||
gpioConfig.pad = MXC_GPIO_PAD_NONE;
|
||||
gpioConfig.port = LED_PORT;
|
||||
gpioConfig.vssel = LED_VDDIO;
|
||||
MXC_GPIO_Config(&gpioConfig);
|
||||
board_led_write(false);
|
||||
|
||||
// Button
|
||||
gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
|
||||
gpioConfig.func = MXC_GPIO_FUNC_IN;
|
||||
gpioConfig.mask = BUTTON_PIN;
|
||||
gpioConfig.pad = BUTTON_PULL;
|
||||
gpioConfig.port = BUTTON_PORT;
|
||||
gpioConfig.vssel = MXC_GPIO_VSSEL_VDDIO;
|
||||
MXC_GPIO_Config(&gpioConfig);
|
||||
|
||||
// UART
|
||||
MXC_UART_Init(ConsoleUart, CFG_BOARD_UART_BAUDRATE);
|
||||
|
||||
//USB
|
||||
// Startup the HIRC96M clock if it's not on already
|
||||
if (!(MXC_GCR->clk_ctrl & MXC_F_GCR_CLK_CTRL_HIRC96_EN)) {
|
||||
MXC_GCR->clk_ctrl |= MXC_F_GCR_CLK_CTRL_HIRC96_EN;
|
||||
MXC_SYS_Clock_Timeout(MXC_F_GCR_CLK_CTRL_HIRC96_RDY);
|
||||
}
|
||||
|
||||
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_USB);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void board_led_write(bool state) {
|
||||
#if LED_STATE_ON
|
||||
state = !state;
|
||||
#endif
|
||||
if (state) {
|
||||
MXC_GPIO_OutClr(LED_PORT, LED_PIN);
|
||||
} else {
|
||||
MXC_GPIO_OutSet(LED_PORT, LED_PIN);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void) {
|
||||
uint32_t state = MXC_GPIO_InGet(BUTTON_PORT, BUTTON_PIN) ? 1 : 0;
|
||||
return BUTTON_STATE_ACTIVE == state;
|
||||
}
|
||||
|
||||
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
|
||||
uint8_t hw_id[13];//USN Buffer
|
||||
MXC_SYS_GetUSN(hw_id, 13);
|
||||
|
||||
size_t act_len = TU_MIN(max_len, 13);
|
||||
memcpy(id, hw_id, act_len);
|
||||
return act_len;
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t *buf, int len) {
|
||||
int uart_val;
|
||||
int act_len = 0;
|
||||
|
||||
while (act_len < len) {
|
||||
if ((uart_val = MXC_UART_ReadCharacterRaw(ConsoleUart)) == E_UNDERFLOW) {
|
||||
break;
|
||||
} else {
|
||||
*buf++ = (uint8_t) uart_val;
|
||||
act_len++;
|
||||
}
|
||||
}
|
||||
return act_len;
|
||||
}
|
||||
|
||||
int board_uart_write(void const *buf, int len) {
|
||||
int act_len = 0;
|
||||
const uint8_t *ch_ptr = (const uint8_t *) buf;
|
||||
while (act_len < len) {
|
||||
MXC_UART_WriteCharacter(ConsoleUart, *ch_ptr++);
|
||||
act_len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
#endif
|
||||
|
||||
void HardFault_Handler(void) {
|
||||
__asm("BKPT #0\n");
|
||||
}
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void) {
|
||||
}
|
152
hw/bsp/max32650/family.cmake
Normal file
152
hw/bsp/max32650/family.cmake
Normal file
@ -0,0 +1,152 @@
|
||||
include_guard()
|
||||
|
||||
set(MAX32_PERIPH ${TOP}/hw/mcu/analog/max32/Libraries/PeriphDrivers)
|
||||
set(MAX32_CMSIS ${TOP}/hw/mcu/analog/max32/Libraries/CMSIS)
|
||||
set(CMSIS_5 ${TOP}/lib/CMSIS_5)
|
||||
|
||||
# include board specific
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
|
||||
# Get the linker file from current location (family)
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
|
||||
# toolchain set up
|
||||
set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
||||
set(JLINK_DEVICE max32650)
|
||||
|
||||
set(FAMILY_MCUS MAX32650 CACHE INTERNAL "")
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
TARGET=MAX32650
|
||||
TARGET_REV=0x4131
|
||||
MXC_ASSERT_ENABLE
|
||||
MAX32650
|
||||
IAR_PRAGMAS=0
|
||||
CFG_TUSB_MCU=OPT_MCU_MAX32650
|
||||
BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
|
||||
)
|
||||
endfunction()
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/GCC/startup_max32650.S)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
#set(STARTUP_FILE_IAR ?)
|
||||
|
||||
set(PERIPH_SRC ${MAX32_PERIPH}/Source)
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/heap.c
|
||||
${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/system_max32650.c
|
||||
${PERIPH_SRC}/SYS/mxc_assert.c
|
||||
${PERIPH_SRC}/SYS/mxc_delay.c
|
||||
${PERIPH_SRC}/SYS/mxc_lock.c
|
||||
${PERIPH_SRC}/SYS/nvic_table.c
|
||||
${PERIPH_SRC}/SYS/pins_me10.c
|
||||
${PERIPH_SRC}/SYS/sys_me10.c
|
||||
${PERIPH_SRC}/TPU/tpu_me10.c
|
||||
${PERIPH_SRC}/TPU/tpu_reva.c
|
||||
${PERIPH_SRC}/FLC/flc_common.c
|
||||
${PERIPH_SRC}/FLC/flc_me10.c
|
||||
${PERIPH_SRC}/FLC/flc_reva.c
|
||||
${PERIPH_SRC}/GPIO/gpio_common.c
|
||||
${PERIPH_SRC}/GPIO/gpio_me10.c
|
||||
${PERIPH_SRC}/GPIO/gpio_reva.c
|
||||
${PERIPH_SRC}/ICC/icc_me10.c
|
||||
${PERIPH_SRC}/ICC/icc_reva.c
|
||||
${PERIPH_SRC}/ICC/icc_common.c
|
||||
${PERIPH_SRC}/UART/uart_common.c
|
||||
${PERIPH_SRC}/UART/uart_me10.c
|
||||
${PERIPH_SRC}/UART/uart_reva.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMSIS_5}/CMSIS/Core/Include
|
||||
${MAX32_CMSIS}/Include
|
||||
${MAX32_CMSIS}/Device/Maxim/MAX32650/Include
|
||||
${MAX32_PERIPH}/Include/MAX32650
|
||||
${PERIPH_SRC}/SYS
|
||||
${PERIPH_SRC}/GPIO
|
||||
${PERIPH_SRC}/TPU
|
||||
${PERIPH_SRC}/ICC
|
||||
${PERIPH_SRC}/FLC
|
||||
${PERIPH_SRC}/UART
|
||||
)
|
||||
|
||||
target_compile_options(${BOARD_TARGET} PRIVATE
|
||||
-Wno-error=strict-prototypes
|
||||
)
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_MAX32650 ${RTOS})
|
||||
target_sources(${TARGET}-tinyusb PUBLIC
|
||||
${TOP}/src/portable/analog/max32/dcd_max32.c
|
||||
)
|
||||
target_compile_options(${TARGET} PRIVATE
|
||||
-Wno-error=strict-prototypes
|
||||
)
|
||||
|
||||
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
|
||||
target_compile_options(${TARGET}-tinyusb PRIVATE
|
||||
-Wno-error=strict-prototypes
|
||||
)
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
|
||||
|
||||
# Flashing
|
||||
family_flash_jlink(${TARGET})
|
||||
endfunction()
|
||||
|
85
hw/bsp/max32650/family.mk
Normal file
85
hw/bsp/max32650/family.mk
Normal file
@ -0,0 +1,85 @@
|
||||
DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/analog/max32
|
||||
|
||||
# Important locations in the hw support for MCU
|
||||
MAX32_CMSIS = hw/mcu/analog/max32/Libraries/CMSIS
|
||||
MAX32_PERIPH = hw/mcu/analog/max32/Libraries/PeriphDrivers
|
||||
|
||||
# Add any board specific make rules
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
CPU_CORE ?= cortex-m4
|
||||
PORT ?= 0
|
||||
|
||||
# GCC
|
||||
SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/GCC/startup_max32650.S
|
||||
|
||||
# IAR
|
||||
#SRC_S_IAR += ?
|
||||
|
||||
# --------------
|
||||
# Compiler Flags
|
||||
# --------------
|
||||
# Flags for the MAX32650/1/2 SDK
|
||||
CFLAGS += -DTARGET=MAX32650 \
|
||||
-DTARGET_REV=0x4131 \
|
||||
-DMXC_ASSERT_ENABLE \
|
||||
-DMAX32650 \
|
||||
-DIAR_PRAGMAS=0
|
||||
|
||||
# Flags for TUSB features
|
||||
CFLAGS += \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_MAX32650 \
|
||||
-DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
|
||||
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=strict-prototypes \
|
||||
-Wno-error=unused-parameter \
|
||||
-Wno-error=cast-align \
|
||||
-Wno-error=cast-qual \
|
||||
-Wno-error=sign-compare
|
||||
|
||||
LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
|
||||
|
||||
# -----------------
|
||||
# Sources & Include
|
||||
# -----------------
|
||||
PERIPH_SRC = $(TOP)/$(MAX32_PERIPH)/Source
|
||||
SRC_C += \
|
||||
src/portable/analog/max32/dcd_max32.c \
|
||||
$(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/heap.c \
|
||||
$(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/system_max32650.c \
|
||||
$(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/header_MAX32650.c \
|
||||
$(PERIPH_SRC)/SYS/mxc_assert.c \
|
||||
$(PERIPH_SRC)/SYS/mxc_delay.c \
|
||||
$(PERIPH_SRC)/SYS/mxc_lock.c \
|
||||
$(PERIPH_SRC)/SYS/nvic_table.c \
|
||||
$(PERIPH_SRC)/SYS/pins_me10.c \
|
||||
$(PERIPH_SRC)/SYS/sys_me10.c \
|
||||
$(PERIPH_SRC)/FLC/flc_common.c \
|
||||
$(PERIPH_SRC)/FLC/flc_me10.c \
|
||||
$(PERIPH_SRC)/FLC/flc_reva.c \
|
||||
$(PERIPH_SRC)/GPIO/gpio_common.c \
|
||||
$(PERIPH_SRC)/GPIO/gpio_me10.c \
|
||||
$(PERIPH_SRC)/GPIO/gpio_reva.c \
|
||||
$(PERIPH_SRC)/ICC/icc_me10.c \
|
||||
$(PERIPH_SRC)/ICC/icc_reva.c \
|
||||
$(PERIPH_SRC)/ICC/icc_common.c \
|
||||
$(PERIPH_SRC)/TPU/tpu_me10.c \
|
||||
$(PERIPH_SRC)/TPU/tpu_reva.c \
|
||||
$(PERIPH_SRC)/UART/uart_common.c \
|
||||
$(PERIPH_SRC)/UART/uart_me10.c \
|
||||
$(PERIPH_SRC)/UART/uart_reva.c \
|
||||
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(BOARD_PATH) \
|
||||
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
|
||||
$(TOP)/$(MAX32_CMSIS)/Include \
|
||||
$(TOP)/$(MAX32_CMSIS)/Device/Maxim/MAX32650/Include \
|
||||
$(TOP)/$(MAX32_PERIPH)/Include/MAX32650 \
|
||||
$(PERIPH_SRC)/SYS \
|
||||
$(PERIPH_SRC)/GPIO \
|
||||
$(PERIPH_SRC)/ICC \
|
||||
$(PERIPH_SRC)/FLC \
|
||||
$(PERIPH_SRC)/TPU \
|
||||
$(PERIPH_SRC)/UART
|
@ -46,7 +46,7 @@ extern "C" {
|
||||
#define BUTTON_PULL MXC_GPIO_PAD_PULL_UP
|
||||
#define BUTTON_STATE_ACTIVE 0
|
||||
|
||||
// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
|
||||
// UART Enable for UART on SWD. Pin Mux handled by the HAL
|
||||
#define UART_NUM 1
|
||||
#define UART_MAP MAP_B
|
||||
|
||||
|
@ -36,13 +36,7 @@ CFLAGS += \
|
||||
CFLAGS += -Wno-error=strict-prototypes \
|
||||
-Wno-error=unused-parameter \
|
||||
-Wno-error=cast-align \
|
||||
-Wno-error=cast-qual \
|
||||
#
|
||||
# -Wno-error=old-style-declaration \
|
||||
# -Wno-error=sign-compare \
|
||||
# -Wno-error=cast-qual \
|
||||
# -Wno-lto-type-mismatch
|
||||
|
||||
-Wno-error=cast-qual
|
||||
LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
|
||||
|
||||
# For flash-jlink target
|
||||
@ -56,7 +50,7 @@ flash: flash-jlink
|
||||
# If the MSDK is installed, flash-msdk can be run to utilize the the modified
|
||||
# openocd with the algorithms
|
||||
MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
|
||||
flash-msdk:
|
||||
flash-msdk: $(BUILD)/$(PROJECT).elf
|
||||
$(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
|
||||
-f interface/cmsis-dap.cfg -f target/max32665.cfg \
|
||||
-c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
|
||||
|
@ -57,7 +57,7 @@ flash: flash-jlink
|
||||
# If the MSDK is installed, flash-msdk can be run to utilize the the modified
|
||||
# openocd with the algorithms
|
||||
MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
|
||||
flash-msdk:
|
||||
flash-msdk: $(BUILD)/$(PROJECT).elf
|
||||
$(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
|
||||
-f interface/cmsis-dap.cfg -f target/max32690.cfg \
|
||||
-c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
|
||||
|
@ -53,7 +53,7 @@ flash: flash-jlink
|
||||
# If the MSDK is installed, flash-msdk can be run to utilize the the modified
|
||||
# openocd with the algorithms
|
||||
MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
|
||||
flash-msdk:
|
||||
flash-msdk: $(BUILD)/$(PROJECT).elf
|
||||
$(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
|
||||
-f interface/cmsis-dap.cfg -f target/max78002.cfg \
|
||||
-c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
|
||||
|
Loading…
x
Reference in New Issue
Block a user