优化串口
This commit is contained in:
@@ -6,9 +6,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
|
||||
-Wno-unused-function \
|
||||
-Wno-unused-variable \
|
||||
-Wno-builtin-declaration-mismatch \
|
||||
-Ofast \
|
||||
")
|
||||
|
||||
# -Ofast \
|
||||
# message(编译参数:${CMAKE_C_FLAGS})
|
||||
|
||||
# cortex-m 系列处理器采用相同的内核arch
|
||||
|
||||
@@ -35,11 +35,15 @@ void uart_tigger(irq_entry_t *irq)
|
||||
{
|
||||
/* read one byte from the receive data register */
|
||||
q_enqueue(&queue, usart_data_receive(PRINT_USARTx));
|
||||
|
||||
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE);
|
||||
}
|
||||
if (usart_interrupt_flag_get(PRINT_USARTx, USART_IDLEF_FLAG) != RESET)
|
||||
{
|
||||
if (irq->irq->wait_thread && thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND)
|
||||
{
|
||||
thread_ready_remote(irq->irq->wait_thread, TRUE);
|
||||
}
|
||||
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +76,8 @@ void uart_init(void)
|
||||
usart_receiver_enable(PRINT_USARTx, TRUE);
|
||||
|
||||
usart_interrupt_enable(PRINT_USARTx, USART_RDBF_INT, TRUE);
|
||||
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE);
|
||||
|
||||
usart_enable(PRINT_USARTx, TRUE);
|
||||
|
||||
uart_is_init=1;
|
||||
|
||||
@@ -6,7 +6,7 @@ typedef struct thread_wait_entry
|
||||
slist_head_t node;
|
||||
thread_t *th;
|
||||
umword_t times;
|
||||
umword_t times_debug;
|
||||
// umword_t times_debug;
|
||||
} thread_wait_entry_t;
|
||||
void thread_check_timeout(void);
|
||||
thread_wait_entry_t *thread_sleep_del(thread_t *th);
|
||||
|
||||
@@ -25,7 +25,7 @@ static inline void thread_wait_entry_init(thread_wait_entry_t *entry,
|
||||
slist_init(&entry->node);
|
||||
entry->th = th;
|
||||
entry->times = times;
|
||||
entry->times_debug = 0;
|
||||
// entry->times_debug = 0;
|
||||
}
|
||||
static void thread_timeout_init(void)
|
||||
{
|
||||
@@ -48,22 +48,27 @@ void thread_check_timeout(void)
|
||||
thread_wait_entry_t *next = slist_next_entry(
|
||||
pos, (slist_head_t *)wait_list,
|
||||
node);
|
||||
|
||||
pos->times_debug++;
|
||||
// pos->times_debug++;
|
||||
if (pos->times != 0)
|
||||
{
|
||||
pos->times--;
|
||||
// pos->times_debug = 0;
|
||||
if (pos->times == 0)
|
||||
{
|
||||
assert(pos->th->status == THREAD_SUSPEND);
|
||||
slist_del(&pos->node);
|
||||
thread_ready(pos->th, TRUE);
|
||||
}
|
||||
} else {
|
||||
// if (pos->times_debug >= 3000)
|
||||
// {
|
||||
// printk("thread:0x%x block times %d.\n", pos->th, pos->times_debug);
|
||||
// }
|
||||
} // !< 如果是0,则一直休眠
|
||||
if (pos->times_debug%2000 == 0)
|
||||
{
|
||||
// printk("thread 0x%x block %d sec.\n", pos->th, pos->times_debug /1000);
|
||||
}
|
||||
// if (pos->times_debug%2000 == 0)
|
||||
// {
|
||||
// // printk("thread 0x%x block %d sec.\n", pos->th, pos->times_debug /1000);
|
||||
// }
|
||||
pos = next;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user