Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Dec 26, 2023
1 parent f94c0a5 commit 1970acb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/hello_nim/hello_nim_async.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ proc blink_led() =
echo "Failed to open /dev/userleds"
return

## On Return: Close the LED Driver
defer: c_close(fd)

## Turn on LED
echo "Set LED 0 to 1"
var ret = c_ioctl(fd, ULEDIOC_SETALL, 1)
Expand All @@ -51,23 +54,19 @@ proc blink_led() =
echo "Waiting..."
c_usleep(1000_000)

## Close the LED Driver
c_close(fd)

## Main Function in Nim
proc hello_nim() {.exportc, cdecl.} =

## On Return: Force the Garbage Collection
defer: GC_runOrc()

## Print something
echo "Hello Nim!"

## Blink the LED 20 times
for loop in 0..19:
blink_led()

## Finish
## Previously: waitFor launch()
GC_runOrc()

## To test the compilation for NuttX:
# export TOPDIR=/workspaces/bookworm/nuttx
# cd /workspaces/bookworm/apps/examples/hello_nim
Expand Down

0 comments on commit 1970acb

Please sign in to comment.