Skip to content
Snippets Groups Projects
Select Git revision
  • f49b61a19c79372ee6fc9ff02d1360db2861adae
  • master default protected
  • fix-warnings
  • tvbgone-fixes
  • genofire/ble-follow-py
  • schneider/ble-stability-new-phy-adv
  • schneider/ble-stability
  • msgctl/gfx_rle
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
36 results

meson.build

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    espan.c 2.21 KiB
    #include "badge23/captouch.h"
    #include "badge23/audio.h"
    #include "badge23/leds.h"
    #include "badge23/display.h"
    #include "../../../revision_config.h"
    
    #include "esp_log.h"
    #include "driver/i2c.h"
    #include "driver/spi_master.h"
    
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <stdint.h>
    
    static const char *TAG = "espan";
    
    #define I2C_MASTER_NUM              0                          /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
    #define I2C_MASTER_FREQ_HZ          400000                     /*!< I2C master clock frequency */
    #define I2C_MASTER_TX_BUF_DISABLE   0                          /*!< I2C master doesn't need buffer */
    #define I2C_MASTER_RX_BUF_DISABLE   0                          /*!< I2C master doesn't need buffer */
    
    #ifdef HARDWARE_REVISION_04
    #define CONFIG_I2C_MASTER_SDA 2
    #define CONFIG_I2C_MASTER_SCL 1
    #endif
    
    #ifdef HARDWARE_REVISION_01
    #define CONFIG_I2C_MASTER_SDA 10
    #define CONFIG_I2C_MASTER_SCL 9
    #endif
    
    static esp_err_t i2c_master_init(void)
    {
        int i2c_master_port = I2C_MASTER_NUM;
    
        i2c_config_t conf = {
            .mode = I2C_MODE_MASTER,
            .sda_io_num = CONFIG_I2C_MASTER_SDA,
            .scl_io_num = CONFIG_I2C_MASTER_SCL,
            .sda_pullup_en = GPIO_PULLUP_ENABLE,
            .scl_pullup_en = GPIO_PULLUP_ENABLE,
            .master.clk_speed = I2C_MASTER_FREQ_HZ,
        };
    
        i2c_param_config(i2c_master_port, &conf);
    
        return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
    }
    
    #define CAPTOUCH_POLLING_PERIOD 10
    
    void os_app_main(void)
    {
        ESP_ERROR_CHECK(i2c_master_init());
        ESP_LOGI(TAG, "I2C initialized successfully");
    
        set_global_vol_dB(-90);
        audio_init();
        leds_init();
        captouch_init();
    
        vTaskDelay(2000 / portTICK_PERIOD_MS);
        set_global_vol_dB(0);
    
        display_init();
        while(1) {
            manual_captouch_readout(1);
            vTaskDelay((CAPTOUCH_POLLING_PERIOD) / portTICK_PERIOD_MS);
            manual_captouch_readout(0);
            vTaskDelay((CAPTOUCH_POLLING_PERIOD) / portTICK_PERIOD_MS);
            //display_draw_scope();
        }
    
        ESP_ERROR_CHECK(i2c_driver_delete(I2C_MASTER_NUM));
        ESP_LOGI(TAG, "I2C de-initialized successfully");
    }