cpu_esp8266.h 2.3 KB

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