mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-03 06:27:47 +00:00
e80a22d0ba
* wifinina: implementation of WiFiNINA driver, including: - TCP client example is working - reading sockets and mqtt working - switched over to common net package also used by espat package - smoke tests and updated README for wifinina
29 lines
448 B
Go
29 lines
448 B
Go
package wifinina
|
|
|
|
import "time"
|
|
|
|
func wait(duration time.Duration) {
|
|
newTimer(duration).WaitUntilExpired()
|
|
}
|
|
|
|
type timer struct {
|
|
start int64
|
|
interval int64
|
|
}
|
|
|
|
func newTimer(interval time.Duration) timer {
|
|
return timer{
|
|
start: time.Now().UnixNano(),
|
|
interval: int64(interval),
|
|
}
|
|
}
|
|
|
|
func (t timer) Expired() bool {
|
|
return time.Now().UnixNano() > (t.start + t.interval)
|
|
}
|
|
|
|
func (t timer) WaitUntilExpired() {
|
|
for !t.Expired() {
|
|
}
|
|
}
|