Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3// Full license header bsp/efinix/EfxSapphireSocRV64/include/LICENSE.MD
5#ifndef IO_H_
6#define IO_H_
7
8#include "type.h"
9#include "soc.h"
10
11
12 static inline u32 read_u32(u32 address){
13 return *((volatile u32*)(u64) address);
14 }
15
16 static inline void write_u32(u32 data, u32 address){
17 *((volatile u32*)(u64) address) = data;
18 }
19
20 static inline u16 read_u16(u32 address){
21 return *((volatile u16*)(u64) address);
22 }
23
24 static inline void write_u16(u16 data, u32 address){
25 *((volatile u16*)(u64) address) = data;
26 }
27
28 static inline u8 read_u8(u32 address){
29 return *((volatile u8*)(u64) address);
30 }
31
32 static inline void write_u8(u8 data, u32 address){
33 *((volatile u8*)(u64) address) = data;
34 }
35
36 static inline void write_u32_ad(u32 address, u32 data){
37 *((volatile u32*)(u64) address) = data;
38 }
39
40 #define writeReg_u32(name, offset) \
41 static inline void name(u32 reg, u32 value){ \
42 write_u32(value, reg + offset); \
43 } \
44
45 #define readReg_u32(name, offset) \
46 static inline u32 name(u32 reg){ \
47 return read_u32(reg + offset); \
48 } \
49
50#endif //IO_H_
51
52
53
54
55
uint64_t u64
Definition type.h:20
uint8_t u8
Definition type.h:26
uint16_t u16
Definition type.h:24
uint32_t u32
Definition type.h:22