|
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)
|
@@ -149,20 +158,26 @@ extern uint8_t esp8266_gpioToFn[16];
|
149 | 158 | #define TCIT 0 //Interrupt Type 0:edge, 1:level
|
150 | 159 |
|
151 | 160 | //RTC Registers
|
152 |
| -#define RTCMEM(i) ESP8266_REG(0x1100 + (((i) & 0xFF) * 4)) //RTC RAM 768 bytes, 192 registers |
153 | 161 | #define RTCSV ESP8266_REG(0x704) //RTC SLEEP COUNTER Target Value
|
154 | 162 | #define RTCCV ESP8266_REG(0x71C) //RTC SLEEP COUNTER Value
|
155 | 163 | #define RTCIS ESP8266_REG(0x720) //RTC INT Status
|
156 | 164 | #define RTCIC ESP8266_REG(0x724) //RTC INT Clear
|
157 | 165 | #define RTCIE ESP8266_REG(0x728) //RTC INT Enable
|
158 |
| -#define RTCS0 ESP8266_REG(0x730) //RTC SCRATCH 0 |
159 |
| -#define RTCS1 ESP8266_REG(0x734) //RTC SCRATCH 1 |
160 |
| -#define RTCS2 ESP8266_REG(0x738) //RTC SCRATCH 2 |
161 |
| -#define RTCS3 ESP8266_REG(0x73C) //RTC SCRATCH 3 |
162 | 166 |
|
163 |
| -//UART SWAP Register |
164 |
| -#define USWAP ESP8266_DREG(0x28) |
165 |
| -#define USWAP0 2 //BIT 2 swaps UART 0 |
| 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 |
166 | 181 |
|
167 | 182 | //UART 0 Registers
|
168 | 183 | #define U0F ESP8266_REG(0x000) //UART FIFO
|
@@ -227,45 +242,49 @@ extern uint8_t esp8266_gpioToFn[16];
|
227 | 242 | #define UIFF 0 //RX FIFO Full
|
228 | 243 |
|
229 | 244 | //UART STATUS Registers Bits
|
230 |
| -#define USTX 31 //TX PIN Level |
231 |
| -#define USRTS 30 //RTS PIN Level |
232 |
| -#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 |
233 | 248 | #define USTXC 16 //TX FIFO COUNT (8bit)
|
234 | 249 | #define USRXD 15 //RX PIN Level
|
235 | 250 | #define USCTS 14 //CTS PIN Level
|
236 | 251 | #define USDSR 13 //DSR PIN Level
|
237 | 252 | #define USRXC 0 //RX FIFO COUNT (8bit)
|
238 | 253 |
|
239 | 254 | //UART CONF0 Registers Bits
|
240 |
| -#define UCDTRI 24 //Invert DTR |
241 |
| -#define UCRTSI 23 //Invert RTS |
242 |
| -#define UCTXI 22 //Invert TX |
243 |
| -#define UCDSRI 21 //Invert DSR |
244 |
| -#define UCCTSI 20 //Invert CTS |
245 |
| -#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 |
246 | 261 | #define UCTXRST 18 //Reset TX FIFO
|
247 | 262 | #define UCRXRST 17 //Reset RX FIFO
|
248 | 263 | #define UCTXHFE 15 //TX Harware Flow Enable
|
249 |
| -#define UCLBE 14 //LoopBack Enable |
250 |
| -#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 |
251 | 266 | #define UCSWDTR 7 //Set this bit to assert DTR
|
252 | 267 | #define UCSWRTS 6 //Set this bit to assert RTS
|
253 |
| -#define UCSBN 4 //StopBits Count (2bit) 0:disable, 1:1bit, 2:1.5bit, 3:2bit |
254 |
| -#define UCBN 2 //DataBits Count (2bin) 0:5bit, 1:6bit, 2:7bit, 3:8bit |
255 |
| -#define UCPAE 1 //Parity Enable |
256 |
| -#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 |
257 | 272 |
|
258 | 273 | //UART CONF1 Registers Bits
|
259 |
| -#define UCTOE 31 //RX TimeOut Enable |
260 |
| -#define UCTOT 24 //RX TimeOut Treshold (7bit) |
| 274 | +#define UCTOE 31 //RX TimeOut Enable |
| 275 | +#define UCTOT 24 //RX TimeOut Treshold (7bit) |
261 | 276 | #define UCRXHFE 23 //RX Harware Flow Enable
|
262 | 277 | #define UCRXHFT 16 //RX Harware Flow Treshold (7bit)
|
263 |
| -#define UCFET 8 //TX FIFO Empty Treshold (7bit) |
264 |
| -#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) |
265 | 284 |
|
266 |
| -//WDT Register used for UART |
267 |
| -#define WDTRST ESP8266_REG(0x914) |
268 |
| -#define WDT_RESET() (WDTRST = 0x73) |
| 285 | +//SPI_READY |
| 286 | +#define SPIRDY ESP8266_DREG(0x0C) |
| 287 | +#define SPIBUSY 9 //wait SPI idle |
269 | 288 |
|
270 | 289 | //SPI0 Registers (SPI0 is used for the flash)
|
271 | 290 | #define SPI0CMD ESP8266_REG(0x200)
|
|
0 commit comments