summaryrefslogtreecommitdiff
path: root/controller/fw/src/main.c
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2020-05-04 21:31:31 +0200
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2020-05-04 21:31:31 +0200
commit9918eb505321183e20357221a4dcf2aa9c1e057c (patch)
tree41e33e84d51ca2aa558ab1dc248ec5109181d6c8 /controller/fw/src/main.c
parent82c1302756d9b8f3d5cfbd4b304411c39651dfa8 (diff)
downloadmaster-thesis-9918eb505321183e20357221a4dcf2aa9c1e057c.tar.gz
master-thesis-9918eb505321183e20357221a4dcf2aa9c1e057c.tar.bz2
master-thesis-9918eb505321183e20357221a4dcf2aa9c1e057c.zip
fw: add working reed-solomon encoder/decoder
Diffstat (limited to 'controller/fw/src/main.c')
-rw-r--r--controller/fw/src/main.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/controller/fw/src/main.c b/controller/fw/src/main.c
index 6e117f6..6547c38 100644
--- a/controller/fw/src/main.c
+++ b/controller/fw/src/main.c
@@ -190,9 +190,11 @@ static struct jtag_img_descriptor {
.img_len = 0x004000,
};
-const char fw_dump[0x4000] = {
+char fw_dump[0x4000] = {
#include "EasyMeter_Q3DA1002_V3.03_fw_dump_0xc000.h"
};
+const int fw_dump_offx = 0xc000;
+const int row2_offx = 0xf438 - fw_dump_offx;
ssize_t jt_spi_flash_read_block(void *usr, int addr, size_t len, uint8_t *out) {
/*
@@ -201,11 +203,25 @@ ssize_t jt_spi_flash_read_block(void *usr, int addr, size_t len, uint8_t *out) {
*/
for (size_t i=0; i<len; i++)
- out[i] = fw_dump[addr - 0xc000 + i];
+ out[i] = fw_dump[addr - fw_dump_offx + i];
return len;
}
+void update_image_flash_counter(void) {
+ static int flash_counter = 0;
+ flash_counter ++;
+ fw_dump[row2_offx + 0] = flash_counter/10000 + '0';
+ flash_counter %= 10000;
+ fw_dump[row2_offx + 1] = flash_counter/1000 + '0';
+ flash_counter %= 1000;
+ fw_dump[row2_offx + 2] = flash_counter/100 + '0';
+ flash_counter %= 100;
+ fw_dump[row2_offx + 3] = flash_counter/10 + '0';
+ flash_counter %= 10;
+ fw_dump[row2_offx + 4] = flash_counter + '0';
+}
+
static unsigned int measurement_errors = 0;
static struct dsss_demod_state demod_state;
static uint32_t freq_sample_ts = 0;
@@ -248,16 +264,18 @@ int main(void)
dsss_demod_init(&demod_state);
con_printf("Booted.\r\n");
- int i=0;
- while (23) {
+ con_printf("Attempting to flash meter...\r\n");
+ int flash_tries = 0;
+ while (flash_tries++ < 25) {
mspd_jtag_init();
- int rv = mspd_jtag_flash_and_reset(jtag_img.devmem_img_start, jtag_img.img_len, jt_spi_flash_read_block, &jtag_img);
- con_printf("%d flash result: %d\r\n", i, rv);
- while (!rv) {}
+ if (!mspd_jtag_flash_and_reset(jtag_img.devmem_img_start, jtag_img.img_len, jt_spi_flash_read_block, &jtag_img))
+ break;
for (int j=0; j<168*1000*5; j++)
asm volatile ("nop");
- i++;
}
+ if (flash_tries == 25)
+ con_printf("Giving up.\r\n");
+
while (23) {
if (adc_fft_buf_ready_idx != -1) {
for (int j=0; j<168*1000*2; j++)