info stack systick

This commit is contained in:
zhangjin1996
2025-03-28 18:04:55 +08:00
parent 9fe9331ea2
commit d68fb81399
7 changed files with 74 additions and 199 deletions
+2 -2
View File
@@ -33,11 +33,11 @@
void InitBoardHardware()
{
sys_cache_enable();
HAL_Init();
sys_stm32_clock_init(192, 5, 2, 4);
delay_init(480);
//delay_init(480);
InitHwUart();
InitBoardMemory((void*)HEAP_START, (void*)HEAP_END);
+3 -4
View File
@@ -24,11 +24,10 @@
void InitBoardHardware();
extern void *__bss_end__;
extern void *_heap_end;
#define HEAP_START ((void *)&__bss_end__)
#define HEAP_END ((void *)&_heap_end)
#define HEAP_START 0x24030000
#define HEAP_END 0x24060000
+11 -13
View File
@@ -11,7 +11,7 @@ MEMORY
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler)
_system_stack_size = 0x200;
_system_stack_size = 0x10000;
SECTIONS
{
@@ -42,9 +42,6 @@ SECTIONS
__isrtbl_end = .;
. = ALIGN(4);
PROVIDE(g_service_table_start = ABSOLUTE(.));
KEEP(*(.g_service_table))
PROVIDE(g_service_table_end = ABSOLUTE(.));
PROVIDE(_etext = ABSOLUTE(.));
@@ -78,11 +75,12 @@ SECTIONS
__data_end__ = . ;
} >sram
__bss_start__ = .;
.bss :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
__bss_start__ = .;
_sbss = .;
*(.bss)
@@ -92,16 +90,16 @@ SECTIONS
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
__bss_end__ = .;
} > sram
.stack :
{
. = ALIGN(8);
/* cpu stack */
. = . + _system_stack_size;
__StackTop = .;
} > sram
__bss_end__ = .;
_end = .;
.stack ORIGIN(sram) + LENGTH(sram) - _system_stack_size :
{
PROVIDE( _heap_end = . );
. = _system_stack_size;
PROVIDE( __StackTop = . );
} >sram
}
@@ -1,7 +1,7 @@
SRC_DIR := libraries
ifeq ($(CONFIG_BSP_USING_UART),y)
SRC_DIR += usart sys delay
SRC_DIR += usart sys
endif
include $(KERNEL_ROOT)/compiler.mk
@@ -31,7 +31,12 @@ RCC_PeriphCLKInitTypeDef rcc_periph_clk_init_struct = {0};
void sys_cache_enable(void)
{
SCB_EnableICache(); /* ʹÄÜI-Cache */
SCB_EnableDCache(); /* ʹÄÜD-Cache */
SCB->CACR |= SCB_CACR_FORCEWT_Msk; /* ʹÄÜD-CacheÇ¿ÖÆÍ¸Ð´ */
}
/**
@@ -22,6 +22,7 @@
#include <connect_uart.h>
#include <usart.h>
#include <stm32h7xx_hal_cortex.h>
#include <stm32h7xx_hal_uart.h>
static struct SerialBus serial_bus_1;
static struct SerialDriver serial_driver_1;
static struct SerialHardwareDevice serial_device_1;
@@ -75,31 +76,19 @@ static void UartHandler(struct SerialBus *serial_bus, struct SerialDriver *seria
{
SerialSetIsr(serial_dev, SERIAL_EVENT_RX_IND);
}
else
{
if (__HAL_UART_GET_FLAG(&(serial_hw_cfg->uart_handle), UART_FLAG_ORE) != RESET)
{
__HAL_UART_CLEAR_OREFLAG(&serial_hw_cfg->uart_handle);
}
if (__HAL_UART_GET_FLAG(&(serial_hw_cfg->uart_handle), UART_FLAG_NE) != RESET)
{
__HAL_UART_CLEAR_NEFLAG(&serial_hw_cfg->uart_handle);
}
if (__HAL_UART_GET_FLAG(&(serial_hw_cfg->uart_handle), UART_FLAG_FE) != RESET)
{
__HAL_UART_CLEAR_FEFLAG(&serial_hw_cfg->uart_handle);
}
if (__HAL_UART_GET_FLAG(&(serial_hw_cfg->uart_handle), UART_FLAG_PE) != RESET)
{
__HAL_UART_CLEAR_PEFLAG(&serial_hw_cfg->uart_handle);
}
}
HAL_UART_IRQHandler(&(serial_hw_cfg->uart_handle));
}
void UartIsr1(int vector, void *param)
{
/* get serial bus 1 */
UartHandler(&serial_bus_1, &serial_driver_1);
x_base lock = 0;
lock = DISABLE_INTERRUPT();
UartHandler(&serial_bus_1, &serial_driver_1);
ENABLE_INTERRUPT(lock);
}
DECLARE_HW_IRQ(USART1_IRQn, UartIsr1, NONE);
@@ -240,11 +229,12 @@ static int SerialPutChar(struct SerialHardwareDevice *serial_dev, char c)
{
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_dev->private_data;
struct Stm32UartHwCfg *serial_hw_cfg = (struct Stm32UartHwCfg *)serial_cfg->hw_cfg.private_data;
/* Polling mode. */
HAL_UART_Transmit(&(serial_hw_cfg->uart_handle), (uint8_t *)&c, 1, 100);
// UART_INSTANCE_CLEAR_FUNCTION(&(serial_hw_cfg->uart_handle), UART_FLAG_TC);
UART_INSTANCE_CLEAR_FUNCTION(&(serial_hw_cfg->uart_handle), UART_FLAG_TC);
serial_hw_cfg->uart_handle.Instance->RDR = c;
while (__HAL_UART_GET_FLAG(&(serial_hw_cfg->uart_handle), UART_FLAG_TC) == RESET);
// serial_hw_cfg->uart_handle.Instance->TDR = c;
// while (__HAL_UART_GET_FLAG(&(serial_hw_cfg->uart_handle), UART_FLAG_TC) == RESET);
return EOK;
}