source: trunk/softs/tsar_boot/include/io.h @ 655

Last change on this file since 655 was 655, checked in by cfuguet, 11 years ago

Fixing bug introduced in last commit :

  • When using IO bridge, some header files were missing in the reset_utils.h file
File size: 1.2 KB
Line 
1/**
2 * \file        io.h
3 * \date        5 September 2012
4 * \author      Cesar Fuguet
5 *
6 * Utility functions to write or read memory mapped hardware registers
7 */
8#ifndef IO_H
9#define IO_H
10
11/**
12 * Read an 32 bits memory mapped hardware register
13 */
14static inline unsigned int ioread32(void * addr)
15{
16        return *(volatile unsigned int *) addr;
17}
18
19/**
20 * Read an 16 bits memory mapped hardware register
21 */
22static inline unsigned short ioread16(void * addr)
23{
24        return *(volatile unsigned short *) addr;
25}
26
27/**
28 * Read an 8 bits memory mapped hardware register
29 */
30static inline unsigned char ioread8(void * addr)
31{
32        return *(volatile unsigned char *) addr;
33}
34
35/**
36 * Write an 32 bits memory mapped hardware register
37 */
38static inline void iowrite32(void * addr, unsigned int value)
39{
40        *(volatile unsigned int *) addr = value;
41        asm volatile("sync" ::: "memory");
42}
43
44/**
45 * Write an 16 bits memory mapped hardware register
46 */
47static inline void iowrite16(void * addr, unsigned short value)
48{
49        *(volatile unsigned short *) addr = value;
50        asm volatile("sync" ::: "memory");
51}
52
53/**
54 * Write an 8 bits memory mapped hardware register
55 */
56static inline void iowrite8(void * addr, unsigned char value)
57{
58        *(volatile unsigned char *) addr = value;
59        asm volatile("sync" ::: "memory");
60}
61
62#endif
Note: See TracBrowser for help on using the repository browser.