generated from hulk/gd32e23x_template
Compare commits
3 Commits
a546f7bf83
...
feature-pr
| Author | SHA1 | Date | |
|---|---|---|---|
| c11db2c9bf | |||
| 11cf546438 | |||
| 1dacace57a |
@@ -91,15 +91,15 @@ set(TARGET_CFLAGS_HARDWARE "-mcpu=cortex-m23 -mfloat-abi=soft -mthumb -mthumb-in
|
|||||||
|
|
||||||
# Conditional flags
|
# Conditional flags
|
||||||
# DEBUG
|
# DEBUG
|
||||||
set(CMAKE_C_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_CXX_FLAGS_DEBUG "-DDEBUG=0 -O0 -g")
|
||||||
set(CMAKE_ASM_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_C_FLAGS_DEBUG "-DDEBUG=0 -O2 -g")
|
||||||
#set(CMAKE_CXX_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_ASM_FLAGS_DEBUG "-DDEBUG=0 -O2 -g")
|
||||||
#set(CMAKE_C_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_CXX_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
|
||||||
#set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
|
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG=0 -Os -g")
|
||||||
|
|
||||||
# RELEASE
|
# RELEASE
|
||||||
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3") # -flto
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3") # -flto
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#define USART_RX_PIN GPIO_PIN_3
|
#define USART_RX_PIN GPIO_PIN_3
|
||||||
#define USART_PHY USART1
|
#define USART_PHY USART1
|
||||||
#define USART_PHY_BAUDRATE 115200U
|
#define USART_PHY_BAUDRATE 115200U
|
||||||
|
#define USART_PHY_IRQ USART1_IRQn
|
||||||
#define RS485_EN_PORT GPIOA
|
#define RS485_EN_PORT GPIOA
|
||||||
#define RS485_EN_PIN GPIO_PIN_4
|
#define RS485_EN_PIN GPIO_PIN_4
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
|
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 4K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
|
||||||
}
|
}
|
||||||
|
|
||||||
ENTRY(Reset_Handler)
|
ENTRY(Reset_Handler)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void watchdog_init(void) {
|
|||||||
rcu_osci_stab_wait(RCU_IRC40K);
|
rcu_osci_stab_wait(RCU_IRC40K);
|
||||||
|
|
||||||
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
|
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
|
||||||
fwdgt_config(6250, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
|
fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
|
||||||
|
|
||||||
/* Enable FWDGT */
|
/* Enable FWDGT */
|
||||||
fwdgt_enable();
|
fwdgt_enable();
|
||||||
|
|||||||
@@ -159,14 +159,15 @@ void EXTI0_1_IRQHandler(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void USART1_IRQHandler(void) {
|
void USART1_IRQHandler(void) {
|
||||||
static uint8_t rx_index = 0;
|
// static uint8_t rx_index = 0;
|
||||||
static uint8_t rx_buffer[RX_BUFFER_SIZE];
|
// static uint8_t rx_buffer[RX_BUFFER_SIZE];
|
||||||
|
|
||||||
if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) {
|
if (RESET != usart_interrupt_flag_get(USART_PHY, USART_INT_FLAG_RBNE)) {
|
||||||
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE);
|
// usart_interrupt_flag_clear(USART_PHY, USART_INT_FLAG_RBNE);
|
||||||
uint8_t received_data = (uint8_t) usart_data_receive(USART0);
|
uint8_t received_data = (uint8_t) usart_data_receive(USART_PHY);
|
||||||
|
|
||||||
// // 将接收到的数据存储到缓冲区
|
// printf("%c", received_data);
|
||||||
|
// 将接收到的数据存储到缓冲区
|
||||||
// if (rx_index < RX_BUFFER_SIZE - 1) {
|
// if (rx_index < RX_BUFFER_SIZE - 1) {
|
||||||
// rx_buffer[rx_index++] = received_data;
|
// rx_buffer[rx_index++] = received_data;
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "newlib.h"
|
||||||
|
|
||||||
volatile uint8_t g_temperature_uint8[2] = {0};
|
volatile uint8_t g_temperature_uint8[2] = {0};
|
||||||
volatile uint16_t g_capture_value;
|
volatile uint16_t g_capture_value;
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,20 @@ static char *strchr_pointer = NULL;
|
|||||||
|
|
||||||
static packet_state_t packet_state = PS_LEN;
|
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) {
|
bool code_seen(char code) {
|
||||||
strchr_pointer = strchr(cmd_buffer[buf_index_r], code);
|
strchr_pointer = NULL;
|
||||||
return (strchr_pointer != NULL); //Return True if a character was found
|
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) {
|
float code_value(void) {
|
||||||
@@ -149,6 +160,7 @@ void start_communication(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buf_length) {
|
if (buf_length) {
|
||||||
|
printf("DONE!\r\n");
|
||||||
prcess_command();
|
prcess_command();
|
||||||
buf_length--;
|
buf_length--;
|
||||||
buf_index_r = (buf_index_r + 1) % BUF_SIZE;
|
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_index_w = (buf_index_w + 1) % BUF_SIZE;
|
||||||
buf_length++;
|
buf_length++;
|
||||||
serial_count = 0;
|
serial_count = 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ void usart_config(void)
|
|||||||
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
|
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
|
||||||
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
|
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
|
||||||
|
|
||||||
usart_deinit(USART_PHY);
|
nvic_irq_enable(USART_PHY_IRQ, 0);
|
||||||
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(USART1_IRQn, 0);
|
|
||||||
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
|
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
|
||||||
// usart_interrupt_enable(USART_PHY, USART_INT_IDLE);
|
// usart_interrupt_enable(USART_PHY, USART_INT_IDLE);
|
||||||
usart_enable(USART_PHY);
|
usart_enable(USART_PHY);
|
||||||
|
|||||||
Reference in New Issue
Block a user