Skip to content
Snippets Groups Projects
Select Git revision
  • 128e627d4f00825fca423ff44b552e9a04c61f19
  • master default protected
  • fix/macos-meta-files-in-menu
  • koalo/bhi160
  • genofire/ble-rewrite
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • ios-workarounds
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • rahix/bma
  • v1.12
  • 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
37 results

dispatcher.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    espan.c 2.42 KiB
    #include "badge23/captouch.h"
    #include "badge23/audio.h"
    #include "badge23/leds.h"
    #include "badge23/display.h"
    #include "badge23/spio.h"
    #include "badge23_hwconfig.h"
    
    #include "esp_log.h"
    #include "driver/i2c.h"
    #include "driver/spi_master.h"
    #include <freertos/timers.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 */
    
    #if defined(CONFIG_BADGE23_HW_GEN_P3) || defined(CONFIG_BADGE23_HW_GEN_P4)
    #define CONFIG_I2C_MASTER_SDA 2
    #define CONFIG_I2C_MASTER_SCL 1
    
    #elif defined(CONFIG_BADGE23_HW_GEN_P1)
    #define CONFIG_I2C_MASTER_SDA 10
    #define CONFIG_I2C_MASTER_SCL 9
    
    #else
    #error "i2c not implemented for this badge generation"
    #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 23
    static uint8_t hw_init_done = 0;
    
    void i2c_task(TimerHandle_t data){
        update_button_state();
        captouch_read_cycle();
    }
    
    void os_app_main(void)
    {
        ESP_LOGI(TAG, "Starting on %s...", badge23_hw_name);
        ESP_ERROR_CHECK(i2c_master_init());
        ESP_LOGI(TAG, "I2C initialized successfully");
    
        set_global_vol_dB(-90);
        audio_init();