Merge pull request #3460 from hathach/bsp_h7_tm4c

Add EK-TM4C1294XL and STM32H747-DISCO bsp
This commit is contained in:
Ha Thach
2026-01-15 10:01:43 +07:00
committed by GitHub
22 changed files with 733 additions and 37 deletions

View File

@ -292,6 +292,7 @@ stm32h723nucleo STM32 H723 Nucleo stm32h7 https://www.s
stm32h743eval STM32 H743 Eval stm32h7 https://www.st.com/en/evaluation-tools/stm32h743i-eval.html
stm32h743nucleo STM32 H743 Nucleo stm32h7 https://www.st.com/en/evaluation-tools/nucleo-h743zi.html
stm32h745disco STM32 H745 Discovery stm32h7 https://www.st.com/en/evaluation-tools/stm32h745i-disco.html
stm32h747disco STM32 H747 Discovery stm32h7 https://www.st.com/en/evaluation-tools/stm32h747i-disco.html
stm32h750_weact STM32 H750 WeAct stm32h7 https://www.adafruit.com/product/5032
stm32h750bdk STM32 H750b Discovery Kit stm32h7 https://www.st.com/en/evaluation-tools/stm32h750b-dk.html
waveshare_openh743i Waveshare Open H743i stm32h7 https://www.waveshare.com/openh743i-c-standard.htm
@ -333,6 +334,7 @@ Board Name Family URL
msp_exp430f5529lp MSP430F5529 LaunchPad msp430 https://www.ti.com/tool/MSP-EXP430F5529LP
msp_exp432e401y MSP432E401Y LaunchPad msp432e4 https://www.ti.com/tool/MSP-EXP432E401Y
ek_tm4c123gxl TM4C123G LaunchPad tm4c https://www.ti.com/tool/EK-TM4C123GXL
ek_tm4c1294xl TM4C1294 LaunchPad tm4c https://www.ti.com/tool/EK-TM4C1294XL
================= ===================== ======== ========================================= ======
Tomu

View File

@ -1,3 +1,3 @@
mcu:TM4C123
mcu:TM4C
mcu:BCM2835
family:espressif

View File

@ -174,6 +174,10 @@
"name": "ek_tm4c123gxl",
"inherits": "default"
},
{
"name": "ek_tm4c1294xl",
"inherits": "default"
},
{
"name": "f1c100s",
"inherits": "default"
@ -718,6 +722,10 @@
"name": "stm32h745disco",
"inherits": "default"
},
{
"name": "stm32h747disco",
"inherits": "default"
},
{
"name": "stm32h750_weact",
"inherits": "default"
@ -1108,6 +1116,11 @@
"description": "Build preset for the ek_tm4c123gxl board",
"configurePreset": "ek_tm4c123gxl"
},
{
"name": "ek_tm4c1294xl",
"description": "Build preset for the ek_tm4c1294xl board",
"configurePreset": "ek_tm4c1294xl"
},
{
"name": "espressif_addax_1",
"description": "Build preset for the espressif_addax_1 board",
@ -1833,6 +1846,11 @@
"description": "Build preset for the stm32h745disco board",
"configurePreset": "stm32h745disco"
},
{
"name": "stm32h747disco",
"description": "Build preset for the stm32h747disco board",
"configurePreset": "stm32h747disco"
},
{
"name": "stm32h750_weact",
"description": "Build preset for the stm32h750_weact board",
@ -2542,6 +2560,19 @@
}
]
},
{
"name": "ek_tm4c1294xl",
"steps": [
{
"type": "configure",
"name": "ek_tm4c1294xl"
},
{
"type": "build",
"name": "ek_tm4c1294xl"
}
]
},
{
"name": "espressif_addax_1",
"steps": [
@ -4427,6 +4458,19 @@
}
]
},
{
"name": "stm32h747disco",
"steps": [
{
"type": "configure",
"name": "stm32h747disco"
},
{
"type": "build",
"name": "stm32h747disco"
}
]
},
{
"name": "stm32h750_weact",
"steps": [

View File

@ -0,0 +1,23 @@
set(MCU_VARIANT stm32h747xx)
set(JLINK_DEVICE stm32h747xi_m7)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/${MCU_VARIANT}_flash_CM7.ld)
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash_CM7.icf)
set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED)
# device default to PORT 1 High Speed
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 1)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 1)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32H747xx
HSE_VALUE=25000000
CORE_CM7
)
endfunction()

View File

@ -0,0 +1,169 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021, Ha Thach (tinyusb.org)
*
* 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.
*/
/* metadata:
name: STM32 H745 Discovery
url: https://www.st.com/en/evaluation-tools/stm32h745i-disco.html
*/
#ifndef BOARD_H_
#define BOARD_H_
#ifdef __cplusplus
extern "C" {
#endif
// UART
#define UART_DEV USART3
#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 1
#define OTG_HS_VBUS_SENSE 0
// USB HS External PHY Pin: CLK, STP, DIR, NXT, D0-D7
#define ULPI_PINS \
{GPIOA, GPIO_PIN_3 }, {GPIOA, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_0 }, {GPIOB, GPIO_PIN_1 }, \
{GPIOB, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_10}, {GPIOB, GPIO_PIN_11}, {GPIOB, GPIO_PIN_12}, \
{GPIOB, GPIO_PIN_13}, {GPIOC, GPIO_PIN_0 }, {GPIOH, GPIO_PIN_4 }, {GPIOI, GPIO_PIN_11}
#define PINID_LED 0
#define PINID_BUTTON 1
#define PINID_UART_TX 2
#define PINID_UART_RX 3
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOI,
.pin_init = { .Pin = GPIO_PIN_12, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 0
},
{ // Button
.port = GPIOC,
.pin_init = { .Pin = GPIO_PIN_13, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART3 },
.active_state = 0
},
{ // UART RX
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_10, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART3 },
.active_state = 0
}
};
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
static inline void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = { 0 };
/*!< Supply configuration update enable */
/* For STM32H750XB, use "HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);" */
HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY);
/* The voltage scaling allows optimizing the power consumption when the
device is clocked below the maximum system frequency, to update the
voltage scaling value regarding system frequency refer to product
datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
/* PLL1 for System Clock */
RCC_OscInitStruct.PLL.PLLM = 5;
RCC_OscInitStruct.PLL.PLLN = 160;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLQ = 4;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
/* PLL3 for USB Clock */
PeriphClkInitStruct.PLL3.PLL3M = 25;
PeriphClkInitStruct.PLL3.PLL3N = 336;
PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
PeriphClkInitStruct.PLL3.PLL3P = 2;
PeriphClkInitStruct.PLL3.PLL3R = 2;
PeriphClkInitStruct.PLL3.PLL3Q = 7;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
/* Select PLL as system clock source and configure bus clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
/*activate CSI clock mondatory for I/O Compensation Cell*/
__HAL_RCC_CSI_ENABLE() ;
/* Enable SYSCFG clock mondatory for I/O Compensation Cell */
__HAL_RCC_SYSCFG_CLK_ENABLE() ;
/* Enables the I/O Compensation Cell */
HAL_EnableCompensationCell();
}
static inline void board_init2(void) {
// For this board does nothing
}
void board_vbus_set(uint8_t rhport, bool state) {
(void) rhport;
(void) state;
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,15 @@
# STM32H747I-DISCO uses OTG_FS
# FIXME: Reset enumerates, un/replug USB plug does not enumerate
MCU_VARIANT = stm32h747xx
CFLAGS += -DSTM32H747xx -DCORE_CM7 -DHSE_VALUE=25000000
# Default is FulSpeed port
PORT ?= 0
LD_FILE_GCC = $(FAMILY_PATH)/linker/${MCU_VARIANT}_flash_CM7.ld
LD_FILE_IAR = $(ST_CMSIS)/Source/Templates/iar/linker/stm32h747xx_flash_CM7.icf
# For flash-jlink target
JLINK_DEVICE = stm32h747xi_m7
# flash target using on-board stlink
flash: flash-stlink

View File

@ -0,0 +1,184 @@
/*
******************************************************************************
**
** File : LinkerScript.ld
**
**
** Abstract : Linker script for STM32H7 series
** 1024Kbytes FLASH and 192Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed as is without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** Copyright (c) 2019 STMicroelectronics.
** All rights reserved.
**
** This software is licensed under terms that can be found in the LICENSE file
** in the root directory of this software component.
** If no LICENSE file comes with this software, it is provided AS-IS.
**
******************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20020000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab :
{
. = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} >FLASH
.ARM :
{
. = ALIGN(4);
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
. = ALIGN(4);
} >FLASH
.preinit_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
} >FLASH
.init_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
} >FLASH
.fini_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}

View File

@ -44,7 +44,13 @@
// skip if included from IAR assembler
#ifndef __IASMARM__
#include "TM4C123.h"
#ifdef TM4C123GH6PM
#include "TM4C123.h"
#elif TM4C1294NCPDT
#include "TM4C129.h"
#else
#error "Unknown TM4C device"
#endif
#endif
/* Cortex M23/M33 port configuration. */

View File

@ -36,20 +36,26 @@
extern "C" {
#endif
#include "TM4C123.h"
#define BOARD_UART UART0
#define BOARD_UART_PORT GPIOA
#define BTN_PORT_CLK 5
#define BOARD_BTN_PORT GPIOF
#define BOARD_BTN 4
#define BOARD_BTN_Msk (1u<<4)
#define BUTTON_STATE_ACTIVE 0
#define LED_PORT_CLK 5
#define LED_PORT GPIOF
#define LED_PIN_RED 1
#define LED_PIN_BLUE 2
#define LED_PIN_GREEN 3
#define LED_STATE_ON 1
#define BOARD_LED_PIN LED_PIN_BLUE
#ifdef __cplusplus
}
#endif

View File

@ -17,7 +17,7 @@ SECTIONS
.text :
{
. = ALIGN(4) ;
*(.vectors)
KEEP(*(.vectors))
*(.text)
*(.text.*)
*(.init)

View File

@ -0,0 +1,28 @@
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x000FFFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2003FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x8000;
define symbol __ICFEDIT_size_heap__ = 0x10000;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };

View File

@ -0,0 +1,13 @@
set(MCU_SUB_VARIANT 129)
set(JLINK_DEVICE TM4C1294NCPDT)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/tm4c1294nc.ld)
set(LD_FILE_IAR ${CMAKE_CURRENT_LIST_DIR}/TM4C1294NC.icf)
set(OPENOCD_OPTION "-f board/ti_ek-tm4c1294xl.cfg")
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
TM4C1294NCPDT
)
endfunction()

View File

@ -0,0 +1,75 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021, Ha Thach (tinyusb.org)
*
* 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.
*/
/* metadata:
name: TM4C1294 LaunchPad
url: https://www.ti.com/tool/EK-TM4C1294XL
*/
#ifndef _BOARD_H_
#define _BOARD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "TM4C129.h"
#define BOARD_UART UART0
#define BOARD_UART_PORT GPIOA
#define BTN_PORT_CLK 8
#define BOARD_BTN_PORT GPIOJ
#define BOARD_BTN 0
#define BOARD_BTN_Msk (1u<<0)
#define BUTTON_STATE_ACTIVE 0
#define LED_PORT_CLK 12
#define LED_PORT GPION
#define LED_PIN_1 1
#define LED_PIN_2 0
#define LED_STATE_ON 1
#define BOARD_LED_PIN LED_PIN_2
#define GPIOA GPIOA_AHB
#define GPIOB GPIOB_AHB
#define GPIOC GPIOC_AHB
#define GPIOD GPIOD_AHB
#define GPIOE GPIOE_AHB
#define GPIOF GPIOF_AHB
#define GPIOG GPIOG_AHB
#define GPIOH GPIOH_AHB
#define GPIOI GPIOI_AHB
#define GPIOJ GPIOJ_AHB
#define GPIOA_Type GPIOA_AHB_Type
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,16 @@
MCU_SUB_VARIANT = 129
CFLAGS += -DTM4C1294NCPDT
LD_FILE_GCC = $(BOARD_PATH)/tm4c1294nc.ld
LD_FILE_IAR = $(BOARD_PATH)/TM4C1294NC.icf
# For flash-jlink target
JLINK_DEVICE = TM4C1294NCPDT
# flash using openocd
OPENOCD_OPTION = -f board/ti_ek-tm4c1294xl.cfg
UNIFLASH_OPTION = -c ${TOP}/${BOARD_PATH}/${BOARD}.ccxml -r 1
flash: flash-openocd

View File

@ -0,0 +1,66 @@
ENTRY(Reset_Handler)
_estack = 0x20008000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0; /* required amount of heap */
_Min_Stack_Size = 0x1000; /* required amount of stack */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000
}
SECTIONS
{
.text :
{
. = ALIGN(4) ;
_text = . ;
KEEP(*(.isr_vector))
*(.text)
*(.text.*)
*(.init)
*(.fini)
*(.rodata)
*(.rodata.*)
*(.ARM.exidx*)
_etext = . ;
. = ALIGN(4) ;
} >FLASH
.data : AT(ADDR(.text) + SIZEOF(.text))
{
_data = .;
. = ALIGN(4);
_ldata = LOADADDR (.data);
*(.data)
*(.data.*)
_edata = .;
. = ALIGN(4);
} >SRAM
.bss :
{
. = ALIGN(4) ;
_bss = .;
*(.bss)
*(.bss.*)
*(.COMMON)
_ebss = .;
. = ALIGN(4);
}>SRAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >SRAM
}

View File

@ -2,7 +2,6 @@
manufacturer: Texas Instruments
*/
#include "TM4C123.h"
#include "bsp/board_api.h"
#include "board.h"
@ -27,6 +26,9 @@ static void board_uart_init(void) {
SYSCTL->RCGCUART |= (1 << 0); // Enable the clock to UART0
SYSCTL->RCGCGPIO |= (1 << 0); // Enable the clock to GPIOA
while (!(SYSCTL->PRGPIO & (1 << 0))) {} // Wait for the GPIOA clock to stabilize
while (!(SYSCTL->PRUART & (1 << 0))) {} // Wait for the UART0 clock to stabilize
GPIOA->AFSEL |= (1 << 1) | (1 << 0); // Enable the alternate function on pin PA0 & PA1
GPIOA->PCTL |= (1 << 0) | (1 << 4); // Configure the GPIOPCTL register to select UART0 in PA0 and PA1
GPIOA->DEN |= (1 << 0) | (1 << 1); // Enable the digital functionality in PA0 and PA1
@ -44,12 +46,26 @@ static void board_uart_init(void) {
UART0->CTL = (1 << 0) | (1 << 8) | (1 << 9); // UART0 Enable, Transmit Enable, Receive Enable
}
static void initialize_board_led(GPIOA_Type* port, uint8_t PinMsk, uint8_t dirmsk) {
/* Enable PortF Clock */
SYSCTL->RCGCGPIO |= (1 << 5);
static void board_button_init(GPIOA_Type* port, uint8_t PinMsk) {
/* Enable Port Clock */
SYSCTL->RCGCGPIO |= (1 << BTN_PORT_CLK);
/* Let the clock stabilize */
while (!((SYSCTL->PRGPIO) & (1 << 5))) {}
while (!((SYSCTL->PRGPIO) & (1 << BTN_PORT_CLK))) {}
/* Port Digital Enable */
port->DEN |= PinMsk;
/* Set direction */
port->DIR &= ~PinMsk;
}
static void board_led_init(GPIOA_Type* port, uint8_t PinMsk, uint8_t dirmsk) {
/* Enable Port Clock */
SYSCTL->RCGCGPIO |= (1 << LED_PORT_CLK);
/* Let the clock stabilize */
while (!((SYSCTL->PRGPIO) & (1 << LED_PORT_CLK))) {}
/* Port Digital Enable */
port->DEN |= PinMsk;
@ -71,7 +87,9 @@ static uint32_t ReadGPIOPin(GPIOA_Type* port, uint8_t pinMsk) {
}
void board_init(void) {
#ifdef TM4C123_H
SystemCoreClockUpdate();
#endif
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
@ -83,6 +101,7 @@ void board_init(void) {
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
#ifdef TM4C123_H
/* Reset USB */
SYSCTL->SRCR2 |= (1u << 16);
@ -99,7 +118,7 @@ void board_init(void) {
/* USB IO Initialization */
SYSCTL->RCGCGPIO |= (1u << 3);
/* Let the clock stabilize */
/* Let the clock stabilize */
while (!(SYSCTL->PRGPIO & (1u << 3))) {}
/* USB IOs to Analog Mode */
@ -107,16 +126,43 @@ void board_init(void) {
GPIOD->DEN &= ~((1u << 4) | (1u << 5));
GPIOD->AMSEL |= ((1u << 4) | (1u << 5));
uint8_t leds = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN);
uint8_t dirmsk = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN);
#else // TM4C129
/* Reset USB */
SYSCTL->SRUSB = 1;
for (volatile uint8_t i = 0; i < 20; i++) {}
SYSCTL->SRUSB = 0;
/* Open the USB clock gate */
SYSCTL->RCGCUSB = 1;
/* Let the clock stabilize */
while(!(SYSCTL->PRUSB & 1)) {}
/* USB IO Initialization */
SYSCTL->RCGCGPIO |= (1u << 10);
/* Let the clock stabilize */
while (!(SYSCTL->PRGPIO & (1u << 10))) {}
/* USB IOs to Analog Mode */
GPIOL->AFSEL &= ~((1u << 6) | (1u << 7));
GPIOL->DEN &= ~((1u << 6) | (1u << 7));
GPIOL->AMSEL |= ((1u << 6) | (1u << 7));
/* USB Clock Configuration */
USB0->CC = 0x207;
#endif
uint8_t leds = 1 << BOARD_LED_PIN;
uint8_t dirmsk = 1 << BOARD_LED_PIN;
/* Configure GPIO for board button */
board_button_init(BOARD_BTN_PORT, BOARD_BTN_Msk);
/* Configure GPIO for board LED */
initialize_board_led(LED_PORT, leds, dirmsk);
/* Configure GPIO for board switch */
GPIOF->DIR &= ~(1 << BOARD_BTN);
GPIOF->PUR |= (1 << BOARD_BTN);
GPIOF->DEN |= (1 << BOARD_BTN);
board_led_init(LED_PORT, leds, dirmsk);
/* Initialize board UART */
board_uart_init();
@ -125,7 +171,7 @@ void board_init(void) {
}
void board_led_write(bool state) {
WriteGPIOPin(LED_PORT, (1 << LED_PIN_BLUE), state);
WriteGPIOPin(LED_PORT, (1 << BOARD_LED_PIN), state);
}
uint32_t board_button_read(void) {

View File

@ -5,14 +5,14 @@ include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
set(MCU_VARIANT tm4c${MCU_SUB_VARIANT})
set(MCU_VARIANT_UPPER TM4C${MCU_SUB_VARIANT})
set(SDK_DIR ${TOP}/hw/mcu/ti/${MCU_VARIANT}xx)
set(SDK_DIR ${TOP}/hw/mcu/ti/tm4c)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
# toolchain set up
set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
set(FAMILY_MCUS TM4C123 CACHE INTERNAL "")
set(FAMILY_MCUS TM4C CACHE INTERNAL "")
#------------------------------------
# Startup & Linker script
@ -20,7 +20,7 @@ set(FAMILY_MCUS TM4C123 CACHE INTERNAL "")
set(LD_FILE_Clang ${LD_FILE_GNU})
set(STARTUP_FILE_GNU ${SDK_DIR}/Source/GCC/${MCU_VARIANT}_startup.c)
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${SDK_DIR}/Source/IAR/${MCU_VARIANT}_startup.c)
#------------------------------------
# Board Target
#------------------------------------
@ -29,7 +29,7 @@ function(family_add_board BOARD_TARGET)
${SDK_DIR}/Source/system_${MCU_VARIANT_UPPER}.c
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/Include/${MCU_VARIANT_UPPER}
${SDK_DIR}/Include
${CMSIS_DIR}/CMSIS/Core/Include
)
@ -41,7 +41,7 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
family_add_tinyusb(${TARGET} OPT_MCU_TM4C123)
family_add_tinyusb(${TARGET} OPT_MCU_TM4C${MCU_SUB_VARIANT})
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
@ -71,13 +71,14 @@ function(family_configure_example TARGET RTOS)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
SKIP_LINTING ON
COMPILE_OPTIONS -w)
endif ()
set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
SKIP_LINTING ON
COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
family_flash_openocd(${TARGET})
family_flash_uniflash(${TARGET})
endfunction()

View File

@ -4,11 +4,11 @@ CPU_CORE ?= cortex-m4
MCU_VARIANT = tm4c${MCU_SUB_VARIANT}
MCU_VARIANT_UPPER = TM4C${MCU_SUB_VARIANT}
SDK_DIR = hw/mcu/ti/${MCU_VARIANT}xx
SDK_DIR = hw/mcu/ti/tm4c
CFLAGS += \
-flto \
-DCFG_TUSB_MCU=OPT_MCU_TM4C123 \
-DCFG_TUSB_MCU=OPT_MCU_TM4C${MCU_SUB_VARIANT} \
-uvectors \
# mcu driver cause following warnings
@ -18,7 +18,7 @@ LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
INC += \
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/$(SDK_DIR)/Include/${MCU_VARIANT_UPPER} \
$(TOP)/$(SDK_DIR)/Include \
$(TOP)/$(BOARD_PATH)
SRC_C += \

View File

@ -175,9 +175,8 @@ static void process_setup_packet(uint8_t rhport) {
// Read setup packet
uint32_t *p = (void*)&_dcd.setup_packet;
volatile uint32_t *fifo_ptr = &musb_regs->fifo[0];
p[0] = *fifo_ptr;
p[1] = *fifo_ptr;
p[0] = musb_regs->fifo[0];
p[1] = musb_regs->fifo[0];
_dcd.pipe0.buf = NULL;
_dcd.pipe0.length = 0;
@ -218,7 +217,7 @@ static bool handle_xfer_in(uint8_t rhport, uint_fast8_t ep_addr)
tu_hwfifo_write_from_fifo(fifo_ptr, (tu_fifo_t *)buf, len, NULL);
} else {
tu_hwfifo_write(fifo_ptr, buf, len, NULL);
pipe->buf = buf + len;
pipe->buf = (uint8_t*)buf + len;
}
pipe->remaining = rem - len;
}
@ -249,7 +248,7 @@ static bool handle_xfer_out(uint8_t rhport, uint_fast8_t ep_addr)
tu_hwfifo_read_to_fifo(fifo_ptr, (tu_fifo_t *)buf, len, NULL);
} else {
tu_hwfifo_read(fifo_ptr, buf, len, NULL);
pipe->buf = buf + len;
pipe->buf = (uint8_t*)buf + len;
}
pipe->remaining = rem - len;
}

View File

@ -35,7 +35,10 @@
#include "TM4C123.h"
#define FIFO0_WORD FIFO0
#define FIFO1_WORD FIFO1
//#elif CFG_TUSB_MCU == OPT_MCU_TM4C129
#elif CFG_TUSB_MCU == OPT_MCU_TM4C129
#include "TM4C129.h"
#define FIFO0_WORD FIFOA
#define FIFO1_WORD FIFOB
#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4
#include "msp.h"
#else

View File

@ -147,7 +147,7 @@ typedef struct TU_ATTR_PACKED {
TU_VERIFY_STATIC(sizeof(musb_ep_csr_t) == 16, "size is not correct");
typedef struct TU_ATTR_PACKED {
typedef struct {
//------------- Common -------------//
__IO uint8_t faddr; // 0x00: FADDR
union {

View File

@ -209,7 +209,7 @@ deps_optional = {
'9442fbb71f855ff2e64fbf662b7726beba511a24',
'stm32wba'],
'hw/mcu/ti': ['https://github.com/hathach/ti_driver.git',
'143ed6cc20a7615d042b03b21e070197d473e6e5',
'083944907e7d08fcb1f614b47598ce45935b8da1',
'msp430 msp432e4 tm4c'],
'hw/mcu/wch/ch32v103': ['https://github.com/openwch/ch32v103.git',
'7578cae0b21f86dd053a1f781b2fc6ab99d0ec17',