Exemple #1
0
void avnet_console_command_iic(demo_t *pInstance, int cargc, char ** cargv) {
	Xuint32 tmp;
	Xuint8 device;
	Xuint16 address, address2;
	Xuint8 data;

	int bDispSyntax = 0;
	tca9548_i2c_mux_select(pInstance->piicps, EMBV_IIC_MUX_CAM);

	if ( cargc > 1 && !strcmp(cargv[1],"help") ) {
		bDispSyntax = 1;
	}
	else if ( cargc < 2 ) {
		bDispSyntax = 1;
	}
	else {
		if (strcmp(cargv[1], "read") == 0) {
			if (cargc < 4) {
				bDispSyntax = 1;
			}
			else {
				scanhex(cargv[2], &tmp);	device = (Xuint8) tmp;
				scanhex(cargv[3], &tmp);	address = (Xuint16) tmp;

//				printf("  device = 0x%02X\n\r", device);
//				printf("  address = 0x%02X\n\r", address);

				XIicPs_A16_Read(pInstance->piicps,  (device >> 1), address, &data, 1);

				printf("  0x%02X[0x%02X] => 0x%02X\n\r", device, address, data);
			}
		}
		else if (strcmp(cargv[1], "write") == 0) {
			if (cargc < 5) {
				bDispSyntax = 1;
			} else {
				scanhex(cargv[2], &tmp);	device = (Xuint8) tmp;
				scanhex(cargv[3], &tmp);	address = (Xuint16) tmp;
				scanhex(cargv[4], &tmp);	data = (Xuint8) tmp;

//				printf("  device = 0x%02X\n\r", device);
//				printf("  address = 0x%02X\n\r", address);
//				printf("  data = 0x%02X\n\r", data);

				XIicPs_A16_Write(pInstance->piicps, (device >> 1), address, &data, 1);

				printf("  0x%02X[0x%02X] <= 0x%02X\n\r", device, address, data);
			}
		}
		else if (strcmp(cargv[1], "dump") == 0) {
Exemple #2
0
void avnet_console_hdmio_command( avnet_console_t *pConsole, int cargc, char ** cargv )
{
   int bDispSyntax = 0;
	Xuint32 tmp;
	Xuint8 clk_delay;

   if ( cargc > 1 && !strcmp(cargv[1],"help") )
   {
	  bDispSyntax = 1;
   }
   else if ( cargc > 1 )
   {
	  if ( !strcmp(cargv[1],"delay") )
	  {
         scanhex(cargv[2], &tmp);	clk_delay = (Xuint8) tmp;
         pzfmc2_hdmio_set_clk_delay( clk_delay );
	  }
   }

   if ( bDispSyntax )
   {
	  pConsole->io_hprintf( pConsole->io_handle, "\tSyntax :\r\n" );
	  pConsole->io_hprintf( pConsole->io_handle, "\t\thdmio delay => Set ADV7511 programmable clk delay (0=-1.2ns, ... 3=0ns, ... 7=+1.2ns)\r\n" );
   }

   return;
}
Exemple #3
0
value sml_int_of_hex(value s)
{ value v;
  long res;
  int sign;
  char * p;

  /* The argument s has form [~]?0x[0-9a-fA-F]+ */

  p = String_val(s);
  sign = 1;
  if (*p == '~') {
    sign = -1;
    p++;
  }
  /* skip 0x in s */
  p += 2;

  res = sign * scanhex(p, (unsigned long)MIN_TAGGED_LONG);
  v = LONG_TO_VAL(res);
  if( VAL_TO_LONG(v) != res )
    goto raise_failure;
  return v;

  raise_failure:
    failwith("sml_int_of_hex");
    return Val_unit;		/* Can't reach return */
}
Exemple #4
0
value sml_word_of_hex(value s)
{ value v;
  long res;
  char * p;

  /* The argument s has form 0wx[0-9a-fA-F]+ */

  p = String_val(s);
  /* skip 0wx in s */
  p += 3;

  res = scanhex(p, 2 * (unsigned long)MIN_TAGGED_LONG);
  v = LONG_TO_VAL((long)res);
  return v;
}
Exemple #5
0
void
adbcmds(void)
{
    char cmd;
    unsigned rtcu, rtcl, dec, pdec, x;
    int i, j;
    unsigned char d[64];

    cmd = skipbl();
    switch (cmd) {
    case 't':
	for (;;) {
	    rtcl = get_rtcl();
	    rtcu = get_rtcu();
	    dec = get_dec();
	    printf("rtc u=%u l=%u dec=%x (%d = %d.%.7d)\n",
		   rtcu, rtcl, dec, pdec - dec, (pdec - dec) / 1000000000,
		   ((pdec - dec) % 1000000000) / 100);
	    pdec = dec;
	    if (cmd == 'x')
		break;
	    while (xmon_read(stdin, &cmd, 1) != 1)
		;
	}
	break;
    case 'r':
	init_adb_log();
	while (adb_bitwait(8, 0, 0, 0) == 0)
	    adb_readin();
	break;
    case 'w':
	i = 0;
	while (scanhex(&x))
	    d[i++] = x;
	init_adb_log();
	j = adb_write(d, i);
	printf("sent %d bytes\n", j);
	while (adb_bitwait(8, 0, 0, 0) == 0)
	    adb_readin();
	break;
    case 'l':
	dump_adb_log();
	break;
    }
}
Exemple #6
0
int avnet_console_input_validate( avnet_console_t *pConsole, char * argv, int min, int max, int *value)
{
	unsigned int uvalue = 0;
	int negative = 0;

	if (argv[0] == '-') {
		argv++;
		negative = 1;
	} else if (argv[0] == '+') {
		argv++;
		negative = 0;
	}

    if (!scanhex( argv, &uvalue )) {
    	pConsole->io_hprintf( pConsole->io_handle, "Non numeric input detected!\r\n");
    	return 0;
    }

    *value = (negative == 1) ? -uvalue : uvalue;
    *value = RANGE_VALIDATE(*value, min, max);

    return 1;
}