support ym

This commit is contained in:
zhangzheng
2025-03-13 09:37:35 +08:00
parent 377c31cdc8
commit c4518d9220
48 changed files with 641 additions and 1800 deletions

View File

@@ -25,30 +25,44 @@ uart_t *uart_get_global(void)
{
return &uart;
}
#define QUEUE_LEN 129
#define QUEUE_LEN 257
static queue_t queue;
static uint8_t queue_data[QUEUE_LEN];
static bool_t uart_is_init;
static void uart_wakeup_waiter(irq_entry_t *irq)
{
if (irq->irq->wait_thread && thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND)
{
thread_ready_remote(irq->irq->wait_thread, TRUE);
}
}
void uart_tigger(irq_entry_t *irq)
{
if (usart_interrupt_flag_get(PRINT_USARTx, USART_RDBF_FLAG) != RESET)
{
/* read one byte from the receive data register */
q_enqueue(&queue, usart_data_receive(PRINT_USARTx));
if (q_enqueue(&queue, usart_data_receive(PRINT_USARTx)) < 0)
{
uart_wakeup_waiter(irq);
}
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, TRUE);
}
// if (q_queue_len(&queue) >= queue.size / 2)
// {
// uart_wakeup_waiter(irq);
// }
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);
}
uart_wakeup_waiter(irq);
usart_interrupt_enable(PRINT_USARTx, USART_IDLE_INT, FALSE);
}
}
void uart_init(void)
{
uart_is_init = 1;
q_init(&queue, queue_data, QUEUE_LEN);
gpio_init_type gpio_init_struct;
@@ -77,10 +91,9 @@ void uart_init(void)
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;
}
INIT_HIGH_HAD(uart_init);
@@ -92,8 +105,9 @@ void uart_set(uart_t *uart)
}
void uart_putc(uart_t *uart, int data)
{
if (!uart_is_init) {
return ;
if (!uart_is_init)
{
return;
}
while (usart_flag_get(USART1, USART_TDBE_FLAG) == RESET)
;

View File

@@ -146,6 +146,9 @@ typedef struct task_vma
mln_rbtree_t alloc_tree; //!< 分配了那些内存
#if IS_ENABLED(MPU_PAGE_FAULT_SUPPORT)
region_info_t *mem_pages_pt_regions[MPU_PAGE_FAULT_REGIONS_NUM]; //!< 用多少个regions模拟缺页
#if MPU_PAGE_FAULT_REGIONS_NUM == 0
#error "MPU_PAGE_FAULT_REGIONS_NUM not is 0."
#endif
int pt_regions_sel; //!< 用于确定下次选用那个region进行映射
#endif
} task_vma_t;

View File

@@ -11,7 +11,7 @@ extern "C"
#endif
#include "stdarg.h"
#define XF_USE_OUTPUT 1 /* 1: Enable output functions */
#define XF_CRLF 0 /* 1: Convert \n ==> \r\n in the output char */
#define XF_CRLF 1 /* 1: Convert \n ==> \r\n in the output char */
#define XF_USE_DUMP 0 /* 1: Enable put_dump function */
#define XF_USE_LLI 0 /* 1: Enable long long integer in size prefix ll */
#define XF_USE_FP 0 /* 1: Enable support for floating point in type e and f */

View File

@@ -10,6 +10,7 @@
*/
#include "log.h"
#include "arch.h"
#include "factory.h"
#include "kobject.h"
#include "globals.h"
@@ -49,6 +50,7 @@ static void log_reg(void)
log.kobj.kobj.put_func = kobject_put;
global_reg_kobj(&log.kobj.kobj, LOG_PROT);
irq_alloc(LOG_INTR_NO, &log.kobj, log_trigger);
arch_set_enable_irq_prio(LOG_INTR_NO, 0, 0);
arch_enable_irq(LOG_INTR_NO);
}
INIT_KOBJ(log_reg);
@@ -106,7 +108,7 @@ log_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag, entry_frame
break;
case READ_DATA:
{
int ret = log_read_data((log_t *)kobj, (uint8_t *)(&f->regs[1]), MIN(f->regs[1], WORD_BYTES * 5));
int ret = log_read_data((log_t *)kobj, (uint8_t *)(&f->regs[1]), MIN(f->regs[1], WORD_BYTES * 3));
tag = msg_tag_init4(0, 0, 0, ret);
}
break;