Improve I2C locking and implement I2C for TactilityC (#147)
I2C: - Lock timeout set to reasonable times - Check lock status in all functions - Refactor lock/unlock to return `bool` values - Implement functions in TactilityC Other: - Updated screenshots
This commit is contained in:
committed by
GitHub
parent
a9e890a7f3
commit
7187e5e49e
@@ -0,0 +1,50 @@
|
||||
#include "tt_hal_i2c.h"
|
||||
#include "hal/i2c/I2c.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_hal_i2c_start(i2c_port_t port) {
|
||||
return tt::hal::i2c::start(port);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_stop(i2c_port_t port) {
|
||||
return tt::hal::i2c::stop(port);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_is_started(i2c_port_t port) {
|
||||
return tt::hal::i2c::isStarted(port);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_master_read(i2c_port_t port, uint8_t address, uint8_t* data, size_t dataSize, TickType_t timeout) {
|
||||
return tt::hal::i2c::masterRead(port, address, data, dataSize, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_master_read_register(i2c_port_t port, uint8_t address, uint8_t reg, uint8_t* data, size_t dataSize, TickType_t timeout) {
|
||||
return tt::hal::i2c::masterRead(port, address, reg, data, dataSize, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_master_write(i2c_port_t port, uint16_t address, const uint8_t* data, uint16_t dataSize, TickType_t timeout) {
|
||||
return tt::hal::i2c::masterWrite(port, address, data, dataSize, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_master_write_register(i2c_port_t port, uint16_t address, uint8_t reg, const uint8_t* data, uint16_t dataSize, TickType_t timeout) {
|
||||
return tt::hal::i2c::masterWrite(port, address, reg, data, dataSize, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_master_write_read(i2c_port_t port, uint8_t address, const uint8_t* writeData, size_t writeDataSize, uint8_t* readData, size_t readDataSize, TickType_t timeout) {
|
||||
return tt::hal::i2c::masterWriteRead(port, address, writeData, writeDataSize, readData, readDataSize, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_master_has_device_at_address(i2c_port_t port, uint8_t address, TickType_t timeout) {
|
||||
return tt::hal::i2c::masterHasDeviceAtAddress(port, address, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_lock(i2c_port_t port, TickType_t timeout) {
|
||||
return tt::hal::i2c::lock(port, timeout);
|
||||
}
|
||||
|
||||
bool tt_hal_i2c_unlock(i2c_port_t port) {
|
||||
return tt::hal::i2c::unlock(port);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <hal/i2c_types.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool tt_hal_i2c_start(i2c_port_t port);
|
||||
bool tt_hal_i2c_stop(i2c_port_t port);
|
||||
bool tt_hal_i2c_is_started(i2c_port_t port);
|
||||
|
||||
bool tt_hal_i2c_master_read(i2c_port_t port, uint8_t address, uint8_t* data, size_t dataSize, TickType_t timeout);
|
||||
bool tt_hal_i2c_master_read_register(i2c_port_t port, uint8_t address, uint8_t reg, uint8_t* data, size_t dataSize, TickType_t timeout);
|
||||
bool tt_hal_i2c_master_write(i2c_port_t port, uint16_t address, const uint8_t* data, uint16_t dataSize, TickType_t timeout);
|
||||
bool tt_hal_i2c_master_write_register(i2c_port_t port, uint16_t address, uint8_t reg, const uint8_t* data, uint16_t dataSize, TickType_t timeout);
|
||||
bool tt_hal_i2c_master_write_read(i2c_port_t port, uint8_t address, const uint8_t* writeData, size_t writeDataSize, uint8_t* readData, size_t readDataSize, TickType_t timeout);
|
||||
bool tt_hal_i2c_master_has_device_at_address(i2c_port_t port, uint8_t address, TickType_t timeout);
|
||||
|
||||
bool tt_hal_i2c_lock(i2c_port_t port, TickType_t timeout);
|
||||
bool tt_hal_i2c_unlock(i2c_port_t port);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "tt_app_alertdialog.h"
|
||||
#include "tt_app_selectiondialog.h"
|
||||
#include "tt_bundle.h"
|
||||
#include "tt_hal_i2c.h"
|
||||
#include "tt_lvgl_spinner.h"
|
||||
#include "tt_lvgl_toolbar.h"
|
||||
#include "tt_message_queue.h"
|
||||
@@ -39,6 +40,17 @@ const struct esp_elfsym elf_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_int32),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_string),
|
||||
ESP_ELFSYM_EXPORT(tt_set_app_manifest),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_start),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_stop),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_is_started),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_master_read),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_master_read_register),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_master_write),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_master_write_register),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_master_write_read),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_master_has_device_at_address),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_lock),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_unlock),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create),
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create_simple),
|
||||
ESP_ELFSYM_EXPORT(tt_message_queue_alloc),
|
||||
|
||||
Reference in New Issue
Block a user