-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples: Refactoring bindings examples #2534
Conversation
589999c
to
b7b38f8
Compare
About Zig's progress. Of all these languages that have internal or external facilities for interoperability with C (some C++ too) zig proves to be very practical, providing built-in auto-conversion (C2Zig). However, in the future Zig will make LLVM optional and some of the features will no longer be provided by default (maybe as an add-on). Note: unlike bindgen-rs and importC (I don't know how to evaluate Swift yet), FFI method
References |
@kassane please fix ci warning:
|
2970dab
to
dba09a9
Compare
This comment was marked as outdated.
This comment was marked as outdated.
@kassane sorry I missed this, wonder if it might be better to blink the LED like leds_rust, instead of doing GPIO? That's because we can test it on QEMU RISC-V, which has an LED Driver. We don't have a GPIO Driver for QEMU. Thanks! |
dlang: use importC to get NuttX include zig: leds_zig added
6fb9387
to
5e6eee2
Compare
New zig example added - using |
Note Curious note regarding leds_swift. Having completed the zig example. I have taken the time and concepts to try to implement the swift port (newly embedded). Swift-Embedded support status: leds-sample: https://gist.github.com/kassane/03a792f92b2430b350429dfa51dd5532 let _ULEDBASE: UInt = 0 // You need to set this to the correct value
let _IOC_TYPE_MASK: UInt = 0xff << 8 // Adjust this based on your system's IOC structure
func _IOC(_ type: UInt, _ nr: UInt) -> UInt {
return (type << 8) | nr
}
func _IOC_TYPE(_ nr: UInt) -> UInt {
return (nr & _IOC_TYPE_MASK) >> 8
}
func _ULEDIOCVALID(_ c: UInt) -> Bool {
return _IOC_TYPE(c) == _ULEDBASE
}
func _ULEDIOC<T: BinaryInteger>(_ nr: T) -> T {
return T(_IOC(_ULEDBASE, UInt(nr)))
}
let ULEDIOC_SUPPORTED: Int32 = _ULEDIOC(0x0001)
let ULEDIOC_SETALL : Int32 = _ULEDIOC(0x0003) # fd = open(CONFIG_EXAMPLES_LEDS_DEVPATH, O_WRONLY)
error: 'open' is unavailable: Variadic function is unavailable
# var ret = ioctl(fd, ULEDIOC_SUPPORTED, supported)
note: 'ioctl' has been explicitly marked unavailable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thanks!
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
This PR adds a new Build Config `rv-virt:leds64_zig` that builds the Zig App `leds_zig` for QEMU RISC-V 64-bit. ref.: apache/nuttx-apps#2534
Summary
Refactoring Zig and D examples
Impact
This refactoring involves giving a better understanding of the usefulness of certain examples.
If these tools don't have any real appeal, then they're completely useless.
Step changes
hello_zig
std.mem.Allocator
+ std containers in example (Zig std works in RTOS??)hello_d
usingimportC
(get nuttx include) onbetterC
mode no GC (garbage collector)Testing
How?
nuttx-apps/examples/hello_zig/hello_zig.zig
Lines 29 to 35 in 19e8f6a
nuttx-apps/examples/hello_zig/hello_zig.zig
Lines 39 to 40 in 19e8f6a
nuttx-apps/examples/hello_zig/hello_zig.zig
Lines 52 to 59 in 19e8f6a
Dlang
Reference
cc: @lupyuen