diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-04-29 18:02:57 +0200 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-04-29 18:02:57 +0200 |
commit | 76c12726e85d0bb25d7f015ee6e515ad7084d36d (patch) | |
tree | 5c7afedd107d7ad1751b325df59faa61feaf7281 /controller/fw/src/main.c | |
parent | 3dd578980020ebf01cf97b0b34ddb8bf61126666 (diff) | |
download | master-thesis-76c12726e85d0bb25d7f015ee6e515ad7084d36d.tar.gz master-thesis-76c12726e85d0bb25d7f015ee6e515ad7084d36d.tar.bz2 master-thesis-76c12726e85d0bb25d7f015ee6e515ad7084d36d.zip |
MSP430 reflash working
Diffstat (limited to 'controller/fw/src/main.c')
-rw-r--r-- | controller/fw/src/main.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/controller/fw/src/main.c b/controller/fw/src/main.c index aec1fdc..6e117f6 100644 --- a/controller/fw/src/main.c +++ b/controller/fw/src/main.c @@ -187,12 +187,23 @@ static struct jtag_img_descriptor { } jtag_img = { .devmem_img_start = 0x00c000, .spiflash_img_start = 0x000000, - .img_len = 0x060000, + .img_len = 0x004000, +}; + +const char fw_dump[0x4000] = { +#include "EasyMeter_Q3DA1002_V3.03_fw_dump_0xc000.h" }; ssize_t jt_spi_flash_read_block(void *usr, int addr, size_t len, uint8_t *out) { + /* struct jtag_img_descriptor *desc = (struct jtag_img_descriptor *)usr; return spif_read(&spif, desc->spiflash_img_start + addr, len, (char *)out); + */ + + for (size_t i=0; i<len; i++) + out[i] = fw_dump[addr - 0xc000 + i]; + + return len; } static unsigned int measurement_errors = 0; @@ -240,15 +251,16 @@ int main(void) int i=0; while (23) { mspd_jtag_init(); - con_printf("%d flash result: %d\r\n", i, - mspd_jtag_flash_and_reset(jtag_img.devmem_img_start, jtag_img.img_len, jt_spi_flash_read_block, &jtag_img)); - for (int i=0; i<168*1000*5; i++) + 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) {} + for (int j=0; j<168*1000*5; j++) asm volatile ("nop"); i++; } while (23) { if (adc_fft_buf_ready_idx != -1) { - for (int i=0; i<168*1000*2; i++) + for (int j=0; j<168*1000*2; j++) asm volatile ("nop"); GPIOA->BSRR = 1<<11; memcpy(adc_fft_buf[!adc_fft_buf_ready_idx], adc_fft_buf[adc_fft_buf_ready_idx] + FMEAS_FFT_LEN/2, sizeof(adc_fft_buf[0][0]) * FMEAS_FFT_LEN/2); @@ -257,8 +269,8 @@ int main(void) bool clip_low=false, clip_high=false; const int clip_thresh = 100; - for (size_t i=FMEAS_FFT_LEN/2; i<FMEAS_FFT_LEN; i++) { - int val = adc_fft_buf[adc_fft_buf_ready_idx][i]; + for (size_t j=FMEAS_FFT_LEN/2; j<FMEAS_FFT_LEN; j++) { + int val = adc_fft_buf[adc_fft_buf_ready_idx][j]; if (val < clip_thresh) clip_low = true; if (val > FMEAS_ADC_MAX-clip_thresh) @@ -266,7 +278,7 @@ int main(void) } GPIOB->ODR = (GPIOB->ODR & ~(3<<11)) | (!clip_low<<11) | (!clip_high<<12); - for (int i=0; i<168*1000*2; i++) + for (int j=0; j<168*1000*2; j++) asm volatile ("nop"); GPIOA->BSRR = 1<<11; |