mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Disable unused ChibiOS options:
CH_CFG_USE_WAITEXIT (used only is Shell run as thread) CH_CFG_USE_EVENTS (NanoVNA not use events) CH_CFG_USE_EVENTS_TIMEOUT (NanoVNA not use events) Implement stack use check in "threads" command, now free stack space show in table as "stk free" in hex Check stack usage by sweep, and main threads (seems all ok, but add 64 bytes to sweep) Replace some const values to defined
This commit is contained in:
parent
d386b0823c
commit
17734f257d
6
chconf.h
6
chconf.h
|
|
@ -156,7 +156,7 @@
|
|||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_WAITEXIT TRUE
|
||||
#define CH_CFG_USE_WAITEXIT FALSE
|
||||
|
||||
/**
|
||||
* @brief Semaphores APIs.
|
||||
|
|
@ -221,7 +221,7 @@
|
|||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_EVENTS TRUE
|
||||
#define CH_CFG_USE_EVENTS FALSE
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs with timeout.
|
||||
|
|
@ -231,7 +231,7 @@
|
|||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_EVENTS.
|
||||
*/
|
||||
#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
|
||||
#define CH_CFG_USE_EVENTS_TIMEOUT FALSE
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages APIs.
|
||||
|
|
|
|||
48
main.c
48
main.c
|
|
@ -80,7 +80,11 @@ int8_t cal_auto_interpolate = TRUE;
|
|||
uint16_t redraw_request = 0; // contains REDRAW_XXX flags
|
||||
int16_t vbat = 0;
|
||||
|
||||
static THD_WORKING_AREA(waThread1, 512);
|
||||
//
|
||||
// Profile stack usage (enable threads command by def ENABLE_THREADS_COMMAND) show:
|
||||
// Stack maximum usage = 480 bytes, free stack = 32+64 bytes
|
||||
//
|
||||
static THD_WORKING_AREA(waThread1, 512+64);
|
||||
static THD_FUNCTION(Thread1, arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
|
@ -110,7 +114,7 @@ static THD_FUNCTION(Thread1, arg)
|
|||
draw_battery_status();
|
||||
}
|
||||
|
||||
/* calculate trace coordinates and plot only if scan completed */
|
||||
// calculate trace coordinates and plot only if scan completed
|
||||
if (completed) {
|
||||
plot_into_index(measured);
|
||||
redraw_request |= REDRAW_CELLS;
|
||||
|
|
@ -124,8 +128,7 @@ static THD_FUNCTION(Thread1, arg)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* plot trace and other indications as raster */
|
||||
// plot trace and other indications as raster
|
||||
draw_all(completed); // flush markmap only if scan completed to prevent remaining traces
|
||||
chMtxUnlock(&mutex);
|
||||
}
|
||||
|
|
@ -207,6 +210,7 @@ transform_domain(void)
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
for (int ch = 0; ch < 2; ch++) {
|
||||
memcpy(tmp, measured[ch], sizeof(measured[0]));
|
||||
for (int i = 0; i < POINTS_COUNT; i++) {
|
||||
|
|
@ -1939,12 +1943,22 @@ VNA_SHELL_FUNCTION(cmd_threads) {
|
|||
thread_t *tp;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
chprintf(chp, "stklimit stack addr refs prio state name"VNA_SHELL_NEWLINE_STR);
|
||||
shell_printf("stklimit| stack|stk free| addr|refs|prio| state| name"VNA_SHELL_NEWLINE_STR);
|
||||
tp = chRegFirstThread();
|
||||
do {
|
||||
uint32_t max_stack_use = 0U;
|
||||
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
|
||||
uint32_t stklimit = (uint32_t)tp->wabase;
|
||||
shell_printf("%08x %08x %08x %4u %4u %9s %12s"VNA_SHELL_NEWLINE_STR,
|
||||
stklimit, (uint32_t)tp->ctx.sp, (uint32_t)tp,
|
||||
#if CH_DBG_FILL_THREADS == TRUE
|
||||
uint8_t *p = (uint8_t *)tp->wabase; while(p[max_stack_use]==CH_DBG_STACK_FILL_VALUE) max_stack_use++;
|
||||
#endif
|
||||
#else
|
||||
uint32_t stklimit = 0U;
|
||||
#endif
|
||||
|
||||
|
||||
shell_printf("%08x|%08x|%08x|%08x|%4u|%4u|%9s|%12s"VNA_SHELL_NEWLINE_STR,
|
||||
stklimit, (uint32_t)tp->ctx.sp, max_stack_use, (uint32_t)tp,
|
||||
(uint32_t)tp->refs - 1, (uint32_t)tp->prio, states[tp->state],
|
||||
tp->name == NULL ? "" : tp->name);
|
||||
tp = chRegNextThread(tp);
|
||||
|
|
@ -2142,6 +2156,11 @@ static DACConfig dac1cfg1 = {
|
|||
datamode: DAC_DHRM_12BIT_RIGHT
|
||||
};
|
||||
|
||||
|
||||
// Main thread stack size defined in makefile USE_PROCESS_STACKSIZE = 0x200
|
||||
// Profile stack usage (enable threads command by def ENABLE_THREADS_COMMAND) show:
|
||||
// Stack maximum usage = 472 bytes (need test more and run all commands), free stack = 40 bytes
|
||||
//
|
||||
int main(void)
|
||||
{
|
||||
halInit();
|
||||
|
|
@ -2161,7 +2180,6 @@ int main(void)
|
|||
*/
|
||||
sduObjectInit(&SDU1);
|
||||
sduStart(&SDU1, &serusbcfg);
|
||||
|
||||
/*
|
||||
* Activates the USB driver and then the USB bus pull-up on D+.
|
||||
* Note, a delay is inserted in order to not have to disconnect the cable
|
||||
|
|
@ -2177,11 +2195,6 @@ int main(void)
|
|||
*/
|
||||
ili9341_init();
|
||||
|
||||
/*
|
||||
* Initialize graph plotting
|
||||
*/
|
||||
plot_init();
|
||||
|
||||
/* restore config */
|
||||
config_recall();
|
||||
|
||||
|
|
@ -2199,8 +2212,6 @@ int main(void)
|
|||
if (config.default_loadcal >= 0)
|
||||
caldata_recall(config.default_loadcal);
|
||||
|
||||
redraw_frame();
|
||||
|
||||
/*
|
||||
* I2S Initialize
|
||||
*/
|
||||
|
|
@ -2211,12 +2222,17 @@ int main(void)
|
|||
i2sStartExchange(&I2SD2);
|
||||
|
||||
ui_init();
|
||||
|
||||
//Initialize graph plotting
|
||||
plot_init();
|
||||
redraw_frame();
|
||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);
|
||||
|
||||
while (1) {
|
||||
if (SDU1.config->usbp->state == USB_ACTIVE) {
|
||||
#ifdef VNA_SHELL_THREAD
|
||||
#if CH_CFG_USE_WAITEXIT == FALSE
|
||||
#error "VNA_SHELL_THREAD use chThdWait, need enable CH_CFG_USE_WAITEXIT in chconf.h"
|
||||
#endif
|
||||
thread_t *shelltp = chThdCreateStatic(waThread2, sizeof(waThread2),
|
||||
NORMALPRIO + 1,
|
||||
myshellThread, NULL);
|
||||
|
|
|
|||
29
plot.c
29
plot.c
|
|
@ -1462,7 +1462,7 @@ cell_drawstring(char *str, int x, int y)
|
|||
static void
|
||||
cell_draw_marker_info(int x0, int y0)
|
||||
{
|
||||
char buf[32];
|
||||
char buf[24];
|
||||
int t;
|
||||
if (active_marker < 0)
|
||||
return;
|
||||
|
|
@ -1474,8 +1474,8 @@ cell_draw_marker_info(int x0, int y0)
|
|||
for (mk = 0; mk < MARKERS_MAX; mk++) {
|
||||
if (!markers[mk].enabled)
|
||||
continue;
|
||||
int xpos = 1 + (j%2)*146 + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*8 - y0;
|
||||
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
setForegroundColor(config.trace_color[t]);
|
||||
if (mk == active_marker)
|
||||
|
|
@ -1507,13 +1507,13 @@ cell_draw_marker_info(int x0, int y0)
|
|||
// draw marker delta
|
||||
if (!uistat.marker_delta && previous_marker >= 0 && active_marker != previous_marker && markers[previous_marker].enabled) {
|
||||
int idx0 = markers[previous_marker].index;
|
||||
int xpos = 180 + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*8 - y0;
|
||||
int xpos = (WIDTH/2+30) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
plot_printf(buf, sizeof buf, S_DELTA"%d-%d", active_marker+1, previous_marker+1);
|
||||
plot_printf(buf, sizeof buf, S_DELTA"%d-%d:", active_marker+1, previous_marker+1);
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
cell_drawstring(buf, xpos, ypos);
|
||||
xpos += 24;
|
||||
xpos += 27;
|
||||
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
|
||||
uint32_t freq = frequencies[idx];
|
||||
uint32_t freq1 = frequencies[idx0];
|
||||
|
|
@ -1528,8 +1528,8 @@ cell_draw_marker_info(int x0, int y0)
|
|||
for (t = 0; t < TRACES_MAX; t++) {
|
||||
if (!trace[t].enabled)
|
||||
continue;
|
||||
int xpos = 1 + (j%2)*146 + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*8 - y0;
|
||||
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
setForegroundColor(config.trace_color[t]);
|
||||
if (t == uistat.current_trace)
|
||||
|
|
@ -1550,8 +1550,8 @@ cell_draw_marker_info(int x0, int y0)
|
|||
}
|
||||
|
||||
// draw marker frequency
|
||||
int xpos = 185 + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*8 - y0;
|
||||
int xpos = (WIDTH/2+40) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
if (uistat.lever_mode == LM_MARKER)
|
||||
|
|
@ -1572,7 +1572,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
if (electrical_delay != 0) {
|
||||
// draw electrical delay
|
||||
int xpos = 21 + CELLOFFSETX - x0;
|
||||
int ypos = 1 + ((j+1)/2)*8 - y0;
|
||||
int ypos = 1 + ((j+1)/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
float light_speed_ps = 299792458e-12; //(m/ps)
|
||||
plot_printf(buf, sizeof buf, "Edelay %Fs %Fm", electrical_delay * 1e-12,
|
||||
|
|
@ -1663,7 +1663,7 @@ draw_battery_status(void)
|
|||
{
|
||||
if (vbat<=0)
|
||||
return;
|
||||
uint8_t string_buf[25];
|
||||
uint8_t string_buf[16];
|
||||
// Set battery color
|
||||
setForegroundColor(vbat < BATTERY_WARNING_LEVEL ? DEFAULT_LOW_BAT_COLOR : DEFAULT_NORMAL_BAT_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
|
|
@ -1697,7 +1697,8 @@ request_to_redraw_grid(void)
|
|||
void
|
||||
redraw_frame(void)
|
||||
{
|
||||
ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
clearScreen();
|
||||
draw_frequencies();
|
||||
draw_cal_status();
|
||||
}
|
||||
|
|
|
|||
15
ui.c
15
ui.c
|
|
@ -1271,7 +1271,7 @@ draw_numeric_area_frame(void)
|
|||
ili9341_fill(0, 240-NUM_INPUT_HEIGHT, 320, NUM_INPUT_HEIGHT, DEFAULT_MENU_COLOR);
|
||||
setForegroundColor(DEFAULT_MENU_TEXT_COLOR);
|
||||
setBackgroundColor(DEFAULT_MENU_COLOR);
|
||||
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 240-FONT_GET_HEIGHT-(NUM_INPUT_HEIGHT-FONT_GET_HEIGHT)/2);
|
||||
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
||||
//ili9341_drawfont(KP_KEYPAD, 300, 216);
|
||||
}
|
||||
|
||||
|
|
@ -1297,8 +1297,8 @@ draw_numeric_input(const char *buf)
|
|||
if (ui_mode == UI_NUMERIC && uistat.digit == 8-i) {
|
||||
fg = DEFAULT_SPEC_INPUT_COLOR;
|
||||
focused = TRUE;
|
||||
if (uistat.digit_mode)
|
||||
bg = DEFAULT_MENU_COLOR;
|
||||
// if (uistat.digit_mode)
|
||||
// bg = DEFAULT_MENU_COLOR;
|
||||
}
|
||||
setForegroundColor(fg);
|
||||
setBackgroundColor(bg);
|
||||
|
|
@ -1307,12 +1307,12 @@ draw_numeric_input(const char *buf)
|
|||
else if (focused) // c not number, but focused
|
||||
ili9341_drawfont(0, x, 240-NUM_INPUT_HEIGHT+4);
|
||||
else // erase
|
||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, 20, 24, bg);
|
||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_WIDTH+2+8, bg);
|
||||
|
||||
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
|
||||
}
|
||||
// erase last
|
||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, 24, DEFAULT_MENU_COLOR);
|
||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, DEFAULT_MENU_COLOR);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1607,7 +1607,7 @@ ui_mode_numeric(int _keypad_mode)
|
|||
keypad_mode = _keypad_mode;
|
||||
ui_mode = UI_NUMERIC;
|
||||
area_width = AREA_WIDTH_NORMAL;
|
||||
area_height = 240-32;//AREA_HEIGHT_NORMAL - 32;
|
||||
area_height = 240-NUM_INPUT_HEIGHT;//AREA_HEIGHT_NORMAL - 32;
|
||||
|
||||
draw_numeric_area_frame();
|
||||
fetch_numeric_target();
|
||||
|
|
@ -1629,7 +1629,7 @@ ui_mode_keypad(int _keypad_mode)
|
|||
keypads_last_index = i;
|
||||
|
||||
ui_mode = UI_KEYPAD;
|
||||
area_width = AREA_WIDTH_NORMAL - 60;
|
||||
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
|
||||
area_height = HEIGHT - 32;
|
||||
draw_menu();
|
||||
draw_keypad();
|
||||
|
|
@ -2051,7 +2051,6 @@ ui_process_lever(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
drag_marker(int t, int m)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue