I was trying to declare a class like ```class some...
# kotlin-native
k
I was trying to declare a class like
Copy code
class someType(override val rawPtr: NativePtr) : CStructVar() {

    companion object : Type(8, 4)

    var regA: Int
        get() = memberAt<IntVar>(0).value
        set(value) { memberAt<IntVar>(0).value = value }

    var regB: Int
        get() = memberAt<IntVar>(4).value
        set(value) { memberAt<IntVar>(4).value = value }
}
o
Not sure if I understand what you're trying to reach. Kotlin/Native is an object oriented language, so primitives you work with are objects. If you need to access raw bits at some address, for example device MMIO interface, approach would be to write few C functions, interop with those and optionally write object oriented wrapper for use in your app
k
I'm just wondering if it is plausible to access registers directly from Kotlin without C on microcontrollers and how such DSL would look like.
I think I found a way to make a structure point to given address
val someType: someType = (0x22_00_00_00L).toCPointer<someType>()!!.pointed
not sure thow if it will work anyway 😛
o
I think you can make rather simple API the way I sketched above, but note that most GP registers are changed during program lifetime quickly, so unless you're in fault handler or interrupt, and they are saved somewhere by hardware - they don't make much sense