4 #define REG16(x)(*((volatile uint16_t *)(x)))
5 #define REG(x)(*((volatile uint32_t *)(x)))
6 #define BIT(x)(0x1 << x)
8 /* Write a uint32_t value to a memory address. */
10 write32(uint32_t address
, uint32_t value
)
15 /* Read an uint32_t from a memory address */
16 static inline uint32_t
17 read32(uint32_t address
)
22 /* Set a 32 bits value depending on a mask */
24 set32(uint32_t address
, uint32_t mask
, uint32_t value
)
27 val
= read32(address
);
30 /* apply the value using the mask */
31 val
|= (value
& mask
);
32 write32(address
, val
);
35 /* Write a uint16_t value to a memory address. */
37 write16(uint32_t address
, uint16_t value
)
39 REG16(address
) = value
;
42 /* Read an uint16_t from a memory address */
43 static inline uint16_t
44 read16(uint32_t address
)
46 return REG16(address
);
49 /* Set a 16 bits value depending on a mask */
51 set16(uint32_t address
, uint16_t mask
, uint16_t value
)
54 val
= read16(address
);
57 /* apply the value using the mask */
58 val
|= (value
& mask
);
59 write16(address
, val
);
62 #endif /* __MMIO_H__ */