fw_reg_base.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. // Copyright 2021 IOsetting <iosetting(at)outlook.com>
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef __FW_REG_BASE_H__
  15. #define __FW_REG_BASE_H__
  16. #if defined (__SDCC_SYNTAX_FIX)
  17. #include <stdbool.h>
  18. #include <lint.h>
  19. # warning unrecognized compiler
  20. #define __BIT bool
  21. #define __DATA
  22. #define __IDATA
  23. #define __PDATA
  24. #define __XDATA
  25. #define __CODE
  26. #define __REENTRANT
  27. #define SBIT(name, addr, bit) volatile bool name
  28. #define SFR(name, addr) volatile unsigned char name
  29. #define SFRX(addr) (*(unsigned char volatile *)(addr))
  30. #define SFR16X(addr) (*(unsigned char volatile *)(addr))
  31. #define INTERRUPT(name, vector) void name (void)
  32. #define INTERRUPT_USING(name, vector, regnum) void name (void)
  33. #define NOP()
  34. #elif defined (SDCC) || defined (__SDCC)
  35. #define __BIT __bit
  36. #define __DATA __data
  37. #define __IDATA __idata
  38. #define __PDATA __pdata
  39. #define __XDATA __xdata
  40. #define __CODE __code
  41. #define __REENTRANT __reentrant
  42. #define SBIT(name, addr, bit) __sbit __at(addr+bit) name
  43. #define SFR(name, addr) __sfr __at(addr) name
  44. #define SFRX(addr) (*(unsigned char volatile __xdata *)(addr))
  45. #define SFR16X(addr) (*(unsigned int volatile __xdata *)(addr))
  46. #define INTERRUPT(name, vector) void name (void) __interrupt (vector)
  47. #define INTERRUPT_USING(name, vector, regnum) void name (void) __interrupt (vector) __using (regnum)
  48. #define NOP() __asm NOP __endasm
  49. #elif defined __CX51__ || defined __C51__
  50. #define __BIT bit
  51. #define __DATA data
  52. #define __IDATA idata
  53. #define __PDATA pdata
  54. #define __XDATA xdata
  55. #define __CODE code
  56. #define __REENTRANT reentrant
  57. #define SBIT(name, addr, bit) sbit name = addr^bit
  58. #define SFR(name, addr) sfr name = addr
  59. #define SFRX(addr) (*(unsigned char volatile xdata *)(addr))
  60. #define SFR16X(addr) (*(unsigned int volatile xdata *)(addr))
  61. #define INTERRUPT(name, vector) void name (void) interrupt vector
  62. #define INTERRUPT_USING(name, vector, regnum) void name (void) interrupt vector using regnum
  63. extern void _nop_ (void);
  64. #define NOP() _nop_()
  65. #endif
  66. #define _P0 0x80
  67. SFR(P0, _P0);
  68. SBIT(P00, _P0, 0);
  69. SBIT(P01, _P0, 1);
  70. SBIT(P02, _P0, 2);
  71. SBIT(P03, _P0, 3);
  72. SBIT(P04, _P0, 4);
  73. SBIT(P05, _P0, 5);
  74. SBIT(P06, _P0, 6);
  75. SBIT(P07, _P0, 7);
  76. SFR(SP, 0x81);
  77. SFR(DPL, 0x82);
  78. SFR(DPH, 0x83);
  79. SFR(S4CON, 0x84);
  80. SFR(S4BUF, 0x85);
  81. SFR(PCON, 0x87);
  82. #define _TCON 0x88
  83. SFR(TCON, _TCON);
  84. SBIT(TF1, _TCON, 7);
  85. SBIT(TR1, _TCON, 6);
  86. SBIT(TF0, _TCON, 5);
  87. SBIT(TR0, _TCON, 4);
  88. SBIT(IE1, _TCON, 3);
  89. SBIT(IT1, _TCON, 2);
  90. SBIT(IE0, _TCON, 1);
  91. SBIT(IT0, _TCON, 0);
  92. SFR(TMOD, 0x89);
  93. SFR(TL0, 0x8A);
  94. SFR(TL1, 0x8B);
  95. SFR(TH0, 0x8C);
  96. SFR(TH1, 0x8D);
  97. SFR(AUXR, 0x8E);
  98. SFR(INTCLKO, 0x8F);
  99. #define _P1 0x90
  100. SFR(P1, _P1);
  101. SBIT(P10, _P1, 0);
  102. SBIT(P11, _P1, 1);
  103. SBIT(P12, _P1, 2);
  104. SBIT(P13, _P1, 3);
  105. SBIT(P14, _P1, 4);
  106. SBIT(P15, _P1, 5);
  107. SBIT(P16, _P1, 6);
  108. SBIT(P17, _P1, 7);
  109. SFR(P1M1, 0x91);
  110. SFR(P1M0, 0x92);
  111. SFR(P0M1, 0x93);
  112. SFR(P0M0, 0x94);
  113. SFR(P2M1, 0x95);
  114. SFR(P2M0, 0x96);
  115. #define _SCON 0x98
  116. SFR(SCON, _SCON);
  117. SBIT(SM0, _SCON, 7);
  118. SBIT(SM1, _SCON, 6);
  119. SBIT(SM2, _SCON, 5);
  120. SBIT(REN, _SCON, 4);
  121. SBIT(TB8, _SCON, 3);
  122. SBIT(RB8, _SCON, 2);
  123. SBIT(TI, _SCON, 1);
  124. SBIT(RI, _SCON, 0);
  125. SFR(SBUF, 0x99);
  126. SFR(S2CON, 0x9A);
  127. SFR(S2BUF, 0x9B);
  128. SFR(IRCBAND, 0x9D);
  129. SFR(LIRTRIM, 0x9E);
  130. SFR(IRTRIM, 0x9F);
  131. #define _P2 0xA0
  132. SFR(P2, _P2);
  133. SBIT(P20, _P2, 0);
  134. SBIT(P21, _P2, 1);
  135. SBIT(P22, _P2, 2);
  136. SBIT(P23, _P2, 3);
  137. SBIT(P24, _P2, 4);
  138. SBIT(P25, _P2, 5);
  139. SBIT(P26, _P2, 6);
  140. SBIT(P27, _P2, 7);
  141. SFR(BUS_SPEED, 0xA1);
  142. SFR(P_SW1, 0xA2);
  143. #define _IE 0xA8
  144. SFR(IE, _IE);
  145. SBIT(EA, _IE, 7);
  146. SBIT(ELVD, _IE, 6);
  147. SBIT(EADC, _IE, 5);
  148. SBIT(ES, _IE, 4);
  149. SBIT(ET1, _IE, 3);
  150. SBIT(EX1, _IE, 2);
  151. SBIT(ET0, _IE, 1);
  152. SBIT(EX0, _IE, 0);
  153. SFR(SADDR, 0xA9);
  154. SFR(WKTCL, 0xAA);
  155. SFR(WKTCH, 0xAB);
  156. SFR(S3CON, 0xAC);
  157. SFR(S3BUF, 0xAD);
  158. SFR(TA, 0xAE);
  159. SFR(IE2, 0xAF);
  160. #define _P3 0xB0
  161. SFR(P3, _P3);
  162. SBIT(P30, _P3, 0);
  163. SBIT(P31, _P3, 1);
  164. SBIT(P32, _P3, 2);
  165. SBIT(P33, _P3, 3);
  166. SBIT(P34, _P3, 4);
  167. SBIT(P35, _P3, 5);
  168. SBIT(P36, _P3, 6);
  169. SBIT(P37, _P3, 7);
  170. SFR(P3M1, 0xB1);
  171. SFR(P3M0, 0xB2);
  172. SFR(P4M1, 0xB3);
  173. SFR(P4M0, 0xB4);
  174. SFR(IP2, 0xB5);
  175. SFR(IP2H, 0xB6);
  176. SFR(IPH, 0xB7);
  177. #define _IP 0xB8
  178. SFR(IP, _IP);
  179. SBIT(PPCA, _IP, 7);
  180. SBIT(PLVD, _IP, 6);
  181. SBIT(PADC, _IP, 5);
  182. SBIT(PS, _IP, 4);
  183. SBIT(PT1, _IP, 3);
  184. SBIT(PX1, _IP, 2);
  185. SBIT(PT0, _IP, 1);
  186. SBIT(PX0, _IP, 0);
  187. SFR(SADEN, 0xB9);
  188. SFR(P_SW2, 0xBA);
  189. SFR(ADC_CONTR, 0xBC);
  190. SFR(ADC_RES, 0xBD);
  191. SFR(ADC_RESL, 0xBE);
  192. #define _P4 0xC0
  193. SFR(P4, _P4);
  194. SBIT(P40, _P4, 0);
  195. SBIT(P41, _P4, 1);
  196. SBIT(P42, _P4, 2);
  197. SBIT(P43, _P4, 3);
  198. SBIT(P44, _P4, 4);
  199. SBIT(P45, _P4, 5);
  200. SBIT(P46, _P4, 6);
  201. SBIT(P47, _P4, 7);
  202. SFR(WDT_CONTR, 0xC1);
  203. SFR(IAP_DATA, 0xC2);
  204. SFR(IAP_ADDRH, 0xC3);
  205. SFR(IAP_ADDRL, 0xC4);
  206. SFR(IAP_CMD, 0xC5);
  207. SFR(IAP_TRIG, 0xC6);
  208. SFR(IAP_CONTR, 0xC7);
  209. #define _P5 0xC8
  210. SFR(P5, _P5);
  211. SBIT(P50, _P5, 0);
  212. SBIT(P51, _P5, 1);
  213. SBIT(P52, _P5, 2);
  214. SBIT(P53, _P5, 3);
  215. SBIT(P54, _P5, 4);
  216. SBIT(P55, _P5, 5);
  217. SBIT(P56, _P5, 6);
  218. SBIT(P57, _P5, 7);
  219. SFR(P5M1, 0xC9);
  220. SFR(P5M0, 0xCA);
  221. SFR(P6M1, 0xCB);
  222. SFR(P6M0, 0xCC);
  223. SFR(SPSTAT, 0xCD);
  224. SFR(SPCTL, 0xCE);
  225. SFR(SPDAT, 0xCF);
  226. #define _PSW 0xD0
  227. SFR(PSW, _PSW);
  228. SBIT(CY, _PSW, 7);
  229. SBIT(AC, _PSW, 6);
  230. SBIT(F0, _PSW, 5);
  231. SBIT(RS1, _PSW, 4);
  232. SBIT(RS0, _PSW, 3);
  233. SBIT(OV, _PSW, 2);
  234. SBIT(F1, _PSW, 1);
  235. SBIT(P, _PSW, 0);
  236. SFR(T4T3M, 0xD1);
  237. SFR(T4H, 0xD2);
  238. SFR(T4L, 0xD3);
  239. SFR(T3H, 0xD4);
  240. SFR(T3L, 0xD5);
  241. SFR(T2H, 0xD6);
  242. SFR(T2L, 0xD7);
  243. SFR(ACC, 0xE0);
  244. #define _P6 0xE8
  245. SFR(P6, _P6);
  246. SBIT(P60, _P6, 0);
  247. SBIT(P61, _P6, 1);
  248. SBIT(P62, _P6, 2);
  249. SBIT(P63, _P6, 3);
  250. SBIT(P64, _P6, 4);
  251. SBIT(P65, _P6, 5);
  252. SBIT(P66, _P6, 6);
  253. SBIT(P67, _P6, 7);
  254. SFR(B, 0xF0);
  255. #define _P7 0xF8
  256. SFR(P7, _P7);
  257. SBIT(P70, _P7, 0);
  258. SBIT(P71, _P7, 1);
  259. SBIT(P72, _P7, 2);
  260. SBIT(P73, _P7, 3);
  261. SBIT(P74, _P7, 4);
  262. SBIT(P75, _P7, 5);
  263. SBIT(P76, _P7, 6);
  264. SBIT(P77, _P7, 7);
  265. #endif