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