Fix clang and update tests

This commit is contained in:
Pebblebed 2024-02-10 10:43:29 +00:00
parent a3e3ac0192
commit fcb7362d96
5 changed files with 80 additions and 98 deletions

View file

@ -110,13 +110,10 @@ void ExtEepromComponent::read(uint32_t memaddr, uint8_t *buff, uint16_t buffer_s
if (memaddr > 0xFFFF)
i2c_address |= 0b100; // Set the block bit to 1
}
if (this->get_address_size_bytes_() == 2)
{
if (this->get_address_size_bytes_() == 2) {
uint8_t maddr[] = {(uint8_t) (memaddr >> 8), (uint8_t) (memaddr & 0xFF)};
ret = this->bus_->write(i2c_address, maddr, 2, false);
}
else
{
} else {
uint8_t maddr[] = {(uint8_t) (memaddr & 0xFF)};
ret = this->bus_->write(i2c_address, maddr, 1, false);
}
@ -319,8 +316,7 @@ void ExtEepromComponent::erase(uint8_t value_to_write) {
void ExtEepromComponent::set_memory_type(EEEDeviceType device_type) {
device_type_ = device_type;
// Set settings based on known memory types
switch (device_type_)
{
switch (device_type_) {
default:
// Unknown type number
break;
@ -378,7 +374,8 @@ void ExtEepromComponent::set_memory_type(EEEDeviceType device_type) {
break;
}
}
void ExtEepromComponent::set_device_config_(uint32_t mem_size, uint8_t address_bytes, uint16_t page_size, uint8_t write_time_ms)
void ExtEepromComponent::set_device_config_(uint32_t mem_size, uint8_t address_bytes, uint16_t page_size,
uint8_t write_time_ms)
{
this->set_memory_size_(mem_size);
this->set_address_size_bytes_(address_bytes);
@ -398,17 +395,14 @@ void ExtEepromComponent::write_block_(uint8_t deviceaddr, uint32_t memaddr, cons
i2c::WriteBuffer buff[2];
i2c::ErrorCode ret;
// Check if the device has two address bytes
if (this->get_address_size_bytes_() == 2)
{
if (this->get_address_size_bytes_() == 2) {
uint8_t maddr[] = {(uint8_t) (memaddr >> 8), (uint8_t) (memaddr & 0xFF)};
buff[0].data = maddr;
buff[0].len = 2;
buff[1].data = obj;
buff[1].len = size;
ret = this->bus_->writev(this->address_, buff, 2, true);
}
else
{
} else {
uint8_t maddr[] = {(uint8_t) (memaddr & 0xFF)};
buff[0].data = maddr;
buff[0].len = 1;
@ -440,10 +434,7 @@ void ExtEepromComponent::set_page_write_time_(uint8_t write_time_ms) { memory_pa
uint8_t ExtEepromComponent::get_page_write_time_() { return memory_page_write_time_ms_; }
/// @brief Set address_bytes for the device
/// @param address_bytes contains the number of bytes the device uses for address
void ExtEepromComponent::set_address_size_bytes_(uint8_t address_bytes)
{
this->address_size_bytes_ = address_bytes;
}
void ExtEepromComponent::set_address_size_bytes_(uint8_t address_bytes) { this->address_size_bytes_ = address_bytes; }
/// @brief Gets the number of bytes used for the address
/// @return size in bytes
uint8_t ExtEepromComponent::get_address_size_bytes_() { return this->address_size_bytes_; }

View file

@ -9,8 +9,7 @@ namespace external_eeprom {
/// @brief This Class provides the methods to read and write data from an 24 LC/AT XX devices such as 24LC32. See
/// https://ww1.microchip.com/downloads/en/devicedoc/doc0336.pdf
enum EEEDeviceType
{
enum EEEDeviceType {
EEE_24XX00,
EEE_24XX01,
EEE_24XX02,
@ -57,8 +56,6 @@ class ExtEepromComponent : public i2c::I2CDevice, public Component {
// Getters and Setters for component config
void set_memory_type(EEEDeviceType device_type);
void set_i2c_buffer_size(uint8_t i2c_buffer_size); // Set the size of hw buffer -2 for control & addr
uint8_t get_i2c_buffer_size(); // Get the size of hw buffer -2 for control & addr
// Functionality to 'get' and 'put' objects to and from EEPROM.

View file

@ -4334,8 +4334,6 @@ alarm_control_panel:
external_eeprom:
id: ext_eeprom_component_1
address: 0x57
ee_page_write_time: 5
ee_page_size: 32
ee_memory_size: 4096
i2c_buffer_size: 126
ee_memory_type: 24XX32
i2c_buffer_size: 128
i2c_id: i2c_bus

View file

@ -736,7 +736,5 @@ adc128s102:
external_eeprom:
id: ext_eeprom_component_1
address: 0x57
ee_page_write_time: 5
ee_page_size: 32
ee_memory_size: 4096
i2c_buffer_size: 126
ee_memory_type: 24XX32
i2c_buffer_size: 128

View file

@ -734,7 +734,5 @@ light:
external_eeprom:
id: ext_eeprom_component_1
address: 0x57
ee_page_write_time: 5
ee_page_size: 32
ee_memory_size: 4096
i2c_buffer_size: 126
ee_memory_type: 24XX32
i2c_buffer_size: 128