#ifndef HARDWARE_PRCMM_H_
#define HARDWARE_PRCMM_H_

typedef struct
{
	volatile unsigned char sel;
	volatile unsigned char en;
	volatile unsigned char cd;
	volatile unsigned char slv0;
	volatile unsigned char slv1;
	volatile unsigned char slp;
	volatile unsigned char st;
	volatile unsigned char ie;
	volatile unsigned char ifr;
} PrcmmRegs;

#define PRCMM_SEL_CODE  (5U << 4)
#define PRCMM_SEL_PLL   (5U << 0)
#define PRCMM_SEL_LRC   (4U << 0)
#define PRCMM_SEL_HRC   (3U << 0)
#define PRCMM_SEL_XTAL  (2U << 0)
#define PRCMM_SEL_EXT   (1U << 0)
#define PRCMM_SEL_DEF   (0U << 0)

#define PRCMM_EN_PLL    (1U << 5)
#define PRCMM_EN_LRC    (1U << 4)
#define PRCMM_EN_HRC    (1U << 3)
#define PRCMM_EN_XTAL   (1U << 2)
#define PRCMM_EN_EXT    (1U << 1)
#define PRCMM_EN_DEF    (1U << 0)

#define PRCMM_SLV0_LSSI1    (1U << 7)
#define PRCMM_SLV0_LSSI0    (1U << 6)
#define PRCMM_SLV0_CMP      (1U << 5)
#define PRCMM_SLV0_ADC      (1U << 5)
#define PRCMM_SLV0_GPIOC    (1U << 4)
#define PRCMM_SLV0_GPIOB    (1U << 3)
#define PRCMM_SLV0_GPIOA    (1U << 2)
#define PRCMM_SLV0_WDT      (1U << 1)
#define PRCMM_SLV0_DBG      (1U << 0)

#define PRCMM_SLV1_TIMER    (1U << 1)
#define PRCMM_SLV1_OWI      (1U << 0)

#define PRCMM_SLP_CODE          (5U << 4)
#define PRCMM_SLP_COLD_SLEEP    (1U << 3)
#define PRCMM_SLP_DEEP_SLEEP    (1U << 2)
#define PRCMM_SLP_SLEEP         (1U << 1)
#define PRCMM_SLP_CPU_SLEEP     (1U << 0)

#define PRCMM_ST_JATG_RST       (1U << 6)
#define PRCMM_ST_WDT_RST        (1U << 5)
#define PRCMM_ST_STABLE_PLL     (1U << 4)
#define PRCMM_ST_STABLE_LRC     (1U << 3)
#define PRCMM_ST_STABLE_HRC     (1U << 2)
#define PRCMM_ST_STABLE_XTAL    (1U << 1)
#define PRCMM_ST_STABLE_EXT     (1U << 0)

#define PRCMM_IE_STABLE_PLL     (1U << 4)
#define PRCMM_IE_STABLE_LRC     (1U << 3)
#define PRCMM_IE_STABLE_HRC     (1U << 2)
#define PRCMM_IE_STABLE_XTAL    (1U << 1)
#define PRCMM_IE_STABLE_EXT     (1U << 0)

#define PRCMM_IF_STABLE_PLL     PRCMM_IE_STABLE_PLL
#define PRCMM_IF_STABLE_LRC     PRCMM_IE_STABLE_LRC
#define PRCMM_IF_STABLE_HRC     PRCMM_IE_STABLE_HRC
#define PRCMM_IF_STABLE_XTAL    PRCMM_IE_STABLE_XTAL
#define PRCMM_IF_STABLE_EXT     PRCMM_IE_STABLE_EXT

#endif /* HARDWARE_PRCMM_H_ */
