timers ****** This module exposes the GBA's 4 hardware timers. Each timer holds a 16-bit value which ticks up by 1 after a certain number of CPU cycles (determined by the the timer's frequency setting). When this value overflows, it will reset to the timer's `start` value and an interrupt will be raised if one has been requested. **Example:** .. code-block:: nim import natu/[irq, timers, mgba] proc myHandler() = mgba.printf("Bonk!") irq.put(iiTimer3, myHandler) # Register the handler. tmcnt[3].init( freq = tf16kHz, start = cast[uint16](-0x4000), # 2^14 ticks at 16 kHz = 1 second active = true, # Enable the timer. irq = true, # Fire an interrupt when the timer overflows. ) .. note:: Timer 0 is used by :doc:`maxmod` for audio, so don't touch it unless you know what you're doing. ----------------------------- Types ===== .. autonim:: timers.TimerFreq .. autonim:: timers.Timer ----------------------------- I/O Registers ============= .. autonim:: timers.tmcnt .. autonim:: timers.count .. autonim:: timers.`start=` .. autonim:: timers.init .. autonim:: timers.edit ----------------------------- Profiling Helpers ================= These procedures allow you to measure exactly how many CPU cycles a section of code takes to execute. .. autonim:: timers.profileStart .. autonim:: timers.profileStop