feat: 添加杰理 JL7016 SOC 代码生成模板

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 16:05:36 +08:00
co-authored by Cursor
parent 0eda925f58
commit 16bffd16b2
914 changed files with 254709 additions and 45 deletions
+174
View File
@@ -0,0 +1,174 @@
#include "system/includes.h"
#include "asm/uart_dev.h"
#include "system/event.h"
#include "key_event_deal.h"
#include "app_task.h"
#if 0
/*
[[ 注意!!! ]]
* 如果当系统任务较少时使用本demo,需要将低功耗关闭(#define TCFG_LOWPOWER_LOWPOWER_SEL 0//SLEEP_EN ),否则任务被串口接收函数调用信号量pend时会导致cpu休眠,串口中断和DMA接收将遗漏数据或数据不正确
*/
#define UART_DEV_USAGE_TEST_SEL 2 //uart_dev.c api接口使用方法选择
// 选择1 串口中断回调函数推送事件,由事件响应函数接收串口数据
// 选择2 由task接收串口数据
#define UART_DEV_TEST_MULTI_BYTE 1 //uart_dev.c 读写多个字节api / 读写1个字节api 选择
#define UART_DEV_FLOW_CTRL 0
const uart_bus_t *uart_bus;
static u8 uart_cbuf[512] __attribute__((aligned(4)));
static u8 uart_rxbuf[512] __attribute__((aligned(4)));
//设备事件响应demo
static void uart_event_handler(struct sys_event *e)
{
u32 uart_rxcnt = 0;
if ((u32)e->arg == DEVICE_EVENT_FROM_UART_RX_OVERFLOW) {
if (e->u.dev.event == DEVICE_EVENT_CHANGE) {
/* printf("uart event: DEVICE_EVENT_FROM_UART_RX_OVERFLOW\n"); */
uart_bus = (const uart_bus_t *)e->u.dev.value;
uart_rxcnt = uart_bus->read(uart_rxbuf, sizeof(uart_rxbuf), 0);
if (uart_rxcnt) {
printf("get_buffer:\n");
for (int i = 0; i < uart_rxcnt; i++) {
my_put_u8hex(uart_rxbuf[i]);
if (i % 16 == 15) {
putchar('\n');
}
}
if (uart_rxcnt % 16) {
putchar('\n');
}
#if (!UART_DEV_FLOW_CTRL)
uart_bus->write(uart_rxbuf, uart_rxcnt);
#endif
}
printf("uart out\n");
}
}
if ((u32)e->arg == DEVICE_EVENT_FROM_UART_RX_OUTTIME) {
if (e->u.dev.event == DEVICE_EVENT_CHANGE) {
/* printf("uart event:DEVICE_EVENT_FROM_UART_RX_OUTTIME\n"); */
uart_bus = (const uart_bus_t *)e->u.dev.value;
uart_rxcnt = uart_bus->read(uart_rxbuf, sizeof(uart_rxbuf), 0);
if (uart_rxcnt) {
printf("get_buffer:\n");
for (int i = 0; i < uart_rxcnt; i++) {
my_put_u8hex(uart_rxbuf[i]);
if (i % 16 == 15) {
putchar('\n');
}
}
if (uart_rxcnt % 16) {
putchar('\n');
}
#if (!UART_DEV_FLOW_CTRL)
uart_bus->write(uart_rxbuf, uart_rxcnt);
#endif
}
printf("uart out\n");
}
}
}
//SYS_EVENT_HANDLER(SYS_DEVICE_EVENT, uart_event_handler, 0);
int uart_tr_send_data(u8 *data, u32 len)
{
#ifndef CONFIG_DEBUG_ENABLE
uart_bus->write(data,len);
#endif // CONFIG_DEBUG_ENABLE
}
extern int dual_ota_app_data_deal(u32 msg, u8 *buf, u32 len);
static void uart_u_task(void *arg)
{
int ret;
u32 uart_rxcnt = 0;
printf("uart_u_task start\n");
while (1) {
//uart_bus->read()在尚未收到串口数据时会pend信号量,挂起task,直到UART_RX_PND或UART_RX_OT_PND中断发生,post信号量,唤醒task
uart_rxcnt = uart_bus->read(uart_rxbuf, sizeof(uart_rxbuf), 0);
if (uart_rxcnt)
{
// uart_tr_send_data(uart_rxbuf,uart_rxcnt);
// dual_ota_app_data_deal(0, uart_rxbuf, uart_rxcnt);
}
}
}
static void uart_isr_hook(void *arg, u32 status)
{
struct sys_event e;
//当CONFIG_UARTx_ENABLE_TX_DMAx = 0, 1)为1时,不要在中断里面调用ubus->write(),因为中断不能pend信号量
if (status == UT_RX) {
printf("uart_rx_isr\n");
#if (UART_DEV_USAGE_TEST_SEL == 1)
e.type = SYS_DEVICE_EVENT;
e.arg = (void *)DEVICE_EVENT_FROM_UART_RX_OVERFLOW;
e.u.dev.event = DEVICE_EVENT_CHANGE;
e.u.dev.value = (int)ubus;
sys_event_notify(&e);
#endif
}
if (status == UT_RX_OT) {
printf("uart_rx_ot_isr\n");
#if (UART_DEV_USAGE_TEST_SEL == 1)
e.type = SYS_DEVICE_EVENT;
e.arg = (void *)DEVICE_EVENT_FROM_UART_RX_OUTTIME;
e.u.dev.event = DEVICE_EVENT_CHANGE;
e.u.dev.value = (int)ubus;
sys_event_notify(&e);
#endif
}
}
void uart_dev_test_main()
{
#ifndef CONFIG_DEBUG_ENABLE
struct uart_platform_data_t u_arg = {0};
u_arg.tx_pin = IO_PORT_DP;
u_arg.rx_pin = -1;
u_arg.rx_cbuf = uart_cbuf;
u_arg.rx_cbuf_size = 512;
u_arg.frame_length = 512;
u_arg.rx_timeout = 10;
u_arg.isr_cbfun = NULL;//uart_isr_hook;
u_arg.baud = 115200;
u_arg.is_9bit = 0;
uart_bus = uart_dev_open(&u_arg);
if (uart_bus != NULL) {
printf("uart_dev_open() success\n");
#if (UART_DEV_USAGE_TEST_SEL == 2)
os_task_create(uart_u_task, (void *)uart_bus, 31, 2048, 0, "uart_u_task");
#endif
}
#endif // CONFIG_DEBUG_ENABLE
}
#else
void uart_dev_test_main()
{
}
int uart_tr_send_data(u8 *data, u32 len)
{
}
#endif