--some updates

This commit is contained in:
Mysteo
2023-07-26 17:38:26 +03:00
parent d5989a496b
commit bfa9d67eb9
13 changed files with 222 additions and 34 deletions

View File

@@ -91,11 +91,11 @@ add_link_options(-specs=nano.specs -specs=nosys.specs)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_custom_command(TARGET ${PROJECT_NAME}.elf PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/${MEM_MAP_FILE_DEBUG}" ${PROJECT_BINARY_DIR}/${MEM_MAP_FILE}
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/${MEM_MAP_FILE_DEBUG}" ${PROJECT_BINARY_DIR}/../${MEM_MAP_FILE}
)
else()
add_custom_command(TARGET ${PROJECT_NAME}.elf PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/${MEM_MAP_FILE}" ${PROJECT_BINARY_DIR}/${MEM_MAP_FILE}
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/${MEM_MAP_FILE}" ${PROJECT_BINARY_DIR}/../${MEM_MAP_FILE}
)
endif()
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD

View File

@@ -16,9 +16,9 @@ public:
Circular_Buffer<uint8_t> *uart1Buf;
Circular_Buffer<uint8_t> *uart2Buf;
bool isTurnOn() const;
void setIsTurnOn(bool isTurnOn);
static volatile uint8_t dataFromUart1;
static volatile uint8_t dataFromUart2;
void setTurnOn(bool isTurnOn);
volatile uint8_t dataFromUart1;
volatile uint8_t dataFromUart2;
void init(void);
private:

View File

@@ -11,26 +11,7 @@ UartBridge* bridgePnt;
uint8_t data[2];
extern "C" void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){
if (huart == bridgePnt->getHuart1())
{
if (!bridgePnt->uart1Buf->is_empty() && (__HAL_UART_GET_FLAG(bridgePnt->getHuart2(), UART_FLAG_TC)))
{
data[1] = bridgePnt->uart1Buf->dequeue();
HAL_UART_Transmit_IT(bridgePnt->getHuart2(), &data[1], 1);
}
}
else if (huart == bridgePnt->getHuart2())
{
if (!bridgePnt->uart2Buf->is_empty() && (__HAL_UART_GET_FLAG(bridgePnt->getHuart1(), UART_FLAG_TC)))
{
data[2] = bridgePnt->uart2Buf->dequeue();
HAL_UART_Transmit_IT(bridgePnt->getHuart1(), &data[2], 1);
}
}
}
extern "C" void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
@@ -75,7 +56,7 @@ bool UartBridge::isTurnOn() const {
return turnOn;
}
void UartBridge::setIsTurnOn(bool isTurnOn) {
void UartBridge::setTurnOn(bool isTurnOn) {
UartBridge::turnOn = isTurnOn;
}
@@ -130,7 +111,7 @@ extern "C" void USART1_IRQHandler(void)
/**
* @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26.
*/
void USART2_IRQHandler(void)
extern "C" void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */

View File

@@ -0,0 +1,186 @@
/*
******************************************************************************
**
** @file : LinkerScript.ld
**
** @author : Auto-generated by STM32CubeIDE
**
** @brief : Linker script for STM32G070CBTx Device from STM32G0 series
** 128Kbytes FLASH
** 36Kbytes 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) 2023 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)
INCLUDE memory_map.inc
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
_Min_Heap_Size = 0x1000; /* required amount of heap */
_Min_Stack_Size = 0x1000; /* required amount of stack */
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 36K
USER_PROG_FLASH_AREA(rx) : ORIGIN = _flash_main_prog_address , LENGTH = _flash_main_prog_size
}
/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
/* The program code and other data into "FLASH" Rom type memory */
.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 */
} >USER_PROG_FLASH_AREA
/* Constant data into "FLASH" Rom type memory */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
.ARM.extab : {
. = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
.ARM : {
. = ALIGN(4);
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
.preinit_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
.init_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
.fini_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
} >USER_PROG_FLASH_AREA
/* Used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections into "RAM" Ram type memory */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> USER_PROG_FLASH_AREA
/* Uninitialized data section into "RAM" Ram type memory */
. = 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" Ram type memory left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
/* Remove information from the compiler libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}