Esempio n. 1
0
/**
 * @brief Reset an I2C bus.
 *
 * Reset is accomplished by clocking out pulses until any hung slaves
 * release SDA and SCL, then generating a START condition, then a STOP
 * condition.
 *
 * @param dev I2C device
 */
void i2c_bus_reset(const i2c_dev *dev) {
    /* Release both lines */
    i2c_master_release_bus(dev);

    /*
     * Make sure the bus is free by clocking it until any slaves release the
     * bus.
     */
    while (!gpio_read_bit(sda_port(dev), dev->sda_pin)) {
        /* Wait for any clock stretching to finish */
        while (!gpio_read_bit(scl_port(dev), dev->scl_pin))
            ;
        delay_us(10);

        /* Pull low */
        gpio_write_bit(scl_port(dev), dev->scl_pin, 0);
        delay_us(10);

        /* Release high again */
        gpio_write_bit(scl_port(dev), dev->scl_pin, 1);
        delay_us(10);
    }

    /* Generate start then stop condition */
    gpio_write_bit(sda_port(dev), dev->sda_pin, 0);
    delay_us(10);
    gpio_write_bit(scl_port(dev), dev->scl_pin, 0);
    delay_us(10);
    gpio_write_bit(scl_port(dev), dev->scl_pin, 1);
    delay_us(10);
    gpio_write_bit(sda_port(dev), dev->sda_pin, 1);
}
Esempio n. 2
0
File: gpio.c Progetto: E-LLP/n900
/* Read pin mux function: 0= pin used as GPIO, 1= pin used for muxed function*/
int pnx4008_gpio_read_pin_mux(unsigned short pin)
{
	int gpio = GPIO_BIT_MASK(pin);
	int ret = -EFAULT;

	gpio_lock();
	if (GPIO_ISBID(pin)) {
		ret = gpio_read_bit(PIO_MUX_STATE, gpio_to_mux_map[gpio]);
	} else if (GPIO_ISOUT(pin)) {
		ret = gpio_read_bit(PIO_MUX_STATE, outp_to_mux_map[gpio]);
	} else if (GPIO_ISMUX(pin)) {
		ret = gpio_read_bit(PIO_MUX_STATE, gpio);
	}
	gpio_unlock();
	return ret;
}
Esempio n. 3
0
int get_gpio(int pin)
{
	int value;
	gpio_set_dir_in(pin);
	gpio_read_bit(pin, &value);
	return value;
}
Esempio n. 4
0
/**
 * Get state of sleep switch
 * @return 1 if in Power up position
 * @return 0 if in Sleep position
 */
bool switch_state() {
	int wakeup = gpio_read_bit(PIN_MAP[MANUAL_WAKEUP_GPIO].gpio_device,
			PIN_MAP[MANUAL_WAKEUP_GPIO].gpio_bit);
	if (wakeup != 0)
		return SWITCH_SLEEP;
	else
		return SWITCH_POWERUP;
}
uint32 digitalRead(uint8 pin) {
    if (pin >= BOARD_NR_GPIO_PINS) {
        return 0;
    }

    return gpio_read_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit) ?
        HIGH : LOW;
}
U8 is_usb_connected(usb_attr_t *attr)
{
	if (usb_attr == NULL || (usb_attr && usb_attr->use_present_pin == 0))
		return usb_connected;
	else
	{
		return gpio_read_bit(usb_attr->present_port, usb_attr->present_pin);
	}
}
Esempio n. 7
0
int receiverA_listenForIR(void) {
  
  receiverA_currentPulse = 0;
 
  while (1) {
    uint16 highPulse, lowPulse;  // temporary storage timing
    highPulse = lowPulse = 0; // start out with no pulse length
 
      while(gpio_read_bit(RECEIVER_A_PORT, RECEIVER_A_PIN)){
       // pin is still HIGH
 
       // count off another few microseconds
       highPulse++;
       delay_us(RESOLUTION);
 
       // If the pulse is too long, we 'timed out' - either nothing
       // was received or the code is finished, so print what
       // we've grabbed so far, and then reset
       if ((highPulse >= MAXPULSE) && (receiverA_currentPulse != 0)) {
         return receiverA_currentPulse;
       }
    }
    // we didn't time out so lets stash the reading
    receiverA_pulses[receiverA_currentPulse][0] = highPulse;
 
    // same as above
    //while (! (IRpin_PIN & _BV(IRpin))) {
      while(!(gpio_read_bit(RECEIVER_A_PORT, RECEIVER_A_PIN))){
       // pin is still LOW
       lowPulse++;
       delay_us(RESOLUTION);
       if ((lowPulse >= MAXPULSE)  && (receiverA_currentPulse != 0)) {
         return receiverA_currentPulse;
       }
    }
    receiverA_pulses[receiverA_currentPulse][1] = lowPulse;
 
    // we read one high-low pulse successfully, continue!
    receiverA_currentPulse++;
    if (receiverA_currentPulse > WANTED_PULSES){
      return 0;
    }
  }
}
Esempio n. 8
0
static int sh_gpio_get_value(struct pinmux_info *gpioc, unsigned gpio)
{
	struct pinmux_data_reg *dr = NULL;
	int bit = 0;

	if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0)
		return -1;

	return gpio_read_bit(dr, bit);
}
Esempio n. 9
0
static void ps_button(void *args)
{
	signal = 0;
	for (;;) {
		if (gpio_read_bit(USR_BUT_PORT, USR_BUT_PIN)) {
//                      os_log(LOG_INFO, "%s - pressed.\n", __func__);
			signal = 1;
		}
		os_process_sleep(10);
	}
}
Esempio n. 10
0
File: gpio.c Progetto: E-LLP/n900
/* Read GPIO pin direction: 0= pin used as input, 1= pin used as output*/
int pnx4008_gpio_read_pin_direction(unsigned short pin)
{
	int gpio = GPIO_BIT_MASK(pin);
	int ret = -EFAULT;

	gpio_lock();
	if (GPIO_ISBID(pin) || GPIO_ISRAM(pin)) {
		ret = gpio_read_bit(PIO_DRV_STATE, gpio);
	}
	gpio_unlock();
	return ret;
}
Esempio n. 11
0
/**
 * @brief Reset an I2C bus.
 *
 * Reset is accomplished by clocking out pulses until any hung slaves
 * release SDA and SCL, then generating a START condition, then a STOP
 * condition.
 *
 * @param dev I2C device
 */
void i2c_bus_reset(i2c_dev *dev) {

    //unsigned clock_count;
    //unsigned stretch_count;

    i2c_deinit(dev);

    /* Release both lines */
    i2c_master_release_bus(dev);

    /*
     * Make sure the bus is free by clocking it until any slaves release the
     * bus.
     */
    while (!gpio_read_bit(dev->gpio_port, dev->sda_pin)) {
        /* Wait for any clock stretching to finish */
        while (!gpio_read_bit(dev->gpio_port, dev->scl_pin))
            ;
        delay_us(10);

        /* Pull low */
        gpio_write_bit(dev->gpio_port, dev->scl_pin, 0);
        delay_us(10);

        /* Release high again */
        gpio_write_bit(dev->gpio_port, dev->scl_pin, 1);
        delay_us(10);
    }

    /* Generate start then stop condition */
    gpio_write_bit(dev->gpio_port, dev->sda_pin, 0);
    delay_us(10);
    gpio_write_bit(dev->gpio_port, dev->scl_pin, 0);
    delay_us(10);
    gpio_write_bit(dev->gpio_port, dev->scl_pin, 1);
    delay_us(10);
    gpio_write_bit(dev->gpio_port, dev->sda_pin, 1);

    i2c_init(dev, 0, I2C_400KHz_SPEED);
}
Esempio n. 12
0
File: gpio.c Progetto: E-LLP/n900
/* Write Value to output */
int pnx4008_gpio_write_pin(unsigned short pin, int output)
{
	int gpio = GPIO_BIT_MASK(pin);
	int ret = -EFAULT;

	gpio_lock();
	if (GPIO_ISOUT(pin)) {
		printk( "writing '%x' to '%x'\n",
				gpio, output ? PIO_OUTP_SET : PIO_OUTP_CLR );
		ret = gpio_set_bit(output ? PIO_OUTP_SET : PIO_OUTP_CLR, gpio);
	} else if (GPIO_ISRAM(pin)) {
		if (gpio_read_bit(PIO_DRV_STATE, gpio) > 0)
			ret = gpio_set_bit(output ? PIO_SDOUTP_SET :
					   PIO_SDOUTP_CLR, gpio);
	} else if (GPIO_ISBID(pin)) {
		if (gpio_read_bit(PIO_DRV_STATE, gpio) > 0)
			ret = gpio_set_bit(output ? PIO_OUTP_SET :
					   PIO_OUTP_CLR, gpio);
	}
	gpio_unlock();
	return ret;
}
Esempio n. 13
0
void cmd_magread(char *line) {
  gpio_set_mode (PIN_MAP[41].gpio_device,PIN_MAP[41].gpio_bit, GPIO_OUTPUT_PP); // MAGPOWER
  gpio_set_mode (PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit, GPIO_INPUT_PU);  // MAGSENSE

  // Power up magsense
  gpio_write_bit(PIN_MAP[41].gpio_device,PIN_MAP[41].gpio_bit,1);

  // wait...
  delay_us(1000);

  // Read magsense
  int magsense = gpio_read_bit(PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit);

  char magsenses[50];
  sprintf(magsenses,"%u\r\n",magsense);
  serial_write_string(magsenses);
}
Esempio n. 14
0
int receiverA_listenSignal(void){
    
    if(gpio_read_bit(RECEIVER_A_PORT, RECEIVER_A_PIN) == 0){

    receiverA_numberPulses = receiverA_listenForIR();
    receiverA_playerNumber = receiverA_interpretCode();

    //In theory, sets the player number to zero if the number of pulses does not fit with criteria.
    if((receiverA_numberPulses > WANTED_PULSES)||(receiverA_numberPulses < (WANTED_PULSES-1))){
      receiverA_playerNumber = 0;
    }
            
    return receiverA_playerNumber;

    } else {
      return 0;
    }
        
}
Esempio n. 15
0
File: gpio.c Progetto: E-LLP/n900
unsigned long pnx4008_gpio_read_pin(unsigned short pin)
{
	unsigned long ret = -EFAULT;
	int gpio = GPIO_BIT_MASK(pin);
	gpio_lock();
	if (GPIO_ISOUT(pin)) {
		ret = gpio_read_bit(PIO_OUTP_STATE, gpio);
	} else if (GPIO_ISRAM(pin)) {
		if (gpio_read_bit(PIO_DRV_STATE, gpio) == 0) {
			ret = gpio_read_bit(PIO_SDINP_STATE, gpio);
		}
	} else if (GPIO_ISBID(pin)) {
		ret = gpio_read_bit(PIO_DRV_STATE, gpio);
		if (ret > 0)
			ret = gpio_read_bit(PIO_OUTP_STATE, gpio);
		else if (ret == 0)
			ret =
			    gpio_read_bit(PIO_INP_STATE, gpio_to_inp_map[gpio]);
	} else if (GPIO_ISIN(pin)) {
		ret = gpio_read_bit(PIO_INP_STATE, gpio);
	}
	gpio_unlock();
	return ret;
}
Esempio n. 16
0
static irqreturn_t  gpio_scankey_handler(int irq, void *dev_id)
{
	unsigned int  reg_tmp=0;
 	static unsigned int perkey = 0;
	unsigned int  reg_tmp1=0;
	unsigned int  reg_tmp2=0;
	static int swresetrepeatcount=0,havevgarepeatcount =0;
	WRITE_REG(TIMER_INTCLR_OFFSET,0x1);
	mdelay(1);
	reg_tmp=READ_REG(GPIO_5_READ_DATA);
	reg_tmp1=gpio_read_bit(GPIO_0_BASE_ADDR,5);///READ_REG(GPIO_2_READ_DATA);vga input signal!!
	reg_tmp2=gpio_read_bit(GPIO_2_BASE_ADDR,5);//READ_REG(GPIO_2_READ_DATA); sw reset button!!
	if (reg_tmp2==0)
		swresetrepeatcount++;
	else
		swresetrepeatcount = 0;

	if (reg_tmp1==0)
		havevgarepeatcount++;
	else
		havevgarepeatcount = 0;
		if ((perkey != reg_tmp))	{
			perkey = reg_tmp;
			time_acculte1 = repkey_timeout +1;
		} else if ((enable_repeatkey!=0)&&((reg_tmp &0x1f)!=0x1f))	{
			time_acculte1+=2*TIMER_EXPIRES_TIME;
		}
	
	if((time_acculte1>repkey_timeout)&&((reg_tmp &0x1f)!=0x1f)){
		reg_tmp = ((~reg_tmp)& 0x1f);
		if (reg_tmp>=0x10) {
			reg_tmp = reg_tmp-0x10;
		}
		key_value[tail]=reg_tmp;          	
		tail++;
		if(tail >200)
		{
			if((tail-head)<255)
			{
				memcpy(&key_value[0],&key_value[head],(tail-head));
				tail=tail-head;
				head=0;
			}
			else
			{
				memcpy(&key_value[0],&key_value[1],254);
				tail=254;
				head=0;
			}
		}
		time_acculte1=0;
	}
	if (swresetrepeatcount >= 75){
		key_value[tail]=16;
		tail++;
		if(tail >200)
		{
			if((tail-head)<255)
			{
				memcpy(&key_value[0],&key_value[head],(tail-head));
				tail=tail-head;
				head=0;
			}
			else
			{
				memcpy(&key_value[0],&key_value[1],254);
				tail=254;
				head=0;
			}
		}
		swresetrepeatcount = 0;		
	}
	if (havevgarepeatcount >= 15)	{
		key_value[tail]=0x20;
		tail++;
		if(tail >200)
		{
			if((tail-head)<255)
			{
				memcpy(&key_value[0],&key_value[head],(tail-head));
				tail=tail-head;
				head=0;
			}
			else
			{
				memcpy(&key_value[0],&key_value[1],254);
				tail=254;
				head=0;
			}
		}
		havevgarepeatcount = 0;
	}
// 	WRITE_REG(GPIO_5_WRITE_DATA,0xff);
    return IRQ_HANDLED;
}
Esempio n. 17
0
static void  _74ls165_handler(unsigned long l)
{
	static int times = 0;
	static int circle = 0;
	static int readtimes = 0;
	static unsigned char value = 0x0;
	
    //printk("jiffies:%x\n",jiffies);
    //enable 1-7,to select the first chip
	g_timer.expires = jiffies + 40;
	add_timer(&g_timer);

	gpio_dir_set_bit(0,2,0);
	gpio_dir_set_bit(0,0,1);
	gpio_dir_set_bit(0,1,1);
	
	/*gpio模拟时钟*/
	gpio_write_bit(0, 0, g_vlevel);
	
	if(times%2 == 0)/*下降触发*/
	{
		/*采样*/
		if((circle%SAMPLE_INTERVAL) == 0 )
		{
			gpio_write_bit(0, 1, 0);
			//mdelay(SHAKE_PROOF_TIME);
		}
		else
		{
			gpio_write_bit(0, 1, 1);
		}
		
		if((circle%SAMPLE_INTERVAL) == 1)
		{
			readtimes = 8;
		}
		
		if(readtimes)
		{
			char tmp = gpio_read_bit(0,2);
			value |= (tmp<<(readtimes-1));
			readtimes -- ;
		}
		else
		{
			if(value != 0)
			{
				if(!IS_BUF_FULL(&g_value_buf))
				{
					g_value_buf.value[g_value_buf.write] = value;
					UPDATE_WRITE(&g_value_buf);
				}
			}
			value = 0;
//			printk("g_value:0x%x\n",g_value);
		}
		circle++;
	}
	
	g_vlevel = !g_vlevel;
	times ++;

}
Esempio n. 18
0
void serial_process_command(char *line) {

  if(in_displayparams) {
    serial_displayparams_run(line);
    in_displayparams = false;
  }

  if(in_setdevicetag) {
    serial_setdevicetag_run(line);
    in_setdevicetag = false;
  }

  if(in_setrtc) {
    serial_setrtc_run(line);
    in_setrtc = false;
  }

  if(in_setkeyval) {
    serial_setkeyval_run(line);
    in_setkeyval = false;
  }

  serial_write_string("\r\n");
  if(strcmp(line,"HELLO") == 0) {
   serial_write_string("GREETINGS PROFESSOR FALKEN.\r\n");
  } else 
  if(strcmp(line,"LIST GAMES") == 0) {
    serial_write_string("I'M KIND OF BORED OF GAMES, TURNS OUT THE ONLY WAY TO WIN IS NOT TO PLAY...\r\n");
  } else 
  if(strcmp(line,"LOGXFER") == 0) {
    serial_sendlog();
  } else 
  if(strcmp(line,"DISPLAYPARAMS") == 0) {
    serial_displayparams();
  } else
  if(strcmp(line,"HELP") == 0) {
    serial_write_string("Available commands: HELP, LOGXFER, DISPLAYTEST, HELLO");
  } else 
  if(strcmp(line,"DISPLAYTEST") == 0) {
    display_test();
  } else
  if(strcmp(line,"LOGTEST") == 0) {
    char stemp[100];

    sprintf(stemp,"Raw log data\r\n");
    serial_write_string(stemp);

    uint8_t *flash_log = flashstorage_log_get();
    for(int n=0;n<1024;n++) {
      sprintf(stemp,"%u ",flash_log[n]);
      serial_write_string(stemp);
      if(n%64 == 0) serial_write_string("\r\n");
    }
    serial_write_string("\r\n");

    log_data_t data;
    data.time = 0;
    data.cpm  = 1;
    data.accel_x_start = 2;
    data.accel_y_start = 3;
    data.accel_z_start = 4;
    data.accel_x_end   = 5;
    data.accel_y_end   = 6;
    data.accel_z_end   = 7;
    data.log_type      = UINT_MAX;
    sprintf(stemp,"Log size: %u\r\n",flashstorage_log_size());
    serial_write_string(stemp);

    sprintf(stemp,"Writing test log entry of size: %u\r\n",sizeof(log_data_t));
    serial_write_string(stemp);

    flashstorage_log_pushback((uint8 *) &data,sizeof(log_data_t));

    sprintf(stemp,"Log size: %u\r\n",flashstorage_log_size());
    serial_write_string(stemp);
  } else 
  if(strcmp(line,"VERSION") == 0) {
    char stemp[50];
    sprintf(stemp,"Version: %s\r\n",OS100VERSION);
    serial_write_string(stemp);
  } else 
  if(strcmp(line,"GETDEVICETAG") == 0) {
    const char *devicetag = flashstorage_keyval_get("DEVICETAG");
    if(devicetag != 0) {
      char stemp[100];
      sprintf(stemp,"Devicetag: %s\r\n",devicetag);
      serial_write_string(stemp);
    } else {
      serial_write_string("No device tag set");
    }
  } else
  if(strcmp(line,"SETDEVICETAG") == 0) {
    serial_setdevicetag();
  } else 
  if(strcmp(line,"READPRIVATEKEY") == 0) {
   // serial_readprivatekey();  // removed for production
  } else
  if(strcmp(line,"WRITEPRIVATEKEY") == 0) {
   // serial_writeprivatekey(); // maybe this should be removed for production?
  } else 
  if(strcmp(line,"MAGREAD") == 0) {
    gpio_set_mode (PIN_MAP[41].gpio_device,PIN_MAP[41].gpio_bit, GPIO_OUTPUT_PP); // MAGPOWER
    gpio_set_mode (PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit, GPIO_INPUT_PU);  // MAGSENSE

    // Power up magsense
    gpio_write_bit(PIN_MAP[41].gpio_device,PIN_MAP[41].gpio_bit,1);

    // wait...
    delay_us(1000);
    
    // Read magsense
    int magsense = gpio_read_bit(PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit);

    char magsenses[50];
    sprintf(magsenses,"%u\r\n",magsense);
    serial_write_string(magsenses);
  } else
  if(strcmp(line,"WRITEDAC") == 0) {
    dac_init(DAC,DAC_CH2);

    int8_t idelta=1;
    uint8_t i=0;
    for(int n=0;n<1000000;n++) {
      
      if(i == 254) idelta = -1;
      if(i == 0  ) idelta =  1;

      i += idelta;

      dac_write_channel(DAC,2,i);
    }
    serial_write_string("WRITEDACFIN");
  } else
  if(strcmp(line,"TESTHP") == 0) {
    gpio_set_mode (PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit, GPIO_OUTPUT_PP);  // HP_COMBINED
    for(int n=0;n<100000;n++) {
      gpio_write_bit(PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit,1);
      delay_us(100);
      gpio_write_bit(PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit,0);
      delay_us(100);
    }
  } else 
  if(strcmp(line,"READADC") == 0) {

    adc_init(PIN_MAP[12].adc_device); // all on ADC1

    adc_set_extsel(PIN_MAP[12].adc_device, ADC_SWSTART);
    adc_set_exttrig(PIN_MAP[12].adc_device, true);

    adc_enable(PIN_MAP[12].adc_device);
    adc_calibrate(PIN_MAP[12].adc_device);
    adc_set_sample_rate(PIN_MAP[12].adc_device, ADC_SMPR_55_5);

    gpio_set_mode (PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit, GPIO_INPUT_ANALOG);
    gpio_set_mode (PIN_MAP[19].gpio_device,PIN_MAP[19].gpio_bit, GPIO_INPUT_ANALOG);
    gpio_set_mode (PIN_MAP[20].gpio_device,PIN_MAP[20].gpio_bit, GPIO_INPUT_ANALOG);

    int n=0;
    uint16 value1 = adc_read(PIN_MAP[12].adc_device,PIN_MAP[12].adc_channel);
    uint16 value2 = adc_read(PIN_MAP[19].adc_device,PIN_MAP[19].adc_channel);
    uint16 value3 = adc_read(PIN_MAP[20].adc_device,PIN_MAP[20].adc_channel);
    char values[50];
    sprintf(values,"PA6 ADC Read: %u\r\n",value1);
    serial_write_string(values);
    sprintf(values,"PC4 ADC Read: %u\r\n",value2);
    serial_write_string(values);
    sprintf(values,"PC5 ADC Read: %u\r\n",value3);
    serial_write_string(values);
  } else
  if(strcmp(line,"SETMICREVERSE") == 0) {
    gpio_set_mode (PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit, GPIO_OUTPUT_PP);  // MICREVERSE
    gpio_set_mode (PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit, GPIO_OUTPUT_PP);  // MICIPHONE
    gpio_write_bit(PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit,1); // MICREVERSE
    gpio_write_bit(PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit,0); // MICIPHONE
    serial_write_string("Set MICREVERSE to 1, MICIPHONE to 0\r\n");
  } else 
  if(strcmp(line,"SETMICIPHONE") == 0) {
    gpio_set_mode (PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit, GPIO_OUTPUT_PP);  // MICREVERSE
    gpio_set_mode (PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit, GPIO_OUTPUT_PP);  // MICIPHONE
    gpio_write_bit(PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit,0); // MICREVERSE
    gpio_write_bit(PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit,1); // MICIPHONE
    serial_write_string("Set MICREVERSE to 0, MICIPHONE to 1\r\n");
  } else
  if(strcmp(line,"TESTSIGN") == 0) {
    serial_signing_test();
  } else 
  if(strcmp(line,"PUBKEY") == 0) {
    signing_printPubKey();
    serial_write_string("\n\r");
  } else 
  if(strcmp(line,"GUID") == 0) {
    signing_printGUID();
    serial_write_string("\n\r");
  } else 
  if(strcmp(line,"KEYVALID") == 0) {
    if( signing_isKeyValid() == 1 )
      serial_write_string("uu_valid VALID KEY\r\n");
    else
      serial_write_string("uu_valid IMPROPER OR UNINITIALIZED KEY\r\n");
  } else 
  if(strcmp(line,"LOGSIG") == 0) {
    signing_hashLog();
    serial_write_string("\n\r");
  } else
  if(strcmp(line,"LOGPAUSE") == 0) {
    flashstorage_log_pause();
  } else 
  if(strcmp(line,"LOGRESUME") == 0) {
    flashstorage_log_resume();
  } else
  if(strcmp(line,"LOGCLEAR") == 0) {
    serial_write_string("Clearing flash log\r\n");
    flashstorage_log_clear();
    serial_write_string("Cleared\r\n");
  } else
  if(strcmp(line,"KEYVALDUMP") == 0) {
    serial_keyvaldump();
  } else
  if(strcmp(line,"KEYVALSET") == 0) {
    serial_setkeyval();
  } else
  if(strcmp(line,"SETRTC") == 0) {
    serial_setrtc();
  } else
  if(strcmp(line,"RTCALARM") == 0) {
    serial_write_string("Alarm triggered for 10s\r\n");
    rtc_set_alarm(RTC,rtc_get_time(RTC)+10);
  }

  serial_write_string("\r\n>");
}