adjusted, but too few SPIs

This commit is contained in:
2021-01-09 23:32:01 +01:00
parent 6671348d22
commit e9914f5bb1
37 changed files with 10253 additions and 744 deletions

View File

@ -3,7 +3,6 @@
#include <eeprom.h>
#include <string.h>
#include <logger.h>
#include <mbusComm.h>
#include <PontCoopScheduler.h>
#include <utils.h>
@ -35,6 +34,8 @@ typedef union {
static t_eepromHeaderBlock eepromHeader;
static const uint16_t CONFIG_BLOCK_ADDR = EEPROM_CONFIG_BLOCK_ADDR;
typedef union {
t_deviceStats s;
@ -44,10 +45,6 @@ typedef union {
static const uint16_t DEVICE_STATS_ADDR = EEPROM_DEVICE_STATS_ADDR;
static t_deviceStatsBlock deviceStats;
static const uint16_t CONFIG_BLOCK_ADDR = EEPROM_CONFIG_BLOCK_ADDR;
static const uint16_t DEVICE_BLOCK_ADDR = EEPROM_DEVICE_BLOCK_BASE_ADDR;
typedef union {
@ -117,10 +114,8 @@ void eepromSpiTxCpltCallback(SPI_HandleTypeDef *hspi) {
static void eepromHourlyUpdateDeviceStats(void *handle) {
deviceStats.s.totalRunningHours += 1;
t_mbusCommStats *stats = mbusCommGetStats();
deviceStats.s.totalRequests += stats->mbusRequestCnt;
deviceStats.s.totalFailures += stats->mbusErrorCnt;
deviceStats.s.totalRequests += 0;
deviceStats.s.totalFailures += 0;
logMsg("eeHUDS, about to write updated device stats");
logMsg("eeHUDS, total powercycles so far: %d", deviceStats.s.totalPowercycles);
@ -146,26 +141,6 @@ void eepromWriteConfigBlock(t_configBlock *srcConfigBlock) {
}
}
void eepromReadDeviceBlock(uint8_t blockNum, t_deviceBlock *destDeviceBlock) {
static_assert((sizeof(*destDeviceBlock) % EEPROM_WRITE_BLOCK_SIZE == 0), "device block has illegal size, must be dividable by 32");
for (uint8_t i = 0; i < (sizeof(*destDeviceBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
eepromRead(DEVICE_BLOCK_ADDR + (blockNum * sizeof(*destDeviceBlock)) + (i * EEPROM_WRITE_BLOCK_SIZE),
((uint8_t*)destDeviceBlock) + (i * EEPROM_WRITE_BLOCK_SIZE),
EEPROM_WRITE_BLOCK_SIZE);
}
}
void eepromWriteDeviceBlock(uint8_t blockNum, t_deviceBlock *srcDeviceBlock) {
for (uint8_t i = 0; i < (sizeof(*srcDeviceBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
eepromWrite(DEVICE_BLOCK_ADDR + (blockNum * sizeof(*srcDeviceBlock)) + (i * EEPROM_WRITE_BLOCK_SIZE),
((uint8_t*)srcDeviceBlock) + (i * EEPROM_WRITE_BLOCK_SIZE),
EEPROM_WRITE_BLOCK_SIZE);
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
}
}
void eepromInit() {
__EEPROM_CS(HIGH);