0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-18 22:29:50 +03:00

Code clean ups + first part of channel squelch (not yet implemented)

This commit is contained in:
OneOfEleven
2023-10-19 19:00:57 +01:00
parent 75aa98cc06
commit 3bae9b5cdb
16 changed files with 245 additions and 244 deletions

View File

@ -22,22 +22,23 @@
void EEPROM_ReadBuffer(const uint16_t address, void *p_buffer, const unsigned int size)
{
if (p_buffer == NULL || address >= 0x2000 || size == 0)
if (p_buffer == NULL || (address + size) > 0x2000 || size == 0)
return;
I2C_Start();
I2C_Write(0xA0);
I2C_Write((address >> 8) & 0xFF);
I2C_Write((address >> 0) & 0xFF);
I2C_Start();
I2C_Write(0xA1);
I2C_ReadBuffer(p_buffer, size);
I2C_Stop();
}
void EEPROM_WriteBuffer(const uint16_t address, const void *p_buffer)
void EEPROM_WriteBuffer8(const uint16_t address, const void *p_buffer)
{
if (p_buffer == NULL || address >= 0x2000)
if (p_buffer == NULL || (address + 8) > 0x2000)
return;
#if 0
@ -50,9 +51,12 @@ void EEPROM_WriteBuffer(const uint16_t address, const void *p_buffer)
I2C_WriteBuffer(p_buffer, 8);
I2C_Stop();
// give the EEPROM time to burn the data in (apparently takes 1.5ms ~ 5ms)
SYSTEM_DelayMs(6);
#else
// eeprom wear reduction
// only write the data IF it's different to what's already in eeprom
// only write the data if it's different to what's already there
uint8_t buffer[8];
EEPROM_ReadBuffer(address, buffer, 8);
@ -64,10 +68,10 @@ void EEPROM_WriteBuffer(const uint16_t address, const void *p_buffer)
I2C_Write((address >> 0) & 0xFF);
I2C_WriteBuffer(p_buffer, 8);
I2C_Stop();
// give the EEPROM time to burn the data in (apparently takes 1.5ms ~ 5ms)
SYSTEM_DelayMs(6);
}
#endif
// give the EEPROM time to burn the data in (apparently takes 5ms)
SYSTEM_DelayMs(8);
}

View File

@ -20,7 +20,7 @@
#include <stdint.h>
void EEPROM_ReadBuffer(const uint16_t address, void *p_buffer, const unsigned int size);
void EEPROM_WriteBuffer(const uint16_t address, const void *p_buffer);
void EEPROM_WriteBuffer8(const uint16_t address, const void *p_buffer);
#endif