2022-06-13 21:15:36 +02:00
|
|
|
#ifndef __VHEX_MPU_SH7305_TMU__
|
|
|
|
# define __VHEX_MPU_SH7305_TMU__
|
|
|
|
|
|
|
|
#include <vhex/defs/attributes.h>
|
|
|
|
#include <vhex/defs/types.h>
|
2022-08-11 19:21:02 +02:00
|
|
|
#include <vhex/defs/call.h>
|
2022-06-13 21:15:36 +02:00
|
|
|
|
|
|
|
/* Clock input
|
|
|
|
|
|
|
|
Standard TMU can count at different speeds. A fast speed offers more
|
|
|
|
precision but a slower speed offers longer delays. vhex automatically
|
|
|
|
selects suitable speeds by default.
|
|
|
|
|
|
|
|
If you want something very particular, you can add (with + or |) a prescaler
|
|
|
|
value to a chosen ID in timer_configure() to request that specific value.
|
|
|
|
The default prescaler if the ID is fixed is TIMER_Pphi_4. */
|
|
|
|
enum {
|
2023-01-17 21:10:51 +01:00
|
|
|
TIMER_Pphi_4 = 0x00,
|
|
|
|
TIMER_Pphi_16 = 0x10,
|
|
|
|
TIMER_Pphi_64 = 0x20,
|
|
|
|
TIMER_Pphi_256 = 0x30,
|
2022-06-13 21:15:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* tmu_t - a single timer from a standard timer unit */
|
|
|
|
typedef volatile struct
|
|
|
|
{
|
2023-01-17 21:10:51 +01:00
|
|
|
uint32_t TCOR; /* Constant register */
|
|
|
|
uint32_t TCNT; /* Counter register, counts down */
|
|
|
|
|
|
|
|
word_union(TCR,
|
|
|
|
uint16_t :7;
|
|
|
|
uint16_t UNF :1; /* Underflow flag */
|
|
|
|
uint16_t :2;
|
|
|
|
uint16_t UNIE :1; /* Underflow interrupt enable */
|
|
|
|
uint16_t CKEG :2; /* Input clock edge */
|
|
|
|
uint16_t TPSC :3; /* Timer prescaler (input clock) */
|
|
|
|
);
|
2022-06-13 21:15:36 +02:00
|
|
|
|
|
|
|
} VPACKED(4) tmu_t;
|
|
|
|
|
|
|
|
/* etmu_t - extra timers on SH7337, SH7355 and SH7305 */
|
|
|
|
typedef volatile struct
|
|
|
|
{
|
2023-01-17 21:10:51 +01:00
|
|
|
uint8_t TSTR; /* Only bit 0 is used */
|
|
|
|
pad(3);
|
2022-06-13 21:15:36 +02:00
|
|
|
|
2023-01-17 21:10:51 +01:00
|
|
|
uint32_t TCOR; /* Constant register */
|
|
|
|
uint32_t TCNT; /* Counter register */
|
2022-06-13 21:15:36 +02:00
|
|
|
|
2023-01-17 21:10:51 +01:00
|
|
|
byte_union(TCR,
|
|
|
|
uint8_t :6;
|
|
|
|
uint8_t UNF :1; /* Underflow flag */
|
|
|
|
uint8_t UNIE :1; /* Underflow interrupt enable */
|
|
|
|
);
|
|
|
|
pad(19);
|
2022-06-13 21:15:36 +02:00
|
|
|
|
|
|
|
} VPACKED(4) etmu_t;
|
|
|
|
|
|
|
|
//---
|
2023-01-17 21:10:51 +01:00
|
|
|
// SH7305 Timer Unit. Refer to:
|
|
|
|
// "Renesas SH7724 User's Manual: Hardware"
|
|
|
|
// Section 20: "Timer Unit (TMU)"
|
2022-06-13 21:15:36 +02:00
|
|
|
//---
|
|
|
|
|
|
|
|
typedef volatile struct
|
|
|
|
{
|
2023-01-17 21:10:51 +01:00
|
|
|
uint8_t TSTR; /* Timer Start Register */
|
|
|
|
pad(3);
|
2022-06-13 21:15:36 +02:00
|
|
|
|
2023-01-17 21:10:51 +01:00
|
|
|
tmu_t TMU[3];
|
2022-06-13 21:15:36 +02:00
|
|
|
|
|
|
|
} VPACKED(4) sh7305_tmu_t;
|
|
|
|
|
|
|
|
#define SH7305_TMU (*((sh7305_tmu_t *)0xa4490004))
|
|
|
|
|
|
|
|
//---
|
2023-01-17 21:10:51 +01:00
|
|
|
// SH7305 Extra Timer Unit. No official documentation exists.
|
2022-06-13 21:15:36 +02:00
|
|
|
//---
|
|
|
|
|
|
|
|
typedef volatile etmu_t sh7305_etmu_t[6];
|
|
|
|
#define SH7305_ETMU (*(sh7305_etmu_t *)0xa44d0030)
|
|
|
|
|
|
|
|
|
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
|
|
|
//---
|
|
|
|
// internal API
|
|
|
|
//---
|
|
|
|
|
|
|
|
#include <vhex/timer.h>
|
|
|
|
|
|
|
|
/* timer */
|
|
|
|
|
|
|
|
/* sh7305_tmu_reserve() : reserve a timer */
|
|
|
|
extern tid_t sh7305_tmu_reserve(uint64_t delay);
|
|
|
|
|
|
|
|
/* sh7305_tmu_configure() : configure timer */
|
2022-08-11 19:21:02 +02:00
|
|
|
extern tid_t sh7305_tmu_configure(uint64_t delay, vhex_call_t callback);
|
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
|
|
|
|
|
|
|
/* sh7305_tmu_start() - start a configured timer */
|
|
|
|
extern int sh7305_tmu_start(tid_t id);
|
|
|
|
|
|
|
|
/* sh7305_tmu_reload() - change a timer's delay constant for next interrupts */
|
|
|
|
extern int sh7305_tmu_reload(tid_t id, uint64_t delay);
|
|
|
|
|
|
|
|
/* sh7305_tmu_pause() - stop a running timer */
|
|
|
|
extern int sh7305_tmu_pause(tid_t id);
|
|
|
|
|
|
|
|
/* sh7305_tmu_stop() - stop and free a timer */
|
|
|
|
extern int sh7305_tmu_stop(tid_t id);
|
|
|
|
|
|
|
|
/* sh7305_tmu_wait(): Wait for a timer to stop */
|
|
|
|
extern int sh7305_tmu_wait(tid_t id);
|
|
|
|
|
|
|
|
/* sh7305_tmu_spinwait(): Start a timer and actively wait for UNF */
|
|
|
|
extern int sh7305_tmu_spinwait(tid_t id);
|
|
|
|
|
|
|
|
/* sh7305_tmu_get_tcnt() : return the timer TCNT register address */
|
|
|
|
extern volatile uint32_t *sh7305_tmu_get_tcnt(tid_t id);
|
|
|
|
|
|
|
|
/* sh7305_tmu_set_tcor() : set the timer TCOR value */
|
|
|
|
extern void sh7305_tmu_set_tcor(tid_t id, uint32_t value);
|
|
|
|
|
|
|
|
/* profiling */
|
|
|
|
|
|
|
|
/* sh7305_tmu_prof_make() : initialise a new */
|
|
|
|
extern int sh7305_tmu_prof_init(timer_prof_t *prof);
|
|
|
|
|
|
|
|
/* sh7305_tmu_prof_enter(): Start counting time for a function */
|
|
|
|
extern void sh7305_tmu_prof_enter(timer_prof_t *prof);
|
|
|
|
|
|
|
|
/* sh7305_tmu_prof_enter_rec(): Start counting time for a recursive function */
|
|
|
|
extern void sh7305_tmu_prof_enter_rec(timer_prof_t *prof);
|
|
|
|
|
|
|
|
/* sh7305_tmu_prof_leave_rec(): Start counting time for a recursive function */
|
|
|
|
extern void sh7305_tmu_prof_leave_rec(timer_prof_t *prof);
|
|
|
|
|
|
|
|
/* sh7305_tmu_prof_leave(): Stop counting time for a function */
|
|
|
|
extern void sh7305_tmu_prof_leave(timer_prof_t *prof);
|
|
|
|
|
|
|
|
/* sh7305_prof_time(): Time spent in a given context, in microseconds */
|
|
|
|
extern uint32_t sh7305_tmu_prof_time(timer_prof_t *prof);
|
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
|
|
|
/* sh7305_tmu_prof_quit() : uninit the profoling object */
|
|
|
|
extern int sh7305_tmu_prof_quit(timer_prof_t *prof);
|
2022-06-13 21:15:36 +02:00
|
|
|
|
2022-08-24 10:17:50 +02:00
|
|
|
/* FSP */
|
|
|
|
|
|
|
|
#include <vhex/timer/fps.h>
|
|
|
|
|
|
|
|
/* sh7305_tmu_fps_init() : initialize fps object */
|
2023-01-17 22:13:43 +01:00
|
|
|
extern void sh7305_tmu_fps_init(fps_t *fps, int fps_target);
|
2022-08-24 10:17:50 +02:00
|
|
|
|
|
|
|
/* sh7305_tmu_fps_sync() : compute frame statistic and wait whanted FPS */
|
2023-01-17 22:13:43 +01:00
|
|
|
extern void sh7305_tmu_fps_sync(fps_t *fps);
|
2022-08-24 10:17:50 +02:00
|
|
|
|
|
|
|
/* sh7305_fps_quit() : uninit the fps object */
|
|
|
|
extern void sh7305_tmu_fps_quit(fps_t *fps);
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-13 21:15:36 +02:00
|
|
|
#endif /* __VHEX_MPU_SH7305_TMU__ */
|