ESP32_RTOS_SDK V1.1.0

- Main Page
- Modules
- Data Structures
- Files

- File List

esp_misc.h
1 /*
2 * ESPRSSIF MIT License
3 *
4 * Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5 *
6 * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP32 only, in which case,
7 * it is free of charge, to any person obtaining a copy of this software and associated
8 * documentation files (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11 * to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or
14 * substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef __ESP_MISC_H__
26 #define __ESP_MISC_H__
27
28 #include "lwip/ip_addr.h"
29
30 #include "freertos/FreeRTOS.h"
31 #include "freertos/semphr.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
45 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
46 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
47
48 #define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
49 ip4_addr2_16(ipaddr), \
50 ip4_addr3_16(ipaddr), \
51 ip4_addr4_16(ipaddr)
52
53 #define IPSTR "%d.%d.%d.%d"
54
55 void ets_delay_us(uint16 us);
56
57 void ets_install_putc1(void (*p)(char c));
58
59 void ets_putc(char c);
60
61 void ets_printf(const char *fmt, ...);
62
63 #define os_delay_us ets_delay_us
64
65 #define os_install_putc1 ets_install_putc1
66
67 #define os_putc ets_putc
68
69 extern SemaphoreHandle_t stdio_mutex_tx;
70
71 #ifdef USE_LIBC_PRINTF
72 #define printf_call printf
73 #else
74 #define printf_call ets_printf
75 #endif
76
77 #define os_printf(fmt, ...) do { \
78 xSemaphoreTake(stdio_mutex_tx, portMAX_DELAY); \
79 printf_call(fmt, ##__VA_ARGS__); \
80 xSemaphoreGive(stdio_mutex_tx); \
81 } while(0)
82
83 #define os_printf_isr(fmt, ...) do { \
84 static const char ram_str[] DRAM_ATTR STORE_ATTR = fmt; \
85 ets_printf(ram_str, ##__VA_ARGS__); \
86 } while(0)
87
88 enum dhcp_status {
89 DHCP_STOPPED,
90 DHCP_STARTED
91 };
92
93 struct dhcps_lease {
94 bool enable;
95 struct ip_addr start_ip;
96 struct ip_addr end_ip;
97 };
98
99 enum dhcps_offer_option {
100 OFFER_START = 0x00,
101 OFFER_ROUTER = 0x01,
102 OFFER_END
103 };
104
105 unsigned long os_random(void);
106
107 int os_get_random(uint8* buf, size_t len);
108
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif
OFFER_END
Definition: esp_misc.h:102
dhcps_offer_option
dhcps_offer_option
Definition: esp_misc.h:99
dhcps_lease
Definition: esp_misc.h:93
dhcps_lease::enable
bool enable
Definition: esp_misc.h:94
DHCP_STARTED
Definition: esp_misc.h:90
DHCP_STOPPED
Definition: esp_misc.h:89
dhcps_lease::end_ip
struct ip_addr end_ip
Definition: esp_misc.h:96
dhcps_lease::start_ip
struct ip_addr start_ip
Definition: esp_misc.h:95
OFFER_ROUTER
Definition: esp_misc.h:101
OFFER_START
Definition: esp_misc.h:100
dhcp_status
dhcp_status
Definition: esp_misc.h:88