Skip to content

Commit

Permalink
tweak stacktraces
Browse files Browse the repository at this point in the history
  • Loading branch information
elcritch committed Aug 27, 2024
1 parent 3dcffec commit 924772f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/nesper/spis.nim
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,13 @@ proc getData*(trn: SpiTrans): seq[byte] =
else:
return trn.rx_data.toSeq()

{.push stacktrace: off.}
proc getSmallData*(trn: SpiTrans): array[4, uint8] =
if trn.trn.rxlength > 32:
raise newException(SpiError, "transaction data too large")

return trn.trn.rx_data



proc pollingStart*(trn: SpiTrans, ticks_to_wait: TickType_t = portMAX_DELAY) {.inline.} =
let ret = spi_device_polling_start(trn.dev.handle, addr(trn.trn), ticks_to_wait)
if (ret != ESP_OK):
Expand All @@ -290,6 +289,7 @@ proc poll*(trn: SpiTrans, ticks_to_wait: TickType_t = portMAX_DELAY) {.inline.}
let ret: esp_err_t = spi_device_polling_transmit(trn.dev.handle, addr(trn.trn))
if (ret != ESP_OK):
raise newEspError[SpiError]("spi polling (" & $esp_err_to_name(ret) & ")", ret)
{.pop.}

proc acquireBus*(trn: SpiDev, wait: TickType_t = portMAX_DELAY) {.inline.} =
let ret: esp_err_t = spi_device_acquire_bus(trn.handle, wait)
Expand Down
6 changes: 5 additions & 1 deletion src/nesper/timers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ proc toMicros*(ts: Millis): Micros =
return Micros(ts.uint64 * 1_000U)

# void IRAM_ATTR delayMicroseconds(uint32_t us)
{.push stacktrace: off.}
proc delayMicros*(us: uint64): uint64 {.discardable.} =
if us.uint64 == 0:
return 0
Expand All @@ -71,6 +72,7 @@ proc delayMicros*(us: uint64): uint64 {.discardable.} =
curr = microsRaw()

return target-curr
{.pop.}

proc delayMillis*(ms: uint64): uint64 {.discardable.} =
var start = millis()
Expand All @@ -89,8 +91,10 @@ proc delay*(ts: Micros) {.discardable.} = discard delayMicros(ts.uint64)
proc newBasicTimer*(): BasicTimer =
return BasicTimer(ts: micros())

proc elapsed*(timer: BasicTimer): Micros =
{.push stacktrace: off.}
proc elapsed*(timer: BasicTimer): Micros {.inline.} =
return micros() - timer.ts
{.pop.}

proc reset*(timer: var BasicTimer) =
timer.ts = micros()
Expand Down

0 comments on commit 924772f

Please sign in to comment.