Exemplo n.º 1
0
extern "C" void user_init(void)
{
    sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
    
    // give the UART some time to settle
    sdk_os_delay_us(500);
    
    printf("\n\n");
    printf("*****\n");
    printf("START\n");
    printf("*****\n");
    printf("SDK version : %s\n\n", sdk_system_get_sdk_version());
    
    // get our 1 second clock running
    esp_start_system_time();

    if(mqtt_pub.m_Mqtt_payload.init(4) != 0) {
        printf("main(): mqtt_pub.m_Mqtt_payload.init(4) != 0\n");
    }
#if defined(WITH_SMARTLINK)
    if(wifi_global.init(esp_open_rtos::wifi::wifi_t::mode_smartlink) != 0) {
        printf("main(): wifi_global.init() != 0\n");
    }
//#elif defined(WITH_SMARTWEB)
//    if(wifi_global.init() != 0) {
//        printf("main(): wifi_global.init() != 0\n");
//    }
#else
    if(wifi_global.init(WIFI_SSID, WIFI_PASS) != 0) {
        printf("main(): wifi_global.init(WIFI_SSID, WIFI_PASS) != 0\n");
    }
#endif
    else if(wifi_global.task_create("wifi") != 0) {
        printf("main(): wifi_global.task_create(wifi) != 0\n");
    }
    //else if(mdns.init(wifi_global) != 0) {
    //    printf("main(): mdns.init(wifi_global) != 0\n");
    //}
    //else if(mdns.task_create("mdns_task") != 0) {
    //    printf("main(): mdns.task_create(mdns_task) != 0\n");
    //}
    //else if(mqtt_client1.init(mqtt_pub.m_Mqtt_payload.mqtt_queue(), wifi_global, "test.mosquitto.org") != 0) {
    //    printf("main(): mqtt_client1.init(mqtt_pub.m_Mqtt_payload.mqtt_queue(), wifi_global, test.mosquitto.org) != 0\n");
    //}
    //else if(mqtt_client2.init(mqtt_pub.m_Mqtt_payload.mqtt_queue(), wifi_global, "192.168.1.82") != 0) {
        //printf("main(): \n");
    //}
    //else if(mqtt_client1.task_create("MQTT_task_1") != 0) {
    //    printf("main(): mqtt_client1.task_create(MQTT_task_1) != 0\n");
    //}
    ////else if(mqtt_client2.task_create("MQTT_task_2") != 0) {
    ////    printf("main(): mqtt_client2.task_create(MQTT_task_2) != 0\n");
    ////}
    //else if(mqtt_pub.init(mqtt_client1) != 0) {
    //    printf("main(): mqtt_pub.init(mqtt_client1) != 0\n");
    //}
    //else if(mqtt_pub.task_create("mqtt_pub_1") != 0) {
    //    printf("main(): mqtt_pub.task_create(mqtt_pub_1) != 0\n");
    //}
}
Exemplo n.º 2
0
extern "C" void user_init(void)
{
    sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
	
    MyQueue.queue_create(10);
    
    task_1.queue = MyQueue;
    task_2.queue = MyQueue;
    
    task_1.task_create("tsk1");
    task_2.task_create("tsk2");
}
Exemplo n.º 3
0
void user_init(void) {
    lastTick = xTaskGetTickCount();
    startMem = lastMem = xPortGetFreeHeapSize();

    sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
    
    setbuf(stdin, NULL);
    setbuf(stdout, NULL);

    // this doesn't have enough stack!
    //lispTask(NULL); return;

    // for now run in a task, in order to allocate a bigger stack
    // 1024 --> (fibo 13)
    // 2048 --> (fibo 30) ???
    xTaskCreate(lispTask, (signed char *)"lispTask", 2048, NULL, 2, NULL);
}
Exemplo n.º 4
0
void user_init(void)
{
    sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
    xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL);

    TIMER(0).CTRL = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256) | TIMER_CTRL_RELOAD;
    TIMER(0).LOAD = 0x200000;

    TIMER(1).LOAD = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256);

    DPORT.INT_ENABLE |= DPORT_INT_ENABLE_TIMER0 | DPORT_INT_ENABLE_TIMER1;
    _xt_isr_attach(INUM_TIMER_FRC1, frc1_handler);
    _xt_isr_unmask(1<<INUM_TIMER_FRC1);
    _xt_isr_attach(INUM_TIMER_FRC2, frc2_handler);
    _xt_isr_unmask(1<<INUM_TIMER_FRC2);

    TIMER(0).CTRL |= TIMER_CTRL_RUN;
    TIMER(1).CTRL |= TIMER_CTRL_RUN;

    dump_timer_regs("timer regs during user_init");
    dump_timer_regs("#2 timer regs during user_init");
    dump_timer_regs("#3 timer regs during user_init");
}
Exemplo n.º 5
0
void user_init(void)
{
    sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
    xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL);

    TIMER_FRC1_CTRL_REG = TIMER_CTRL_DIV_256|TIMER_CTRL_INT_EDGE|TIMER_CTRL_RELOAD;
    TIMER_FRC1_LOAD_REG = 0x200000;

    TIMER_FRC2_CTRL_REG = TIMER_CTRL_DIV_256|TIMER_CTRL_INT_EDGE;

    DP_INT_ENABLE_REG |= INT_ENABLE_FRC1|INT_ENABLE_FRC2;
    _xt_isr_attach(INUM_TIMER_FRC1, frc1_handler);
    _xt_isr_unmask(1<<INUM_TIMER_FRC1);
    _xt_isr_attach(INUM_TIMER_FRC2, frc2_handler);
    _xt_isr_unmask(1<<INUM_TIMER_FRC2);

    TIMER_FRC1_CTRL_REG |= TIMER_CTRL_RUN;
    TIMER_FRC2_CTRL_REG |= TIMER_CTRL_RUN;

    dump_timer_regs("timer regs during user_init");
    dump_timer_regs("#2 timer regs during user_init");
    dump_timer_regs("#3 timer regs during user_init");
}
Exemplo n.º 6
0
void user_init(void)
{
    sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
    printf("\n\n\n");
    printf("SDK version:%s\n", sdk_system_get_sdk_version());
    cli_init();

#ifndef CONFIG_NO_WIFI
    struct sdk_station_config config = {
        .ssid = WIFI_SSID,
        .password = WIFI_PASS,
    };

    /* required to call wifi_set_opmode before station_set_config */
    sdk_wifi_set_opmode(STATION_MODE);
    sdk_wifi_station_set_config(&config);
#endif // CONFIG_NO_WIFI

    xTaskCreate(&server_task, (signed char *) "server_task", 256, NULL, 2, NULL);
#ifndef CONFIG_NO_PIR
    xTaskCreate(&pir_task, (signed char *) "pir_task", 256, NULL, 2, NULL);
#endif // CONFIG_NO_PIR
}