6
#include "user_config.h"
9
#include "user_interface.h"
11
extern int swapforth(), swapforth2();
16
#define user_procTaskPrio 0
17
#define user_procTaskQueueLen 128
18
os_event_t user_procTaskQueue[user_procTaskQueueLen];
19
static void user_procTask(os_event_t *events);
21
volatile os_timer_t some_timer;
23
struct espconn *_ptrUDPServer;
24
uint8 udpServerIP[] = { 192, 168, 0, 64 };
28
uint32*ptr = (uint32_t*)a;
31
ets_printf("%08x: ", a);
32
for (i = 0; i < 8; i++)
33
ets_printf("%08x ", *ptr++);
37
void timer_action(void *arg)
39
system_os_post(user_procTaskPrio, 0, 0 );
42
void some_timerfunc(void *arg)
45
if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT2)
48
gpio_output_set(0, BIT2, BIT2, 0);
53
gpio_output_set(BIT2, 0, BIT2, 0);
60
ets_printf("Hello World %d!\r\n", i);
65
uint32*ptr = (uint32_t*)0x60000600;
68
for (i = 0; i < 24; i++) {
69
ets_printf("%08x ", *ptr++);
82
_ptrUDPServer = (struct espconn *) os_zalloc(sizeof(struct espconn));
83
_ptrUDPServer->type = ESPCONN_UDP;
84
_ptrUDPServer->state = ESPCONN_NONE;
85
_ptrUDPServer->proto.udp = (esp_udp *) os_zalloc(sizeof(esp_udp));
86
_ptrUDPServer->proto.udp->local_port = espconn_port();
87
_ptrUDPServer->proto.udp->remote_port = 2115;
88
os_memcpy(_ptrUDPServer->proto.udp->remote_ip, udpServerIP, 4);
89
espconn_create(_ptrUDPServer);
93
os_sprintf(USER_DATA, "%07d\n", i);
94
espconn_sent(_ptrUDPServer, (uint8 *) USER_DATA, (uint16) strlen(USER_DATA));
96
system_os_post(user_procTaskPrio, 0, 0 );
100
static void ICACHE_FLASH_ATTR
101
user_procTask(os_event_t *e)
106
swapforth2(e->sig, e->par);
112
#include "uart_register.h"
115
uart0_rx_intr_handler(void *para)
118
gpio_output_set(BIT2, 0, BIT2, 0);
120
if (UART_RXFIFO_FULL_INT_ST != (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_FULL_INT_ST)) {
124
WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR);
126
if (READ_PERI_REG(UART_STATUS(UART0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
127
uint8 RcvChar = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;
130
system_os_post(user_procTaskPrio, 0x947, RcvChar );
134
#define BAUDRATE 921600
137
uart_config(uint8 uart_no)
139
if (uart_no == UART1) {
140
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
143
ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, NULL);
144
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
145
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
148
uart_div_modify(uart_no, UART_CLK_FREQ / BAUDRATE);
152
SET_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST);
153
CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST);
156
WRITE_PERI_REG(UART_CONF1(uart_no), (1 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S);
159
WRITE_PERI_REG(UART_INT_CLR(uart_no), 0xffff);
161
SET_PERI_REG_MASK(UART_INT_ENA(uart_no), UART_RXFIFO_FULL_INT_ENA);
163
ETS_UART_INTR_ENABLE();
168
const char ssid[32] = "bowmanvilleshed";
169
const char password[64] = "qwertyui";
170
wifi_station_get_connect_status();
171
struct station_config stationConf;
173
wifi_set_opmode(STATION_MODE);
174
stationConf.bssid_set = 0;
175
os_memcpy(&stationConf.ssid, ssid, 32);
176
os_memcpy(&stationConf.password, password, 64);
177
wifi_station_set_config(&stationConf);
182
void ICACHE_FLASH_ATTR
185
system_set_os_print(0);
186
uart_div_modify(0, UART_CLK_FREQ / BAUDRATE);
194
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
197
gpio_output_set(0, BIT2, BIT2, 0);
201
os_timer_disarm(&some_timer);
204
os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);
212
os_timer_disarm(&some_timer);
213
os_timer_setfn(&some_timer, (os_timer_func_t *)timer_action, NULL);
217
system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
220
for (j = 0; j < 2000; j++)
232
os_timer_arm(&some_timer, 2000, 1);