Beispiel #1
0
int main (int argc, char **argv) {
	int value;
	
	if (argc != 2) {
		usage();
		exit(1);
	}
	else if (strcmp(argv[1],"on") == 0) {
		value=read_control();
		if (value > 0)
			value--;
		show_status(write_control(value));
	}
	else if (strcmp(argv[1],"off") == 0) {
		show_status(write_control(read_control() + 1));
	}
	else if (strcmp(argv[1],"status") == 0) {
		verify_daemon_running();
		show_status(read_control());
	}
	else {
		usage();
		exit(1);
	}
	exit(0);
}
Beispiel #2
0
void init_lcd(void) {
   DDRC |= _BV(LCD_E_PIN);
   DDRF |= _BV(LCD_RS_PIN);
   DDRA = 0xFF; //make all the data pins output

/*   write_control(0x38);  //function set
   _delay_ms(5);

   write_control(0x38);  //function set
   _delay_us(160);

   write_control(0x38);  //function set
   _delay_us(160);
   write_control(0x38);  //function set
   _delay_us(160);
   write_control(0x08);  //turn display off
   _delay_us(160);
   write_control(0x01);  //clear display
   _delay_us(4000);
   write_control(0x06);  //set entry mode
   _delay_us(160);*/

   write_control(0x38); //function set
   _delay_us(100);
   write_control(0x0C);
   _delay_us(100);
   
}
Beispiel #3
0
SR_PRIV int hantek_6xxx_update_vdiv(const struct sr_dev_inst *sdi)
{
	struct dev_context *devc = sdi->priv;
	int ret1, ret2;

	sr_dbg("update vdiv %d %d", voltage_to_reg(devc->voltage[0]),
		voltage_to_reg(devc->voltage[1]));

	ret1 = write_control(sdi, VDIV_CH1_REG, voltage_to_reg(devc->voltage[0]));
	ret2 = write_control(sdi, VDIV_CH2_REG, voltage_to_reg(devc->voltage[1]));

	return MIN(ret1, ret2);
}
Beispiel #4
0
SR_PRIV int hantek_6xxx_update_samplerate(const struct sr_dev_inst *sdi)
{
	struct dev_context *devc = sdi->priv;
	sr_dbg("update samplerate %d", samplerate_to_reg(devc->samplerate));

	return write_control(sdi, SAMPLERATE_REG, samplerate_to_reg(devc->samplerate));
}
//perform all initialization
void initialize(void) {
    DDRC = 0x00;

    sbi(DDRD,4);
    sbi(DDRD,5);
    sbi(DDRD,6);

    sbi(PORTD,4);
    cbi(PORTD,5);
    cbi(PORTD,6);

    sbi(DDRB,0);
    sbi(DDRB,1);
    cbi(PORTB,0); //set E low
    cbi(PORTB,1); //set RS low

    sbi(PORTD,7); //enable pullup for switch

    //initialization for each system
    //commenting out unused systems increases overall performance
    //servo_init();
    adc_init();
    lcd_init();
    //motor_init();

    /*Turn off watchdog timer*/
    WDTCR |= (1<<WDTOE) | (1<<WDE);
    WDTCR = 0x00;

    write_control(0x0C); //turn on lcd
    delay_us(160);
}
Beispiel #6
0
SR_PRIV int hantek_6xxx_update_channels(const struct sr_dev_inst *sdi)
{
	struct dev_context *devc = sdi->priv;
	uint8_t chan = devc->ch_enabled[1] ? 2 : 1;
	sr_dbg("update channels amount %d", chan);

	return write_control(sdi, CHANNELS_REG, chan);
}
Beispiel #7
0
SR_PRIV int hantek_6xxx_update_coupling(const struct sr_dev_inst *sdi)
{
	struct dev_context *devc = sdi->priv;
	uint8_t coupling = 0xFF & ((devc->coupling[1] << 4) | devc->coupling[0]);

	sr_dbg("update coupling 0x%x", coupling);

	return write_control(sdi, COUPLING_REG, coupling);
}
Beispiel #8
0
void lcd_cursor(uint8_t col, uint8_t row)
{
   if (col >= 16 || row >= 2)
   {
      return;
   }

   u08 addr = _HOME_ADDR + row * _LINE_INCR + col;
   write_control(addr);
}
Beispiel #9
0
    // UI to host
    Q_SLOT void portChange(int p) {
        float val = widgets[p]->get_value();
#ifndef ROGUI_UI_TEST
        write_control(p, val);
#endif
        QLabel* label = labels[p];
        if (label) {
            label->setNum(val);
        }
    }
static void __init lasi_ps2_reset(unsigned long hpa)
{
	u8 control;

	/* reset the interface */
	gsc_writeb(0xff, hpa+LASI_RESET);
	gsc_writeb(0x0 , hpa+LASI_RESET);		

	/* enable it */
	control = read_control(hpa);
	write_control(control | LASI_CTRL_ENBL, hpa);
}
/* this might become useful again at some point.  not now  -prumpf */
int lasi_ps2_test(void *hpa)
{
	u8 control,c;
	int i, ret = 0;

	control = read_control(hpa);
	write_control(control | LASI_CTRL_LPBXR | LASI_CTRL_ENBL, hpa);

	for (i=0; i<256; i++) {
		write_output(i, hpa);

		while (!(read_status(hpa) & LASI_STAT_RBNE))
		    /* just wait */;
		    
		c = read_input(hpa);
		if (c != i)
			ret--;
	}

	write_control(control, hpa);

	return ret;
}
Beispiel #12
0
void lcd_init(void) {
  //initialize the LCD as described in the HD44780 datasheet

  write_control(0x38);  //function set
  delay_ms(5);

  write_control(0x38);  //function set
  delay_us(160);

  write_control(0x38);  //function set
  delay_us(160);
  write_control(0x38);  //function set
  delay_us(160);
  write_control(0x08);  //turn display off
  delay_us(160);
  write_control(0x01);  //clear display
  delay_us(4000);
  write_control(0x06);  //set entry mode
  delay_us(160);
}
Beispiel #13
0
// Moves the LCD cursor to row <row> column <col>.
// <row> ranges from 0 to 1.
// <col> ranges from 0 to 16.
void lcd_cursor(u08 row, u08 col) {
  write_control(HOME | (row << 6) | (col % 17));
  delay_us(100);
}
Beispiel #14
0
static int pmc_cpu_write_control(int nrctrs, struct pmc_control *control)
{
	return(write_control(nrctrs, control));
}
int main(int argc, char **argv){

  /* Set the loop speed to default. This will get raised if the loop is to
   * slow 
   */
  loop_speed_ns = LOOP_SPEED_NS;

  /* Parse the input */
  if(argc < 3){
    printf("Usage: controller_framework [IP_ADDR] [PORT] [BT_ADDR] "); 
    printf("[RF_COMM CHANNEL]\n");
    return EINVAL;
  }

  /* Initialize communication */
  if(init_udp_conn(argv[1], argv[2]))
    return -1;

  if(init_bt_conn(argv[3], argv[4]))
    return -1;

  /* Preset the send buffer, since the protocol part of it does not change */
  send_buf[0] = BLUETOOTH_PROTOCOL_START;
  send_buf[3] = BLUETOOTH_PROTOCOL_STOP;

  /* initialization of mutex for threading */
  pthread_mutex_init(&readMutex, NULL);


  /* if the thread is successfully created -> start the algorithm */
  if (!pthread_create(&visionReadThread, NULL, read_vision_thread, (void *)NULL))
  {

    /* Intitialize the controller*/
    //The controller needs vision data to initialize, therefore it sits here.

    while(1){

      /* Get the current time */
      clock_gettime(CLK_ID, &start_time);


      /* Write the control information at the begining of the loop.
       * This way we have a defined point at where we write it.
       */
      write_control();

      /* Copy the vision data from the read thread */
      pthread_mutex_lock(&readMutex);
      memcpy(&vision_data_copy, &vision_data, sizeof(PI_IN));
      pthread_mutex_unlock(&readMutex);


      /* Call the controller */
      //the_algorithm(vision_data_copy, &steering_val, &throttle_val);


      /* Get current time */
      clock_gettime(CLK_ID, &end_time);
      /* Calculate runtime and sleep */
      finishCycle();

    }
  }
  else
  {
    printf("Error when creating the thread!\n");
  }

  pthread_exit(NULL);

  return 0;
}
Beispiel #16
0
SR_PRIV int hantek_6xxx_stop_data_collecting(const struct sr_dev_inst *sdi)
{
	return write_control(sdi, TRIGGER_REG, 0);
}
Beispiel #17
0
SR_PRIV int hantek_6xxx_start_data_collecting(const struct sr_dev_inst *sdi)
{
	sr_dbg("trigger");
	return write_control(sdi, TRIGGER_REG, 1);
}
Beispiel #18
0
 void QueryAgent::wakeup() {
   char buf = '!';
   if(write(write_control(), &buf, 1) < 0) {
     std::cerr << "[QA: Write error: " << strerror(errno) << "]\n";
   }
 }
Beispiel #19
0
void clear_screen(void) {
  write_control(0x01);  //clear display
  _delay_us(4000);
}
Beispiel #20
0
void next_line(void) {
  write_control(0xc0);  //go to the second line on the display
  delay_us(100);
}