dual_core_messaging.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2026 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 双核消息传递示例
#
# 此示例展示了如何通过专用的OpenAMP端点将消息从HE核
# 传递到HP核。HE任务不断计数,并将每个值发送给
# HP核,在HP核上通过注册的回调函数送达。

import time
import openamp


# 每当HE任务调用ept.send()时,此回调就会在HP核上运行。
def task_callback(src_addr, data):
    print("HP received:", data.decode())


# 将回调传给装饰器会把它绑定到该任务的端点。
@openamp.async_remote(task_callback)
async def task1(ept):
    import asyncio
    count = 0
    while True:
        ept.send(f"count = {count}")
        count += 1
        await asyncio.sleep(1)


# 启动HE核。
rproc = openamp.RemoteProc(0x80320000)
rproc.start()

while True:
    time.sleep(1)

results matching ""

    No results matching ""