feat: 完成通信配置

This commit is contained in:
bmy
2024-03-02 16:00:29 +08:00
parent 038098ff2d
commit c03d2ddc74
4 changed files with 195 additions and 16 deletions

View File

@@ -90,9 +90,7 @@ void EXTI15_10_IRQHandler(void) __attribute__((interrupt()));
void USART1_IRQHandler(void) void USART1_IRQHandler(void)
{ {
if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) {
uint8_t data_s = 0;
uart_query_byte(UART_1, &data_s);
by_tiny_frame_parse_uart_handle(data_s);
USART_ClearITPendingBit(USART1, USART_IT_RXNE); USART_ClearITPendingBit(USART1, USART_IT_RXNE);
} }
} }
@@ -107,12 +105,15 @@ void USART2_IRQHandler(void)
void USART3_IRQHandler(void) void USART3_IRQHandler(void)
{ {
if (USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { if (USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) {
USART_ClearITPendingBit(USART3, USART_IT_RXNE);
} }
} }
void UART4_IRQHandler(void) void UART4_IRQHandler(void)
{ {
if (USART_GetITStatus(UART4, USART_IT_RXNE) != RESET) { if (USART_GetITStatus(UART4, USART_IT_RXNE) != RESET) {
uint8_t data_s = 0;
uart_query_byte(UART_4, &data_s);
by_tiny_frame_parse_uart_handle(data_s);
USART_ClearITPendingBit(UART4, USART_IT_RXNE); USART_ClearITPendingBit(UART4, USART_IT_RXNE);
} }
} }

View File

@@ -49,20 +49,14 @@ int main(void)
by_pwm_init(); by_pwm_init();
by_buzzer_init(); by_buzzer_init();
by_tiny_frame_init(); by_tiny_frame_init();
Page_Init(); Page_Init();
printf("ok\r\n"); printf("ok\r\n");
while (1) { while (1) {
by_buzzer_run(); by_buzzer_run();
Page_Run(); Page_Run();
/** 测试完成后移除 **/
by_tiny_frame_run(); by_tiny_frame_run();
// by_tiny_frame_pack_send(&frame_now);
system_delay_ms(10);
by_tiny_frame_parse_timer_handle();
/** 测试完成后移除 **/
} }
} }

View File

@@ -3,9 +3,9 @@
#define BY_TF_DEBUG (1) #define BY_TF_DEBUG (1)
#define BY_TF_UART_TX_PIN (UART1_MAP0_TX_A9) #define BY_TF_UART_TX_PIN (UART4_MAP1_TX_B0)
#define BY_TF_UART_RX_PIN (UART1_MAP0_RX_A10) #define BY_TF_UART_RX_PIN (UART4_MAP1_RX_B1)
#define BY_TF_UART_INDEX (UART_1) #define BY_TF_UART_INDEX (UART_4)
#define BY_TF_UART_BAUDRATE (115200) #define BY_TF_UART_BAUDRATE (115200)
#define BY_TF_PARSE_BUFFER_SIZE (50) #define BY_TF_PARSE_BUFFER_SIZE (50)

View File

@@ -1 +1,185 @@
ENTRY( _start ) ENTRY( _start )
__stack_size = 2048;
PROVIDE( _stack_size = __stack_size );
MEMORY
{
/* CH32V30x_D8C - CH32V305RB-CH32V305FB
CH32V30x_D8 - CH32V303CB-CH32V303RB
*/
/*
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
*/
/* CH32V30x_D8C - CH32V307VC-CH32V307WC-CH32V307RC
CH32V30x_D8 - CH32V303VC-CH32V303RC
FLASH + RAM supports the following configuration
FLASH-192K + RAM-128K
FLASH-224K + RAM-96K
FLASH-256K + RAM-64K
FLASH-288K + RAM-32K
*/
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 288K
}
SECTIONS
{
.init :
{
_sinit = .;
. = ALIGN(4);
KEEP(*(SORT_NONE(.init)))
. = ALIGN(4);
_einit = .;
} >FLASH AT>FLASH
.vector :
{
*(.vector);
. = ALIGN(64);
} >FLASH AT>FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text.*)
*(.rodata)
*(.rodata*)
*(.glue_7)
*(.glue_7t)
*(.gnu.linkonce.t.*)
. = ALIGN(4);
} >FLASH AT>FLASH
.fini :
{
KEEP(*(SORT_NONE(.fini)))
. = ALIGN(4);
} >FLASH AT>FLASH
PROVIDE( _etext = . );
PROVIDE( _eitcm = . );
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH AT>FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH AT>FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH AT>FLASH
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} >FLASH AT>FLASH
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} >FLASH AT>FLASH
.dalign :
{
. = ALIGN(4);
PROVIDE(_data_vma = .);
} >RAM AT>FLASH
.dlalign :
{
. = ALIGN(4);
PROVIDE(_data_lma = .);
} >FLASH AT>FLASH
.data :
{
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.sdata2.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
. = ALIGN(4);
PROVIDE( _edata = .);
} >RAM AT>FLASH
.bss :
{
. = ALIGN(4);
PROVIDE( _sbss = .);
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss*)
*(.gnu.linkonce.b.*)
*(COMMON*)
. = ALIGN(4);
PROVIDE( _ebss = .);
} >RAM AT>FLASH
PROVIDE( _end = _ebss);
PROVIDE( end = . );
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
{
PROVIDE( _heap_end = . );
. = ALIGN(4);
PROVIDE(_susrstack = . );
. = . + __stack_size;
PROVIDE( _eusrstack = .);
} >RAM
}