From b8e98e95b903e3afbd4f8384915a84de68c9a8a7 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 29 Jun 2020 22:16:07 +0300 Subject: [PATCH 1/6] Reduce USB buffer size from 128 to 32 --- halconf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halconf.h b/halconf.h index 0b48487..9a90280 100644 --- a/halconf.h +++ b/halconf.h @@ -317,7 +317,7 @@ * buffers. */ #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_SIZE 128 +#define SERIAL_USB_BUFFERS_SIZE 32 #endif /** From a2ff8edabdc87cfe13fd0c363aa38395c2897ed6 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 29 Jun 2020 22:17:43 +0300 Subject: [PATCH 2/6] Small style fixes SPI_BUFFER_SIZE depend from CELLWIDTH and CELLHEIGHT --- chconf.h | 2 +- nanovna.h | 2 +- sa_core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chconf.h b/chconf.h index 08860ae..deb0f9e 100644 --- a/chconf.h +++ b/chconf.h @@ -529,7 +529,7 @@ /** * ChibiOS/os/various/shell/shell_cmd.c */ -#define SHELL_CMD_EXIT_ENABLED TRUE +#define SHELL_CMD_EXIT_ENABLED FALSE #define SHELL_CMD_INFO_ENABLED FALSE #define SHELL_CMD_ECHO_ENABLED FALSE #define SHELL_CMD_SYSTIME_ENABLED FALSE diff --git a/nanovna.h b/nanovna.h index 3c952b5..5b19e7b 100644 --- a/nanovna.h +++ b/nanovna.h @@ -502,7 +502,7 @@ extern volatile uint8_t redraw_request; #define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) ) // Define size of screen buffer in pixels (one pixel 16bit size) -#define SPI_BUFFER_SIZE 1024 +#define SPI_BUFFER_SIZE (CELLWIDTH*CELLHEIGHT) #define LCD_WIDTH 320 #define LCD_HEIGHT 240 diff --git a/sa_core.c b/sa_core.c index 32e8612..42a6695 100644 --- a/sa_core.c +++ b/sa_core.c @@ -34,7 +34,7 @@ uint32_t maxFreq = 520000000; uint32_t measured_sweep_time = 0; //int setting.refer = -1; // Off by default -int const reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000}; +static const int reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000}; int in_selftest = false; From ace88a0b5a6b513e60105b4a35e04c55fffa3658 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 29 Jun 2020 22:18:32 +0300 Subject: [PATCH 3/6] Reduce sweep thread stack size from 900 to 768 --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 7cb6e73..9e4daee 100644 --- a/main.c +++ b/main.c @@ -124,7 +124,7 @@ extern int dirty; bool completed = false; -static THD_WORKING_AREA(waThread1, 900); +static THD_WORKING_AREA(waThread1, 768); static THD_FUNCTION(Thread1, arg) { (void)arg; @@ -2784,7 +2784,7 @@ void hard_fault_handler_c(uint32_t *sp) uint32_t psr = sp[7]; int y = 0; int x = 20; -static char buf[16]; + static char buf[16]; ili9341_set_background(0x0000); ili9341_set_foreground(0xFFFF); From 3ff7cd98e65bd078d83d3da7153c203ba41cf0e0 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 29 Jun 2020 22:21:49 +0300 Subject: [PATCH 4/6] Reduce main thread stack size from 576 to 384 Reduce interrupt stack size from 512 to 256 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index aec3636..ad5d38a 100644 --- a/Makefile +++ b/Makefile @@ -65,13 +65,13 @@ endif # Stack size to be allocated to the Cortex-M process stack. This stack is # the stack used by the main() thread. ifeq ($(USE_PROCESS_STACKSIZE),) - USE_PROCESS_STACKSIZE = 0x240 + USE_PROCESS_STACKSIZE = 0x180 endif # Stack size to the allocated to the Cortex-M main/exceptions stack. This # stack is used for processing interrupts and exceptions. ifeq ($(USE_EXCEPTIONS_STACKSIZE),) - USE_EXCEPTIONS_STACKSIZE = 0x200 + USE_EXCEPTIONS_STACKSIZE = 0x100 endif # From 0e9a37c5e6c22d6b75ea9ca16b868f5aa5a58d04 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 29 Jun 2020 22:23:29 +0300 Subject: [PATCH 5/6] Implement shiftInBuf for fast read RSSI data (not used, need check speed and correct timings) --- si4432.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/si4432.c b/si4432.c index 247a0b4..316014c 100644 --- a/si4432.c +++ b/si4432.c @@ -59,18 +59,6 @@ static void shiftOut(uint8_t val) { SI4432_log(SI4432_Sel); SI4432_log(val); -#if 0 - uint8_t i = 0; - do { - if (val & 0x80) - SPI2_SDI_HIGH; - else - SPI2_SDI_LOW; - val<<=1; - SPI2_CLK_HIGH; - SPI2_CLK_LOW; - }while((++i) & 0x07); -#else uint8_t i = 0; do { if (val & 0x80) @@ -79,7 +67,6 @@ static void shiftOut(uint8_t val) SPI2_RESET; val<<=1; }while((++i) & 0x07); -#endif } static uint8_t shiftIn(void) @@ -95,21 +82,32 @@ static uint8_t shiftIn(void) return value>>GPIO_SPI2_SDO; } -static void shiftInBuf(uint8_t *buf, uint16_t size, uint16_t delay) { +static inline void shiftInBuf(uint16_t sel, uint8_t addr, uint8_t *buf, uint16_t size, uint16_t delay) { uint8_t i = 0; do{ - uint8_t value = 0; + uint32_t value = addr; + palClearPad(GPIOC, sel); + do { + if (value & 0x80) + SPI2_SDI_HIGH; + SPI2_CLK_HIGH; + SPI2_RESET; + value<<=1; + }while((++i) & 0x07); + value = 0; do { SPI2_CLK_HIGH; - value = (value<<1)|SPI2_SDO; + value<<=1; + value|=SPI2_portSDO; SPI2_CLK_LOW; }while((++i) & 0x07); - *buf++=value; + palSetPad(GPIOC, sel); + *buf++=value>>GPIO_SPI2_SDO; if (delay) my_microsecond_delay(delay); }while(--size); } - +#if 0 static void shiftOutBuf(uint8_t *buf, uint16_t size) { uint8_t i = 0; do{ @@ -125,7 +123,7 @@ static void shiftOutBuf(uint8_t *buf, uint16_t size) { }while((++i) & 0x07); }while(--size); } - +#endif const int SI_nSEL[3] = { GPIO_RX_SEL, GPIO_LO_SEL, 0}; // #3 is dummy!!!!!! volatile int SI4432_Sel = 0; // currently selected SI4432 @@ -402,7 +400,8 @@ void SI4432_Fill(int s, int start) } else t = 0; - +// START_PROFILE; +#if 1 SPI2_CLK_LOW; int i = start; do { @@ -414,6 +413,10 @@ void SI4432_Fill(int s, int start) if (t) my_microsecond_delay(t); } while(1); +#else + shiftInBuf(sel, SI4432_REG_RSSI, (uint8_t *)&age[start], sweep_points - start, t); +#endif +// STOP_PROFILE; buf_index = start; // Is used to skip 1st entry during level triggering buf_read = true; } From 8878c6f0bfc291eeb1d021242d9de9a22b3abcd3 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 29 Jun 2020 22:52:46 +0300 Subject: [PATCH 6/6] =?UTF-8?q?Big=20font=20fixes=20Better=20look=20'm'=20?= =?UTF-8?q?letter=20Replace=20'u'=20letter=20to=20'=C2=B5'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- numfont20x22.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/numfont20x22.c b/numfont20x22.c index 9affa97..0b495d3 100644 --- a/numfont20x22.c +++ b/numfont20x22.c @@ -515,12 +515,12 @@ const uint16_t numfont16x22[] = { 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, - 0b1111001100110000, - 0b1111011111111100, - 0b1111111111111110, - 0b1111111111111110, - 0b1111111111011111, - 0b1111101111001111, + 0b1110111000011100, + 0b1111111100111110, + 0b1111111111111111, + 0b1111111111111111, + 0b1111001111001111, + 0b1111001111001111, 0b1111001111001111, 0b1111001111001111, 0b1111001111001111, @@ -536,22 +536,22 @@ const uint16_t numfont16x22[] = { 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000011111, - 0b1111100000111111, - 0b1111110001111111, - 0b0111111111111111, - 0b0011111111101111, - 0b0001111111001111, + 0b1111000000011110, + 0b1111000000011110, + 0b1111000000011110, + 0b1111000000011110, + 0b1111000000011110, + 0b1111000000011110, + 0b1111000000011110, + 0b1111000000011110, + 0b1111100000111110, + 0b1111110001111110, + 0b1111111111111110, + 0b1111111111111111, + 0b1111011111001111, + 0b1111001110000111, + 0b1111000000000000, + 0b1111000000000000, 0b0000000000000000, // n 0b0000000000000000,