예제 #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");
    //}
}
예제 #2
0
파일: simple.c 프로젝트: urx/esp-open-rtos
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());
    mainqueue = xQueueCreate(10, sizeof(uint32_t));
    xTaskCreate(task1, "tsk1", 256, &mainqueue, 2, NULL);
    xTaskCreate(task2, "tsk2", 256, &mainqueue, 2, NULL);
}
예제 #3
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    sdk_wifi_set_sleep_type(WIFI_SLEEP_MODEM);

    wificfg_init(80, dispatch_list);
}
예제 #4
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    vSemaphoreCreateBinary(wifi_alive);
    publish_queue = xQueueCreate(3, PUB_MSG_LEN);
    xTaskCreate(&wifi_task, (int8_t *)"wifi_task",  256, NULL, 2, NULL);
    xTaskCreate(&beat_task, (int8_t *)"beat_task", 256, NULL, 3, NULL);
    xTaskCreate(&mqtt_task, (int8_t *)"mqtt_task", 1024, NULL, 4, NULL);
}
예제 #5
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);

    hd44780_t lcd = {
        .i2c_dev.bus = I2C_BUS,
        .i2c_dev.addr = ADDR,
        .font = HD44780_FONT_5X8,
        .lines = 2,
        .pins = {
            .rs = 0,
            .e  = 2,
            .d4 = 4,
            .d5 = 5,
            .d6 = 6,
            .d7 = 7,
            .bl = 3
        },
        .backlight = true
    };

    hd44780_init(&lcd);
    hd44780_upload_character(&lcd, 0, char_data);
    hd44780_upload_character(&lcd, 1, char_data + 8);

    hd44780_gotoxy(&lcd, 0, 0);
    hd44780_puts(&lcd, "\x08 Hello world!");
    hd44780_gotoxy(&lcd, 0, 1);
    hd44780_puts(&lcd, "\x09 ");

    char time[16];

    while (true)
    {
        hd44780_gotoxy(&lcd, 2, 1);

        snprintf(time, 7, "%u     ", sdk_system_get_time() / 1000000);
        time[sizeof(time) - 1] = 0;

        hd44780_puts(&lcd, time);

        for (uint32_t i = 0; i < 1000; i++)
            sdk_os_delay_us(1000);
    }
}
예제 #6
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    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);

    xTaskCreate(&http_get_task, (signed char *)"get_task", 256, NULL, tskIDLE_PRIORITY+1, NULL);
}
예제 #7
0
void user_init(void)
{
    uart_set_baud(0, 115200);

    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    // Set led to indicate wifi status.
    sdk_wifi_status_led_install(2, PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);

    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);

    xTaskCreate(&broadcast_temperature, "broadcast_temperature", 256, NULL, 2, NULL);
}
예제 #8
0
void user_init(void)
{
    uint8_t pins[1];
    uart_set_baud(0, 115200);

    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    printf("pwm_init(1, [14])\n");
    pins[0] = 14;
    pwm_init(1, pins);

    printf("pwm_set_freq(1000)     # 1 kHz\n");
    pwm_set_freq(1000);

    printf("pwm_set_duty(UINT16_MAX/2)     # 50%%\n");
    pwm_set_duty(UINT16_MAX/2);

    printf("pwm_start()\n");
    pwm_start();

    xTaskCreate(task1, (signed char *)"tsk1", 256, NULL, 2, NULL);
}
예제 #9
0
void user_init(void)
{
    i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);

    uart_set_baud(0, 115200);
    printf("SDK version:%s\n\n", sdk_system_get_sdk_version());

    ms561101ba03_t device = {
        .i2c_dev.bus = I2C_BUS,
        .i2c_dev.addr = MS561101BA03_ADDR_CSB_LOW,
        .osr  = MS561101BA03_OSR_4096,
    };

    while (!ms561101ba03_init(&device))
        printf("Device not found\n");

    while (true)
    {
        if (!ms561101ba03_get_sensor_data(&device))
            printf("Error reading sensor data from device");
        printf("Temperature in C * 100: %i \nPressure in mbar * 100: %i\n", device.result.temperature, device.result.pressure);
    }
}
예제 #10
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
}
예제 #11
0
void user_init(void)
{
    // Setup HW
    user_setup();

    // Just some infomations
    printf("\n");
    printf("SDK version : %s\n", sdk_system_get_sdk_version());
    printf("GIT version : %s\n", GITSHORTREV);

    // Use our user inform implementation
    bmp180_informUser = bmp180_i2c_informUser;

    // Init BMP180 Interface
    bmp180_init(SCL_PIN, SDA_PIN);

    // Create Main Communication Queue
    mainqueue = xQueueCreate(10, sizeof(my_event_t));

    // Create user interface task
    xTaskCreate(bmp180_task, (const char * const)"bmp180_task", 256, &mainqueue, 2, NULL);

    // Create Timer (Trigger a measurement every second)
    timerHandle = xTimerCreate((const char * const)"BMP180 Trigger", 1000/portTICK_RATE_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);

    if (timerHandle != NULL)
    {
        if (xTimerStart(timerHandle, 0) != pdPASS)
        {
            printf("%s: Unable to start Timer ...\n", __FUNCTION__);
        }
    }
    else
    {
        printf("%s: Unable to create Timer ...\n", __FUNCTION__);
    }
}
예제 #12
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    i2c_init(SCL_PIN, SDA_PIN);

    // setup EEPROM values
    if (mcp4725_get_power_mode(ADDR, true) != MCP4725_PM_NORMAL)
    {
        printf("DAC was sleeping... Wake up Neo!\n");
        mcp4725_set_power_mode(ADDR, MCP4725_PM_NORMAL, true);
        wait_for_eeprom();
    }

    printf("Set default DAC ouptut value to MAX...\n");
    mcp4725_set_raw_output(ADDR, MCP4725_MAX_VALUE, true);
    wait_for_eeprom();

    printf("And now default DAC output value is 0x%03x\n", mcp4725_get_raw_output(ADDR, true));

    printf("Now let's generate the sawtooth wave in slow manner\n");

    float vout = 0;
    while (true)
    {
        vout += 0.1;
        if (vout > VDD) vout = 0;

        printf("Vout: %.02f\n", vout);
        mcp4725_set_voltage(ADDR, VDD, vout, false);

        // It will be very low freq wave
        vTaskDelay(100 / portTICK_PERIOD_MS);
    }
}
예제 #13
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());
    xTaskCreate(loop, "loop", 1024, NULL, 2, NULL);
}
예제 #14
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());
    xTaskCreate(json_test, (signed char *)"jsont", 1024, NULL, 2, NULL);
}
예제 #15
0
extern "C" void user_init(void)
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());
    xTaskCreate(task1, (signed char *)"tsk1", 256, NULL, 2, NULL);
}
예제 #16
0
void user_init(void)
{
#if (OVERCLOCK)
    sdk_system_update_cpu_freq(160);
#endif

    // Setup HW
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

#if (I2C_CONNECTION)
    i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_400K);
#else
#if (CS_PIN == 15)
    spi_init(SPI_BUS, SPI_MODE0, SPI_FREQ_DIV_8M, true, SPI_LITTLE_ENDIAN, false);
#else
    spi_init(SPI_BUS, SPI_MODE0, SPI_FREQ_DIV_8M, true, SPI_LITTLE_ENDIAN, true);
    gpio_enable(CS_PIN, GPIO_OUTPUT);
#endif
#endif
#if (RST_PIN != LV_DRIVER_NOPIN)
    gpio_enable(RST_PIN, GPIO_OUTPUT);
#endif

    /*Gui initialization*/
    lv_init();

    /*Screen initialization*/
#if (I2C_CONNECTION)
    dev.i2c_dev = (lv_i2c_handle_t)&i2c_dev;
#else
    dev.spi_dev = (lv_spi_handle_t)&spi_dev;
#endif
    dev.protocol = PROTOCOL ; //SSD1306_PROTO_SPI3;
    dev.screen   = SH1106_SCREEN; //SSD1306_SCREEN,  SH1106_SCREEN
    dev.width    = LV_HOR_RES;
    dev.height   = LV_VER_RES;
    dev.rst_pin  = RST_PIN; //No RST PIN USED

    while (ssd1306_init(&dev) != 0) {
        printf("%s: failed to init SSD1306 lcd\n", __func__);
        vTaskDelay(SECOND);
    }

    ssd1306_set_whole_display_lighting(&dev, true);

    /*inverse screen (180°) */
    ssd1306_set_scan_direction_fwd(&dev,true);
    ssd1306_set_segment_remapping_enabled(&dev, false);
    vTaskDelay(SECOND);

    /*lvgl screen registration */
    lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    /*Set up the functions to access to your display*/
    disp_drv.disp_flush = ssd1306_flush; /*Used in buffered mode (LV_VDB_SIZE != 0  in lv_conf.h)*/
    disp_drv.disp_fill = NULL;//ex_disp_fill;   /*Used in unbuffered mode (LV_VDB_SIZE == 0  in lv_conf.h)*/
    disp_drv.disp_map = NULL;//ex_disp_map;    /*Used in unbuffered mode (LV_VDB_SIZE == 0  in lv_conf.h)*/
    disp_drv.vdb_wr = ssd1306_vdb_wr;
    lv_disp_drv_register(&disp_drv);

    /* Create user interface task */
    xTaskCreate(ssd1306_task, "ssd1306_task", 512, NULL, 2, NULL);

    font_timer_handle = xTimerCreate("font_timer", 5 * SECOND, pdTRUE, NULL, font_timer);
    xTimerStart(font_timer_handle, 0);

#if (!TICK_HANDLER && !LV_TICK_CUSTOM)
    lvgl_timer_handle = xTimerCreate("lvgl_timer", TICK_INC_MS/portTICK_PERIOD_MS, pdTRUE, NULL, lvgl_timer);
    xTimerStart(lvgl_timer_handle, 0);
#endif
}