1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

Move .C to .CPP in the code (#5696)

Use g++ to compile core files to get additional C++ checks on the code.

Also move libb64 constants to PROGMEM, saving ~128 bytes of heap when used.
This commit is contained in:
Earle F. Philhower, III 2019-02-07 02:06:17 +00:00 committed by Develo
parent 24fa59df4b
commit f706c83b66
37 changed files with 390 additions and 190 deletions

View File

@ -27,6 +27,9 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "StackThunk.h" #include "StackThunk.h"
#include <ets_sys.h>
extern "C" {
uint32_t *stack_thunk_ptr = NULL; uint32_t *stack_thunk_ptr = NULL;
uint32_t *stack_thunk_top = NULL; uint32_t *stack_thunk_top = NULL;
@ -115,8 +118,10 @@ void stack_thunk_dump_stack()
} }
ets_printf(">>>stack>>>\n"); ets_printf(">>>stack>>>\n");
while (pos < stack_thunk_ptr) { while (pos < stack_thunk_ptr) {
ets_printf("%08x: %08x %08x %08x %08x\n", pos, pos[0], pos[1], pos[2], pos[3]); ets_printf("%08x: %08x %08x %08x %08x\n", (int32_t)pos, pos[0], pos[1], pos[2], pos[3]);
pos += 4; pos += 4;
} }
ets_printf("<<<stack<<<\n"); ets_printf("<<<stack<<<\n");
} }
};

View File

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include "ets_sys.h" #include "ets_sys.h"
extern "C" {
#define CONT_STACKGUARD 0xfeefeffe #define CONT_STACKGUARD 0xfeefeffe
@ -80,3 +81,5 @@ void cont_repaint_stack(cont_t *cont)
cont->stack[pos] = CONT_STACKGUARD; cont->stack[pos] = CONT_STACKGUARD;
} }
} }
};

View File

@ -23,7 +23,9 @@
#include <stdbool.h> #include <stdbool.h>
#include "eboot_command.h" #include "eboot_command.h"
uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length) extern "C" {
static uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
{ {
uint32_t i; uint32_t i;
bool bit; bool bit;
@ -45,7 +47,7 @@ uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
return crc; return crc;
} }
uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd) static uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
{ {
return crc_update(0xffffffff, (const uint8_t*) cmd, return crc_update(0xffffffff, (const uint8_t*) cmd,
offsetof(struct eboot_command, crc32)); offsetof(struct eboot_command, crc32));
@ -86,3 +88,4 @@ void eboot_command_clear()
RTC_MEM[offsetof(struct eboot_command, crc32) / sizeof(uint32_t)] = 0; RTC_MEM[offsetof(struct eboot_command, crc32) / sizeof(uint32_t)] = 0;
} }
};

View File

@ -25,6 +25,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "flash_utils.h" #include "flash_utils.h"
extern "C" {
int SPIEraseAreaEx(const uint32_t start, const uint32_t size) int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
{ {
@ -62,3 +63,4 @@ int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
return 0; return 0;
} }
};

View File

@ -23,11 +23,11 @@
#include "Arduino.h" #include "Arduino.h"
#include "osapi.h" #include "osapi.h"
#include "ets_sys.h" #include "ets_sys.h"
#include "i2s_reg.h" #include "i2s_reg.h"
#include "i2s.h" #include "i2s.h"
extern "C" {
#define SLC_BUF_CNT (8) // Number of buffers in the I2S circular buffer #define SLC_BUF_CNT (8) // Number of buffers in the I2S circular buffer
#define SLC_BUF_LEN (64) // Length of one buffer, in 32-bit words. #define SLC_BUF_LEN (64) // Length of one buffer, in 32-bit words.
@ -573,3 +573,5 @@ void i2s_end() {
rx = NULL; rx = NULL;
} }
} }
};

View File

@ -29,6 +29,8 @@
#include <math.h> #include <math.h>
#include "stdlib_noniso.h" #include "stdlib_noniso.h"
extern "C" {
char* ltoa(long value, char* result, int base) { char* ltoa(long value, char* result, int base) {
return itoa((int)value, result, base); return itoa((int)value, result, base);
} }
@ -109,3 +111,5 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
*out = 0; *out = 0;
return s; return s;
} }
};

View File

@ -19,7 +19,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
@ -27,80 +26,83 @@
#include "c_types.h" #include "c_types.h"
#include "ets_sys.h" #include "ets_sys.h"
#include "spi_flash.h" #include "spi_flash.h"
#include "user_interface.h"
extern "C" {
static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] = static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
{ {
[0] = 5, // Reserved, do not change /*[0] =*/ 5, // Reserved, do not change
[1] = 8, // Reserved, do not change /*[1] =*/ 8, // Reserved, do not change
[2] = 4, // Reserved, do not change /*[2] =*/ 4, // Reserved, do not change
[3] = 2, // Reserved, do not change /*[3] =*/ 2, // Reserved, do not change
[4] = 5, // Reserved, do not change /*[4] =*/ 5, // Reserved, do not change
[5] = 5, // Reserved, do not change /*[5] =*/ 5, // Reserved, do not change
[6] = 5, // Reserved, do not change /*[6] =*/ 5, // Reserved, do not change
[7] = 2, // Reserved, do not change /*[7] =*/ 2, // Reserved, do not change
[8] = 5, // Reserved, do not change /*[8] =*/ 5, // Reserved, do not change
[9] = 0, // Reserved, do not change /*[9] =*/ 0, // Reserved, do not change
[10] = 4, // Reserved, do not change /*[10] =*/ 4, // Reserved, do not change
[11] = 5, // Reserved, do not change /*[11] =*/ 5, // Reserved, do not change
[12] = 5, // Reserved, do not change /*[12] =*/ 5, // Reserved, do not change
[13] = 4, // Reserved, do not change /*[13] =*/ 4, // Reserved, do not change
[14] = 5, // Reserved, do not change /*[14] =*/ 5, // Reserved, do not change
[15] = 5, // Reserved, do not change /*[15] =*/ 5, // Reserved, do not change
[16] = 4, // Reserved, do not change /*[16] =*/ 4, // Reserved, do not change
[17] = -2, // Reserved, do not change /*[17] =*/ (uint8_t)-2, // Reserved, do not change
[18] = -3, // Reserved, do not change /*[18] =*/ (uint8_t)-3, // Reserved, do not change
[19] = -1, // Reserved, do not change /*[19] =*/ (uint8_t)-1, // Reserved, do not change
[20] = -16, // Reserved, do not change /*[20] =*/ (uint8_t)-16, // Reserved, do not change
[21] = -16, // Reserved, do not change /*[21] =*/ (uint8_t)-16, // Reserved, do not change
[22] = -16, // Reserved, do not change /*[22] =*/ (uint8_t)-16, // Reserved, do not change
[23] = -32, // Reserved, do not change /*[23] =*/ (uint8_t)-32, // Reserved, do not change
[24] = -32, // Reserved, do not change /*[24] =*/ (uint8_t)-32, // Reserved, do not change
[25] = -32, // Reserved, do not change /*[25] =*/ (uint8_t)-32, // Reserved, do not change
[26] = 225, // spur_freq_cfg, spur_freq=spur_freq_cfg/spur_freq_cfg_div /*[26] =*/ 225, // spur_freq_cfg, spur_freq=spur_freq_cfg/spur_freq_cfg_div
[27] = 10, // spur_freq_cfg_div /*[27] =*/ 10, // spur_freq_cfg_div
// each bit for 1 channel, 1 to select the spur_freq if in band, else 40 // each bit for 1 channel, 1 to select the spur_freq if in band, else 40
[28] = 0xff, // spur_freq_en_h /*[28] =*/ 0xff, // spur_freq_en_h
[29] = 0xff, // spur_freq_en_l /*[29] =*/ 0xff, // spur_freq_en_l
[30] = 0xf8, // Reserved, do not change /*[30] =*/ 0xf8, // Reserved, do not change
[31] = 0, // Reserved, do not change /*[31] =*/ 0, // Reserved, do not change
[32] = 0xf8, // Reserved, do not change /*[32] =*/ 0xf8, // Reserved, do not change
[33] = 0xf8, // Reserved, do not change /*[33] =*/ 0xf8, // Reserved, do not change
[34] = 78, // target_power_qdb_0, target power is 78/4=19.5dbm /*[34] =*/ 78, // target_power_qdb_0, target power is 78/4=19.5dbm
[35] = 74, // target_power_qdb_1, target power is 74/4=18.5dbm /*[35] =*/ 74, // target_power_qdb_1, target power is 74/4=18.5dbm
[36] = 70, // target_power_qdb_2, target power is 70/4=17.5dbm /*[36] =*/ 70, // target_power_qdb_2, target power is 70/4=17.5dbm
[37] = 64, // target_power_qdb_3, target power is 64/4=16dbm /*[37] =*/ 64, // target_power_qdb_3, target power is 64/4=16dbm
[38] = 60, // target_power_qdb_4, target power is 60/4=15dbm /*[38] =*/ 60, // target_power_qdb_4, target power is 60/4=15dbm
[39] = 56, // target_power_qdb_5, target power is 56/4=14dbm /*[39] =*/ 56, // target_power_qdb_5, target power is 56/4=14dbm
[40] = 0, // target_power_index_mcs0 /*[40] =*/ 0, // target_power_index_mcs0
[41] = 0, // target_power_index_mcs1 /*[41] =*/ 0, // target_power_index_mcs1
[42] = 1, // target_power_index_mcs2 /*[42] =*/ 1, // target_power_index_mcs2
[43] = 1, // target_power_index_mcs3 /*[43] =*/ 1, // target_power_index_mcs3
[44] = 2, // target_power_index_mcs4 /*[44] =*/ 2, // target_power_index_mcs4
[45] = 3, // target_power_index_mcs5 /*[45] =*/ 3, // target_power_index_mcs5
[46] = 4, // target_power_index_mcs6 /*[46] =*/ 4, // target_power_index_mcs6
[47] = 5, // target_power_index_mcs7 /*[47] =*/ 5, // target_power_index_mcs7
// crystal_26m_en // crystal_26m_en
// 0: 40MHz // 0: 40MHz
// 1: 26MHz // 1: 26MHz
// 2: 24MHz // 2: 24MHz
#if F_CRYSTAL == 40000000 #if F_CRYSTAL == 40000000
[48] = 0, /*[48] =*/ 0,
#else #else
[48] = 1, /*[48] =*/ 1,
#endif #endif
/*[49] =*/ 0,
// sdio_configure // sdio_configure
// 0: Auto by pin strapping // 0: Auto by pin strapping
// 1: SDIO dataoutput is at negative edges (SDIO V1.1) // 1: SDIO dataoutput is at negative edges (SDIO V1.1)
// 2: SDIO dataoutput is at positive edges (SDIO V2.0) // 2: SDIO dataoutput is at positive edges (SDIO V2.0)
[50] = 0, /*[50] =*/ 0,
// bt_configure // bt_configure
// 0: None,no bluetooth // 0: None,no bluetooth
@ -113,7 +115,7 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// MTMS -> BT_PRIORITY // MTMS -> BT_PRIORITY
// MTCK -> BT_ACTIVE // MTCK -> BT_ACTIVE
// U0RXD -> ANT_SEL_BT // U0RXD -> ANT_SEL_BT
[51] = 0, /*[51] =*/ 0,
// bt_protocol // bt_protocol
// 0: WiFi-BT are not enabled. Antenna is for WiFi // 0: WiFi-BT are not enabled. Antenna is for WiFi
@ -122,16 +124,16 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// 3: WiFi-BT 3-wire are enabled, (when BT_ACTIVE = 0, BT_PRIORITY must be 0), independent ant // 3: WiFi-BT 3-wire are enabled, (when BT_ACTIVE = 0, BT_PRIORITY must be 0), independent ant
// 4: WiFi-BT 2-wire are enabled, (only use BT_ACTIVE), share ant // 4: WiFi-BT 2-wire are enabled, (only use BT_ACTIVE), share ant
// 5: WiFi-BT 3-wire are enabled, (when BT_ACTIVE = 0, BT_PRIORITY must be 0), share ant // 5: WiFi-BT 3-wire are enabled, (when BT_ACTIVE = 0, BT_PRIORITY must be 0), share ant
[52] = 0, /*[52] =*/ 0,
// dual_ant_configure // dual_ant_configure
// 0: None // 0: None
// 1: dual_ant (antenna diversity for WiFi-only): GPIO0 + U0RXD // 1: dual_ant (antenna diversity for WiFi-only): GPIO0 + U0RXD
// 2: T/R switch for External PA/LNA: GPIO0 is high and U0RXD is low during Tx // 2: T/R switch for External PA/LNA: GPIO0 is high and U0RXD is low during Tx
// 3: T/R switch for External PA/LNA: GPIO0 is low and U0RXD is high during Tx // 3: T/R switch for External PA/LNA: GPIO0 is low and U0RXD is high during Tx
[53] = 0, /*[53] =*/ 0,
[54] = 2, // Reserved, do not change /*[54] =*/ 2, // Reserved, do not change
// share_xtal // share_xtal
// This option is to share crystal clock for BT // This option is to share crystal clock for BT
@ -140,28 +142,53 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// 1: Forcely On // 1: Forcely On
// 2: Automatically On according to XPD_DCDC // 2: Automatically On according to XPD_DCDC
// 3: Automatically On according to GPIO2 // 3: Automatically On according to GPIO2
[55] = 0, /*[55] =*/ 0,
[64] = 225, // spur_freq_cfg_2, spur_freq_2=spur_freq_cfg_2/spur_freq_cfg_div_2 /*[56] =*/ 0,
[65] = 10, // spur_freq_cfg_div_2 /*[57] =*/ 0,
[66] = 0, // spur_freq_en_h_2 /*[58] =*/ 0,
[67] = 0, // spur_freq_en_l_2 /*[59] =*/ 0,
[68] = 0, // spur_freq_cfg_msb /*[60] =*/ 0,
[69] = 0, // spur_freq_cfg_2_msb /*[61] =*/ 0,
[70] = 0, // spur_freq_cfg_3_low /*[62] =*/ 0,
[71] = 0, // spur_freq_cfg_3_high /*[63] =*/ 0,
[72] = 0, // spur_freq_cfg_4_low
[73] = 0, // spur_freq_cfg_4_high
[74] = 1, // Reserved, do not change /*[64] =*/ 225, // spur_freq_cfg_2, spur_freq_2=spur_freq_cfg_2/spur_freq_cfg_div_2
[75] = 0x93, // Reserved, do not change /*[65] =*/ 10, // spur_freq_cfg_div_2
[76] = 0x43, // Reserved, do not change /*[66] =*/ 0, // spur_freq_en_h_2
[77] = 0x00, // Reserved, do not change /*[67] =*/ 0, // spur_freq_en_l_2
/*[68] =*/ 0, // spur_freq_cfg_msb
/*[69] =*/ 0, // spur_freq_cfg_2_msb
/*[70] =*/ 0, // spur_freq_cfg_3_low
/*[71] =*/ 0, // spur_freq_cfg_3_high
/*[72] =*/ 0, // spur_freq_cfg_4_low
/*[73] =*/ 0, // spur_freq_cfg_4_high
/*[74] =*/ 1, // Reserved, do not change
/*[75] =*/ 0x93, // Reserved, do not change
/*[76] =*/ 0x43, // Reserved, do not change
/*[77] =*/ 0x00, // Reserved, do not change
/*[78] =*/ 0,
/*[79] =*/ 0,
/*[80] =*/ 0,
/*[81] =*/ 0,
/*[82] =*/ 0,
/*[83] =*/ 0,
/*[84] =*/ 0,
/*[85] =*/ 0,
/*[86] =*/ 0,
/*[87] =*/ 0,
/*[88] =*/ 0,
/*[89] =*/ 0,
/*[90] =*/ 0,
/*[91] =*/ 0,
/*[92] =*/ 0,
// low_power_en // low_power_en
// 0: disable low power mode // 0: disable low power mode
// 1: enable low power mode // 1: enable low power mode
[93] = 0, /*[93] =*/ 0,
// lp_rf_stg10 // lp_rf_stg10
// the attenuation of RF gain stage 0 and 1, // the attenuation of RF gain stage 0 and 1,
@ -173,7 +200,7 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// 0x8: -14db, // 0x8: -14db,
// 0x4: -17.5, // 0x4: -17.5,
// 0x0: -23 // 0x0: -23
[94] = 0x00, /*[94] =*/ 0x00,
// lp_bb_att_ext // lp_bb_att_ext
@ -188,20 +215,29 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// 7: -1.75db, // 7: -1.75db,
// 8: -2db // 8: -2db
// max valve is 24(-6db) // max valve is 24(-6db)
[95] = 0, /*[95] =*/ 0,
// pwr_ind_11b_en // pwr_ind_11b_en
// 0: 11b power is same as mcs0 and 6m // 0: 11b power is same as mcs0 and 6m
// 1: enable 11b power different with ofdm // 1: enable 11b power different with ofdm
[96] = 0, /*[96] =*/ 0,
// pwr_ind_11b_0 // pwr_ind_11b_0
// 1m, 2m power index [0~5] // 1m, 2m power index [0~5]
[97] = 0, /*[97] =*/ 0,
// pwr_ind_11b_1 // pwr_ind_11b_1
// 5.5m, 11m power index [0~5] // 5.5m, 11m power index [0~5]
[98] = 0, /*[98] =*/ 0,
/*[99] =*/ 0,
/*[100] =*/ 0,
/*[101] =*/ 0,
/*[102] =*/ 0,
/*[103] =*/ 0,
/*[104] =*/ 0,
/*[105] =*/ 0,
/*[106] =*/ 0,
// vdd33_const // vdd33_const
// the voltage of PA_VDD // the voltage of PA_VDD
@ -220,10 +256,14 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// getVcc function (system_get_vdd33): // getVcc function (system_get_vdd33):
// is only available when TOUT pin17 is suspended (floating), this function measure the power voltage of VDD3P3 pin 3 and 4 // is only available when TOUT pin17 is suspended (floating), this function measure the power voltage of VDD3P3 pin 3 and 4
// For this function the vdd33_const must be set to 255 (0xFF). // For this function the vdd33_const must be set to 255 (0xFF).
[107] = 33, /*[107] =*/ 33,
// disable RF calibration for certain number of times // disable RF calibration for certain number of times
[108] = 0, /*[108] =*/ 0,
/*[109] =*/ 0,
/*[110] =*/ 0,
/*[111] =*/ 0,
// freq_correct_en // freq_correct_en
// bit[0]:0->do not correct frequency offset, 1->correct frequency offset. // bit[0]:0->do not correct frequency offset, 1->correct frequency offset.
@ -234,20 +274,21 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
// 3: auto measure frequency offset and correct it, bbpll is 160M, it only can correct + frequency offset. // 3: auto measure frequency offset and correct it, bbpll is 160M, it only can correct + frequency offset.
// 5: use 113 byte force_freq_offset to correct frequency offset, bbpll is 168M, it can correct + and - frequency offset. // 5: use 113 byte force_freq_offset to correct frequency offset, bbpll is 168M, it can correct + and - frequency offset.
// 7: use 113 byte force_freq_offset to correct frequency offset, bbpll is 160M , it only can correct + frequency offset. // 7: use 113 byte force_freq_offset to correct frequency offset, bbpll is 160M , it only can correct + frequency offset.
[112] = 0, /*[112] =*/ 0,
// force_freq_offset // force_freq_offset
// signed, unit is 8kHz // signed, unit is 8kHz
[113] = 0, /*[113] =*/ 0,
// rf_cal_use_flash // rf_cal_use_flash
// 0: RF init no RF CAL, using all RF CAL data in flash, it takes about 2ms for RF init // 0: RF init no RF CAL, using all RF CAL data in flash, it takes about 2ms for RF init
// 1: RF init only do TX power control CAL, others using RF CAL data in flash, it takes about 20ms for RF init // 1: RF init only do TX power control CAL, others using RF CAL data in flash, it takes about 20ms for RF init
// 2: RF init no RF CAL, using all RF CAL data in flash, it takes about 2ms for RF init (same as 0?!) // 2: RF init no RF CAL, using all RF CAL data in flash, it takes about 2ms for RF init (same as 0?!)
// 3: RF init do all RF CAL, it takes about 200ms for RF init // 3: RF init do all RF CAL, it takes about 200ms for RF init
[114] = 1 /*[114] =*/ 1
}; };
// These functions will be overriden from C++ code. // These functions will be overriden from C++ code.
// Unfortunately, we can't use extern "C" because Arduino preprocessor // Unfortunately, we can't use extern "C" because Arduino preprocessor
// doesn't generate forward declarations for extern "C" functions correctly, // doesn't generate forward declarations for extern "C" functions correctly,
@ -260,6 +301,7 @@ static bool spoof_init_data = false;
extern int __real_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size); extern int __real_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
extern int ICACHE_RAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size); extern int ICACHE_RAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size);
extern int __get_adc_mode();
extern int ICACHE_RAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size) extern int ICACHE_RAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size)
{ {
@ -313,3 +355,5 @@ void user_rf_pre_init()
void ICACHE_RAM_ATTR user_spi_flash_dio_to_qio_pre_init() {} void ICACHE_RAM_ATTR user_spi_flash_dio_to_qio_pre_init() {}
};

View File

@ -22,6 +22,8 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>
#include "debug.h" #include "debug.h"
#include "ets_sys.h" #include "ets_sys.h"
#include "user_interface.h" #include "user_interface.h"
@ -31,6 +33,8 @@
#include "gdb_hooks.h" #include "gdb_hooks.h"
#include "StackThunk.h" #include "StackThunk.h"
extern "C" {
extern void __real_system_restart_local(); extern void __real_system_restart_local();
// These will be pointers to PROGMEM const strings // These will be pointers to PROGMEM const strings
@ -91,7 +95,8 @@ void __wrap_system_restart_local() {
raise_exception(); raise_exception();
} }
struct rst_info rst_info = {0}; struct rst_info rst_info;
memset(&rst_info, 0, sizeof(rst_info));
system_rtc_mem_read(0, &rst_info, sizeof(rst_info)); system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
if (rst_info.reason != REASON_SOFT_WDT_RST && if (rst_info.reason != REASON_SOFT_WDT_RST &&
rst_info.reason != REASON_EXCEPTION_RST && rst_info.reason != REASON_EXCEPTION_RST &&
@ -100,7 +105,8 @@ void __wrap_system_restart_local() {
return; return;
} }
ets_install_putc1(&uart_write_char_d); // TODO: ets_install_putc1 definition is wrong in ets_sys.h, need cast
ets_install_putc1((void *)&uart_write_char_d);
if (s_panic_line) { if (s_panic_line) {
ets_printf_P(PSTR("\nPanic %S:%d %S"), s_panic_file, s_panic_line, s_panic_func); ets_printf_P(PSTR("\nPanic %S:%d %S"), s_panic_file, s_panic_line, s_panic_func);
@ -175,7 +181,7 @@ void __wrap_system_restart_local() {
custom_crash_callback( &rst_info, sp_dump + offset, stack_end ); custom_crash_callback( &rst_info, sp_dump + offset, stack_end );
delayMicroseconds(10000); ets_delay_us(10000);
__real_system_restart_local(); __real_system_restart_local();
} }
@ -248,3 +254,4 @@ void __panic_func(const char* file, int line, const char* func) {
raise_exception(); raise_exception();
} }
};

View File

@ -23,6 +23,8 @@
#include "pins_arduino.h" #include "pins_arduino.h"
#include "wiring_private.h" #include "wiring_private.h"
extern "C" {
unsigned int preferred_si2c_clock = 100000; unsigned int preferred_si2c_clock = 100000;
#include "twi_util.h" #include "twi_util.h"
@ -99,7 +101,7 @@ static void onSdaChange(void);
static ETSEvent eventTaskQueue[EVENTTASK_QUEUE_SIZE]; static ETSEvent eventTaskQueue[EVENTTASK_QUEUE_SIZE];
static void eventTask(ETSEvent *e); static void eventTask(ETSEvent *e);
static ETSTimer timer; static ETSTimer timer;
static void onTimer(); static void onTimer(void *unused);
#define SDA_LOW() (GPES = (1 << twi_sda)) //Enable SDA (becomes output and since GPO is 0 for the pin, it will pull the line low) #define SDA_LOW() (GPES = (1 << twi_sda)) //Enable SDA (becomes output and since GPO is 0 for the pin, it will pull the line low)
#define SDA_HIGH() (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high) #define SDA_HIGH() (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high)
@ -179,6 +181,7 @@ static void ICACHE_RAM_ATTR twi_delay(unsigned char v){
for (i = 0; i < v; i++) { for (i = 0; i < v; i++) {
reg = GPI; reg = GPI;
} }
(void)reg;
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
} }
@ -478,8 +481,9 @@ void ICACHE_RAM_ATTR twi_onTwipEvent(uint8_t status)
} }
} }
void ICACHE_RAM_ATTR onTimer() void ICACHE_RAM_ATTR onTimer(void *unused)
{ {
(void)unused;
twi_releaseBus(); twi_releaseBus();
twip_status = TW_BUS_ERROR; twip_status = TW_BUS_ERROR;
twi_onTwipEvent(twip_status); twi_onTwipEvent(twip_status);
@ -781,3 +785,5 @@ void ICACHE_RAM_ATTR onSdaChange(void)
break; break;
} }
} }
};

View File

@ -21,6 +21,8 @@
#include "Arduino.h" // using pinMode #include "Arduino.h" // using pinMode
extern "C" {
// definitions in esp8266_peri.h style // definitions in esp8266_peri.h style
#define GPSD ESP8266_REG(0x368) // GPIO_SIGMA_DELTA register @ 0x600000368 #define GPSD ESP8266_REG(0x368) // GPIO_SIGMA_DELTA register @ 0x600000368
#define GPSDT 0 // target, 8 bits #define GPSDT 0 // target, 8 bits
@ -172,3 +174,5 @@ uint8_t ICACHE_FLASH_ATTR sigmaDeltaGetPrescaler(void)
{ {
return (uint8_t)((GPSD >> GPSDP) & 0xFF); return (uint8_t)((GPSD >> GPSDP) & 0xFF);
} }
};

View File

@ -24,6 +24,8 @@
#include "c_types.h" #include "c_types.h"
#include "ets_sys.h" #include "ets_sys.h"
extern "C" {
// ------------------------------------------------------------------ - // ------------------------------------------------------------------ -
// timer 1 // timer 1
@ -101,3 +103,5 @@ void ICACHE_RAM_ATTR timer0_detachInterrupt() {
timer0_user_cb = NULL; timer0_user_cb = NULL;
ETS_CCOMPARE0_DISABLE(); ETS_CCOMPARE0_DISABLE();
} }
};

View File

@ -41,6 +41,8 @@
#include "ets_sys.h" #include "ets_sys.h"
#include "core_esp8266_waveform.h" #include "core_esp8266_waveform.h"
extern "C" {
// Maximum delay between IRQs // Maximum delay between IRQs
#define MAXIRQUS (10000) #define MAXIRQUS (10000)
@ -303,3 +305,5 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
#endif #endif
TEIE |= TEIE1; // Edge int enable TEIE |= TEIE1; // Edge int enable
} }
};

View File

@ -25,6 +25,9 @@
#include "user_interface.h" #include "user_interface.h"
#include "cont.h" #include "cont.h"
extern "C" {
extern void ets_delay_us(uint32_t us);
extern void esp_schedule(); extern void esp_schedule();
extern void esp_yield(); extern void esp_yield();
@ -210,3 +213,5 @@ void init() {
os_timer_setfn(&micros_overflow_timer, (os_timer_func_t*) &micros_overflow_tick, 0); os_timer_setfn(&micros_overflow_timer, (os_timer_func_t*) &micros_overflow_tick, 0);
os_timer_arm(&micros_overflow_timer, 60000, REPEAT); os_timer_arm(&micros_overflow_timer, 60000, REPEAT);
} }
};

View File

@ -24,7 +24,9 @@
#include "wiring_private.h" #include "wiring_private.h"
#include "pins_arduino.h" #include "pins_arduino.h"
#include "user_interface.h"
extern "C" {
extern int __analogRead(uint8_t pin) extern int __analogRead(uint8_t pin)
{ {
@ -36,3 +38,5 @@ extern int __analogRead(uint8_t pin)
} }
extern int analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead"))); extern int analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead")));
};

View File

@ -24,8 +24,11 @@
#include "c_types.h" #include "c_types.h"
#include "eagle_soc.h" #include "eagle_soc.h"
#include "ets_sys.h" #include "ets_sys.h"
#include "user_interface.h"
#include "core_esp8266_waveform.h" #include "core_esp8266_waveform.h"
extern "C" {
uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C, 0x20, 0x24, 0x28, 0x2C, 0x30, 0x04, 0x08, 0x0C, 0x10}; uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C, 0x20, 0x24, 0x28, 0x2C, 0x30, 0x04, 0x08, 0x0C, 0x10};
extern void __pinMode(uint8_t pin, uint8_t mode) { extern void __pinMode(uint8_t pin, uint8_t mode) {
@ -232,3 +235,4 @@ extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead")
extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt"))); extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt")));
extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt"))); extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt")));
};

View File

@ -22,6 +22,7 @@
#include "wiring_private.h" #include "wiring_private.h"
#include "pins_arduino.h" #include "pins_arduino.h"
extern "C" {
extern uint32_t xthal_get_ccount(); extern uint32_t xthal_get_ccount();
@ -53,3 +54,5 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
{ {
return pulseIn(pin, state, timeout); return pulseIn(pin, state, timeout);
} }
};

View File

@ -24,6 +24,7 @@
#include <Arduino.h> #include <Arduino.h>
#include "core_esp8266_waveform.h" #include "core_esp8266_waveform.h"
extern "C" {
static uint32_t analogMap = 0; static uint32_t analogMap = 0;
static int32_t analogScale = PWMRANGE; static int32_t analogScale = PWMRANGE;
@ -76,3 +77,5 @@ extern void __analogWrite(uint8_t pin, int val) {
extern void analogWrite(uint8_t pin, int val) __attribute__((weak, alias("__analogWrite"))); extern void analogWrite(uint8_t pin, int val) __attribute__((weak, alias("__analogWrite")));
extern void analogWriteFreq(uint32_t freq) __attribute__((weak, alias("__analogWriteFreq"))); extern void analogWriteFreq(uint32_t freq) __attribute__((weak, alias("__analogWriteFreq")));
extern void analogWriteRange(uint32_t range) __attribute__((weak, alias("__analogWriteRange"))); extern void analogWriteRange(uint32_t range) __attribute__((weak, alias("__analogWriteRange")));
};

View File

@ -26,6 +26,7 @@
*/ */
#include "wiring_private.h" #include "wiring_private.h"
extern "C" {
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
uint8_t value = 0; uint8_t value = 0;
@ -55,3 +56,5 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
digitalWrite(clockPin, LOW); digitalWrite(clockPin, LOW);
} }
} }
};

View File

@ -22,6 +22,7 @@
#define ESP8266_PERI_H_INCLUDED #define ESP8266_PERI_H_INCLUDED
#include "c_types.h" #include "c_types.h"
#include "esp8266_undocumented.h"
#define ESP8266_REG(addr) *((volatile uint32_t *)(0x60000000+(addr))) #define ESP8266_REG(addr) *((volatile uint32_t *)(0x60000000+(addr)))
#define ESP8266_DREG(addr) *((volatile uint32_t *)(0x3FF00000+(addr))) #define ESP8266_DREG(addr) *((volatile uint32_t *)(0x3FF00000+(addr)))

View File

@ -0,0 +1,18 @@
// ROM and blob calls without official headers available
#ifdef __cplusplus
extern "C" {
#endif
// ROM
extern void rom_i2c_writeReg_Mask(int, int, int, int, int, int);
extern int rom_i2c_readReg_Mask(int, int, int, int, int);
extern int uart_baudrate_detect(int, int);
extern void ets_delay_us(uint32_t us);
#ifdef __cplusplus
};
#endif

View File

@ -24,6 +24,7 @@
/* gdb_init and gdb_do_break do not return anything, but since the return /* gdb_init and gdb_do_break do not return anything, but since the return
value is in register, it doesn't hurt to return a bool, so that the value is in register, it doesn't hurt to return a bool, so that the
same stub can be used for gdb_present. */ same stub can be used for gdb_present. */
extern "C" {
static bool ICACHE_RAM_ATTR __gdb_no_op() static bool ICACHE_RAM_ATTR __gdb_no_op()
{ {
@ -40,3 +41,4 @@ void gdbstub_set_uart_isr_callback(void (*func)(void*, uint8_t), void* arg) __at
void gdbstub_write_char(char c) __attribute__ ((weak, alias("__gdb_no_op"))); void gdbstub_write_char(char c) __attribute__ ((weak, alias("__gdb_no_op")));
void gdbstub_write(const char* buf, size_t size) __attribute__ ((weak, alias("__gdb_no_op"))); void gdbstub_write(const char* buf, size_t size) __attribute__ ((weak, alias("__gdb_no_op")));
};

View File

@ -8,6 +8,8 @@
#include <c_types.h> #include <c_types.h>
#include <sys/reent.h> #include <sys/reent.h>
extern "C" {
// Debugging helper, last allocation which returned NULL // Debugging helper, last allocation which returned NULL
void *umm_last_fail_alloc_addr = NULL; void *umm_last_fail_alloc_addr = NULL;
int umm_last_fail_alloc_size = 0; int umm_last_fail_alloc_size = 0;
@ -189,3 +191,5 @@ void system_show_malloc(void)
{ {
umm_info(NULL, 1); umm_info(NULL, 1);
} }
};

View File

@ -5,15 +5,18 @@ This is part of the libb64 project, and has been placed in the public domain.
For details, see http://sourceforge.net/projects/libb64 For details, see http://sourceforge.net/projects/libb64
*/ */
#include "cdecode.h" #include <pgmspace.h>
#include <stdint.h> #include <stdint.h>
#include "cdecode.h"
extern "C" {
static int base64_decode_value_signed(int8_t value_in){ static int base64_decode_value_signed(int8_t value_in){
static const int8_t decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51}; static const int8_t decoding[] PROGMEM = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
static const int8_t decoding_size = sizeof(decoding); static const int8_t decoding_size = sizeof(decoding);
value_in -= 43; value_in -= 43;
if (value_in < 0 || value_in > decoding_size) return -1; if (value_in < 0 || value_in > decoding_size) return -1;
return decoding[(int)value_in]; return pgm_read_byte( &decoding[(int)value_in] );
} }
void base64_init_decodestate(base64_decodestate* state_in){ void base64_init_decodestate(base64_decodestate* state_in){
@ -97,3 +100,5 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out){ int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out){
return base64_decode_chars_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out); return base64_decode_chars_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out);
} }
};

View File

@ -5,8 +5,11 @@ This is part of the libb64 project, and has been placed in the public domain.
For details, see http://sourceforge.net/projects/libb64 For details, see http://sourceforge.net/projects/libb64
*/ */
#include <pgmspace.h>
#include "cencode.h" #include "cencode.h"
extern "C" {
void base64_init_encodestate(base64_encodestate* state_in){ void base64_init_encodestate(base64_encodestate* state_in){
state_in->step = step_A; state_in->step = step_A;
state_in->result = 0; state_in->result = 0;
@ -21,9 +24,9 @@ void base64_init_encodestate_nonewlines(base64_encodestate* state_in){
} }
char base64_encode_value(char value_in){ char base64_encode_value(char value_in){
static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char encoding[] PROGMEM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
if (value_in > 63) return '='; if (value_in > 63) return '=';
return encoding[(int)value_in]; return pgm_read_byte( &encoding[(int)value_in] );
} }
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in){ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in){
@ -107,3 +110,5 @@ int base64_encode_chars(const char* plaintext_in, int length_in, char* code_out)
int len = base64_encode_block(plaintext_in, length_in, code_out, &_state); int len = base64_encode_block(plaintext_in, length_in, code_out, &_state);
return len + base64_encode_blockend((code_out + len), &_state); return len + base64_encode_blockend((code_out + len), &_state);
} }
};

View File

@ -45,6 +45,7 @@
#include "user_interface.h" #include "user_interface.h"
#include "debug.h" #include "debug.h"
extern "C" {
int ICACHE_RAM_ATTR _open_r (struct _reent* unused, const char *ptr, int mode) { int ICACHE_RAM_ATTR _open_r (struct _reent* unused, const char *ptr, int mode) {
(void)unused; (void)unused;
@ -129,3 +130,5 @@ int atexit(void (*func)()) {
(void) func; (void) func;
return 0; return 0;
} }
};

View File

@ -43,6 +43,8 @@
#include <os_type.h> #include <os_type.h>
#include "coredecls.h" #include "coredecls.h"
extern "C" {
static void (*_settimeofday_cb)(void) = NULL; static void (*_settimeofday_cb)(void) = NULL;
void settimeofday_cb (void (*cb)(void)) void settimeofday_cb (void (*cb)(void))
@ -55,6 +57,8 @@ void settimeofday_cb (void (*cb)(void))
#include <pgmspace.h> #include <pgmspace.h>
static const char stod14[] PROGMEM = "settimeofday() can't set time!\n"; static const char stod14[] PROGMEM = "settimeofday() can't set time!\n";
bool sntp_set_timezone(sint8 timezone);
void sntp_set_daylight(int daylight);
int settimeofday(const struct timeval* tv, const struct timezone* tz) int settimeofday(const struct timeval* tv, const struct timezone* tz)
{ {
@ -461,3 +465,5 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
} }
#endif // lwip2 only #endif // lwip2 only
};

View File

@ -10,6 +10,8 @@
#if SPIFFS_CACHE #if SPIFFS_CACHE
extern "C" {
// returns cached page for give page index, or null if no such cached page // returns cached page for give page index, or null if no such cached page
static spiffs_cache_page *spiffs_cache_page_get(spiffs *fs, spiffs_page_ix pix) { static spiffs_cache_page *spiffs_cache_page_get(spiffs *fs, spiffs_page_ix pix) {
spiffs_cache *cache = spiffs_get_cache(fs); spiffs_cache *cache = spiffs_get_cache(fs);
@ -316,4 +318,5 @@ void spiffs_cache_init(spiffs *fs) {
} }
} }
};
#endif // SPIFFS_CACHE #endif // SPIFFS_CACHE

View File

@ -37,6 +37,8 @@
} while (0) } while (0)
#endif #endif
extern "C" {
//--------------------------------------- //---------------------------------------
// Look up consistency // Look up consistency
@ -925,7 +927,7 @@ static s32_t spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id o
} else { // span index } else { // span index
// objix page, see if header can be found // objix page, see if header can be found
int r = spiffs_object_index_search(fs, obj_id); int r = spiffs_object_index_search(fs, obj_id);
u8_t delete = 0; u8_t _delete = 0;
if (r == -1) { if (r == -1) {
// not in temporary index, try finding it // not in temporary index, try finding it
spiffs_page_ix objix_hdr_pix; spiffs_page_ix objix_hdr_pix;
@ -936,7 +938,7 @@ static s32_t spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id o
obj_table[*log_ix] = obj_id & ~SPIFFS_OBJ_ID_IX_FLAG; obj_table[*log_ix] = obj_id & ~SPIFFS_OBJ_ID_IX_FLAG;
} else if (res == SPIFFS_ERR_NOT_FOUND) { } else if (res == SPIFFS_ERR_NOT_FOUND) {
// not found, register as unreachable // not found, register as unreachable
delete = 1; _delete = 1;
obj_table[*log_ix] = obj_id | SPIFFS_OBJ_ID_IX_FLAG; obj_table[*log_ix] = obj_id | SPIFFS_OBJ_ID_IX_FLAG;
} else { } else {
SPIFFS_CHECK_RES(res); SPIFFS_CHECK_RES(res);
@ -949,11 +951,11 @@ static s32_t spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id o
// in temporary index, check reachable flag // in temporary index, check reachable flag
if ((obj_table[r] & SPIFFS_OBJ_ID_IX_FLAG)) { if ((obj_table[r] & SPIFFS_OBJ_ID_IX_FLAG)) {
// registered as unreachable // registered as unreachable
delete = 1; _delete = 1;
} }
} }
if (delete) { if (_delete) {
SPIFFS_CHECK_DBG("IX: FIXUP: pix "_SPIPRIpg", obj id:"_SPIPRIid" spix:"_SPIPRIsp" is orphan index - deleting\n", SPIFFS_CHECK_DBG("IX: FIXUP: pix "_SPIPRIpg", obj id:"_SPIPRIid" spix:"_SPIPRIsp" is orphan index - deleting\n",
cur_pix, obj_id, p_hdr.span_ix); cur_pix, obj_id, p_hdr.span_ix);
CHECK_CB(fs, SPIFFS_CHECK_INDEX, SPIFFS_CHECK_DELETE_ORPHANED_INDEX, cur_pix, obj_id); CHECK_CB(fs, SPIFFS_CHECK_INDEX, SPIFFS_CHECK_DELETE_ORPHANED_INDEX, cur_pix, obj_id);
@ -992,4 +994,6 @@ s32_t spiffs_object_index_consistency_check(spiffs *fs) {
return res; return res;
} }
};
#endif // !SPIFFS_READ_ONLY #endif // !SPIFFS_READ_ONLY

View File

@ -3,6 +3,8 @@
#if !SPIFFS_READ_ONLY #if !SPIFFS_READ_ONLY
extern "C" {
// Erases a logical block and updates the erase counter. // Erases a logical block and updates the erase counter.
// If cache is enabled, all pages that might be cached in this block // If cache is enabled, all pages that might be cached in this block
// is dropped. // is dropped.
@ -603,4 +605,6 @@ s32_t spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix) {
return res; return res;
} }
};
#endif // !SPIFFS_READ_ONLY #endif // !SPIFFS_READ_ONLY

View File

@ -8,6 +8,8 @@
#include "spiffs.h" #include "spiffs.h"
#include "spiffs_nucleus.h" #include "spiffs_nucleus.h"
extern "C" {
#if SPIFFS_CACHE == 1 #if SPIFFS_CACHE == 1
static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh); static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh);
#endif #endif
@ -1450,3 +1452,5 @@ s32_t SPIFFS_vis(spiffs *fs) {
return res; return res;
} }
#endif #endif
};

View File

@ -1,6 +1,8 @@
#include "spiffs.h" #include "spiffs.h"
#include "spiffs_nucleus.h" #include "spiffs_nucleus.h"
extern "C" {
static s32_t spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) { static s32_t spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
if (pix == (spiffs_page_ix)-1) { if (pix == (spiffs_page_ix)-1) {
@ -2357,3 +2359,5 @@ void spiffs_fd_temporal_cache_rehash(
} }
} }
#endif #endif
};

View File

@ -110,6 +110,10 @@
#ifndef SPIFFS_NUCLEUS_H_ #ifndef SPIFFS_NUCLEUS_H_
#define SPIFFS_NUCLEUS_H_ #define SPIFFS_NUCLEUS_H_
#if defined(__cplusplus)
extern "C" {
#endif
#define _SPIFFS_ERR_CHECK_FIRST (SPIFFS_ERR_INTERNAL - 1) #define _SPIFFS_ERR_CHECK_FIRST (SPIFFS_ERR_INTERNAL - 1)
#define SPIFFS_ERR_CHECK_OBJ_ID_MISM (SPIFFS_ERR_INTERNAL - 1) #define SPIFFS_ERR_CHECK_OBJ_ID_MISM (SPIFFS_ERR_INTERNAL - 1)
#define SPIFFS_ERR_CHECK_SPIX_MISM (SPIFFS_ERR_INTERNAL - 2) #define SPIFFS_ERR_CHECK_SPIX_MISM (SPIFFS_ERR_INTERNAL - 2)
@ -839,4 +843,8 @@ s32_t spiffs_object_index_consistency_check(
#endif #endif
#endif //_SPIFFS_TEST #endif //_SPIFFS_TEST
#if defined(__cplusplus)
};
#endif
#endif /* SPIFFS_NUCLEUS_H_ */ #endif /* SPIFFS_NUCLEUS_H_ */

View File

@ -2,6 +2,8 @@
#include <coredecls.h> #include <coredecls.h>
#include <stdint.h> #include <stdint.h>
extern "C" {
uint32_t sqrt32 (uint32_t n) uint32_t sqrt32 (uint32_t n)
{ {
// http://www.codecodex.com/wiki/Calculate_an_integer_square_root#C // http://www.codecodex.com/wiki/Calculate_an_integer_square_root#C
@ -54,3 +56,5 @@ int main (void)
* *
*/ */
};

View File

@ -22,6 +22,8 @@
#include "sntp.h" #include "sntp.h"
#include "coredecls.h" #include "coredecls.h"
extern "C" {
#ifndef _TIMEVAL_DEFINED #ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED #define _TIMEVAL_DEFINED
struct timeval { struct timeval {
@ -33,6 +35,7 @@ struct timeval {
extern char* sntp_asctime(const struct tm *t); extern char* sntp_asctime(const struct tm *t);
extern struct tm* sntp_localtime(const time_t *clock); extern struct tm* sntp_localtime(const time_t *clock);
extern uint64_t micros64(); extern uint64_t micros64();
extern void sntp_set_daylight(int daylight);
// time gap in seconds from 01.01.1900 (NTP time) to 01.01.1970 (UNIX time) // time gap in seconds from 01.01.1900 (NTP time) to 01.01.1970 (UNIX time)
#define DIFF1900TO1970 2208988800UL #define DIFF1900TO1970 2208988800UL
@ -101,3 +104,5 @@ int _gettimeofday_r(struct _reent* unused, struct timeval *tp, void *tzp)
} }
return 0; return 0;
} }
};

View File

@ -42,6 +42,7 @@
*/ */
#include "Arduino.h" #include "Arduino.h"
#include <pgmspace.h> #include <pgmspace.h>
#include "../../libraries/GDBStub/src/GDBStub.h"
#include "uart.h" #include "uart.h"
#include "esp8266_peri.h" #include "esp8266_peri.h"
#include "user_interface.h" #include "user_interface.h"
@ -70,8 +71,9 @@
kept running to enable GDB to do commands. kept running to enable GDB to do commands.
*/ */
static int s_uart_debug_nr = UART0; extern "C" {
static int s_uart_debug_nr = UART0;
struct uart_rx_buffer_ struct uart_rx_buffer_
{ {
@ -974,3 +976,5 @@ uart_detect_baudrate(int uart_nr)
return default_rates[i]; return default_rates[i];
} }
};

View File

@ -499,6 +499,8 @@
#include "umm_malloc_cfg.h" /* user-dependent */ #include "umm_malloc_cfg.h" /* user-dependent */
extern "C" {
// From UMM, the last caller of a malloc/realloc/calloc which failed: // From UMM, the last caller of a malloc/realloc/calloc which failed:
extern void *umm_last_fail_alloc_addr; extern void *umm_last_fail_alloc_addr;
extern int umm_last_fail_alloc_size; extern int umm_last_fail_alloc_size;
@ -905,7 +907,8 @@ static int check_poison_all_blocks(void) {
* *
* `size_w_poison` is a size of the whole block, including a poison. * `size_w_poison` is a size of the whole block, including a poison.
*/ */
static void *get_poisoned( unsigned char *ptr, size_t size_w_poison ) { static void *get_poisoned( void *vptr, size_t size_w_poison ) {
unsigned char *ptr = (unsigned char *)vptr;
if (size_w_poison != 0 && ptr != NULL) { if (size_w_poison != 0 && ptr != NULL) {
/* Put exact length of the user's chunk of memory */ /* Put exact length of the user's chunk of memory */
@ -930,7 +933,8 @@ static void *get_poisoned( unsigned char *ptr, size_t size_w_poison ) {
* *
* Returns unpoisoned pointer, i.e. actual pointer to the allocated memory. * Returns unpoisoned pointer, i.e. actual pointer to the allocated memory.
*/ */
static void *get_unpoisoned( unsigned char *ptr ) { static void *get_unpoisoned( void *vptr ) {
unsigned char *ptr = (unsigned char *)vptr;
if (ptr != NULL) { if (ptr != NULL) {
unsigned short int c; unsigned short int c;
@ -1775,4 +1779,6 @@ size_t ICACHE_FLASH_ATTR umm_block_size( void ) {
return sizeof(umm_block); return sizeof(umm_block);
} }
};
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */

View File

@ -56,17 +56,17 @@ CORE_CPP_FILES := $(addprefix $(CORE_PATH)/,\
FS.cpp \ FS.cpp \
spiffs_api.cpp \ spiffs_api.cpp \
MD5Builder.cpp \ MD5Builder.cpp \
core_esp8266_noniso.cpp \
spiffs/spiffs_cache.cpp \
spiffs/spiffs_check.cpp \
spiffs/spiffs_gc.cpp \
spiffs/spiffs_hydrogen.cpp \
spiffs/spiffs_nucleus.cpp \
libb64/cencode.cpp \
Schedule.cpp \ Schedule.cpp \
) )
CORE_C_FILES := $(addprefix $(CORE_PATH)/,\ CORE_C_FILES := $(addprefix $(CORE_PATH)/,\
core_esp8266_noniso.c \
spiffs/spiffs_cache.c \
spiffs/spiffs_check.c \
spiffs/spiffs_gc.c \
spiffs/spiffs_hydrogen.c \
spiffs/spiffs_nucleus.c \
libb64/cencode.c \
) )
MOCK_CPP_FILES_COMMON := $(addprefix common/,\ MOCK_CPP_FILES_COMMON := $(addprefix common/,\