Open
Description
Background:
I am working on an IoT project involving ZigBee SDK (pre-compiled archive & C code) and FreeRTOS (C & ASM). Targeted for nrf52840 (1MB flash, 256KB RAM) and similar board.
I was writing code in pure C, mainly
- RTOS scheduling for running tasks
- Protothread-like scheduling for event-based "jobs" within a task (using full-blown RTOS task would create too much overhead)
- I am also thinking to add a consensus algorithm for job configurations
I am considering replacing 2) and 3) with golang, since the language got concurrency build in. And I might be able to use an existing consensus algorithm written in go (e.g. etcd/raft).
Question:
- I understand tinygo uses LLVM to produce an optimised objective file. The Call-Convention section in the docs mentioned the argument with only integer and pointers will be stable. Does it mean I can invoke functions written in go with a pointer to a C struct, and by using cgo, I can parse the C struct in go without any problem?
- On the tinygo documentation, I see more of how to use c code within go. Rather than how to link go code to existing C project. Is this intentional, what are the downsides of doing this?
PS: I know here is not the best place to ask newbie questions, but I can't find a forum online.
Hope it will be informative to other people as well.