cpu_esp8266.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef __CPU_ESP8266_H__
  2. #define __CPU_ESP8266_H__
  3. #ifndef NO_CPU_ESP8266_INCLUDE
  4. #include "os_type.h"
  5. #include "spi_flash.h"
  6. #include "pin_map.h"
  7. #include "user_config.h"
  8. #include "flash_api.h"
  9. #endif
  10. // Number of resources (0 if not available/not implemented)
  11. #define NUM_GPIO GPIO_PIN_NUM
  12. #define NUM_SPI 2
  13. #define NUM_UART 1
  14. #define NUM_PWM GPIO_PIN_NUM
  15. #define NUM_ADC 1
  16. #define NUM_CAN 0
  17. #define NUM_I2C 1
  18. #define NUM_OW GPIO_PIN_NUM
  19. #define NUM_TMR 7
  20. #if defined(FLASH_512K)
  21. #define FLASH_SEC_NUM 0x80 // 4MByte: 0x400, 2MByte: 0x200, 1MByte: 0x100, 512KByte: 0x80
  22. #elif defined(FLASH_1M)
  23. #define FLASH_SEC_NUM 0x100
  24. #elif defined(FLASH_2M)
  25. #define FLASH_SEC_NUM 0x200
  26. #elif defined(FLASH_4M)
  27. #define FLASH_SEC_NUM 0x400
  28. #elif defined(FLASH_8M)
  29. #define FLASH_SEC_NUM 0x800
  30. #elif defined(FLASH_16M)
  31. #define FLASH_SEC_NUM 0x1000
  32. #elif defined(FLASH_AUTOSIZE)
  33. #if defined(FLASH_SAFE_API)
  34. #define FLASH_SEC_NUM (flash_safe_get_sec_num())
  35. #else
  36. #define FLASH_SEC_NUM (flash_rom_get_sec_num())
  37. #endif // defined(FLASH_SAFE_API)
  38. #else
  39. #define FLASH_SEC_NUM 0x80
  40. #endif
  41. // SDK 1.5.4.1 added 1 sector for rf_cal
  42. #define SYS_PARAM_SEC_NUM 5
  43. #define SYS_PARAM_SEC_START (FLASH_SEC_NUM - SYS_PARAM_SEC_NUM)
  44. #define INTERNAL_FLASH_SECTOR_SIZE SPI_FLASH_SEC_SIZE
  45. // #define INTERNAL_FLASH_SECTOR_ARRAY { 0x4000, 0x4000, 0x4000, 0x4000, 0x10000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000 }
  46. #define INTERNAL_FLASH_WRITE_UNIT_SIZE 4
  47. #define INTERNAL_FLASH_READ_UNIT_SIZE 4
  48. #define INTERNAL_FLASH_SIZE ( (SYS_PARAM_SEC_START) * INTERNAL_FLASH_SECTOR_SIZE )
  49. #define INTERNAL_FLASH_MAPPED_ADDRESS 0x40200000
  50. // SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
  51. // SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
  52. // SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
  53. #if defined(FLASH_SAFE_API)
  54. #define flash_write flash_safe_write
  55. #define flash_erase flash_safe_erase_sector
  56. #define flash_read flash_safe_read
  57. #else
  58. #define flash_write spi_flash_write
  59. #define flash_erase spi_flash_erase_sector
  60. #define flash_read spi_flash_read
  61. #endif // defined(FLASH_SAFE_API)
  62. #define CACHE_FLASH_CTRL_REG 0x3ff0000c
  63. #define CACHE_FLASH_ACTIVE 0x00000100
  64. #define CACHE_FLASH_MAPPED0 0x02000000
  65. #define CACHE_FLASH_MAPPED1 0x00010000
  66. #endif // #ifndef __CPU_ESP8266_H__