示例#1
0
struct netif * ICACHE_FLASH_ATTR eagle_lwip_if_alloc(struct ieee80211_conn *conn, uint8 *macaddr, struct ip_info *info)
{
	struct netif *myif = conn->myif;
    if (myif == NULL) {
        myif = (void *) pvPortMalloc(sizeof(struct netif)); // SDK 1.1.2 : pvPortZalloc(64)
        conn->myif = myif;
    }
    if(myif == NULL) return NULL;
    if (conn->dhcps_if == 0) { // +176
        if(default_hostname) {
    		wifi_station_set_default_hostname(macaddr);
    	}
    	myif->hostname = hostname; // +40
    }
    else myif->hostname = NULL; // +40

    myif->state = conn; // +28
    myif->name[0] = 'e'; // + 54
    myif->name[1] = 'w'; // + 55
    myif->output = etharp_output; // +20
    myif->linkoutput = ieee80211_output_pbuf; // +24
    ets_memcpy(myif->hwaddr, macaddr, 6); // +47

	ETSEvent *queue = (void *) pvPortMalloc(sizeof(struct ETSEventTag) * QUEUE_LEN); // pvPortZalloc(80)
	if(queue == NULL) return NULL;

    if (conn->dhcps_if != 0) { // +176
	    lwip_if_queues[1] = queue;
	    netif_set_addr(myif, &info->ip, &info->netmask, &info->gw);
	    ets_task(task_if1, LWIP_IF1_PRIO, (ETSEvent *)lwip_if_queues[1], QUEUE_LEN);
	    netif_add(myif, &info->ip, &info->netmask, &info->gw, conn, init_fn, ethernet_input);
	    if(dhcps_flag) {
	    	dhcps_start(info);
	    	os_printf("dhcp server start:(ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR ")\n", IP2STR(&info->ip), IP2STR(&info->netmask), IP2STR(&info->gw));
	    }
    }
    else {
    	lwip_if_queues[0] = queue;
	    ets_task(task_if0, LWIP_IF0_PRIO, (ETSEvent *)lwip_if_queues[0], QUEUE_LEN);
	    struct ip_info ipn;
		if(wifi_station_dhcpc_status()) {
		    ipn.ip.addr = 0;
		    ipn.netmask.addr = 0;
		    ipn.gw.addr = 0;
		}
		else {
			ipn =  *info;
		}
	    netif_add(myif, &ipn.ip, &ipn.netmask, &ipn.gw, conn, init_fn, ethernet_input);
    }
    return myif;
}
示例#2
0
/******************************************************************************
 * FunctionName : espconn_init
 * Description  : used to init the function that should be used when
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR espconn_init(void)
{
  ets_task(espconn_Task, espconn_TaskPrio, espconn_TaskQueue, espconn_TaskQueueLen);
  ets_run();
	// espcon_event_t even;
	// xTaskCreatePinnedToCore(&espconn_Task, "espconn_Task", 4096, &even, 5, NULL, 0);
}
struct netif *
eagle_lwip_if_alloc(struct myif_state *state, u8_t hw[6], ip_addr_t *ips)
{
    struct ETSEventTag *queue;
    struct netif *myif;
    ip_addr_t ipaddr = ips[0];
    ip_addr_t netmask = ips[1];
    ip_addr_t gw = ips[2];

    if (state->myif == NULL) {
        myif = (void *)os_zalloc(sizeof(struct netif));
    }

    myif->state = state;
    myif->name[0] = 'e';
    myif->name[1] = 'w';
    myif->linkoutput = ieee80211_output_pbuf;
    myif->output = etharp_output;
    ets_memcpy(myif->hwaddr, hw, 6);

    queue = (void *) os_malloc(sizeof(struct ETSEventTag) * QUEUE_LEN);

    if (state->dhcps_if == 0) {
#if LWIP_NETIF_HOSTNAME
#ifdef LWIP_NETIF_HOSTNAME_PREFIX
        myif->hostname = os_malloc(sizeof(LWIP_NETIF_HOSTNAME_PREFIX)+10);
        os_sprintf(myif->hostname, "%s%02x%02x%02x", LWIP_NETIF_HOSTNAME_PREFIX,
                myif->hwaddr[3], myif->hwaddr[4], myif->hwaddr[5]);
#endif
#endif

        ets_task(task_if0, TASK_IF0_PRIO, queue, QUEUE_LEN);
    } else {
        netif_set_addr(myif, &ipaddr, &netmask, &gw);
        if (dhcps_flag != 0) {
            dhcps_start((struct ip_info *)ips);
            os_printf("dhcp server start:(ip:%08x,mask:%08x,gw:%08x)\n",
                    ipaddr.addr, netmask.addr, gw.addr);
        }

        ets_task(task_if1, TASK_IF1_PRIO, queue, QUEUE_LEN);
    }

    netif_add(myif, &ipaddr, &netmask, &gw, state, init_fn, ethernet_input);

    return myif;
}
示例#4
0
文件: wdt.c 项目: Postlast/webscale
void ICACHE_FLASH_ATTR wdt_init(void)
{
//	RTC_MEM(0) = 0;
	ets_task(wdt_task, WDT_TASK_PRIO, &wdt_eventq, 1);
	ets_isr_attach(ETS_WDT_INUM , wdt_feed, NULL);
	INTC_EDGE_EN |= 1; // 0x3ff00004 |= 1
	ets_wdt_enable(2,3,3); // mode 2 (wdt isr), step 1680403 us
}
示例#5
0
// Timer init func is in ROM, and calls ets_task by relative addr directly in ROM
// so, we have to re-init task using our handler
void ets_timer_init() {
    printf("ets_timer_init\n");
//    _ets_timer_init();
    ets_isr_attach(10, my_timer_isr, NULL);
    SET_PERI_REG_MASK(0x3FF00004, 4);
    ETS_INTR_ENABLE(10);
    ets_task((os_task_t)0x40002E3C, 0x1f, (os_event_t*)0x3FFFDDC0, 4);

    WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + 0x30, 0);
    WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + 0x28, 0x88);
    WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + 0x30, 0);
    printf("Installed timer ISR\n");
}
示例#6
0
extern "C" void user_init(void) {
    struct rst_info *rtc_info_ptr = system_get_rst_info();
    memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));

    uart_div_modify(0, UART_CLK_FREQ / (115200));

    init();

    initVariant();

    cont_init(g_pcont);

    ets_task(loop_task,
        LOOP_TASK_PRIORITY, s_loop_queue,
        LOOP_QUEUE_SIZE);

    system_init_done_cb(&init_done);
}
示例#7
0
void twi_init(unsigned char sda, unsigned char scl)
{
  // set timer function
  ets_timer_setfn(&timer, onTimer, NULL);

  // create event task
  ets_task(eventTask, EVENTTASK_QUEUE_PRIO, eventTaskQueue, EVENTTASK_QUEUE_SIZE);

  twi_sda = sda;
  twi_scl = scl;
  pinMode(twi_sda, INPUT_PULLUP);
  pinMode(twi_scl, INPUT_PULLUP);
  twi_setClock(preferred_si2c_clock);
  twi_setClockStretchLimit(230); // default value is 230 uS

  if (twi_addr != 0)
  {
	attachInterrupt(scl, onSclChange, CHANGE);
	attachInterrupt(sda, onSdaChange, CHANGE);
  }
}
示例#8
0
struct netif * ICACHE_FLASH_ATTR
eagle_lwip_if_alloc(struct myif_state *state, u8_t hw[6], struct ip_info * ips)
{
#if 1 // optimize ...
    struct netif *myif = state->myif;
    if (myif == NULL) {
        myif = (void *) pvPortMalloc(sizeof(struct netif)); // pvPortZalloc(60)
        state->myif = myif;
    }
    myif->state = state; // +28
    myif->name[0] = 'e'; // +50
    myif->name[1] = 'w'; // +51
    myif->linkoutput = ieee80211_output_pbuf; // +24
    myif->output = etharp_output; // +20
    ets_memcpy(myif->hwaddr, hw, 6); // +43

	ETSEvent *queue = (void *) pvPortMalloc(sizeof(struct ETSEventTag) * QUEUE_LEN); // pvPortZalloc(80)
    if (state->dhcps_if != 0) { // +176
	    lwip_if_queues[1] = queue;
	    netif_set_addr(myif, &ips->ip, &ips->netmask, &ips->gw);
	    ets_task(task_if1, TASK_IF1_PRIO, (ETSEvent *)lwip_if_queues[1], QUEUE_LEN);
	    netif_add(myif, &ips->ip, &ips->netmask, &ips->gw, state, init_fn, ethernet_input);
	    if(dhcps_flag) {
	    	dhcps_start(ips);
//	    	os_printf("dhcp server start:(ip:%08x,mask:%08x,gw:%08x)\n", ips->ip.addr, ips->netmask.addr, ips->gw.addr);
	    }
    }
    else {
    	lwip_if_queues[0] = queue;
	    ets_task(task_if0, TASK_IF0_PRIO, (ETSEvent *)lwip_if_queues[0], QUEUE_LEN);
	    struct ip_info ipn;
		if(wifi_station_dhcpc_status()) {
			ipn =  *ips;
		}
		else {
		    ipn.ip.addr = 0;
		    ipn.netmask.addr = 0;
		    ipn.gw.addr = 0;
		}
	    netif_add(myif, &ipn.ip, &ipn.netmask, &ipn.gw, state, init_fn, ethernet_input);
    }
    return myif;
#else // source
	ETSEvent *queue;
    ip_addr_t ipaddr;
    ip_addr_t netmask;
    ip_addr_t gw;
    struct netif *myif = state->myif;

    if (myif == NULL) {
        myif = (void *) pvPortMalloc(sizeof(struct netif)); // pvPortZalloc(60)
        state->myif = myif;
    }
    myif->state = state; // +28
    myif->name[0] = 'e'; // +50
    myif->name[1] = 'w'; // +51
    myif->linkoutput = ieee80211_output_pbuf; // +24
    myif->output = etharp_output; // +20
    ets_memcpy(myif->hwaddr, hw, 6); // +43

    if (state->dhcps_if != 0) { // +176
	    ipaddr = ips->ip;
	    netmask = ips->netmask;
	    gw = ips->gw;
	    netif_set_addr(myif, &ipaddr, &netmask, &gw);
	    queue = (void *) pvPortMalloc(sizeof(struct ETSEventTag) * QUEUE_LEN); // pvPortZalloc(80)
	    lwip_if_queues[1] = queue;
	    ets_task(task_if1, TASK_IF1_PRIO, (ETSEvent *)queue, QUEUE_LEN);
	    netif_add(myif, &ipaddr, &netmask, &gw, state, init_fn, ethernet_input);
	    if(dhcps_flag) {
	    	dhcps_start(ips);
//	    	os_printf("dhcp server start:(ip:%08x,mask:%08x,gw:%08x)\n", ipaddr.addr, netmask.addr, gw.addr);
	    }

    }
    else {
    	if(wifi_station_dhcpc_status()) {
    	    ipaddr = ips->ip;
    	    netmask = ips->netmask;
    	    gw = ips->gw;
    	}
    	else {
        	ipaddr.addr = 0;
        	netmask.addr = 0;
        	gw.addr = 0;
    	}
	    queue = (void *) pvPortMalloc(sizeof(struct ETSEventTag) * QUEUE_LEN); // pvPortZalloc(80)
	    lwip_if_queues[0] = queue;
	    ets_task(task_if0, TASK_IF0_PRIO, (ETSEvent *)queue, QUEUE_LEN);
	    netif_add(myif, &ipaddr, &netmask, &gw, state, init_fn, ethernet_input);
    }
    return myif;
#endif
}
示例#9
0
/******************************************************************************
 * FunctionName : espconn_init
 * Description  : used to init the function that should be used when
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR espconn_init(void)
{
  ets_task(espconn_Task, espconn_TaskPrio, espconn_TaskQueue, espconn_TaskQueueLen);
}