This commit is contained in:
yelvlab 2025-01-20 14:45:52 +08:00
parent 39d800cb1b
commit a546f7bf83
6 changed files with 24 additions and 24 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

@ -41,12 +41,12 @@
/******************************************************************************/
#define USART_GPIO_RCU RCU_GPIOA
#define USART_RCU RCU_USART0
#define USART_RCU RCU_USART1
#define USART_GPIO_PORT GPIOA
#define USART_GPIO_AF GPIO_AF_1
#define USART_TX_PIN GPIO_PIN_2
#define USART_RX_PIN GPIO_PIN_3
#define USART_PHY USART0
#define USART_PHY USART1
#define USART_PHY_BAUDRATE 115200U
#define RS485_EN_PORT GPIOA
#define RS485_EN_PIN GPIO_PIN_4

View File

@ -15,7 +15,7 @@ void watchdog_init(void) {
rcu_osci_stab_wait(RCU_IRC40K);
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
fwdgt_config(6250, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
/* Enable FWDGT */
fwdgt_enable();

View File

@ -158,12 +158,12 @@ void EXTI0_1_IRQHandler(void) {
}
}
void USART0_IRQHandler(void) {
void USART1_IRQHandler(void) {
static uint8_t rx_index = 0;
static uint8_t rx_buffer[RX_BUFFER_SIZE];
if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) {
// usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE);
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE);
uint8_t received_data = (uint8_t) usart_data_receive(USART0);
// // 将接收到的数据存储到缓冲区

View File

@ -25,36 +25,36 @@ int main(void)
/* configure LED */
led_blink_config();
/* configure FWDGT */
watchdog_init();
// watchdog_init();
#ifdef SOFTWARE_IIC
soft_i2c_config();
#else
i2c_config();
#endif
// #ifdef SOFTWARE_IIC
// soft_i2c_config();
// #else
// i2c_config();
// #endif
printf("system start!\r\n");
ultrasonic_config();
// ultrasonic_config();
while(1){
// gd60914_get_object_tempture();
delay_ms(500);
// start_communication();
start_communication();
printf("hello world!\r\n");
// ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
watchdog_reload();
// watchdog_reload();
}
}
/* retarget the C library printf function to the USART */
int _write(int fd, char *pBuffer, int size) {
for (int i = 0; i < size; i++) {
usart_data_transmit(USART0, (uint8_t) pBuffer[i]);
while (RESET == usart_flag_get(USART0, USART_FLAG_TBE));
usart_data_transmit(USART1, (uint8_t) pBuffer[i]);
while (RESET == usart_flag_get(USART1, USART_FLAG_TBE));
}
return size;
}

View File

@ -31,7 +31,7 @@ void usart_config(void)
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(USART0_IRQn, 0);
nvic_irq_enable(USART1_IRQn, 0);
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
// usart_interrupt_enable(USART_PHY, USART_INT_IDLE);
usart_enable(USART_PHY);