Skip to content

unit TickerP

em.examples.basic/TickerP.em
package em.examples.basic

from em$distro import BoardC
from BoardC import AppLed
from BoardC import SysLed

from em.mcu import Common

from em.utils import FiberMgr
from em.utils import TickerMgr

module TickerP

private:

    function appTickCb: TickerMgr.TickCallback
    function sysTickCb: TickerMgr.TickCallback

    config appTicker: TickerMgr.Ticker&
    config sysTicker: TickerMgr.Ticker&

end

def em$construct()
    appTicker = TickerMgr.createH()
    sysTicker = TickerMgr.createH()
end

def em$run()
    appTicker.start(256, appTickCb)
    sysTicker.start(256, sysTickCb)
    FiberMgr.run()
end

def appTickCb()
    %%[c]
    AppLed.on()
    Common.BusyWait.wait(100000)
    AppLed.off()
end

def sysTickCb()
    %%[d]
    SysLed.on()
    Common.BusyWait.wait(100000)
    SysLed.off()
end