7 #include "../SDK/src/ISConstants.h" 8 #include "../SDK/src/com_manager.h" 9 #include "conf_common.h" 10 #include "misc/utilities.h" 18 #define ROUNDUP(x, y) ((x % y) ? ((x) += 4-((x)%4)) : (x)) 21 #define PARAM_STARTING_LINE 1 22 #define MAX_NUM_LINES 50 23 #define MAX_NAME_LENGTH 60 24 #define MAX_VALUE_LENGTH 20 27 typedef enum number_type_t{
R_X08=0,
R_U08,
R_S08,
R_X16,
R_U16,
R_S16,
R_X32,
R_U32,
R_S32,
R_F32,
R_F64,
R_F32_R2D,
R_STR,
R_BLANK }
number_type_t;
60 #if 0 // terminal code 62 static char g_refresh_term;
63 static int g_numLines;
64 static int g_selLine=1;
66 static int g_valueSize=0;
86 int n =
vsnprintf(debugMsg,
sizeof(debugMsg - 1), format, ap) + 1;
94 void dg_prt_apd(
const char *__fmt, ...)
100 n =
vsnprintf(&g_txBuf[g_txN], TXBUF_SIZE-g_txN, __fmt, ap);
103 n =
min(n, TXBUF_SIZE);
109 void dg_prt_snd(
void)
111 DBG_WRITE((
unsigned char*) g_txBuf, g_txN);
117 void dg_prt_clr(
void)
125 #if 0 // terminal code 127 void dg_vt100_clear(
void) {
dg_printf(
"\x1B[2J"); }
128 void dg_vt100_home(
void) {
dg_printf(
"\x1B[H"); }
129 void dg_vt100_row(
unsigned int row) {
dg_printf(
"\x1B[%dH", row); }
130 void dg_vt100_belowParams(
void) {
dg_printf(
"\x1B[%dH", g_numLines+2); }
143 void term_update(
void)
162 buf[0] = tolower(buf[0]);
165 (buf[0]>=
'a' && buf[0]<=
'f')) ||
166 buf[0]==
'.' || buf[0]==
'-' || (buf[0]>=
'0' && buf[0]<=
'9') )
169 memcpy( &g_value[g_valueSize], buf, n);
173 switch(g_term[g_selLine].
numType)
175 case R_X08: sscanf(g_value,
"%x", &i); g_term[g_selLine].
u08 = (
U8)i;
break;
176 case R_U08: sscanf(g_value,
"%u", &i); g_term[g_selLine].
u08 = (
U8)i;
break;
177 case R_S08: sscanf(g_value,
"%d", &i); g_term[g_selLine].
s08 = (
S8)i;
break;
178 case R_X16: sscanf(g_value,
"%x", &i); g_term[g_selLine].
u16 = (
U8)i;
break;
179 case R_U16: sscanf(g_value,
"%u", &i); g_term[g_selLine].
u16 = (
U8)i;
break;
180 case R_S16: sscanf(g_value,
"%d", &i); g_term[g_selLine].
s16 = (
S8)i;
break;
181 case R_X32: sscanf(g_value,
"%x", &g_term[g_selLine].
u32);
break;
182 case R_U32: sscanf(g_value,
"%u", &g_term[g_selLine].u32);
break;
183 case R_S32: sscanf(g_value,
"%d", &g_term[g_selLine].
s32);
break;
184 case R_F32: sscanf(g_value,
"%f", &g_term[g_selLine].
f32);
break;
185 case R_F64: sscanf(g_value,
"%lf", &g_term[g_selLine].
f64);
break;
197 switch(g_term[g_selLine].
numType)
200 case R_U08: *g_term[g_selLine].
u08p = g_term[g_selLine].
u08;
break;
201 case R_S08: *g_term[g_selLine].
s08p = g_term[g_selLine].
s08;
break;
203 case R_U16: *g_term[g_selLine].
u16p = g_term[g_selLine].
u16;
break;
204 case R_S16: *g_term[g_selLine].
s16p = g_term[g_selLine].
s16;
break;
206 case R_U32: *g_term[g_selLine].
u32p = g_term[g_selLine].
u32;
break;
207 case R_S32: *g_term[g_selLine].
s32p = g_term[g_selLine].
s32;
break;
209 case R_F32: *g_term[g_selLine].
f32p = g_term[g_selLine].
f32;
break;
210 case R_F64: *g_term[g_selLine].
f64p = g_term[g_selLine].
f64;
break;
220 switch(g_term[g_selLine].
numType)
223 case R_U08: flash_write_U08( (
void*)(g_term[g_selLine].
u08p), g_term[g_selLine].
u08 );
break;
224 case R_S08: flash_write_S08( (
void*)(g_term[g_selLine].
s08p), g_term[g_selLine].
s08 );
break;
226 case R_U16: flash_write_U16( (
void*)(g_term[g_selLine].
u16p), g_term[g_selLine].
u16 );
break;
227 case R_S16: flash_write_S16( (
void*)(g_term[g_selLine].
s16p), g_term[g_selLine].
s16 );
break;
229 case R_U32: flash_write_U32( (
void*)(g_term[g_selLine].
u32p), g_term[g_selLine].
u32 );
break;
230 case R_S32: flash_write_S32( (
void*)(g_term[g_selLine].
s32p), g_term[g_selLine].
s32 );
break;
232 case R_F32: flash_write_F32( (
void*)(g_term[g_selLine].
f32p), g_term[g_selLine].
f32 );
break;
233 case R_F64: flash_write_F64( (
void*)(g_term[g_selLine].
f64p), g_term[g_selLine].
f64 );
break;
266 g_selLine =
max(--g_selLine, 0);
268 switch( g_term[g_selLine].
numType )
273 g_selLine =
min(++g_selLine, g_numLines-1);
275 g_selLine =
max(--g_selLine, 0);
283 g_selLine =
min(++g_selLine, g_numLines-1);
285 switch( g_term[g_selLine].numType )
289 if(g_selLine==g_numLines-1)
290 g_selLine =
max(--g_selLine, 0);
292 g_selLine =
min(++g_selLine, g_numLines-1);
316 g_selLine =
max(--g_selLine, 0);
318 switch( g_term[g_selLine].numType )
323 g_selLine =
min(++g_selLine, g_numLines-1);
325 g_selLine =
max(--g_selLine, 0);
333 g_selLine =
min(++g_selLine, g_numLines-1);
335 switch( g_term[g_selLine].numType )
339 if(g_selLine==g_numLines-1)
340 g_selLine =
max(--g_selLine, 0);
342 g_selLine =
min(++g_selLine, g_numLines-1);
351 g_menu = buf[3] - 48;
353 g_menu = buf[3] - 49;
359 g_menu = buf[3] - 39;
361 g_menu = buf[3] - 40;
377 g_valueSize =
max(--g_valueSize, 0);
378 g_value[g_valueSize] = 0;
380 switch(g_term[g_selLine].numType)
382 case R_X08: sscanf(g_value,
"%x", &i); g_term[g_selLine].
u08 = (
U8)i;
break;
383 case R_U08: sscanf(g_value,
"%u", &i); g_term[g_selLine].
u08 = (
U8)i;
break;
384 case R_S08: sscanf(g_value,
"%d", &i); g_term[g_selLine].
s08 = (
S8)i;
break;
385 case R_X16: sscanf(g_value,
"%x", &i); g_term[g_selLine].
u16 = (
U8)i;
break;
386 case R_U16: sscanf(g_value,
"%u", &i); g_term[g_selLine].
u16 = (
U8)i;
break;
387 case R_S16: sscanf(g_value,
"%d", &i); g_term[g_selLine].
s16 = (
S8)i;
break;
388 case R_X32: sscanf(g_value,
"%x", &g_term[g_selLine].
u32);
break;
389 case R_U32: sscanf(g_value,
"%u", &g_term[g_selLine].u32);
break;
390 case R_S32: sscanf(g_value,
"%d", &g_term[g_selLine].
s32);
break;
391 case R_F32: sscanf(g_value,
"%f", &g_term[g_selLine].
f32);
break;
393 case R_F64: sscanf(g_value,
"%lf", &g_term[g_selLine].
f64);
break;
401 memset((
void*)g_value, 0,
sizeof(g_value));
416 g_selLine =
max(
min(g_selLine, g_numLines-1), 0);
423 for( i=0; i<g_numLines; i++)
429 if(g_valueSize) c =
'>';
437 if( i==g_selLine && g_valueSize>0)
442 case R_U08:
dg_printf(
"%c %12u %c%s", c, g_term[i].u08, mt, g_term[i].name);
break;
443 case R_S08:
dg_printf(
"%c %12d %c%s", c, g_term[i].
s08, mt, g_term[i].name);
break;
444 case R_X16:
dg_printf(
"%c 0x%4x %c%s", c, g_term[i].
u16, mt, g_term[i].name);
break;
445 case R_U16:
dg_printf(
"%c %12u %c%s", c, g_term[i].u16, mt, g_term[i].name);
break;
446 case R_S16:
dg_printf(
"%c %12d %c%s", c, g_term[i].
s16, mt, g_term[i].name);
break;
447 case R_X32:
dg_printf(
"%c 0x%8x %c%s", c, g_term[i].
u32, mt, g_term[i].name);
break;
448 case R_U32:
dg_printf(
"%c %12u %c%s", c, g_term[i].u32, mt, g_term[i].name);
break;
449 case R_S32:
dg_printf(
"%c %12d %c%s", c, g_term[i].
s32, mt, g_term[i].name);
break;
450 case R_F32:
dg_printf(
"%c %12f %c%s", c, g_term[i].
f32, mt, g_term[i].name);
break;
452 case R_F64:
dg_printf(
"%c %12lf %c%s", c, g_term[i].
f64, mt, g_term[i].name);
break;
461 case R_U08:
dg_printf(
"%c %12u %c%s", c, *g_term[i].u08p, mt, g_term[i].name);
break;
463 case R_X16:
dg_printf(
"%c 0x%4x %c%s", c, *g_term[i].
u16p, mt, g_term[i].name);
break;
465 case R_U16:
dg_printf(
"%c %12u %c%s", c, *g_term[i].u16p, mt, g_term[i].name);
break;
466 case R_X32:
dg_printf(
"%c 0x%8x %c%s", c, *g_term[i].
u32p, mt, g_term[i].name);
break;
467 case R_U32:
dg_printf(
"%c %12u %c%s", c, *g_term[i].u32p, mt, g_term[i].name);
break;
471 case R_F64:
dg_printf(
"%c %12lf %c%s", c, *g_term[i].
f64p, mt, g_term[i].name);
break;
472 case R_STR:
dg_printf(
"%c %s %s", c, g_term[i].s08p, g_term[i].name);
break;
507 case R_U08: g_term[g_numLines].
u08p = (
unsigned char*)ptr;
break;
508 case R_S08: g_term[g_numLines].
s08p = (
char*)ptr;
break;
510 case R_U16: g_term[g_numLines].
u16p = (
unsigned short*)ptr;
break;
511 case R_S16: g_term[g_numLines].
s16p = (
short*)ptr;
break;
513 case R_U32: g_term[g_numLines].
u32p = (
unsigned int*)ptr;
break;
514 case R_S32: g_term[g_numLines].
s32p = (
int*)ptr;
break;
516 case R_F32_R2D: g_term[g_numLines].
f32p = (
float*)ptr;
break;
517 case R_F64: g_term[g_numLines].
f64p = (
double*)ptr;
break;
523 memcpy((
void*)g_term[g_numLines].name, name, nameLen);
532 void term_addBlankLine(
void)
546 const char blankStr[] =
" ";
547 void term_addLabel(
char*
name ) { term_addVarStr( (
void*)blankStr, name ); }
575 #endif // terminal code
struct term_line_t term_line_t
int8_t S8
8-bit signed integer.
#define PARAM_STARTING_LINE
#define min(a, b)
Takes the minimal value of a and b.
#define max(a, b)
Takes the maximal value of a and b.
void term_add(void *val, char *name, memory_type_t memType, number_type_t numType)
char name[MAX_NAME_LENGTH]
void dg_printf(const char *format,...)
uint8_t U8
8-bit unsigned integer.
Standard board header file.