RCM — ESP32 Room Controller
WT32-ETH01 firmware
Loading...
Searching...
No Matches
i2c_cmd_device.c File Reference

Периодическая отправка команд на LCM по I2C (тестовая задача). More...

#include "i2c_cmd_device.h"
#include "driver/i2c_master.h"
#include "esp_check.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "i2c_bus.h"

Go to the source code of this file.

Macros

#define I2C_DEVICE_ADDR   0x20
 Заводской адрес LCM (7 бит); после SET_ADDR может отличаться
 
#define CMD_INTERVAL_MS   1000
 

Functions

static esp_err_t i2c_cmd_send (uint8_t *data, size_t data_len)
 
esp_err_t i2c_cmd_device_init (void)
 Добавляет LCM как устройство на общую шину (i2c_bus_init при необходимости).
 
static void i2c_cmd_task (void *arg)
 
esp_err_t i2c_cmd_device_start (void)
 Запускает задачу циклической отправки команд на LCM.
 

Variables

static const char * TAG = "i2c_cmd"
 
static uint8_t s_commands []
 
static i2c_master_dev_handle_t s_i2c_dev
 
static bool s_initialized
 

Detailed Description

Периодическая отправка команд на LCM по I2C (тестовая задача).

Использует общую шину i2c_bus. Адрес LCM: 0x7F (заводской) или из NVM.

Definition in file i2c_cmd_device.c.

Macro Definition Documentation

◆ CMD_INTERVAL_MS

#define CMD_INTERVAL_MS   1000

Definition at line 21 of file i2c_cmd_device.c.

Referenced by i2c_cmd_device_start(), and i2c_cmd_task().

◆ I2C_DEVICE_ADDR

#define I2C_DEVICE_ADDR   0x20

Заводской адрес LCM (7 бит); после SET_ADDR может отличаться

Definition at line 20 of file i2c_cmd_device.c.

Referenced by i2c_cmd_device_init().

Function Documentation

◆ i2c_cmd_device_init()

esp_err_t i2c_cmd_device_init ( void )

Добавляет LCM как устройство на общую шину (i2c_bus_init при необходимости).

Definition at line 37 of file i2c_cmd_device.c.

References i2c_bus_add_device(), i2c_bus_init(), I2C_DEVICE_ADDR, s_i2c_dev, s_initialized, and TAG.

Referenced by app_main().

◆ i2c_cmd_device_start()

esp_err_t i2c_cmd_device_start ( void )

Запускает задачу циклической отправки команд на LCM.

Definition at line 73 of file i2c_cmd_device.c.

References CMD_INTERVAL_MS, i2c_cmd_task(), s_initialized, and TAG.

Referenced by app_main().

◆ i2c_cmd_send()

static esp_err_t i2c_cmd_send ( uint8_t * data,
size_t data_len )
static

Definition at line 32 of file i2c_cmd_device.c.

References I2C_BUS_TIMEOUT_MS, and s_i2c_dev.

Referenced by i2c_cmd_task().

◆ i2c_cmd_task()

static void i2c_cmd_task ( void * arg)
static

Definition at line 52 of file i2c_cmd_device.c.

References CMD_INTERVAL_MS, i2c_cmd_send(), s_commands, and TAG.

Referenced by i2c_cmd_device_start().

Variable Documentation

◆ s_commands

uint8_t s_commands[]
static
Initial value:
= {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11
}

Definition at line 23 of file i2c_cmd_device.c.

Referenced by i2c_cmd_task().

◆ s_i2c_dev

i2c_master_dev_handle_t s_i2c_dev
static

Definition at line 29 of file i2c_cmd_device.c.

Referenced by i2c_cmd_device_init(), and i2c_cmd_send().

◆ s_initialized

bool s_initialized
static

Definition at line 30 of file i2c_cmd_device.c.

Referenced by i2c_cmd_device_init(), and i2c_cmd_device_start().

◆ TAG

const char* TAG = "i2c_cmd"
static

Definition at line 17 of file i2c_cmd_device.c.

Referenced by i2c_cmd_device_init(), i2c_cmd_device_start(), and i2c_cmd_task().