Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alios-things
AliOS-Things
提交
44b70745
A
AliOS-Things
项目概览
alios-things
/
AliOS-Things
11 个月 前同步成功
通知
62
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AliOS-Things
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
44b70745
编写于
4月 28, 2022
作者:
H
HonestQiao
提交者:
skylarCai
4月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle specific calls for ESP32-C3
上级
2a587382
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
68 addition
and
4 deletion
+68
-4
components/py_engine/adapter/esp32/machine_pin.c
components/py_engine/adapter/esp32/machine_pin.c
+1
-1
components/py_engine/adapter/esp32/uart.c
components/py_engine/adapter/esp32/uart.c
+55
-3
components/py_engine/adapter/esp32/uart.h
components/py_engine/adapter/esp32/uart.h
+12
-0
未找到文件。
components/py_engine/adapter/esp32/machine_pin.c
浏览文件 @
44b70745
...
...
@@ -261,7 +261,7 @@ STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
#if CONFIG_IDF_TARGET_ESP32C3
if
(
self
->
id
==
18
||
self
->
id
==
19
)
{
CLEAR_PERI_REG_MASK
(
USB_DEVICE_CONF0_REG
,
USB_DEVICE_USB_PAD_ENABLE
);
//
CLEAR_PERI_REG_MASK(USB_DEVICE_CONF0_REG, USB_DEVICE_USB_PAD_ENABLE);
}
#endif
...
...
components/py_engine/adapter/esp32/uart.c
浏览文件 @
44b70745
...
...
@@ -34,24 +34,76 @@
#include "py/runtime.h"
#include "py/mphal.h"
#ifdef CONFIG_IDF_TARGET_ESP32C3
#include "uart.h"
#endif
STATIC
void
uart_irq_handler
(
void
*
arg
);
void
uart_init
(
void
)
{
#ifdef CONFIG_IDF_TARGET_ESP32C3
uart_config_t
uartcfg
=
{
.
baud_rate
=
MICROPY_HW_UART_REPL_BAUD
,
.
data_bits
=
UART_DATA_8_BITS
,
.
parity
=
UART_PARITY_DISABLE
,
.
stop_bits
=
UART_STOP_BITS_1
,
.
flow_ctrl
=
UART_HW_FLOWCTRL_DISABLE
,
.
rx_flow_ctrl_thresh
=
0
};
uart_param_config
(
MICROPY_HW_UART_REPL
,
&
uartcfg
);
const
uint32_t
rxbuf
=
129
;
// IDF requires > 128 min
const
uint32_t
txbuf
=
0
;
uart_driver_install
(
MICROPY_HW_UART_REPL
,
rxbuf
,
txbuf
,
0
,
NULL
,
0
);
#endif
uart_isr_handle_t
handle
;
#ifdef CONFIG_IDF_TARGET_ESP32C3
uart_isr_free
(
MICROPY_HW_UART_REPL
);
uart_isr_register
(
MICROPY_HW_UART_REPL
,
uart_irq_handler
,
NULL
,
ESP_INTR_FLAG_LOWMED
|
ESP_INTR_FLAG_IRAM
,
&
handle
);
uart_enable_rx_intr
(
MICROPY_HW_UART_REPL
);
#else
uart_isr_register
(
UART_NUM_0
,
uart_irq_handler
,
NULL
,
ESP_INTR_FLAG_LOWMED
|
ESP_INTR_FLAG_IRAM
,
&
handle
);
uart_enable_rx_intr
(
UART_NUM_0
);
#endif
}
#ifdef CONFIG_IDF_TARGET_ESP32C3
int
uart_stdout_tx_strn
(
const
char
*
str
,
size_t
len
)
{
size_t
remaining
=
len
;
// TODO add a timeout
for
(;;)
{
int
ret
=
uart_tx_chars
(
MICROPY_HW_UART_REPL
,
str
,
remaining
);
if
(
ret
==
-
1
)
{
return
-
1
;
}
remaining
-=
ret
;
if
(
remaining
<=
0
)
{
break
;
}
str
+=
ret
;
ulTaskNotifyTake
(
pdFALSE
,
1
);
}
return
len
-
remaining
;
}
#endif
// all code executed in ISR must be in IRAM, and any const data must be in DRAM
STATIC
void
IRAM_ATTR
uart_irq_handler
(
void
*
arg
)
{
volatile
uart_dev_t
*
uart
=
&
UART0
;
#if CONFIG_IDF_TARGET_ESP32S3
uart
->
int_clr
.
rxfifo_full_int_clr
=
1
;
uart
->
int_clr
.
rxfifo_tout_int_clr
=
1
;
#else
uart
->
int_clr
.
rxfifo_full
=
1
;
uart
->
int_clr
.
frm_err
=
1
;
uart
->
int_clr
.
frm_err
=
1
;
uart
->
int_clr
.
rxfifo_tout
=
1
;
#endif
while
(
uart
->
status
.
rxfifo_cnt
)
{
#if CONFIG_IDF_TARGET_ESP32
uint8_t
c
=
uart
->
fifo
.
rw_byte
;
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|| CONFIG_IDF_TARGET_ESP32S3
uint8_t
c
=
READ_PERI_REG
(
UART_FIFO_AHB_REG
(
0
));
// UART0
#endif
if
(
c
==
mp_interrupt_char
)
{
...
...
@@ -61,4 +113,4 @@ STATIC void IRAM_ATTR uart_irq_handler(void *arg) {
ringbuf_put
(
&
stdin_ringbuf
,
c
);
}
}
}
}
\ No newline at end of file
components/py_engine/adapter/esp32/uart.h
浏览文件 @
44b70745
...
...
@@ -28,6 +28,18 @@
#ifndef MICROPY_INCLUDED_ESP32_UART_H
#define MICROPY_INCLUDED_ESP32_UART_H
#ifdef CONFIG_IDF_TARGET_ESP32C3
#ifndef MICROPY_HW_UART_REPL
#define MICROPY_HW_UART_REPL (UART_NUM_0)
#endif
#ifndef MICROPY_HW_UART_REPL_BAUD
#define MICROPY_HW_UART_REPL_BAUD (115200)
#endif
int
uart_stdout_tx_strn
(
const
char
*
str
,
size_t
len
);
#endif
void
uart_init
(
void
);
#endif // MICROPY_INCLUDED_ESP32_UART_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录