コード例 #1
0
ファイル: diginwithlib.c プロジェクト: HITliuyu/NES15_HEVC
int main()
{
	initPin(GPIO_PIN1);
	initPin(GPIO_PIN2);
	setPinDirection(GPIO_PIN1, IN);
	setPinDirection(GPIO_PIN2, IN);

  struct itimerval it_val;	/* for setting itimer */

  /* Upon SIGALRM, call DoStuff().
   * Set interval timer.  We want frequency in ms, 
   * but the setitimer call needs seconds and useconds. */
  if (signal(SIGALRM, (void (*)(int)) countPeopleInFunc) == SIG_ERR) {
    perror("Unable to catch SIGALRM");
    exit(1);
  }
/*
  if (signal(SIGALRM, (void (*)(int)) countPeopleOutFunc) == SIG_ERR) {
    perror("Unable to catch SIGALRM");
    exit(1);
  }
*/
  it_val.it_value.tv_sec =     INTERVAL/1000;
  it_val.it_value.tv_usec =    (INTERVAL*1000) % 1000000;	
  it_val.it_interval = it_val.it_value;
  if (setitimer(ITIMER_REAL, &it_val, NULL) == -1) {
    perror("error calling setitimer()");
    exit(1);
  }





/*
while(1)
	{
		value1 = getPinValue(GPIO_PIN1);
		value2 = getPinValue(GPIO_PIN2);
		countPeopleInFunc(value1);
		countPeopleOutFunc(value2);
	//	printf("value1: %d\n",value1);
	//	printf("value2: %d\n",value2);
	//printf("value1: %d\n",b);
		pauseNanoSec(50000);

	}
*/


  while (1) 
    pause();
	return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: NeverKnewTheName/R_RTOS
void portInit( void )
{
    // Init all needed modules ********************************************************************
    initPin( PTB5, 0x1u, 0x1u );    // PIN FOR SPEAKER IS NOT CONNECTED; INIT WITH PULLUP
    initPin( OUTPUT_PIN( PIN_LED0 ), 0x1u, 0 );    // red LED
    initPin( OUTPUT_PIN( PIN_LED1 ), 0x1u, 0 );    // yellow LED
    initPin( OUTPUT_PIN( PIN_LED2 ), 0x1u, 0 );    // green LED
    initPin( OUTPUT_PIN( PIN_LED3 ), 0x1u, 0 );    // 'orange' LED

    //initPin( PIN_IRQ_TAS0, 0x1u, 0x1u );    // PIN

    // SET ALL LEDS OFF BY DEFAULT (LOW-ACTIVE)
    SET_PIN_HIGH( PIN_LED0 );
    SET_PIN_HIGH( PIN_LED1 );
    SET_PIN_HIGH( PIN_LED2 );
    SET_PIN_HIGH( PIN_LED3 );
}
コード例 #3
0
ファイル: adc.c プロジェクト: coumbsek/projetRobot
void main(void) {
    unsigned char tens;
    initClock();
    initPin();
    initTimer0();
    initInterruptButtons();
    while(1) {
        ADCON0bits.GO = 1;
        while(!ADCON0bits.DONE);
        tens = ADRESH;
        if (tens < 254*10/3.2/5) {
            PORTBbits.RB5=1;
        }
        else {
            PORTBbits.RB5=0;
        }
    }
}
コード例 #4
0
ファイル: db_key.cpp プロジェクト: jbfavre/xca
void db_key::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
{
	QMenu *menu = new QMenu(mainwin);
	currentIdx = index;

	pki_key *key = static_cast<pki_key*>(currentIdx.internalPointer());

	menu->addAction(tr("New Key"), this, SLOT(newItem()));
	menu->addAction(tr("Import"), this, SLOT(load()));
	if (index != QModelIndex()) {
		menu->addAction(tr("Rename"), this, SLOT(edit()));
		menu->addAction(tr("Show Details"), this, SLOT(showItem()));
		menu->addAction(tr("Delete"), this, SLOT(delete_ask()));
		menu->addAction(tr("Export"), this, SLOT(store()));
		if (key->isPrivKey() && !key->isToken()) {
			switch (key->getOwnPass()) {
			case pki_key::ptCommon:
				menu->addAction(tr("Change password"), this,
						SLOT(setOwnPass()));
				break;
			case pki_key::ptPrivate:
				menu->addAction(tr("Reset password"), this,
						SLOT(resetOwnPass()));
				break;
			}
		}
		if (key->isToken() && pkcs11::loaded()) {
			menu->addAction(tr("Change PIN"), this,
				SLOT(changePin()));
			menu->addAction(tr("Init PIN with SO PIN (PUK)"), this,
				SLOT(initPin()));
			menu->addAction(tr("Change SO PIN (PUK)"), this,
				SLOT(changeSoPin()));
		}
		if (!key->isToken() && pkcs11::loaded()) {
			menu->addAction(tr("Store on Security token"),
				this, SLOT(toToken()));
		}
	}
	contextMenu(e, menu);
	currentIdx = QModelIndex();
	return;
}
コード例 #5
0
ファイル: sensorAnalyzer.c プロジェクト: apassi99/ECE-4534
// Public API
void startSensorTask(SensorAStruct *sensorT, unsigned portBASE_TYPE uxPriority, vtI2CStruct *i2c, MoveTaskStruct *moveT, mapTStruct *mapT, unsigned int unit_distance)
{
	/* Start the task */
	portBASE_TYPE retval;
	sensorT->i2cDev = i2c;
	sensorT->moveT = moveT;
	sensorT->mapT = mapT;
	sensorT->unit_distance = unit_distance;
    
	if ((retval =
         xTaskCreate( sensorTask,
                     ( signed char * ) "Sensor Analyzer", sensorSTACK_SIZE, (void *) sensorT,
                     uxPriority, ( xTaskHandle * ) NULL )) != pdPASS) {
             VT_HANDLE_FATAL_ERROR(retval);
         }
	// initialize pin and set direction
	pinState_respRcvd = initPin();
	GPIO_SetDir(0, pinMask_respRcvd, 1);
}
コード例 #6
0
int __init load_module(void)
{
	  _major = register_chrdev (0,"brightnessMajor",&mod_fops);
	  if (_major < 0) {
		  printk("Registering the character device failed with (Major)-  %d\n",  _major);
		  return _major;
	  }
	  if (_major > 0) {
		  printk("Registering the character device success with (Major)-  %d\n",  _major);
	  }

	  _minor=misc_register(&mod_misc);

	  if (_minor){
		printk("Registering the character device failed with (Minor) -  %d\n",  _minor);
		return -EIO;
	  }
	  printk("Registering the character device success with (Minor) -  %d\n",  _minor);

	  initPin();

	  printk(KERN_ALERT "brightness Module Load Successfuly\n");
	  return 0;
}
コード例 #7
0
ファイル: MW_menu.cpp プロジェクト: PhoenixWu666/xca
	import->addAction(tr("Template"), tempView, SLOT(load()) );
	import->addAction(tr("Revocation list"), crlView, SLOT(load()));
	import->addAction(tr("PEM file"), this, SLOT(loadPem()) );
	import->addAction(tr("Paste PEM file"), this, SLOT(pastePem()));

	token = menuBar()->addMenu(tr("&Token"));
	token->addAction(tr("&Manage Security token"), this,
				SLOT(manageToken()));
	token->addAction(tr("&Init Security token"),  this,
				SLOT(initToken()));
	token->addAction(tr("&Change PIN"), this,
				SLOT(changePin()) );
	token->addAction(tr("Change &SO PIN"), this,
				SLOT(changeSoPin()) );
	token->addAction(tr("Init PIN"), this,
				SLOT(initPin()) );

	extra = menuBar()->addMenu(tr("Extra"));
	acList += extra->addAction(tr("&Dump DataBase"), this,
				SLOT(dump_database()));
	acList += extra->addAction(tr("&Export Certificate Index"), this,
				SLOT(exportIndex()));
	acList += extra->addAction(tr("&Export Certificate Index hierarchy"), this,
				SLOT(exportIndexHierarchy()));
	acList += extra->addAction(tr("C&hange DataBase password"), this,
				SLOT(changeDbPass()));
#if 0
	acList += extra->addAction(tr("&Undelete items"), this,
				SLOT(undelete()));
#endif
	extra->addAction(tr("Generate DH parameter"), this,
コード例 #8
0
ファイル: main.c プロジェクト: HITliuyu/NES15_HEVC
int main(
    int argc,
    char *argv[])
{
    BACNET_ADDRESS src = {
        0
    };  /* address where message came from */
    uint16_t pdu_len = 0;
    unsigned timeout = 1;       /* milliseconds */
    time_t last_seconds = 0;
    time_t current_seconds = 0;
    uint32_t elapsed_seconds = 0;
    uint32_t elapsed_milliseconds = 0;
    uint32_t address_binding_tmr = 0;
    uint32_t recipient_scan_tmr = 0;
    uint16_t count = 0;

    /* allow the device ID to be set */
    if (argc > 1)
        Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
    printf("BACnet Server Demo\n" "BACnet Stack Version %s\n"
        "BACnet Device ID: %u\n" "Max APDU: %d\n", BACnet_Version,
        Device_Object_Instance_Number(), MAX_APDU);
    /* load any static address bindings to show up
       in our device bindings list */
    address_init();
    Init_Service_Handlers();
    dlenv_init();
    atexit(datalink_cleanup);
    /* configure the timeout values */
    last_seconds = time(NULL);
    /* broadcast an I-Am on startup */
    Send_I_Am(&Handler_Transmit_Buffer[0]);

//////////////////////////////////////
	initPin(GPIO_PIN1);
	initPin(GPIO_PIN2);
	setPinDirection(GPIO_PIN1, IN);
	setPinDirection(GPIO_PIN2, IN);

  struct itimerval it_val;	/* for setting itimer */

  /* Upon SIGALRM, call DoStuff().
   * Set interval timer.  We want frequency in ms, 
   * but the setitimer call needs seconds and useconds. */
  if (signal(SIGALRM, (void (*)(int)) countPeopleInFunc) == SIG_ERR) {
    perror("Unable to catch SIGALRM");
    exit(1);
  }
/*
  if (signal(SIGALRM, (void (*)(int)) countPeopleOutFunc) == SIG_ERR) {
    perror("Unable to catch SIGALRM");
    exit(1);
  }
*/
  it_val.it_value.tv_sec =     INTERVAL/1000;
  it_val.it_value.tv_usec =    (INTERVAL*1000) % 1000000;	
  it_val.it_interval = it_val.it_value;
  if (setitimer(ITIMER_REAL, &it_val, NULL) == -1) {
    perror("error calling setitimer()");
    exit(1);
  }
////////////////////////////////////////////////////



    /* loop forever */
    for (;;) {
        /* input */
        current_seconds = time(NULL);

        /* returns 0 bytes on timeout */
        pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);

        /* process */
        if (pdu_len) {
            npdu_handler(&src, &Rx_Buf[0], pdu_len);
        }
        /* at least one second has passed */
        elapsed_seconds = (uint32_t) (current_seconds - last_seconds);
        if (elapsed_seconds) {
            last_seconds = current_seconds;
            dcc_timer_seconds(elapsed_seconds);
#if defined(BACDL_BIP) && BBMD_ENABLED
            bvlc_maintenance_timer(elapsed_seconds);
#endif
            dlenv_maintenance_timer(elapsed_seconds);
            Load_Control_State_Machine_Handler();
            elapsed_milliseconds = elapsed_seconds * 1000;
            handler_cov_timer_seconds(elapsed_seconds);
            tsm_timer_milliseconds(elapsed_milliseconds);
            trend_log_timer(elapsed_seconds);
#if defined(INTRINSIC_REPORTING)
            Device_local_reporting();
#endif
        }
        handler_cov_task();
        /* scan cache address */
        address_binding_tmr += elapsed_seconds;
        if (address_binding_tmr >= 60) {
            address_cache_timer(address_binding_tmr);
            address_binding_tmr = 0;
        }
#if defined(INTRINSIC_REPORTING)
        /* try to find addresses of recipients */
        recipient_scan_tmr += elapsed_seconds;
        if (recipient_scan_tmr >= NC_RESCAN_RECIPIENTS_SECS) {
            Notification_Class_find_recipient();
            recipient_scan_tmr = 0;
        }
#endif
	
        /* output */

        /* blink LEDs, Turn on or off outputs, etc */
    }

    return 0;
}
コード例 #9
0
ファイル: main.c プロジェクト: taylor123454321/c_control
// Main function
void main(void) {
	reset_peripheral(); initClock(); initTimer(); initDisplay(); initPin();
	initGPIO(); initADC(); initConsole(); int i = 0;
	//init_password();
	send_data();

	initCircBuf (&speed_buffer, BUF_SIZE); init_set_speed_data(&speed_set_data);

	int screen = 0; int screen_prev = 0; float speed = 0; float buffed_speed = 0;
	int fake_speed = 0; float acc = 0; float max_acc = 0; //float fuel_eco = 0;
	float distance = 0;

	bool fix = 0; uint8_t satillite = 0; float quality = 0; clock time;
	int aim_pos = 0; unsigned long adc = 0; //int error_stepper = 0;

	IntMasterEnable();

	while(1){
		//reading data
		read_data = split_data(UART_char_data_old, read_data); 	// decode data
		speed = read_speed();									//read data into variables
		adc = run_adc()/7;

		//calculations
		aim_pos = speed_feedback(buffed_speed, encoder_1/40, speed_set_data.speed);
		if (speed_set_data.enable == 1){
			step_motor_control(encoder_1/40, aim_pos);
		}

		//sending fake data
		fake_speed = (int)adc;//= random_at_most(100/1.852);
		send_info(fake_speed);//knots

		//storing data
		store_speed(speed);
		buffed_speed = analysis_speed();
		acc = read_acceleration(buffed_speed);
		max_acc = max_acc_func(acc, max_acc);
		time = read_time();
		satillite = read_satillite();
		fix = read_fix();
		quality = read_quality();
		debounce_button();										// debounce buttons
		screen = read_button_screen(screen, fix);
		distance = read_distance();
		select_read();											//need a mosfet for turning power off
																// select adds a an on and off switch yo

		if (screen == 1){
			if(screen_prev != 1 && screen == 1){
				speed_set_data.speed = buffed_speed;
			}
			speed_set_data.speed = set_speed(speed_set_data.speed);					// set the speed to cruise at
		}
		if (screen == 2){ //0 to 100
			acceleration_test(speed);
		}
		// refresh chainging
		if (fix == 1 && speed_set_data.old == speed_set_data.speed && refresh_rate < 4){
			UARTSend((unsigned char *)PMTK_SET_NMEA_UPDATE_5HZ, 18, 0);
			refresh_rate += 1;
		}
		if (i >= 50){
			display(screen, buffed_speed, acc, max_acc, speed_set_data.speed, satillite,
					encoder_1/40, time, distance, quality, UART_char_data_old, aim_pos, adc, acc_times);
			i = 0;
		}
		screen_prev = screen;
		i++;
	}
}
コード例 #10
0
ファイル: MW_menu.cpp プロジェクト: J-Javan/xca
void MainWindow::init_menu()
{
	QMenu *file, *help, *import, *token;

	file = menuBar()->addMenu(tr("&File"));
	file->addAction(tr("&New DataBase"), this, SLOT(new_database()),
		QKeySequence::New);
	file->addAction(tr("&Open DataBase"), this, SLOT(load_database()),
		QKeySequence::Open);
	file->addAction(tr("Generate DH parameter"), this,
				 SLOT(generateDHparam()));
	acList += file->addAction(tr("&Close DataBase"), this,
		SLOT(close_database()), QKeySequence(QKeySequence::Close));
	acList += file->addAction(tr("&Dump DataBase"), this,
				SLOT(dump_database()));
	acList += file->addAction(tr("C&hange DataBase password"), this,
				SLOT(changeDbPass()));
	acList += file->addAction(tr("&Import old db_dump"), this,
				SLOT(import_dbdump()));
	acList += file->addAction(tr("&Undelete items"), this,
				SLOT(undelete()));
	file->addSeparator();
	acList += file->addAction(tr("Options"), this, SLOT(setOptions()));
	file->addSeparator();
	file->addAction(tr("Exit"), qApp, SLOT(quit()), Qt::ALT+Qt::Key_F4);

	import = menuBar()->addMenu(tr("I&mport"));
	import->addAction(tr("Keys"), this,
				SLOT(on_BNimportKey_clicked()) );
	import->addAction(tr("Requests"), this,
				SLOT(on_BNimportReq_clicked()) );
	import->addAction(tr("Certificates"), this,
				SLOT(on_BNimportCert_clicked()) );
	import->addAction(tr("PKCS#12"), this,
				SLOT(on_BNimportPKCS12_clicked()) );
	import->addAction(tr("PKCS#7"), this,
				SLOT(on_BNimportPKCS7_clicked()) );
	import->addAction(tr("Template"), this,
				SLOT(on_BNimportTemp_clicked()) );
	import->addAction(tr("Revocation list"), this,
				SLOT(on_BNimportCrl_clicked()) );
	import->addAction(tr("PEM file"), this,
				SLOT(loadPem()) );
	import->addAction(tr("paste PEM file"), this,
				SLOT(pastePem()) );

	token = menuBar()->addMenu(tr("&Token"));
	token->addAction(tr("&Manage Security token"), this,
				SLOT(manageToken()));
	token->addAction(tr("&Init Security token"),  this,
				SLOT(initToken()));
	token->addAction(tr("&Change PIN"), this,
				SLOT(changePin()) );
	token->addAction(tr("Change &SO PIN"), this,
				SLOT(changeSoPin()) );
	token->addAction(tr("Init PIN"), this,
				SLOT(initPin()) );

	help = menuBar()->addMenu(tr("&Help") );
	help->addAction(tr("&Content"), this, SLOT(help()),
			QKeySequence::HelpContents);
	help->addAction(tr("&About"), this, SLOT(about()) );
	help->addAction(tr("Donations"), this, SLOT(donations()) );
	wdList += import;
	scardList += token;
}
コード例 #11
0
ファイル: efiGpio.cpp プロジェクト: yongfeicao/rusefi
void OutputPin::initPin(const char *msg, brain_pin_e brainPin) {
	initPin(msg, brainPin, &DEFAULT_OUTPUT);
}