]> rtime.felk.cvut.cz Git - arc.git/blob - include/io.h
Added lots of debug to Nvm
[arc.git] / include / io.h
1 /* -------------------------------- Arctic Core ------------------------------
2  * Copyright (C) 2009-2011 ArcCore AB <contact@arccore.com>
3  * Licensed under ArcCore Embedded Software License Agreement.
4  * -------------------------------- Arctic Core ------------------------------*/
5
6 #ifndef IO_H_
7 #define IO_H_
8
9 #define WRITE8(address, value)      (*(uint8_t*)(address) = (value))
10 #define READ8(address)              ((uint8_t)(*(uint8_t*)(address)))
11
12 #define WRITE16(address, value)     (*(vuint16_t*)(address) = (value))
13 #define READ16(address)             ((uint16_t)(*(vuint16_t*)(address)))
14
15 #define WRITE32(address, value)     (*(vuint32_t*)(address) = (value))
16 #define READ32(address)             ((uint32_t)(*(vuint32_t*)(address)))
17
18 #define WRITE64(address, value)     (*(vuint64_t*)(address) = (value))
19 #define READ64(address)             ((uint64_t)(*(vuint64_t*)(address)))
20
21 /* Not aligned reads */
22 #define READ32_NA(address )                     ( (((uint32_t)(((uint8_t *)address)[0]))<<24) + \
23                                                                           (((uint32_t)(((uint8_t *)address)[1]))<<16) + \
24                                                                           (((uint32_t)(((uint8_t *)address)[2]))<<8) +  \
25                                                                           ((uint32_t)(((uint8_t *)address)[3])) )
26
27 #define READ16_NA(address )                     ( (((uint32_t)(((uint8_t *)address)[0]))<<8) +  \
28                                                                           (((uint32_t)(((uint8_t *)address)[1]))) )
29
30 #define WRITE32_NA(address, value ) \
31         do { \
32         ((uint8_t *)address)[0] = ((value&0xff)<<24); \
33         ((uint8_t *)address)[1] = ((value&0xff)<<16); \
34         ((uint8_t *)address)[2] = ((value&0xff)<<8);  \
35         ((uint8_t *)address)[3] = ((value&0xff)); \
36         } while(0)
37
38 #define WRITE16_NA(address, value ) \
39         do { \
40         ((uint8_t *)address)[0] = ((value&0xff)<<8); \
41         ((uint8_t *)address)[1] = ((value&0xff)); \
42         } while(0)
43
44
45
46 #endif /* IO_H_ */