generated from hulk/gd32e23x_template
暂存
This commit is contained in:
parent
39d800cb1b
commit
a546f7bf83
@ -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
|
||||||
|
@ -41,12 +41,12 @@
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#define USART_GPIO_RCU RCU_GPIOA
|
#define USART_GPIO_RCU RCU_GPIOA
|
||||||
#define USART_RCU RCU_USART0
|
#define USART_RCU RCU_USART1
|
||||||
#define USART_GPIO_PORT GPIOA
|
#define USART_GPIO_PORT GPIOA
|
||||||
#define USART_GPIO_AF GPIO_AF_1
|
#define USART_GPIO_AF GPIO_AF_1
|
||||||
#define USART_TX_PIN GPIO_PIN_2
|
#define USART_TX_PIN GPIO_PIN_2
|
||||||
#define USART_RX_PIN GPIO_PIN_3
|
#define USART_RX_PIN GPIO_PIN_3
|
||||||
#define USART_PHY USART0
|
#define USART_PHY USART1
|
||||||
#define USART_PHY_BAUDRATE 115200U
|
#define USART_PHY_BAUDRATE 115200U
|
||||||
#define RS485_EN_PORT GPIOA
|
#define RS485_EN_PORT GPIOA
|
||||||
#define RS485_EN_PIN GPIO_PIN_4
|
#define RS485_EN_PIN GPIO_PIN_4
|
||||||
|
@ -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(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 */
|
/* Enable FWDGT */
|
||||||
fwdgt_enable();
|
fwdgt_enable();
|
||||||
|
@ -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_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(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);
|
uint8_t received_data = (uint8_t) usart_data_receive(USART0);
|
||||||
|
|
||||||
// // 将接收到的数据存储到缓冲区
|
// // 将接收到的数据存储到缓冲区
|
||||||
|
24
src/main.c
24
src/main.c
@ -25,36 +25,36 @@ int main(void)
|
|||||||
/* configure LED */
|
/* configure LED */
|
||||||
led_blink_config();
|
led_blink_config();
|
||||||
/* configure FWDGT */
|
/* configure FWDGT */
|
||||||
watchdog_init();
|
// watchdog_init();
|
||||||
|
|
||||||
#ifdef SOFTWARE_IIC
|
// #ifdef SOFTWARE_IIC
|
||||||
soft_i2c_config();
|
// soft_i2c_config();
|
||||||
#else
|
// #else
|
||||||
i2c_config();
|
// i2c_config();
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
printf("system start!\r\n");
|
printf("system start!\r\n");
|
||||||
|
|
||||||
ultrasonic_config();
|
// ultrasonic_config();
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
// gd60914_get_object_tempture();
|
// gd60914_get_object_tempture();
|
||||||
|
|
||||||
delay_ms(500);
|
delay_ms(500);
|
||||||
// start_communication();
|
start_communication();
|
||||||
|
printf("hello world!\r\n");
|
||||||
|
|
||||||
// ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
|
// ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
|
||||||
|
|
||||||
watchdog_reload();
|
// watchdog_reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retarget the C library printf function to the USART */
|
/* retarget the C library printf function to the USART */
|
||||||
int _write(int fd, char *pBuffer, int size) {
|
int _write(int fd, char *pBuffer, int size) {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
usart_data_transmit(USART0, (uint8_t) pBuffer[i]);
|
usart_data_transmit(USART1, (uint8_t) pBuffer[i]);
|
||||||
while (RESET == usart_flag_get(USART0, USART_FLAG_TBE));
|
while (RESET == usart_flag_get(USART1, USART_FLAG_TBE));
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ void usart_config(void)
|
|||||||
usart_baudrate_set(USART_PHY, 115200U);
|
usart_baudrate_set(USART_PHY, 115200U);
|
||||||
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);
|
||||||
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_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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user