|
25 | 25 |
|
26 | 26 | #define ESP8266_REG(addr) *((volatile uint32_t *)(0x60000000+(addr)))
|
27 | 27 | #define ESP8266_DREG(addr) *((volatile uint32_t *)(0x3FF00000+(addr)))
|
| 28 | +#define ESP8266_CLOCK 80000000UL |
| 29 | + |
| 30 | +//CPU Register |
| 31 | +#define CPU2X ESP8266_DREG(0x14) //when bit 0 is set, F_CPU = 160MHz |
| 32 | + |
| 33 | +//OTP Registers |
| 34 | +#define MAC0 ESP8266_DREG(0x50) |
| 35 | +#define MAC1 ESP8266_DREG(0x54) |
| 36 | +#define CHIPID ESP8266_DREG(0x58) |
28 | 37 |
|
29 | 38 | //GPIO (0-15) Control Registers
|
30 | 39 | #define GPO ESP8266_REG(0x300) //GPIO_OUT R/W (Output Level)
|
@@ -148,10 +157,27 @@ extern uint8_t esp8266_gpioToFn[16];
|
148 | 157 | #define TCPD 2 //Prescale Devider (2bit) 0:1(12.5ns/tick), 1:16(0.2us/tick), 2/3:256(3.2us/tick)
|
149 | 158 | #define TCIT 0 //Interrupt Type 0:edge, 1:level
|
150 | 159 |
|
151 |
| - |
152 |
| -//UART SWAP Register |
153 |
| -#define USWAP ESP8266_DREG(0x28) |
154 |
| -#define USWAP0 2 //BIT 2 swaps UART 0 |
| 160 | +//RTC Registers |
| 161 | +#define RTCSV ESP8266_REG(0x704) //RTC SLEEP COUNTER Target Value |
| 162 | +#define RTCCV ESP8266_REG(0x71C) //RTC SLEEP COUNTER Value |
| 163 | +#define RTCIS ESP8266_REG(0x720) //RTC INT Status |
| 164 | +#define RTCIC ESP8266_REG(0x724) //RTC INT Clear |
| 165 | +#define RTCIE ESP8266_REG(0x728) //RTC INT Enable |
| 166 | + |
| 167 | +//IO SWAP Register |
| 168 | +#define IOSWAP ESP8266_DREG(0x28) |
| 169 | +#define IOSWAPU 0 //Swaps UART |
| 170 | +#define IOSWAPS 1 //Swaps SPI |
| 171 | +#define IOSWAPU0 2 //Swaps UART 0 pins (u0rxd <-> u0cts), (u0txd <-> u0rts) |
| 172 | +#define IOSWAPU1 3 //Swaps UART 1 pins (u1rxd <-> u1cts), (u1txd <-> u1rts) |
| 173 | +#define IOSWAPHS 5 //Sets HSPI with higher prio |
| 174 | +#define IOSWAP2HS 6 //Sets Two SPI Masters on HSPI |
| 175 | +#define IOSWAP2CS 7 //Sets Two SPI Masters on CSPI |
| 176 | + |
| 177 | +//UART INT Status |
| 178 | +#define UIS ESP8266_DREG(0x20020) |
| 179 | +#define UIS0 0 |
| 180 | +#define UIS1 2 |
155 | 181 |
|
156 | 182 | //UART 0 Registers
|
157 | 183 | #define U0F ESP8266_REG(0x000) //UART FIFO
|
@@ -216,45 +242,49 @@ extern uint8_t esp8266_gpioToFn[16];
|
216 | 242 | #define UIFF 0 //RX FIFO Full
|
217 | 243 |
|
218 | 244 | //UART STATUS Registers Bits
|
219 |
| -#define USTX 31 //TX PIN Level |
220 |
| -#define USRTS 30 //RTS PIN Level |
221 |
| -#define USDTR 39 //DTR PIN Level |
| 245 | +#define USTX 31 //TX PIN Level |
| 246 | +#define USRTS 30 //RTS PIN Level |
| 247 | +#define USDTR 39 //DTR PIN Level |
222 | 248 | #define USTXC 16 //TX FIFO COUNT (8bit)
|
223 | 249 | #define USRXD 15 //RX PIN Level
|
224 | 250 | #define USCTS 14 //CTS PIN Level
|
225 | 251 | #define USDSR 13 //DSR PIN Level
|
226 | 252 | #define USRXC 0 //RX FIFO COUNT (8bit)
|
227 | 253 |
|
228 | 254 | //UART CONF0 Registers Bits
|
229 |
| -#define UCDTRI 24 //Invert DTR |
230 |
| -#define UCRTSI 23 //Invert RTS |
231 |
| -#define UCTXI 22 //Invert TX |
232 |
| -#define UCDSRI 21 //Invert DSR |
233 |
| -#define UCCTSI 20 //Invert CTS |
234 |
| -#define UCRXI 19 //Invert RX |
| 255 | +#define UCDTRI 24 //Invert DTR |
| 256 | +#define UCRTSI 23 //Invert RTS |
| 257 | +#define UCTXI 22 //Invert TX |
| 258 | +#define UCDSRI 21 //Invert DSR |
| 259 | +#define UCCTSI 20 //Invert CTS |
| 260 | +#define UCRXI 19 //Invert RX |
235 | 261 | #define UCTXRST 18 //Reset TX FIFO
|
236 | 262 | #define UCRXRST 17 //Reset RX FIFO
|
237 | 263 | #define UCTXHFE 15 //TX Harware Flow Enable
|
238 |
| -#define UCLBE 14 //LoopBack Enable |
239 |
| -#define UCBRK 8 //Send Break on the TX line |
| 264 | +#define UCLBE 14 //LoopBack Enable |
| 265 | +#define UCBRK 8 //Send Break on the TX line |
240 | 266 | #define UCSWDTR 7 //Set this bit to assert DTR
|
241 | 267 | #define UCSWRTS 6 //Set this bit to assert RTS
|
242 |
| -#define UCSBN 4 //StopBits Count (2bit) 0:disable, 1:1bit, 2:1.5bit, 3:2bit |
243 |
| -#define UCBN 2 //DataBits Count (2bin) 0:5bit, 1:6bit, 2:7bit, 3:8bit |
244 |
| -#define UCPAE 1 //Parity Enable |
245 |
| -#define UCPA 0 //Parity 0:even, 1:odd |
| 268 | +#define UCSBN 4 //StopBits Count (2bit) 0:disable, 1:1bit, 2:1.5bit, 3:2bit |
| 269 | +#define UCBN 2 //DataBits Count (2bin) 0:5bit, 1:6bit, 2:7bit, 3:8bit |
| 270 | +#define UCPAE 1 //Parity Enable |
| 271 | +#define UCPA 0 //Parity 0:even, 1:odd |
246 | 272 |
|
247 | 273 | //UART CONF1 Registers Bits
|
248 |
| -#define UCTOE 31 //RX TimeOut Enable |
249 |
| -#define UCTOT 24 //RX TimeOut Treshold (7bit) |
| 274 | +#define UCTOE 31 //RX TimeOut Enable |
| 275 | +#define UCTOT 24 //RX TimeOut Treshold (7bit) |
250 | 276 | #define UCRXHFE 23 //RX Harware Flow Enable
|
251 | 277 | #define UCRXHFT 16 //RX Harware Flow Treshold (7bit)
|
252 |
| -#define UCFET 8 //TX FIFO Empty Treshold (7bit) |
253 |
| -#define UCFFT 0 //RX FIFO Full Treshold (7bit) |
| 278 | +#define UCFET 8 //TX FIFO Empty Treshold (7bit) |
| 279 | +#define UCFFT 0 //RX FIFO Full Treshold (7bit) |
| 280 | + |
| 281 | +//WDT Feed (the dog) Register |
| 282 | +#define WDTFEED ESP8266_REG(0x914) |
| 283 | +#define WDT_FEED() (WDTFEED = 0x73) |
254 | 284 |
|
255 |
| -//WDT Register used for UART |
256 |
| -#define WDTRST ESP8266_REG(0x914) |
257 |
| -#define WDT_RESET() (WDTRST = 0x73) |
| 285 | +//SPI_READY |
| 286 | +#define SPIRDY ESP8266_DREG(0x0C) |
| 287 | +#define SPIBUSY 9 //wait SPI idle |
258 | 288 |
|
259 | 289 | //SPI0 Registers (SPI0 is used for the flash)
|
260 | 290 | #define SPI0CMD ESP8266_REG(0x200)
|
|
0 commit comments