#ifndef HARDWARE_OWI_H_
#define HARDWARE_OWI_H_

typedef struct
{
	volatile unsigned char cfg;
	volatile unsigned char buf;
	volatile unsigned char st;
	volatile unsigned char msk;
	volatile unsigned char prcr;
	volatile unsigned char ctrl;
} OwiRegs;

#define OWI_CFG_OWI_IN  (1U << 3)
#define OWI_CFG_FOW     (1U << 2)
#define OWI_CFG_SRA     (1U << 1)
#define OWI_CFG_1WR     (1U << 0)

#define OWI_ST_OW_LOW   (1U << 7)
#define OWI_ST_OW_SHORT (1U << 6)
#define OWI_ST_RSRF     (1U << 5)
#define OWI_ST_RBF      (1U << 4)
#define OWI_ST_TEMT     (1U << 3)
#define OWI_ST_TBE      (1U << 2)
#define OWI_ST_PDR      (1U << 1)
#define OWI_ST_PD       (1U << 0)

#define OWI_MSK_OW_LOW      OWI_ST_OW_LOW
#define OWI_MSK_OW_SHORT    OWI_ST_OW_SHORT
#define OWI_MSK_RSRF        OWI_ST_RSRF
#define OWI_MSK_RBF         OWI_ST_RBF
#define OWI_MSK_TEMT        OWI_ST_TEMT
#define OWI_MSK_TBE         OWI_ST_TBE
#define OWI_MSK_PD          OWI_ST_PD

#define OWI_PRCR_CLK_EN     (1U << 7)
#define OWI_PRCR_DIV_128    (7U << 2)
#define OWI_PRCR_DIV_64     (6U << 2)
#define OWI_PRCR_DIV_32     (5U << 2)
#define OWI_PRCR_DIV_16     (4U << 2)
#define OWI_PRCR_DIV_8      (3U << 2)
#define OWI_PRCR_DIV_4      (2U << 2)
#define OWI_PRCR_DIV_2      (1U << 2)
#define OWI_PRCR_DIV_1      (0U << 2)
#define OWI_PRCR_PRE_7      (3U << 0)
#define OWI_PRCR_PRE_5      (2U << 0)
#define OWI_PRCR_PRE_3      (1U << 0)
#define OWI_PRCR_PRE_1      (0U << 0)

#define OWI_CTRL_OD         (1U << 6)
#define OWI_CTRL_BIT_CTRL   (1U << 5)
#define OWI_CTRL_EN_FLOW    (1U << 2)
#define OWI_CTRL_PPM        (1U << 1)
#define OWI_CTRL_LLM        (1U << 0)

#endif /* HARDWARE_OWI_H_ */
