From 76c12726e85d0bb25d7f015ee6e515ad7084d36d Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 29 Apr 2020 18:02:57 +0200 Subject: MSP430 reflash working --- controller/fw/src/main.c | 28 ++++++++++++++++++-------- controller/fw/src/mspdebug_wrapper.c | 39 +++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 26 deletions(-) (limited to 'controller') 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; iBSRR = 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_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; diff --git a/controller/fw/src/mspdebug_wrapper.c b/controller/fw/src/mspdebug_wrapper.c index aada33a..aaf75ab 100644 --- a/controller/fw/src/mspdebug_wrapper.c +++ b/controller/fw/src/mspdebug_wrapper.c @@ -1,6 +1,7 @@ #include #include +#include #include "output.h" #include "jtaglib.h" @@ -53,6 +54,18 @@ void mspd_jtag_init() { gpio_pin_setup(gpios[i].gpio, gpios[i].pin, gpios[i].mode, 3, 0, 0); } +static void sr_gpio_write(int num, int out) { + if (out) + gpios[num].gpio->BSRR = 1<BSRR = 1<BSRR = 1<BSRR = 1<