Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | /* Port and memory mapped registers I/O operations */
/*
* Copyright (c) 2015 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __SYS_IO_H__
#define __SYS_IO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h>
#include <stddef.h>
typedef u32_t io_port_t;
typedef u32_t mm_reg_t;
typedef u32_t mem_addr_t;
/* Port I/O functions */
/**
* @fn static inline void sys_out8(u8_t data, io_port_t port);
* @brief Output a byte to an I/O port
*
* This function writes a byte to the given port.
*
* @param data the byte to write
* @param port the port address where to write the byte
*/
/**
* @fn static inline u8_t sys_in8(io_port_t port);
* @brief Input a byte from an I/O port
*
* This function reads a byte from the port.
*
* @param port the port address from where to read the byte
*
* @return the byte read
*/
/**
* @fn static inline void sys_out16(u16_t data, io_port_t port);
* @brief Output a 16 bits to an I/O port
*
* This function writes a 16 bits to the given port.
*
* @param data the 16 bits to write
* @param port the port address where to write the 16 bits
*/
/**
* @fn static inline u16_t sys_in16(io_port_t port);
* @brief Input 16 bits from an I/O port
*
* This function reads 16 bits from the port.
*
* @param port the port address from where to read the 16 bits
*
* @return the 16 bits read
*/
/**
* @fn static inline void sys_out32(u32_t data, io_port_t port);
* @brief Output 32 bits to an I/O port
*
* This function writes 32 bits to the given port.
*
* @param data the 32 bits to write
* @param port the port address where to write the 32 bits
*/
/**
* @fn static inline u32_t sys_in32(io_port_t port);
* @brief Input 32 bits from an I/O port
*
* This function reads 32 bits from the port.
*
* @param port the port address from where to read the 32 bits
*
* @return the 32 bits read
*/
/**
* @fn static inline void sys_io_set_bit(io_port_t port, unsigned int bit)
* @brief Set the designated bit from port to 1
*
* This functions takes the designated bit starting from port and sets it to 1.
*
* @param port the port address from where to look for the bit
* @param bit the designated bit to set (from 0 to n)
*/
/**
* @fn static inline void sys_io_clear_bit(io_port_t port, unsigned int bit)
* @brief Clear the designated bit from port to 0
*
* This functions takes the designated bit starting from port and sets it to 0.
*
* @param port the port address from where to look for the bit
* @param bit the designated bit to clear (from 0 to n)
*/
/**
* @fn static inline int sys_io_test_bit(io_port_t port, unsigned int bit)
* @brief Test the bit from port if it is set or not
*
* This functions takes the designated bit starting from port and tests its
* current setting. It will return the current setting.
*
* @param port the port address from where to look for the bit
* @param bit the designated bit to test (from 0 to n)
*
* @return 1 if it is set, 0 otherwise
*/
/**
* @fn static inline int sys_io_test_and_set_bit(io_port_t port, unsigned int bit)
* @brief Test the bit from port and set it
*
* This functions takes the designated bit starting from port, tests its
* current setting and sets it. It will return the previous setting.
*
* @param port the port address from where to look for the bit
* @param bit the designated bit to test and set (from 0 to n)
*
* @return 1 if it was set, 0 otherwise
*/
/**
* @fn static inline int sys_io_test_and_clear_bit(io_port_t port, unsigned int bit)
* @brief Test the bit from port and clear it
*
* This functions takes the designated bit starting from port, tests its
* current setting and clears it. It will return the previous setting.
*
* @param port the port address from where to look for the bit
* @param bit the designated bit to test and clear (from 0 to n)
*
* @return 0 if it was clear, 1 otherwise
*/
/* Memory mapped registers I/O functions */
/**
* @fn static inline void sys_write8(u8_t data, mm_reg_t addr);
* @brief Write a byte to a memory mapped register
*
* This function writes a byte to the given memory mapped register.
*
* @param data the byte to write
* @param addr the memory mapped register address where to write the byte
*/
/**
* @fn static inline u8_t sys_read8(mm_reg_t addr);
* @brief Read a byte from a memory mapped register
*
* This function reads a byte from the given memory mapped register.
*
* @param addr the memory mapped register address from where to read the byte
*
* @return the byte read
*/
/**
* @fn static inline void sys_write16(u16_t data, mm_reg_t addr);
* @brief Write 16 bits to a memory mapped register
*
* This function writes 16 bits to the given memory mapped register.
*
* @param data the 16 bits to write
* @param addr the memory mapped register address where to write the 16 bits
*/
/**
* @fn static inline u16_t sys_read16(mm_reg_t addr);
* @brief Read 16 bits from a memory mapped register
*
* This function reads 16 bits from the given memory mapped register.
*
* @param addr the memory mapped register address from where to read
* the 16 bits
*
* @return the 16 bits read
*/
/**
* @fn static inline void sys_write32(u32_t data, mm_reg_t addr);
* @brief Write 32 bits to a memory mapped register
*
* This function writes 32 bits to the given memory mapped register.
*
* @param data the 32 bits to write
* @param addr the memory mapped register address where to write the 32 bits
*/
/**
* @fn static inline u32_t sys_read32(mm_reg_t addr);
* @brief Read 32 bits from a memory mapped register
*
* This function reads 32 bits from the given memory mapped register.
*
* @param addr the memory mapped register address from where to read
* the 32 bits
*
* @return the 32 bits read
*/
/* Memory bits manipulation functions */
/**
* @fn static inline void sys_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Set the designated bit from addr to 1
*
* This functions takes the designated bit starting from addr and sets it to 1.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to set (from 0 to 31)
*/
/**
* @fn static inline void sys_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Clear the designated bit from addr to 0
*
* This functions takes the designated bit starting from addr and sets it to 0.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to clear (from 0 to 31)
*/
/**
* @fn static inline int sys_test_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit if it is set or not
*
* This functions takes the designated bit starting from addr and tests its
* current setting. It will return the current setting.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to test (from 0 to 31)
*
* @return 1 if it is set, 0 otherwise
*/
/**
* @fn static inline int sys_test_and_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and set it
*
* This functions takes the designated bit starting from addr, tests its
* current setting and sets it. It will return the previous setting.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to test and set (from 0 to 31)
*
* @return 1 if it was set, 0 otherwise
*/
/**
* @fn static inline int sys_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and clear it
*
* This functions takes the designated bit starting from addr, test its
* current setting and clears it. It will return the previous setting.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to test and clear (from 0 to 31)
*
* @return 0 if it was clear, 1 otherwise
*/
/**
* @fn static inline void sys_bitfield_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Set the designated bit from addr to 1
*
* This functions takes the designated bit starting from addr and sets it to 1.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to set (arbitrary)
*/
/**
* @fn static inline void sys_bitfield_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Clear the designated bit from addr to 0
*
* This functions takes the designated bit starting from addr and sets it to 0.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to clear (arbitrary)
*/
/**
* @fn static inline int sys_bitfield_test_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit if it is set or not
*
* This functions takes the designated bit starting from addr and tests its
* current setting. It will return the current setting.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to test (arbitrary
*
* @return 1 if it is set, 0 otherwise
*/
/**
* @fn static inline int sys_bitfield_test_and_set_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and set it
*
* This functions takes the designated bit starting from addr, tests its
* current setting and sets it. It will return the previous setting.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to test and set (arbitrary)
*
* @return 1 if it was set, 0 otherwise
*/
/**
* @fn static inline int sys_bitfield_test_and_clear_bit(mem_addr_t addr, unsigned int bit)
* @brief Test the bit and clear it
*
* This functions takes the designated bit starting from addr, test its
* current setting and clears it. It will return the previous setting.
*
* @param addr the memory address from where to look for the bit
* @param bit the designated bit to test and clear (arbitrary)
*
* @return 0 if it was clear, 1 otherwise
*/
#ifdef __cplusplus
}
#endif
#endif /* __SYS_IO_H__ */
|