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
|
2019-07-23 06:22:38 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
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
|
I2C sw driver with support of multiple buses, Slow, Fast, FastPlus, and user-defined speed selection (#2465)
* I2C driver speed-up, i2c.SLOW, i2c.FAST and user-defined speed selection
* - Multiple buses (up to 10) with different speeds on each bus
- Standard(Slow, 100kHz), Fast(400kHz) and FastPlus(1MHz) modes or an
arbitrary clock speed
- Sharing SDA line over multiple I²C buses to save available pins
- GPIO16 pin can be used as SCL pin, but it does not support clock
stretching and selected bus will be limited to FAST speed.
* Dynamic memory allocation, error checks, simplification, timing tweaks.
* Separated the code of old driver for better compatibility and simplicity
* Change of driver interface
* Add bus status check in setup(); simplify getDC(); remove unnesessary lines in ACK read/write
* Fix for moved doc file and trailing whitespaces
2019-04-05 06:56:11 +02:00
|
|
|
|
|
|
|
#ifndef I2C_MASTER_OLD_VERSION
|
|
|
|
#define NUM_I2C 10
|
|
|
|
#else
|
2014-12-22 12:35:05 +01:00
|
|
|
#define NUM_I2C 1
|
I2C sw driver with support of multiple buses, Slow, Fast, FastPlus, and user-defined speed selection (#2465)
* I2C driver speed-up, i2c.SLOW, i2c.FAST and user-defined speed selection
* - Multiple buses (up to 10) with different speeds on each bus
- Standard(Slow, 100kHz), Fast(400kHz) and FastPlus(1MHz) modes or an
arbitrary clock speed
- Sharing SDA line over multiple I²C buses to save available pins
- GPIO16 pin can be used as SCL pin, but it does not support clock
stretching and selected bus will be limited to FAST speed.
* Dynamic memory allocation, error checks, simplification, timing tweaks.
* Separated the code of old driver for better compatibility and simplicity
* Change of driver interface
* Add bus status check in setup(); simplify getDC(); remove unnesessary lines in ACK read/write
* Fix for moved doc file and trailing whitespaces
2019-04-05 06:56:11 +02:00
|
|
|
#endif //I2C_MASTER_OLD_VERSION
|
|
|
|
|
2014-12-22 12:35:05 +01:00
|
|
|
#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:48:28 +01:00
|
|
|
#define FLASH_SEC_NUM (flash_rom_get_sec_num())
|
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
|
|
|
#define flash_write spi_flash_write
|
|
|
|
#define flash_erase spi_flash_erase_sector
|
|
|
|
#define flash_read spi_flash_read
|
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__
|