@@ 9,7 9,7 @@
#include "fsl_common.h"
#include "log/log.hpp"
-// generic i2c read() & write() doesn't provide correct i2c frame sequence for eeprom. i2c HAL API should be modified.
+#include "task.h"
namespace bsp::eeprom
{
@@ 18,7 18,7 @@ namespace bsp::eeprom
std::shared_ptr<drivers::DriverI2C> i2c;
drivers::I2CAddress addr = {
- .deviceAddress = static_cast<uint32_t>(M24256_MEM_DEVICE_ADDR), .subAddress = 0, .subAddressSize = 2};
+ .deviceAddress = static_cast<std::uint32_t>(M24256_MEM_DEVICE_ADDR), .subAddress = 0, .subAddressSize = 2};
} // namespace
@@ 34,7 34,7 @@ namespace bsp::eeprom
bool isPresent(int busid)
{
std::uint8_t readout;
- addr.deviceAddress |= static_cast<uint32_t>(busid) & M24256_DEV_ID_MASK;
+ addr.deviceAddress |= static_cast<std::uint32_t>(busid) & M24256_DEV_ID_MASK;
addr.subAddress = 0x0000;
return i2c->Read(addr, &readout, 1) > 0;
}
@@ 44,7 44,7 @@ namespace bsp::eeprom
size_t written = 0;
char *ptr = const_cast<char *>(buf);
- addr.deviceAddress |= static_cast<uint32_t>(busid) & M24256_DEV_ID_MASK;
+ addr.deviceAddress |= static_cast<std::uint32_t>(busid) & M24256_DEV_ID_MASK;
addr.subAddress = mem_addr;
size_t bl_len = static_cast<size_t>(eeprom_block_size(busid));
@@ 56,8 56,8 @@ namespace bsp::eeprom
if (chunks > 0) {
for (size_t i = 0; i < chunks; i++) {
LOG_DEBUG("[EEPROM - W] writing chunk %d of %d", i, chunks);
- written += i2c->Write(addr, reinterpret_cast<uint8_t *>(ptr), static_cast<size_t>(bl_len));
- vTaskDelay(10 / portTICK_PERIOD_MS);
+ written += i2c->Write(addr, reinterpret_cast<std::uint8_t *>(ptr), static_cast<size_t>(bl_len));
+ vTaskDelay(pdMS_TO_TICKS(10));
ptr += bl_len;
addr.subAddress += bl_len;
}
@@ 65,8 65,8 @@ namespace bsp::eeprom
// reminder
if (reminder > 0) {
LOG_DEBUG("[EEPROM - W] writing remaining %d bytes", reminder);
- written += i2c->Write(addr, reinterpret_cast<uint8_t *>(ptr), reminder);
- vTaskDelay(10 / portTICK_PERIOD_MS);
+ written += i2c->Write(addr, reinterpret_cast<std::uint8_t *>(ptr), reminder);
+ vTaskDelay(pdMS_TO_TICKS(10));
}
return static_cast<int>(written);
@@ 77,7 77,7 @@ namespace bsp::eeprom
size_t read = 0;
char *ptr = const_cast<char *>(buf);
- addr.deviceAddress |= static_cast<uint32_t>(busid) & M24256_DEV_ID_MASK;
+ addr.deviceAddress |= static_cast<std::uint32_t>(busid) & M24256_DEV_ID_MASK;
addr.subAddress = mem_addr;
size_t bl_len = static_cast<size_t>(eeprom_block_size(busid));
@@ 89,7 89,7 @@ namespace bsp::eeprom
if (chunks > 0) {
for (size_t i = 0; i < chunks; i++) {
LOG_DEBUG("[EEPROM - R] reading chunk %d of %d", i, chunks);
- read += i2c->Read(addr, reinterpret_cast<uint8_t *>(ptr), static_cast<size_t>(bl_len));
+ read += i2c->Read(addr, reinterpret_cast<std::uint8_t *>(ptr), static_cast<size_t>(bl_len));
ptr += bl_len;
addr.subAddress += bl_len;
}
@@ 97,7 97,7 @@ namespace bsp::eeprom
// reminder
if (reminder > 0) {
LOG_DEBUG("[EEPROM - R] reading remaining %d bytes", reminder);
- read += i2c->Read(addr, reinterpret_cast<uint8_t *>(ptr), reminder);
+ read += i2c->Read(addr, reinterpret_cast<std::uint8_t *>(ptr), reminder);
}
return static_cast<int>(read);
@@ 107,7 107,7 @@ namespace bsp::eeprom
{
// note that M24256 doesn't provide any ID or info register. So i assume that with T7 rev. this memory is @0x0h
// address
- if (busid == 0x00)
+ if (busid == M24256_SLAVE_ADDR)
return M24256_TOTAL_SIZE;
else
return -EFAULT;
@@ 117,10 117,10 @@ namespace bsp::eeprom
{
// note that M24256 doesn't provide any ID or info register. So i assume that with T7 rev. this memory is @0x0h
// address
- if (busid == 0x00)
+ if (busid == M24256_SLAVE_ADDR)
return M24256_PAGE_SIZE;
else
return -EFAULT;
}
-} // namespace bsp::eeprom>
\ No newline at end of file
+} // namespace bsp::eeprom
@@ 131,7 131,7 @@ enum class BoardDefinitions
LIGHT_SENSOR_IRQ = 15, // GPIO_B0_15
EEPROM_I2C = AUDIOCODEC_I2C,
- EEPROM_I2C_BAUDRATE = AUDIOCODEC_I2C_BAUDRATE,
+ EEPROM_I2C_BAUDRATE = I2C_STD_BAUDRATE,
};
#endif //PUREPHONE_BOARDDEFINITIONS_HPP