Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is the FreeRTOS xTaskCreate that I believe has been passed through c2nim
- type
- TaskFunction_t* = proc (a1: pointer) {.cdecl.}
- proc xTaskCreate*(pvTaskCode: TaskFunction_t; pcName: cstring;
- usStackDepth: uint32; pvParameters: pointer;
- uxPriority: UBaseType_t; pvCreatedTask: ptr TaskHandle_t): BaseType_t {.
- inline.} =
- return xTaskCreatePinnedToCore(pvTaskCode, pcName, usStackDepth, pvParameters,
- uxPriority, pvCreatedTask, tskNO_AFFINITY)
- ## Okay, so my crappy incorrect code
- type
- Task* = object
- name: string
- handle: TaskHandle_t
- ret: BaseType_t
- proc newTask*(cb: proc(), name: string, stackSize: SzBytes): Task =
- result.name = name
- # This obviously doesn't work
- proc wrapper (a1: pointer) {.cdecl.} =
- cb()
- result.ret = xTaskCreate(wrapper, cstring(result.name), stackSize.uint32, nil, 10, addr result.handle)
- proc `=destroy`*(t: var Task) =
- vTaskDelete(t.handle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement