2022-06-13 21:15:36 +02:00
|
|
|
#ifndef __VHEX_TIMER__
|
|
|
|
#define __VHEX_TIMER__
|
|
|
|
|
2022-08-11 19:21:02 +02:00
|
|
|
#include <vhex/defs/call.h>
|
2022-06-13 21:15:36 +02:00
|
|
|
#include <vhex/timer/types.h>
|
|
|
|
|
|
|
|
/* TIMER_DELAY_MS() : convert ms into us */
|
|
|
|
#define TIMER_DELAY_MS(ms) (ms * 1000)
|
|
|
|
#define TIMER_DELAY_SEC(sec) (sec * 1000000)
|
|
|
|
|
|
|
|
/* returned status from a callback */
|
|
|
|
enum {
|
2022-06-14 21:56:06 +02:00
|
|
|
TIMER_CONTINUE = 0,
|
|
|
|
TIMER_STOP = 1,
|
2022-06-13 21:15:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* timer_configure(): Reserve and configure a timer
|
|
|
|
|
|
|
|
This function finds and configures a timer (without starting it). On
|
|
|
|
success, it returns the ID of the configured timer, which is used in all
|
|
|
|
other timer functions. If no timer matching the requested settings is
|
|
|
|
available, this function returns -1.
|
|
|
|
|
|
|
|
When started, the configured timer will run for the requested delay and call
|
|
|
|
the supplied callback function at the end of this delay. The callback
|
|
|
|
function can then decide whether to leave the timer running (and be called
|
|
|
|
again after the same delay) or stop the timer. */
|
2022-08-11 19:21:02 +02:00
|
|
|
extern tid_t timer_configure(uint64_t delay_us, vhex_call_t callback);
|
2022-06-13 21:15:36 +02:00
|
|
|
|
VxKernel 0.6.0-13 : Add keyboard API + update timer API
@add
<> include/vhex/driver/mpu/sh/sh7305/keysc
| add internal driver primitives
<> include/vhex/driver/mpu/sh/sh7305/tmu
| add internal driver primitives
<> include/vhex/keyboard
| add getkey* (high-level) API
| add key event API
| add key status API
| add keycode information
| add keyboard driver interface
@update
<> include/vhex/driver
| add KEYBOARD driver flags
<> include/vhex/keyboard
| isolate each part of the keyboard module
| link the keycache part with the driver-provided keycache information
<> src/drivers/mpu/sh/sh7305/keysc
| use the new keycache API (high-level interrupt handler)
| update keycache API
| link the new API in the driver device
<> src/drivers/mpu/sh/sh7305/tmu
| add timer reservation (WIP)
| use a "reservation" cache to known which timer is free instead of hardware
| rename internal functions
<> src/module/display
| Now, by default, DSTACK_CALL() create a pointer on a dstack_call_t
| use dsubimage dstack primitive in dimage()
@fix
<> board/fxcg50/fxcg50.ld
| remove the IL-memory and allow only the X-memory area. This because the
bootloader uses the IL-memory for DMA transfer and other "low-level"
routine used by Gint.
Moreover, I originally try to move each "display-driver" in this place,
but after some profiling and tests, the dclear()/dupdate() combo went from
9155us up to 33250us (for many reason). So, I keep this area free, but I
moved-back from RAM display routines.
<> board/fxcg50/initialize
| remove "section" copy. This role has been delegated to the bootload (vxBoot)
because, in the final ELF file generated by GCC, many relocalization
information for the IL/X memory has been set and the bootloader cannot
performs general relocalization.
So, all "special section/memory" displacement has been moved in the
bootloader and we don't have to worrying about the section copy.
<> src/drivers/mpu/sh/sh7305/tmu
| fix delay calculation in timer reload primitive
| disable interruption for profiling timer
<> src/module/dislay/
| fix shader index used during the dstack_render()
| fix many errors in dimage() shadow render (WIP)
2022-06-24 15:33:36 +02:00
|
|
|
/* timer_reserve() : reserve a timer
|
|
|
|
|
|
|
|
The timer can be used normaly, but no callback nor interruption will occur.
|
|
|
|
This primitive is usefull if you whant to have only the timer counter */
|
|
|
|
extern tid_t timer_reserve(uint64_t delay_us);
|
|
|
|
|
2022-06-13 21:15:36 +02:00
|
|
|
/* timer_start(): Start a configured timer */
|
|
|
|
extern int timer_start(tid_t timer);
|
|
|
|
|
|
|
|
/* timer_pause(): Pause a timer without freeing it */
|
|
|
|
extern int timer_pause(tid_t timer);
|
|
|
|
|
|
|
|
/* timer_stop(): Stop and free a timer */
|
|
|
|
extern int timer_stop(tid_t timer);
|
|
|
|
|
|
|
|
/* timer_wait(): Wait for a timer to stop
|
|
|
|
Waits until the timer pauses or stops. If the timer is not running, returns
|
|
|
|
immediately. Even after timer_wait(), the timer may not be available since
|
|
|
|
it may have only paused. If the timer never stops, you're in trouble. */
|
|
|
|
extern int timer_wait(tid_t timer);
|
|
|
|
|
|
|
|
/* timer_spinwait(): Start a timer and actively wait
|
|
|
|
Waits until the timer has finished its countdown, without sleeping. This is
|
|
|
|
useful for delays in driver code that is run when interrupts are disabled.
|
|
|
|
Interrupt are disabled before starting the timer and waiting, so the callback
|
|
|
|
is never called. */
|
|
|
|
extern int timer_spinwait(tid_t timer);
|
|
|
|
|
|
|
|
/* timer_reload(): Change a timer's delay constant for next interrupts */
|
|
|
|
extern int timer_reload(tid_t timer, uint64_t delay);
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __VHEX_TIMER__ */
|