Compare commits

...

2 Commits

Author SHA1 Message Date
c11db2c9bf for debug 2025-01-23 10:35:12 +08:00
11cf546438 for debug 2025-01-22 09:26:20 +08:00
6 changed files with 48 additions and 36 deletions

View File

@ -91,15 +91,15 @@ set(TARGET_CFLAGS_HARDWARE "-mcpu=cortex-m23 -mfloat-abi=soft -mthumb -mthumb-in
# Conditional flags
# DEBUG
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
#set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
#set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
#set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
#set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=0 -O2 -g")
#set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG=0 -O2 -g")
#set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -O2 -g")
#set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
#set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
#set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
# RELEASE
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3") # -flto

View File

@ -2,7 +2,7 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 4K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
}
ENTRY(Reset_Handler)

View File

@ -163,15 +163,15 @@ void USART1_IRQHandler(void) {
// static uint8_t rx_buffer[RX_BUFFER_SIZE];
if (RESET != usart_interrupt_flag_get(USART_PHY, USART_INT_FLAG_RBNE)) {
usart_interrupt_flag_clear(USART_PHY, USART_INT_FLAG_RBNE);
// usart_interrupt_flag_clear(USART_PHY, USART_INT_FLAG_RBNE);
uint8_t received_data = (uint8_t) usart_data_receive(USART_PHY);
printf("%c", received_data);
// // 将接收到的数据存储到缓冲区
// printf("%c", received_data);
// 将接收到的数据存储到缓冲区
// if (rx_index < RX_BUFFER_SIZE - 1) {
// rx_buffer[rx_index++] = received_data;
// }
// store_char(received_data, &rx_buffer);
store_char(received_data, &rx_buffer);
}
//
// if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {

View File

@ -6,6 +6,8 @@
*/
#include "main.h"
#include "newlib.h"
volatile uint8_t g_temperature_uint8[2] = {0};
volatile uint16_t g_capture_value;

View File

@ -18,9 +18,20 @@ static char *strchr_pointer = NULL;
static packet_state_t packet_state = PS_LEN;
// bool code_seen(char code) {
// // strchr_pointer = strchr(cmd_buffer[buf_index_r], code);
// return (strchr_pointer != NULL); //Return True if a character was found
// }
bool code_seen(char code) {
strchr_pointer = strchr(cmd_buffer[buf_index_r], code);
return (strchr_pointer != NULL); //Return True if a character was found
strchr_pointer = NULL;
for (int i = 0; cmd_buffer[buf_index_r][i] != '\0'; i++) {
if (cmd_buffer[buf_index_r][i] == code) {
strchr_pointer = &cmd_buffer[buf_index_r][i];
break;
}
}
return (strchr_pointer != NULL); // Return True if a character was found
}
float code_value(void) {
@ -149,6 +160,7 @@ void start_communication(void) {
}
if (buf_length) {
printf("DONE\r\n");
prcess_command();
buf_length--;
buf_index_r = (buf_index_r + 1) % BUF_SIZE;
@ -206,6 +218,8 @@ void get_command(void) {
buf_index_w = (buf_index_w + 1) % BUF_SIZE;
buf_length++;
serial_count = 0;
default:
break;
}
}
}

View File

@ -27,10 +27,6 @@ void usart_config(void)
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
usart_deinit(USART_PHY);
usart_baudrate_set(USART_PHY, 115200U);
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
nvic_irq_enable(USART_PHY_IRQ, 0);
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
// usart_interrupt_enable(USART_PHY, USART_INT_IDLE);