86 lines
1.9 KiB
C
86 lines
1.9 KiB
C
#ifndef __VHEX_MPU_SH7305_TMU__
|
|
# define __VHEX_MPU_SH7305_TMU__
|
|
|
|
#include <vhex/defs/attributes.h>
|
|
#include <vhex/defs/types.h>
|
|
|
|
/* 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 {
|
|
TIMER_Pphi_4 = 0x00,
|
|
TIMER_Pphi_16 = 0x10,
|
|
TIMER_Pphi_64 = 0x20,
|
|
TIMER_Pphi_256 = 0x30,
|
|
};
|
|
|
|
/* tmu_t - a single timer from a standard timer unit */
|
|
typedef volatile struct
|
|
{
|
|
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) */
|
|
);
|
|
|
|
} VPACKED(4) tmu_t;
|
|
|
|
/* etmu_t - extra timers on SH7337, SH7355 and SH7305 */
|
|
typedef volatile struct
|
|
{
|
|
uint8_t TSTR; /* Only bit 0 is used */
|
|
pad(3);
|
|
|
|
uint32_t TCOR; /* Constant register */
|
|
uint32_t TCNT; /* Counter register */
|
|
|
|
byte_union(TCR,
|
|
uint8_t :6;
|
|
uint8_t UNF :1; /* Underflow flag */
|
|
uint8_t UNIE :1; /* Underflow interrupt enable */
|
|
);
|
|
pad(19);
|
|
|
|
} VPACKED(4) etmu_t;
|
|
|
|
//---
|
|
// SH7305 Timer Unit. Refer to:
|
|
// "Renesas SH7724 User's Manual: Hardware"
|
|
// Section 20: "Timer Unit (TMU)"
|
|
//---
|
|
|
|
typedef volatile struct
|
|
{
|
|
uint8_t TSTR; /* Timer Start Register */
|
|
pad(3);
|
|
|
|
tmu_t TMU[3];
|
|
|
|
} VPACKED(4) sh7305_tmu_t;
|
|
|
|
#define SH7305_TMU (*((sh7305_tmu_t *)0xa4490004))
|
|
|
|
//---
|
|
// SH7305 Extra Timer Unit. No official documentation exists.
|
|
//---
|
|
|
|
typedef volatile etmu_t sh7305_etmu_t[6];
|
|
#define SH7305_ETMU (*(sh7305_etmu_t *)0xa44d0030)
|
|
|
|
|
|
|
|
|
|
#endif /* __VHEX_MPU_SH7305_TMU__ */
|