Example #1
0
/** \brief Init HydraNFC functions
 *
 * \param con t_hydra_console*: hydra console (optional can be NULL if unused)
 * \return bool: return TRUE if success or FALSE if failure
 *
 */
bool hydranfc_init(t_hydra_console *con)
{
	if(init_gpio(con) ==  FALSE) {
		deinit_gpio();
		return FALSE;
	}

	init(con, NULL);

	return TRUE;
}
Example #2
0
int main(void)
{

    SystemInit();
    init_gpio();
    tim_init4();

    while(1)
    {
    }

}
void prvHardwareSetup(void) {
    // init shard_buf
    volatile unsigned long *addr = IO_TYPE;
    *addr = EMPTY_REQ;

    // set GPIO direction
    init_gpio();
    // create mutex and semaphore
    init_locks();
    // enable interrupt for sensors
    init_sensor();
}
Example #4
0
/**
 * \brief  LED1 Toggle with a delay, button SW1 toggles LED2 (ISR)
 *
 * \param  void
 *
 * \return void
 */
int main(void)
{
    init_gpio();
    //MOS_GPIO_Toggle (PTB,LED2);
    //MOS_GPIO_Output (PTB,LED2);
    while (1)
    {
        //toggle();
        delay();
    }

}
Example #5
0
void rpi_init(void){
	clearBss();
	// システムタイマーを初期化
	init_syst();
	// GPIOをすべてINPUT_PULLUPに設定
	init_gpio();

	// 起動確認用
	pinMode(16,OUTPUT);
	digitalWrite(16, LOW);
	
}
Example #6
0
bool init_fan_pins()
{
    printf("starting...\n");
    init_gpio(23);
    set_gpio_direction(23, "in");
    init_gpio(15);
    set_gpio_direction(15, "in");
    init_gpio(18);
    set_gpio_direction(18, "in");

    set_gpio_direction(23, "out");
    set_gpio(23, 1);
    set_gpio_direction(15, "out");
    set_gpio(15, 1);
    set_gpio_direction(18, "out");
    set_gpio(18, 1);

    init_gpio(25);
    set_gpio_direction(25, "out");
    set_gpio(25, 0);
    return true;
}
Example #7
0
int main()
{
	xil_printf("Program Started\n\r");
    init_platform();
    init_spi(&SpiInstance);
    init_gpio(&GpioInstance);

    u8 LED_data = 0x1;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    xil_printf("Tests started.\n\r");
    LED_data |= 0x1<<1;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);

    // Test for proper initial read/write
    int addr = 0;
    int value = 10;
	spi_write(&SpiInstance, addr, value);
	u8 res = spi_read(&SpiInstance, addr);
	xil_printf("Wrote to %X. %d transmitted. %d read back. The send and received values should match.\n\r", addr, value, res);
	// Test for proper overwriting of same address with new value
	value = 16;
	spi_write(&SpiInstance, addr, value);
	res = spi_read(&SpiInstance, addr);
	xil_printf("Wrote to %X again. %d transmitted. %d read back. The received value should be updated to the new sent value.\n\r", addr, value, res);
	// Test for making sure multiple addresses work
	addr = 1;
	value = 20;
	spi_write(&SpiInstance, addr, value);
	res = spi_read(&SpiInstance, addr);
	xil_printf("Wrote to %X. %d transmitted. %d read back. The new address should function as well as the old one.\n\r", addr, value, res);
	// Test to make sure every address works
	xil_printf("Writing and reading to all 32 memory addresses:\r\n(sent and received values should match, value + address should sum to 32)\n\r");
	int i;
	for (i = 0; i < 32; ++i){
		addr = i;
		value = 32 - i;
		spi_write(&SpiInstance, addr, value);
		res = spi_read(&SpiInstance, addr);
		xil_printf("Wrote to %X. %d transmitted. %d read back.\n\r", addr, value, res);
	}


    LED_data |= 0x1<<2;
    xil_printf("Tests complete. Please review results.\n\r");

    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    LED_data |= 0x1<<3;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    cleanup_platform();
    return 0;
}
Example #8
0
int ads_init_gpios(void) {

    //Init GPIOs
    if ( init_gpio(GPIO_DATA_READY) ||
         set_gpio_direction(GPIO_DATA_READY, "in") ) {
        return -1;
    }

#ifdef ADS1198
    if ( init_gpio(GPIO_RESET) ||
         set_gpio_direction(GPIO_RESET, "out") ) {
        return -1;
    }

    if ( init_gpio(GPIO_START) ||
         set_gpio_direction(GPIO_START, "out") ) {
        return -1;
    }
    set_gpio_value(GPIO_START, 0);
    usleep(10000);
#endif
    return 0;
}
Example #9
0
int main(int argc, char **argv)
{
  int i;
  // Set up gpi pointer for direct register access
  setup_io();

  // Switch GPIO 7..11 to output mode
  init_gpio(CLOCK);
  init_gpio(CLEAR);
  init_gpio(A);
  init_gpio(B);

  for (;;) {
    for (i=0; i!=256; i++) {
      //printf("%d -", i);
      write_number(i);
      //printf("\n");
      usleep(250000);
    }
  }

  return 0;

}
Example #10
0
int main()
{
    init_platform();
    init_gpio();
    init_uart_interrupt();

	while(1){
		read_from_mp();
		decode_and_print();
	}



    return 0;
}
Example #11
0
int main(int argc, char ** argv)
{
	int fd = open("/dev/uio0", O_RDWR);
	if(fd < 0)
	{
		ERROR("Cannot open /dev/uio0");
		return -1;
	}

	void *gpio_regs = mmap(NULL, 0x600, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 2*getpagesize());
	init_gpio(gpio_regs);


	return 0;
}
int board_init(void)
{
	struct gether_control_regs *gether = GETHER_CONTROL_BASE;

	init_gpio();
	set_pmb_on_board_init();

	/* Sets TXnDLY to B'010 */
	writel(0x00000202, &gether->gbecont);

	init_usb_phy();
	init_gether_mdio();

	return 0;
}
Example #13
0
int main()
{
	xil_printf("Program Started\n\r");
    init_platform();
    init_spi(&SpiInstance);
    init_gpio(&GpioInstance);

    u8 LED_data = 0x1;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    xil_printf("Tests started.\n\r");
    LED_data |= 0x1<<1;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);

    //TODO: Create better tests
    // no.
 //    int addr = 0;
 //    int value = 10;
	// spi_write(&SpiInstance, addr, value);
	// u8 res = spi_read(&SpiInstance, addr);
	// xil_printf("Wrote to %X. %X transmitted. %X readback.\n\r", addr, value, res);
	int tests_passed = 1;
	for(int addr = 0; addr < 128; addr = addr + 1 )
	{
		for (int value = 0; value < 256; value = value + 1 )
		{
			spi_write(&SpiInstance, addr, value);
			u8 res = spi_read(&SpiInstance, addr);
			if (res != value)
			{
				xil_printf("Test failed!!! Wrote to %X. %X transmitted. %X readback.\n\r", addr, value, res);
				tests_passed = 0;
			} else
			{
				xil_printf("Test passed");
			}

		}
	}

    LED_data |= 0x1<<2;
    xil_printf("Tests complete. Result: %X.\n\r", tests_passed);

    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    LED_data |= 0x1<<3;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    cleanup_platform();
    return 0;
}
Example #14
0
ssize_t dev_open(struct inode *inode,struct file *filp)
{
	int ret = nonseekable_open(inode,filp);
	if(ret < 0)
	{
		return ret;
	}
	init_gpio();
	ret = request_irqs();
	if(ret < 0)
	{
		return ret;
	}
	init_devbuffer();
	return ret;
}
Example #15
0
int main(void)
{
	init_gpio();
	init_timer_A();

	PWM_init();
	
	PWM0->_2_LOAD = 4999;
	//PWM0->_2_CMPA = 4846;
	
	while(1)
	{
		sweep_counter_clockwise();
		sweep_clockwise();
	}
}
Example #16
0
int main(void)
{
	char display_string1[] = "*Hello Amigos. Rolling Banner!*";
	char display_string2[] = "+-+-+-+-+";
	uint8_t i;
	
	init_gpio();			// Initialize GPIO	
  	init_timer_A();		// Initialize TIMER0->TIMERA as 16-bit, one-shot and counts down
	init_timer_B();		// Init TIMER0B as 16-bit, periodic and counts down
	nvic_init();			// Init NVIC for TIMER0B
	init_pushButton();	
		
	// Initialize LCD display
	LCD_init();
	PWM_init();	

	for(i=0; display_string1[i] != '\0'; i++)
	{
		send_data(display_string1[i]);
		delay_timer(100);
		
		// Since screen has enough to display 16 chars per line, if going off line, start shifting screen.
		if ( i >= 14 )
			send_command(0x18);
	}
	send_command(0x2);		// Return cursor home
	send_command(0xC0);		// Go to line 2

	for(i=0; display_string2[i] != '\0'; i++)
	{
		send_data(display_string2[i]);
		delay_timer(100);
		
		// Since screen has enough to display 16 chars per line, if going off line, start shifting screen.
		if ( i >= 14 )
			send_command(0x18);
	}
	
	interrupt_timer(scroll_delay);		// Interrupt timer handler scrolls the screen
	//send_command(0x18);		// Shift display to the right by 1
	//send_command(0x8);		// Turn display off
	//send_command(0xF);		// Turn display on, cursor ON, cursor position ON
	//GPIOF->DATA |= (1UL << 3);    //LED ON
	//GPIOF->DATA &= ~(1UL << 3);		//LED OFF
	while(1)
	{}
}
Example #17
0
static int __devinit wmt_gpio_pmic_probe(struct platform_device *pdev)
{
	int				i;
	struct wmt_gpio_pmic_info		*info;
	struct regulator_init_data	*initdata;
	struct regulation_constraints	*c;
	struct regulator_dev		*rdev;

	init_gpio();
	for (i = 0, info = NULL; i < ARRAY_SIZE(wmt_pmic_regs); i++) {
		if (wmt_pmic_regs[i].desc.id != pdev->id)
			continue;
		info = wmt_pmic_regs + i;
		break;
	}
	if (!info)
		return -ENODEV;

	initdata = &wmt_corepower;

	c = &initdata->constraints;
	c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
	c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
				| REGULATOR_CHANGE_MODE
				| REGULATOR_CHANGE_STATUS;
	c->always_on = true;

	rdev = regulator_register(&info->desc, &pdev->dev, initdata, info);
	if (IS_ERR(rdev)) {
		dev_err(&pdev->dev, "can't register %s, %ld\n",
				info->desc.name, PTR_ERR(rdev));
		return PTR_ERR(rdev);
	}
	request_irq(IRQ_OST3, wmt_ostimer_isr,
			IRQF_DISABLED,
			"pmic", NULL); 
#ifdef CONFIG_HAS_EARLYSUSPEND
	wmt_gpio_pmic_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	wmt_gpio_pmic_early_suspend.suspend = wmt_gpio_early_suspend;
	wmt_gpio_pmic_early_suspend.resume = wmt_gpio_late_resume;
	register_early_suspend(&wmt_gpio_pmic_early_suspend);
#endif

	platform_set_drvdata(pdev, rdev);

	return 0;
}
Example #18
0
void init_all()
{
    init_gpio();
    pwm_init();
    adc_init();
    init_all_pulse_counter();
    LPLD_Flash_Init();
    init_sdhc();          //SD卡模块初始化   
    uart_interr_init();
    init_i2c();           //MPU6050初始化
    //LPLD_MMA8451_Init();
    OLED_Init();
    pit_init();
    init_paranum();   
    init_setpara();    
    init_readpara();
    save.g_s16SDDenoteNum = 0;//防止不小心保存非0数
}
Example #19
0
int *gpio_thread(void *ptr)
{
    init_gpio ();
    while (running)
    {
        //Read from the GPIO queue and send to the sound queue
        if (!queue_empty (&gpio_input_q))
            queue_add (&sfx_q, (queue_remove (&gpio_input_q)));

        //Write to the sound queue and send out to the WPC CPU
        if (!queue_empty (&gpio_output_q) && !output_waiting)
            write_gpio (queue_remove (&gpio_output_q));
    }
    digitalWrite (STATUS_LED, 0);
    if (verbose)
        fprintf (stdout, "GPIO thread stopped\n");
    return 0;
}
Example #20
0
int main(void)
{
	sysclk_init();

	init_dbg_rs232(FMCK_HZ);

	init_gpio();
	assign_main_event_handlers();
	init_events();
	init_tc();
	init_spi();
	init_adc();

	irq_initialize_vectors();
	register_interrupts();
	cpu_irq_enable();

	init_usb_host();
	init_monome();

	if(flash_is_fresh()) {
		// nothing has been stored in the flash memory so far
		// so you need to initialize any variables you store in flash here with appropriate default values
	}
	else {
		// read from flash
		flash_read();
	}

	clock_pulse = &clock;
	clock_external = !gpio_get_pin_value(B09);

	// start timers that track clock, ADCs (including the clock and the param knobs) and the front panel button
	timer_add(&clockTimer,120,&clockTimer_callback, NULL);
	timer_add(&keyTimer,50,&keyTimer_callback, NULL);
	timer_add(&adcTimer,100,&adcTimer_callback, NULL);
	clock_temp = 10000; // out of ADC range to force tempo

	// main loop - you probably don't need to do anything here as everything should be done by handlers
	while (true) {
		check_events();
	}
}
Example #21
0
int main(void)
/*****************************************************************************
*   Input    :
*   Output   :
*   Function : The super loop.
******************************************************************************/
{
  INT8U event;
  INT8U counter_value;

  disable_global_int();
  init_systick();
  init_gpio();
  enable_global_int();


  // Loop forever.
  while(1)
  {
	// System part of the super loop.
	// ------------------------------
	while( !ticks );


	// The following will be executed every 5mS
	ticks--;

	if( ! --alive_timer )
	{
    	alive_timer =	MILLISEC( 500 );
	  	GPIO_PORTD_DATA_R ^= 0x40;
	}

    // Protected operating system mode
    swt_ctrl();

    // Application mode
    task_rtc( TASK_RTC );
    task_button( TASK_BUTTON );
    task_set_time( TASK_SET_TIME );
    task_lcd( TASK_LCD );
  }
}
Example #22
0
int main(void)
{
    // Disable interrupts during initialization
    cli();

    // Turn on timer0 and init for interrupt
    init_timer0();

    init_gpio();

    // Enable interrupts when initialization is done
    sei();

    while (1)
    {
        PORTB ^= _BV(PINB1);
        _delay_ms(1000);
    }
}
int main(void) {
	  // setup the watchdog timer as an interval timer
	WDTCTL =(WDTPW +	// (bits 15-8) password
						// bit 7=0 => watchdog timer on
						// bit 6=0 => NMI on rising edge (not used here)
						// bit 5=0 => RST/NMI pin does a reset (not used here)
				WDTTMSEL +   // (bit 4) select interval timer mode
				WDTCNTCL); 	// (bit 3) clear watchdog timer counter
							// bit 2=0 => SMCLK is the source
				            // bits 1-0 = 10 => source/32K.


	IE1 |= WDTIE;		// enable the WDT interrupt (in the system interrupt register IE1)

	BCSCTL1 = CALBC1_8MHZ;
	DCOCTL = CALDCO_8MHZ;	//8MHz calibration for clock

	begin_update = 0;

	last_state = 0;
	state = 'i';
	begin_countdown = 0;

	MINUTES = 2;
	SECONDS = 0;
	wdt_ctr_timer = 0;

	wdt_ctr = 0;
	second_ctr = 0;

	RED_SCORE = 0;
	GRN_SCORE = 0;

	OWN_SECONDS = 0;
	OWN_MINUTES = 0;

	REDPRESS = 0;
	GRNPRESS = 0;

	init_gpio();

	_bis_SR_register(GIE+LPM0_bits);
}
Example #24
0
void bs60_init( int wa )
{
    DBG( "[%s] ... initializing broadsheet for 6-inch panel\n", __FUNCTION__ );
    bs_chip_init();
    init_gpio();
    bs_cmd_set_hif_mode_cmd( );
    bs_cmd_wr_reg( 0x006, 0x0000 );

    // It's really very important to sleep here to make sure the controller
    // is correctly power on.
    bs_sleep(5);

    bs_cmd_init_sys_run( );
    bs_cmd_wr_reg( 0x0106, 0x0203 );

    bs_cmd_init_dspe_cfg( BS60_INIT_HSIZE,
                          BS60_INIT_VSIZE,
                          BS60_INIT_SDRV_CFG,
                          BS60_INIT_GDRV_CFG,
                          BS60_INIT_LUTIDXFMT );

    bs_cmd_init_dspe_tmg( BS60_INIT_FSLEN,
                          ( BS60_INIT_FELEN << 8 ) | BS60_INIT_FBLEN,
                          BS60_INIT_LSLEN,
                          ( BS60_INIT_LELEN << 8 ) | BS60_INIT_LBLEN,
                          BS60_INIT_PIXCLKDIV );
    bs_cmd_print_disp_timings( );

    bs_cmd_set_wfm( wa );
    bs_cmd_print_wfm_info( );

    DBG( "[%s] ... display engine initialized with waveform\n", __FUNCTION__ );

    bs_cmd_clear_gd( );

    bs_cmd_wr_reg( 0x01A, 4 ); // i2c clock divider
    bs_cmd_wr_reg( 0x320, 0 ); // temp auto read on

    bs_cmd_set_lut_auto_sel_mode(0); // make sure auto-lut mode is off
    bs_cmd_set_rotmode(3);  // set rotation mode
    bs60_white();
}
Example #25
0
int main (void)
{
    printf(" Initialing \n");
    init_gpio();
    clock_init();
    printf("\n start test!\n");
    process_init();
    process_start(&etimer_process,NULL);
    autostart_start(autostart_processes);
    
    printf(" Processes running \n");
    while(1)
    {
        do
        {
        }while(process_run()>0);
        idle_cnt++;
    }
	return 0;
}
Example #26
0
int main(void)
{
	init_gpio();

	/* Setup Timers */
	init_timer_0A();
	init_timer_0B();
	
	// Default to theremin on startup
	turn_on_red_LED();

	PWM_init();
	init_ADC();
	init_nvic();

	init_pushButton();
	
	while(1)
	{}
}
int main(int ac, char *av[])
{
	int ret=0;

	if(ac < 2 || ac > 4){
		usage(av[0]);
		return -1;
	}

	if(strncmp(QUIET, av[1], strlen(QUIET)) == 0)
		quiet = 1;

	if(strncmp(INIT, av[1], strlen(INIT)) == 0){
		if((ret = init_gpio(av[2])) == -1)
			return -1;
		if(!quiet)
			printf("%02x\n", ret);
	}
	else if(strncmp(READ, av[1], strlen(READ)) == 0){
		if((ret = read_gpio()) < 0)
			return -1;
		if(!quiet)
			printf("%02x\n", ret);
	}
	else if(strncmp(WRITE, av[1], strlen(WRITE)) == 0){
		if(write_gpio(av[2]) < 0)
			return -1;
		if((ret = read_gpio()) < 0)
			return -1;
		if(!quiet)
			printf("%02x\n", ret);
	}
	else{
		usage(av[0]);
		return -1;
	}

	return ret;
}
Example #28
0
void rpi_init(void){
	// bssのクリア
	clearBss();

	// 割り込み不許可
	disable_all_IRQ();

	// ベクタテーブルセット
	set_vector_table();

	// システムタイマーを初期化
	init_syst();
	// GPIOをすべてINPUT_PULLUPに設定
	init_gpio();

	// 起動確認用
	pinMode(16,OUTPUT);
	digitalWrite(16, LOW);

	// UARTを有効
	Serial_begin(115200);
}
Example #29
0
int main(int argc, char **argv) {

	// initialize gpio17 that is hooked up to the switch
	if(init_gpio()) {
		perror("could not initialize gpio17");
		return 1;
	}

	// S points to the switch values structure
	SWITCH_T * S = init_switch();

	while(1) {
		// read the switch values
		if(get_debounce_vals(S)) {
			perror("could not read values");
		}
		// print the state of the switch and light led accordingly
		switch_led(S);
	}

	return 0;
}
int gpio(void) {
	int i, gpio;
	char buf[4];
	// First we must open the Port.
	// We want tu use the first 16 lines of Port D
	printf("Reading GPIO-Port: ");
	gpio = init_gpio("demo",'D',0x0000FFFFUL,O_RDONLY);
	if(gpio<0) {
		printf("Can't open GPIO-Port D: %s\n",strerror(errno));
		return gpio;
	}
	// Now we can use the default read/write calls
	// from the OS
	i = read(gpio,buf,4);
	if(i<0) {
		printf("Can't read from GPIO-Port: %s\n",strerror(errno));
		return i;
	}
	printf("done.\nStatus of Port D is 0x%02X%02X%02X%02X\n",
			buf[0],buf[1],buf[2],buf[3]);
	destroy_gpio("demo",gpio);
}