2014-12-22 12:35:05 +01:00
|
|
|
#ifndef __CPU_ESP8266_H__
|
|
|
|
#define __CPU_ESP8266_H__
|
|
|
|
|
2016-07-22 23:18:47 +02:00
|
|
|
#ifndef NO_CPU_ESP8266_INCLUDE
|
2014-12-22 12:35:05 +01:00
|
|
|
#include "os_type.h"
|
|
|
|
#include "spi_flash.h"
|
|
|
|
#include "pin_map.h"
|
|
|
|
#include "user_config.h"
|
2014-12-30 19:47:44 +01:00
|
|
|
#include "flash_api.h"
|
2016-07-22 23:18:47 +02:00
|
|
|
#endif
|
2014-12-22 12:35:05 +01:00
|
|
|
// Number of resources (0 if not available/not implemented)
|
|
|
|
#define NUM_GPIO GPIO_PIN_NUM
|
2015-01-16 21:41:34 +01:00
|
|
|
#define NUM_SPI 2
|
2017-04-24 22:06:54 +02:00
|
|
|
#define NUM_UART 2
|
2014-12-22 12:35:05 +01:00
|
|
|
#define NUM_PWM GPIO_PIN_NUM
|
|
|
|
#define NUM_ADC 1
|
|
|
|
#define NUM_CAN 0
|
|
|
|
#define NUM_I2C 1
|
|
|
|
#define NUM_OW GPIO_PIN_NUM
|
|
|
|
#define NUM_TMR 7
|
|
|
|
|
|
|
|
#if defined(FLASH_512K)
|
|
|
|
#define FLASH_SEC_NUM 0x80 // 4MByte: 0x400, 2MByte: 0x200, 1MByte: 0x100, 512KByte: 0x80
|
|
|
|
#elif defined(FLASH_1M)
|
|
|
|
#define FLASH_SEC_NUM 0x100
|
|
|
|
#elif defined(FLASH_2M)
|
|
|
|
#define FLASH_SEC_NUM 0x200
|
|
|
|
#elif defined(FLASH_4M)
|
|
|
|
#define FLASH_SEC_NUM 0x400
|
2015-02-11 14:01:57 +01:00
|
|
|
#elif defined(FLASH_8M)
|
|
|
|
#define FLASH_SEC_NUM 0x800
|
|
|
|
#elif defined(FLASH_16M)
|
|
|
|
#define FLASH_SEC_NUM 0x1000
|
2014-12-30 19:47:44 +01:00
|
|
|
#elif defined(FLASH_AUTOSIZE)
|
2015-03-15 17:51:47 +01:00
|
|
|
#if defined(FLASH_SAFE_API)
|
|
|
|
#define FLASH_SEC_NUM (flash_safe_get_sec_num())
|
|
|
|
#else
|
2015-03-15 17:48:28 +01:00
|
|
|
#define FLASH_SEC_NUM (flash_rom_get_sec_num())
|
2015-03-15 17:51:47 +01:00
|
|
|
#endif // defined(FLASH_SAFE_API)
|
2014-12-22 12:35:05 +01:00
|
|
|
#else
|
|
|
|
#define FLASH_SEC_NUM 0x80
|
|
|
|
#endif
|
2016-07-22 23:18:47 +02:00
|
|
|
// SDK 1.5.4.1 added 1 sector for rf_cal
|
|
|
|
#define SYS_PARAM_SEC_NUM 5
|
2014-12-22 12:35:05 +01:00
|
|
|
#define SYS_PARAM_SEC_START (FLASH_SEC_NUM - SYS_PARAM_SEC_NUM)
|
|
|
|
|
|
|
|
#define INTERNAL_FLASH_SECTOR_SIZE SPI_FLASH_SEC_SIZE
|
|
|
|
// #define INTERNAL_FLASH_SECTOR_ARRAY { 0x4000, 0x4000, 0x4000, 0x4000, 0x10000, 0x20000, 0x20000, 0x20000, 0x20000, 0x20000 }
|
|
|
|
#define INTERNAL_FLASH_WRITE_UNIT_SIZE 4
|
|
|
|
#define INTERNAL_FLASH_READ_UNIT_SIZE 4
|
|
|
|
|
|
|
|
#define INTERNAL_FLASH_SIZE ( (SYS_PARAM_SEC_START) * INTERNAL_FLASH_SECTOR_SIZE )
|
2015-12-03 02:03:22 +01:00
|
|
|
#define INTERNAL_FLASH_MAPPED_ADDRESS 0x40200000
|
2014-12-22 12:35:05 +01:00
|
|
|
|
|
|
|
// SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
|
|
|
|
// SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
|
|
|
|
// SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
|
2015-03-15 17:51:47 +01:00
|
|
|
#if defined(FLASH_SAFE_API)
|
2015-03-15 17:48:28 +01:00
|
|
|
#define flash_write flash_safe_write
|
|
|
|
#define flash_erase flash_safe_erase_sector
|
|
|
|
#define flash_read flash_safe_read
|
2015-03-15 17:51:47 +01:00
|
|
|
#else
|
|
|
|
#define flash_write spi_flash_write
|
|
|
|
#define flash_erase spi_flash_erase_sector
|
|
|
|
#define flash_read spi_flash_read
|
|
|
|
#endif // defined(FLASH_SAFE_API)
|
2014-12-22 12:35:05 +01:00
|
|
|
|
2015-12-08 00:25:05 +01:00
|
|
|
#define CACHE_FLASH_CTRL_REG 0x3ff0000c
|
|
|
|
#define CACHE_FLASH_ACTIVE 0x00000100
|
|
|
|
#define CACHE_FLASH_MAPPED0 0x02000000
|
|
|
|
#define CACHE_FLASH_MAPPED1 0x00010000
|
|
|
|
|
2014-12-22 12:35:05 +01:00
|
|
|
#endif // #ifndef __CPU_ESP8266_H__
|