espmissingincludes.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef ESPMISSINGINCLUDES_H
  2. #define ESPMISSINGINCLUDES_H
  3. #include <user_interface.h>
  4. #include <eagle_soc.h>
  5. #include <stdint.h>
  6. #include <c_types.h>
  7. #include <ets_sys.h>
  8. #include <stdarg.h>
  9. //Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere.
  10. //MOST OF THESE ARE GUESSED! but they seem to work and shut up the compiler.
  11. typedef struct espconn espconn;
  12. bool wifi_station_set_hostname(char *);
  13. char *wifi_station_get_hostname(void);
  14. int atoi(const char *nptr);
  15. //void ets_install_putc1(void *routine); // necessary for #define os_xxx -> ets_xxx
  16. //void ets_isr_attach(int intr, void *handler, void *arg);
  17. void ets_isr_mask(unsigned intr);
  18. void ets_isr_unmask(unsigned intr);
  19. int ets_memcmp(const void *s1, const void *s2, size_t n);
  20. void *ets_memcpy(void *dest, const void *src, size_t n);
  21. void *ets_memmove(void *dest, const void *src, size_t n);
  22. void *ets_memset(void *s, int c, size_t n);
  23. int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
  24. int ets_str2macaddr(void *, void *);
  25. int ets_strcmp(const char *s1, const char *s2);
  26. char *ets_strcpy(char *dest, const char *src);
  27. //size_t ets_strlen(const char *s);
  28. //int ets_strncmp(const char *s1, const char *s2, int len);
  29. char *ets_strncpy(char *dest, const char *src, size_t n);
  30. char *ets_strstr(const char *haystack, const char *needle);
  31. //void ets_timer_arm_new(ETSTimer *a, int b, int c, int isMstimer);
  32. void ets_timer_disarm(ETSTimer *a);
  33. void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg);
  34. void ets_update_cpu_frequency(int freqmhz);
  35. #ifdef SDK_DBG
  36. #define DEBUG_SDK true
  37. #else
  38. #define DEBUG_SDK false
  39. #endif
  40. int ets_vsprintf(char *str, const char *format, va_list argptr);
  41. int ets_vsnprintf(char *buffer, size_t sizeOfBuffer, const char *format, va_list argptr);
  42. int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__((format(printf, 3, 4)));
  43. int os_printf_plus(const char *format, ...) __attribute__((format(printf, 1, 2)));
  44. #undef os_printf
  45. #define os_printf(format, ...) do { \
  46. system_set_os_print(true); \
  47. os_printf_plus(format, ## __VA_ARGS__); \
  48. system_set_os_print(DEBUG_SDK); \
  49. } while (0)
  50. // memory allocation functions are "different" due to memory debugging functionality
  51. // added in SDK 1.4.0
  52. //void vPortFree(void *ptr, const char * file, int line);
  53. //void *pvPortMalloc(size_t xWantedSize, const char * file, int line);
  54. //void *pvPortZalloc(size_t, const char * file, int line);
  55. void *vPortMalloc(size_t xWantedSize);
  56. void pvPortFree(void *ptr);
  57. //void uart_div_modify(int no, unsigned int freq);
  58. uint32 system_get_time();
  59. int rand(void);
  60. void ets_bzero(void *s, size_t n);
  61. //void ets_delay_us(int ms);
  62. // disappeared in SDK 1.1.0:
  63. #define os_timer_done ets_timer_done
  64. #define os_timer_handler_isr ets_timer_handler_isr
  65. #define os_timer_init ets_timer_init
  66. // This is not missing in SDK 1.1.0 but causes a parens error
  67. #undef PIN_FUNC_SELECT
  68. #define PIN_FUNC_SELECT(PIN_NAME, FUNC) do { \
  69. WRITE_PERI_REG(PIN_NAME, \
  70. (READ_PERI_REG(PIN_NAME) & ~(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) \
  71. |( (((FUNC&BIT2)<<2)|(FUNC&0x3))<<PERIPHS_IO_MUX_FUNC_S) ); \
  72. } while (0)
  73. // Shortcuts for memory functions
  74. //#define os_malloc pvPortMalloc // defined in SDK 1.4.0 onwards
  75. //#define os_free vPortFree // defined in SDK 1.4.0 onwards
  76. //#define os_zalloc pvPortZalloc // defined in SDK 1.4.0 onwards
  77. //uint8 wifi_get_opmode(void); // defined in SDK 1.0.0 onwards
  78. //int os_random(); // defined in SDK 1.1.0 onwards
  79. #endif