cpu_esp8266.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 2
  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. #define FLASH_SEC_NUM (flash_rom_get_sec_num())
  34. #else
  35. #define FLASH_SEC_NUM 0x80
  36. #endif
  37. // SDK 1.5.4.1 added 1 sector for rf_cal
  38. #define SYS_PARAM_SEC_NUM 5
  39. #define SYS_PARAM_SEC_START (FLASH_SEC_NUM - SYS_PARAM_SEC_NUM)
  40. #define INTERNAL_FLASH_SECTOR_SIZE SPI_FLASH_SEC_SIZE
  41. // #define INTERNAL_FLASH_SECTOR_ARRAY { 0x4000, 0x4000, 0x4000, 0x4000, 0x10000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000 }
  42. #define INTERNAL_FLASH_WRITE_UNIT_SIZE 4
  43. #define INTERNAL_FLASH_READ_UNIT_SIZE 4
  44. #define INTERNAL_FLASH_SIZE ( (SYS_PARAM_SEC_START) * INTERNAL_FLASH_SECTOR_SIZE )
  45. #define INTERNAL_FLASH_MAPPED_ADDRESS 0x40200000
  46. // SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
  47. // SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
  48. // SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
  49. #define flash_write spi_flash_write
  50. #define flash_erase spi_flash_erase_sector
  51. #define flash_read spi_flash_read
  52. #define CACHE_FLASH_CTRL_REG 0x3ff0000c
  53. #define CACHE_FLASH_ACTIVE 0x00000100
  54. #define CACHE_FLASH_MAPPED0 0x02000000
  55. #define CACHE_FLASH_MAPPED1 0x00010000
  56. #endif // #ifndef __CPU_ESP8266_H__