Пример #1
0
void user_init(void)
{
    uart_set_baud(0, 115200);

    /* configure GPIOs */
    gpio_enable(gpio_frc1, GPIO_OUTPUT);
    gpio_enable(gpio_frc2, GPIO_OUTPUT);
    gpio_write(gpio_frc1, 1);

    /* stop both timers and mask their interrupts as a precaution */
    timer_set_interrupts(FRC1, false);
    timer_set_run(FRC1, false);
    timer_set_interrupts(FRC2, false);
    timer_set_run(FRC2, false);

    /* set up ISRs */
    _xt_isr_attach(INUM_TIMER_FRC1, frc1_interrupt_handler);
    _xt_isr_attach(INUM_TIMER_FRC2, frc2_interrupt_handler);

    /* configure timer frequencies */
    timer_set_frequency(FRC1, freq_frc1);
    timer_set_frequency(FRC2, freq_frc2);

    /* unmask interrupts and start timers */
    timer_set_interrupts(FRC1, true);
    timer_set_run(FRC1, true);
    timer_set_interrupts(FRC2, true);
    timer_set_run(FRC2, true);

    gpio_write(gpio_frc1, 0);
}
Пример #2
0
void user_init(void)
{
    uart_set_baud(0, 115200);

    rboot_config conf = rboot_get_config();
    printf("esp-gizmo. Running on flash slot %d / %d\n",
           conf.current_rom, conf.count);

    key_task_init();
    load_driver_init();
    mqtt_task_init();

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

    printf("Starting TFTP server...");
    ota_tftp_init_server(TFTP_PORT);

    xTaskCreate(main_task, "main", 1024, NULL, 1, NULL);
    xTaskCreate(health_state, "health_state", 512, NULL, 1, NULL);
}
Пример #3
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);

    xTaskCreate(tsl4531MeasurementTask, "tsl4531MeasurementTask", 256, NULL, 2, NULL);
}
Пример #4
0
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);
}
Пример #5
0
// Setup HW
void user_setup(void)
{
    // Set UART Parameter
    uart_set_baud(0, 115200);

    // Give the UART some time to settle
    sdk_os_delay_us(500);
}
extern "C" void user_init(void)
{
    uart_set_baud(0, 115200);

    user.xQueue = xQueueCreate(2, sizeof(uint32_t));
    xTaskCreate(readTask, (signed char *)"readTask", 256, &user, tskIDLE_PRIORITY+1, NULL);
    xTaskCreate(transmitTask, (signed char*)"transmitTask", 256, &user, tskIDLE_PRIORITY, &user.xHandle);
}
Пример #7
0
void user_init(void) {
    uart_set_baud(0, 115200);

    wifi_init();
    if (button_create(BUTTON_PIN, button_callback)) {
        printf("Failed to initialize button\n");
    }
    homekit_server_init(&config);
}
Пример #8
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);
}
Пример #9
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    gpio_enable(gpio, GPIO_INPUT);
    gpio_enable(gpio_blink, GPIO_OUTPUT);

    tsqueue = xQueueCreate(2, sizeof(uint32_t));
    xTaskCreate(buttonIntTask, (signed char *)"buttonIntTask", 256, &tsqueue, 2, NULL);
    xTaskCreate(buttonPollTask, (signed char*)"buttonPollTask", 256, NULL, 1, NULL);
}
Пример #10
0
void main()
{
	char command; 
	uart_set_baud(1200);
	while(1)
	{
		command = uart_getkey();
		lcd("Key Value: %c  ",command);
	}
}
Пример #11
0
void user_init(void)
{
    // Set UART Parameter.
    uart_set_baud(0, 115200);
    // Give the UART some time to settle
    vTaskDelay(1);
    
    /** -- MANDATORY PART -- */

    #ifdef SPI_USED

    spi_bus_init (SPI_BUS, SPI_SCK_GPIO, SPI_MISO_GPIO, SPI_MOSI_GPIO);

    // init the sensor connected to SPI_BUS with SPI_CS_GPIO as chip select.
    sensor = bme680_init_sensor (SPI_BUS, 0, SPI_CS_GPIO);
    
    #else  // I2C

    // Init all I2C bus interfaces at which BME680 sensors are connected
    i2c_init(I2C_BUS, I2C_SCL_PIN, I2C_SDA_PIN, I2C_FREQ);

    // init the sensor with slave address BME680_I2C_ADDRESS_2 connected to I2C_BUS.
    sensor = bme680_init_sensor (I2C_BUS, BME680_I2C_ADDRESS_2, 0);

    #endif  // SPI_USED

    if (sensor)
    {
        /** -- SENSOR CONFIGURATION PART (optional) --- */

        // Changes the oversampling rates to 4x oversampling for temperature
        // and 2x oversampling for humidity. Pressure measurement is skipped.
        bme680_set_oversampling_rates(sensor, osr_4x, osr_none, osr_2x);

        // Change the IIR filter size for temperature and pressure to 7.
        bme680_set_filter_size(sensor, iir_size_7);

        // Change the heater profile 0 to 200 degree Celcius for 100 ms.
        bme680_set_heater_profile (sensor, 0, 200, 100);
        bme680_use_heater_profile (sensor, 0);

        // Set ambient temperature to 10 degree Celsius
        bme680_set_ambient_temperature (sensor, 10);
            
        /** -- TASK CREATION PART --- */

        // must be done last to avoid concurrency situations with the sensor 
        // configuration part

        // Create a task that uses the sensor
        xTaskCreate(user_task, "user_task", TASK_STACK_DEPTH, NULL, 2, NULL);
    }
    else
        printf("Could not initialize BME680 sensor\n");
}
Пример #12
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);
}
Пример #13
0
void
user_init(void)
{
    uart_set_baud(0, 115200);
    sdk_wifi_set_opmode(STATION_MODE);
    /*
     * Run at a high enough priority so that the initial time-set doesn't get interrupted
     * Later calls and listen-only mode calls run in the high-priority "tcpip_thread" (LWIP)
     *
     * While 196 heap seemed sufficient for many tests, use of an NTP pool
     * with DNS caused heap errors/warnings on starting NTP at 256 heap
     */
    xTaskCreate(sntp_task, "SNTP task", 288, NULL, 6, NULL);
}
Пример #14
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);
    }
}
Пример #15
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);
}
Пример #16
0
void user_init(void)
{
    // Set UART Parameter
    uart_set_baud(0, 115200);
    // Give the UART some time to settle
    sdk_os_delay_us(500);

    /** -- MANDATORY PART -- */

    // Init all I2C bus interfaces at which BME680 sensors are connected
    i2c_init(I2C_BUS, I2C_SCL_PIN, I2C_SDA_PIN, I2C_FREQ_100K);

    // Init the sensors
    sensor1 = bme680_init_sensor (I2C_BUS, BME680_I2C_ADDRESS_2, 0);
    sensor2 = bme680_init_sensor (SPI_BUS, 0, SPI_CS_GPIO);

    if (sensor1 && sensor2)
    {
        /** -- SENSOR CONFIGURATION PART (optional) --- */

        // Changes the oversampling rates for both sensor to different values
        bme680_set_oversampling_rates(sensor1, osr_4x, osr_2x, osr_1x);
        bme680_set_oversampling_rates(sensor2, osr_8x, osr_8x, osr_8x);

        // Change the IIR filter size for temperature and and pressure to 7.
        bme680_set_filter_size(sensor1, iir_size_7);
        bme680_set_filter_size(sensor2, iir_size_7);

        // Change the heater profile 0 to 200 degree Celcius for 150 ms.
        bme680_set_heater_profile (sensor1, 0, 200, 150);
        bme680_set_heater_profile (sensor2, 0, 200, 150);

        // Activate the heater profile 0
        bme680_use_heater_profile (sensor1, 0);
        bme680_use_heater_profile (sensor2, 0);

        /** -- TASK CREATION PART --- */

        // must be done last to avoid concurrency situations with the sensor 
        // configuration part

        // Create the tasks that use the sensors
        xTaskCreate(user_task_sensor1, "user_task_sensor1", 256, NULL, 2, 0);
        xTaskCreate(user_task_sensor2, "user_task_sensor2", 256, NULL, 2, 0);
    }
}
Пример #17
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);
}
Пример #18
0
void uart_setup()
{
    uart_disable;

    // configure transmission
    nrf_gpio_pin_dir_set(PIN_UART_TXD, NRF_GPIO_PIN_DIR_OUTPUT);
    uart_select_pin_as_TXD(PIN_UART_TXD);
    uart_select_pin_as_RTS(UART_PIN_DISABLE);
    uart_select_pin_as_CTS(UART_PIN_DISABLE);
    uart_set_baud(baud_9600);
    uart_set_parity_exclude;
    uart_flow_control_enable;

    // configure reception
    uart_select_pin_as_RXD(PIN_UART_RXD);
    uart_interrupt_upon_RXDRDY_enable;
    uart_interrupt_upon_RXTO_enable;
    uart_interrupt_upon_ERROR_enable;
    uart_start_receiver;

    uart_enable;
}
Пример #19
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);
}
Пример #20
0
void user_init(void)
{
    uart_set_baud(0, 115200);

    midea_ir_init(&ir, 14);
    config_init();

    rboot_config conf = rboot_get_config();
    printf("Currently running on flash slot %d / %d\n",
           conf.current_rom, conf.count);

    printf("Image addresses in flash:\n");
    for(int i = 0; i <conf.count; i++) {
        printf("%c%d: offset 0x%08x\n", i == conf.current_rom ? '*':' ', i,
                conf.roms[i]);
    }
    start_config_server();

    xTaskCreate(main_task, (signed char *)"main", 512, NULL, 4, NULL);
    /* xTaskCreate(test_task, (signed char *)"test", 512, NULL, 2, NULL); */

    ota_tftp_init_server(TFTP_PORT);
}
Пример #21
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);
    }
}
Пример #22
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);
    }
}
Пример #23
0
void play_task(void *pvParameters)
{
    esp_spiffs_init();
    if (esp_spiffs_mount() != SPIFFS_OK) {
        printf("Error mount SPIFFS\n");
    }

    int fd = open("sample.wav", O_RDONLY);

    if (fd < 0) {
        printf("Error opening file\n");
        return;
    }

    dumb_wav_header_t wav_header;
    read(fd, (void*)&wav_header, sizeof(wav_header));
    printf("Number of channels: %d\n", wav_header.num_channels);
    printf("Bits per sample: %d\n", wav_header.bits_per_sample);
    printf("Sample rate: %d\n", wav_header.sample_rate);
    printf("Data size: %d\n", wav_header.data_size);

    if (wav_header.bits_per_sample != 16) {
        printf("Only 16 bit per sample is supported\n");
        return;
    }

    if (wav_header.num_channels != 2) {
        printf("Only 2 channels is supported\n");
        return;
    }

    i2s_clock_div_t clock_div = i2s_get_clock_div(
            wav_header.sample_rate * 2 * 16);

    printf("i2s clock dividers, bclk=%d, clkm=%d\n",
            clock_div.bclk_div, clock_div.clkm_div);

    i2s_pins_t i2s_pins = {.data = true, .clock = true, .ws = true};

    i2s_dma_init(dma_isr_handler, clock_div, i2s_pins);

    while (1) {
        init_descriptors_list();

        i2s_dma_start(dma_block_list);
        lseek(fd, sizeof(dumb_wav_header_t), SEEK_SET);

        while (play_data(fd)) {};
        i2s_dma_stop();

        vQueueDelete(dma_queue);

        printf("underrun counter: %d\n", underrun_counter);

        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }

    close(fd);
}

void user_init(void)
{
    uart_set_baud(0, 115200);

    xTaskCreate(play_task, "test_task", 1024, NULL, 2, NULL);
}
Пример #24
0
void user_init(void) {
    uart_set_baud(0, 921600);

    printf("\n\nESP8266 UMAC\n\n");

    bridge_init();
    umac_cfg um_cfg = {
        .timer_fn = umac_impl_request_future_tick,
        .cancel_timer_fn = umac_impl_cancel_future_tick,
        .now_fn = umac_impl_now_tick,
        .tx_byte_fn = umac_impl_tx_byte,
        .tx_buf_fn = umac_impl_tx_buf,
        .rx_pkt_fn = umac_impl_rx_pkt,
        .rx_pkt_ack_fn = bridge_pkt_acked,
        .timeout_fn = bridge_timeout,
        .nonprotocol_data_fn = NULL
    };
    umac_init(&um, &um_cfg, rx_buf);

    um_tim_hdl = xTimerCreate(
                     (signed char *)"umac_tim",
                     10,
                     false,
                     (void *)um_tim_id, um_tim_cb);

    char ap_cred[128];
    struct sdk_station_config config;
    bool setup_ap = true;

    systask_init();
    device_id = 0;
    fs_init();
    if (fs_mount() >= 0) {
#if 0
        spiffs_DIR d;
        struct spiffs_dirent e;
        struct spiffs_dirent *pe = &e;

        fs_opendir("/", &d);
        while ((pe = fs_readdir(&d, pe))) {
            printf("%s [%04x] size:%i\n", pe->name, pe->obj_id, pe->size);
        }
        fs_closedir(&d);
#endif

        // read preferred ssid
        spiffs_file fd_ssid = fs_open(".ssid", SPIFFS_RDONLY, 0);
        if (fd_ssid > 0) {
            if (fs_read(fd_ssid, (uint8_t *)ap_cred, sizeof(ap_cred)) > 0) {
                fs_close(fd_ssid);
                char *nl_ix = strchr(ap_cred, '\n');
                if (nl_ix > 0) {
                    memset(&config, 0, sizeof(struct sdk_station_config));
                    strncpy((char *)&config.ssid, ap_cred, nl_ix - ap_cred);
                    char *nl_ix2 = strchr(nl_ix + 1, '\n');
                    if (nl_ix2 > 0) {
                        strncpy((char *)&config.password, nl_ix + 1, nl_ix2 - (nl_ix + 1));
                        setup_ap = false;
                    }
                }
                printf("ssid:%s\n", config.ssid);
            } // if read
            else {
                printf("could not read .ssid\n");
            }
        } // if fs_ssid
        else {
            printf("no .ssid found, running softAP\n");
        }
        // find device id or create one
        spiffs_file fd_devid = fs_open(".devid", SPIFFS_RDONLY, 0);
        if (fd_devid < 0) {
            device_id = hwrand();
            fd_devid = fs_open(".devid", SPIFFS_O_CREAT | SPIFFS_O_TRUNC | SPIFFS_O_WRONLY | SPIFFS_O_APPEND, 0);
            fs_write(fd_devid, &device_id, 4);
            printf("create devid\n");
        } else {
            fs_read(fd_devid, &device_id, 4);
        }
        fs_close(fd_devid);
        printf("devid %08x\n", device_id);

        // remove previous scan results
        fs_remove(SYSTASK_AP_SCAN_FILENAME);
    } // if mount

    if (setup_ap) {
        sdk_wifi_set_opmode(SOFTAP_MODE);

        struct ip_info ap_ip;
        IP4_ADDR(&ap_ip.ip, 192, 169, 1, 1);
        IP4_ADDR(&ap_ip.gw, 0, 0, 0, 0);
        IP4_ADDR(&ap_ip.netmask, 255, 255, 255, 0);
        sdk_wifi_set_ip_info(1, &ap_ip);


        struct sdk_softap_config ap_cfg = {
            .ssid = "WISLEEP",
            .password = "",
            .ssid_len = 7,
            .channel = 1,
            .authmode = AUTH_OPEN,
            .ssid_hidden = false,
            .max_connection = 255,
            .beacon_interval = 100
        };

        sdk_wifi_softap_set_config(&ap_cfg);

        ip_addr_t first_client_ip;
        IP4_ADDR(&first_client_ip, 192, 169, 1, 100);
        dhcpserver_start(&first_client_ip, 4);
    } else {
        // required to call wifi_set_opmode before station_set_config
        sdk_wifi_set_opmode(STATION_MODE);
        sdk_wifi_station_set_config(&config);
    }

    server_init(server_actions);
    um_mutex = xSemaphoreCreateMutex();
    xTaskCreate(uart_task, (signed char * )"uart_task", 512, NULL, 2, NULL);
    xTaskCreate(server_task, (signed char *)"server_task", 1024, NULL, 2, NULL);
}
Пример #25
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);
}
Пример #26
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);
}
Пример #27
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    xTaskCreate(blinkenTask, (signed char *)"blinkenTask", 256, NULL, 2, NULL);
    //xTaskCreate(blinkenRegisterTask, (signed char *)"blinkenRegisterTask", 256, NULL, 2, NULL);
}
Пример #28
0
void user_init(void)
{
    uart_set_baud(0, 115200);
    xTaskCreate(dhtMeasurementTask, (signed char *)"dhtMeasurementTask", 256, NULL, 2, NULL);
}
Пример #29
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);
}
Пример #30
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
}