Exemple #1
0
void main(void) {
  uart_init();
  led_init();
  put_string("boot\r\n");
  while (1) {
    led_toggle();
    char c = get_char();
    put_char(c);
    if (c == '\r')
      put_char('\n');
  }
}
Exemple #2
0
void init(){
  led_init();
  motor_init();
  switch_init();
  ground_init();
  dist_init();
  servo_init();
  if(DEBUG) usart_init();

  motor1 = Motor(&OCR1A, &MOTOR1_DIR_PORT, MOTOR1_DIR_PIN, MAX_POWER);
  motor2 = Motor(&OCR1B, &MOTOR2_DIR_PORT, MOTOR2_DIR_PIN, MAX_POWER);
}
Exemple #3
0
void uos_init (void)
{
        led_init();
	joystick_init ();
	gpanel_init (&display, &font_fixed6x8);
	gpanel_clear (&display, 0);
        gpanel_backlight (&display, 1);

	puts (&display, "Task created.\n\n");

	task_create (hello, "Task", "hello", 1, task, sizeof (task));
}
Exemple #4
0
void rt_hw_led_init(void)
{
    led_init();

    led1_thread = rt_thread_create("led1", led1_thread_entry, RT_NULL, 384, 29, 5);
    if (led1_thread != RT_NULL) 
        rt_thread_startup(led1_thread);
    
    led2_thread = rt_thread_create("led2", led2_thread_entry, RT_NULL, 384, 30, 5);
    if (led2_thread != RT_NULL) 
        rt_thread_startup(led2_thread);
}
int main()
{
	led_init(); // 配置LED
	LPC_GPIO1->IE |= (1<<9); // 允许P1.9引脚上的中断
	LPC_GPIO1->IE |= (1<<10); // 允许P1.10引脚上的中断
	NVIC_EnableIRQ(EINT1_IRQn); // 打开GPIO1中断
	
	while(1)
	{
		;
	}
}
Exemple #6
0
int main()
{
    hardware();
    
    led_init();
    delay_init();
    sx1276_cfg_init();
    
    xTaskCreate(task_led, "led", configMINIMAL_STACK_SIZE, NULL, 0, NULL);

    vTaskStartScheduler();
}
void led_test()
{
	led_init();

	while(1){
		led_blink(1);
		mydelay();
		led_blink(0);
		mydelay();
	}
	
}
Exemple #8
0
int main(void)
{
	/*
	 * pgm_read_byte gets cached and there doesn't seem to be any other
	 * way to dissuade gcc from doing this.
	 */
	volatile int zero = 0;
	uint32_t loop = 0;

	board_init();
	spi_init();

	_delay_ms(10);

	/* set MCP2515 clkdiv to /2  for 8MHz */
	can_cs_l();
	spi_io(INSTRUCTION_WRITE);
	spi_io(CANCTRL);
	spi_io(0x85);
	can_cs_h();

	led_init();

	usb_init();
	dfu_init();

	/* move interrupt vectors to the boot loader */
	MCUCR = 1 << IVCE;
	MCUCR = 1 << IVSEL;

	sei();

	while (loop < 5) {
		led_a_on();
		led_b_on();
		_delay_ms(50);
		led_a_off();
		led_b_off();
		_delay_ms(400);

		if (dfu.state == dfuIDLE && pgm_read_byte(zero) != 0xff)
			loop++;
		else
			loop = 0;
	}

	cli();

	usb_reset();
	run_payload();

	while (1);
}
Exemple #9
0
int init_systems() {
  var_load(CONFIG_FILE); // Nacti vsechny promenne
  led_init();
  input_event_init(); // Klavesnice
  enc_init(); // Nastav encodery
//  motor_init(); // PID -> zapinat az po encoderech
  i2c_init(); // Priprav i2c komunikaci

  pthread_attr_t *thAttr = NULL;
  pthread_create(&bumpers_loop_tid, thAttr, bumpers_loop, NULL);
  return 0;
}
Exemple #10
0
/*!
 *  @brief      启动前进行检测(检测按键是否按下,按下则进入死循环,防止进入 main 函数,松开按键后再按下则进行解锁)
 *  @since      v5.0
 *  @note       此函数可避免 下载口在 main 前 复用了导致无法下载等问题
 */
void start_check()
{
#if 0
    uint8 flag = 0;

    key_init(KEY_A);

    if(key_check(KEY_A) == KEY_DOWN )
    {
        //按键按下

        led_init(LED0);

        while(1)
        {

            if(key_check(KEY_A) == KEY_UP)
            {
                flag = 1;
            }

            led_turn(LED0);
            printf("\n进入死循环等待!");
            DELAY_MS(500);                          //此处的延时,可起到 按键 消抖的功能

            //如果 送开按键后,再按下 按键,则 进行解锁 操作
            if((flag == 1)  && (key_check(KEY_A) == KEY_DOWN ))
            {
                while(key_check(KEY_A) == KEY_DOWN)         //等待按键 弹起
                {
                    led_turn(LED0);
                    DELAY_MS(100);                          //此处的延时,可起到 按键 消抖的功能
                }

                while(key_check(KEY_A) == KEY_UP)         //等待按键 弹起后 再 进行解锁
                {
                    led_turn(LED0);
                    DELAY_MS(50);                          //此处的延时,可起到 按键 消抖的功能
                }

                printf("\n进行解锁操作,请重新刷入固件");

                //解锁单片机
                flash_init();
                DELAY_MS(100);
                flash_erase_sector(0);        //擦除扇区 0  (解锁)
                NVIC_SystemReset();           //复位单片机

            }
        }
    }
#endif
}
Exemple #11
0
/**
 * Main function
 * Initialize controller and handle Modbus requests
**/
int main(void) {
	uint8_t i;

	// load config data from eeprom
	loadEepromValues();

	// init modules
	led_init();
	adc_init();
	windspeed_init(&windspeed, &errcnt, &cnt);
	onewiretemp_init();
	mb_init();
	mb_setIP(config.ip);

	// register adc handlers
	adc_register(0, read_temperature);
	adc_register(1, read_winddir);

	// register Modbus handlers and registers
	mb_addReadRegister(ENABLENUM, &(config.enable));
	mb_addReadRegister(3, (uint16_t*)&winddir);
	mb_addReadRegister(4, (uint16_t*)&windspeed);
	mb_addReadRegister(5, (uint16_t*)&temperature);
	mb_addReadRegister(6, (uint16_t*)&errcnt);
	mb_addReadRegister(7, (uint16_t*)&cnt);
	mb_addReadRegister(8, (uint16_t*)&insideTemperature);

	mb_addWriteRegister(IP_HIGH, write_IP);
	mb_addWriteRegister(IP_LOW, write_IP);
	mb_addWriteRegister(ENABLENUM, write_enable);
	for (i = TEMPNUM; i < TEMPNUM+2*ARRAY_SIZE(config.temperatureCalibration); i++)
		mb_addWriteRegister(i, write_temperatureCalibration);

	// set DDR for sensor on/off
	SENS_DDR |= _BV(SENS_PIN);

	// enable interrupts
	sei();

	// start proccessing
	setSensorStatus();

	while (1) {
		// apply new IP address if requested
		if (renewIP) {
			renewIP = 0;
			mb_setIP(config.ip);
		}
		mb_handleRequest();
		onewiretemp_update(&insideTemperature);
	}
}
void APP2_Initialize ( void )
{
    led_init();
    sc_timer_service_init(
			&timer_service,
			timers,
			MAX_TIMERS,
			(sc_raise_time_event_fp) &lightSwitch_raiseTimeEvent
			);
    
    lightSwitch_init(&handle);
    lightSwitch_enter(&handle);
}
Exemple #13
0
void led_warning(unsigned char n)
{
    led_init();
    for(unsigned char  i=0; i<n; i++)
    {
        _delay_ms(LED_TIME);
        led_set(0,0);
        led_enact();
        _delay_ms(LED_TIME);
        led_set(0,1);
        led_enact();
    }
}
Exemple #14
0
/**
 * @brief Initialize the board
 */
void board_init(void) {

    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);

    /* initialize the CPU */
    cpu_init();

    /* initialize the boards LEDs */
    led_init();
}
void system_init(void) {
	generic_init();
	
	led_init();

	temperature_sensor_init();
	
	seven_segment_init();
	seven_segments_sm_init();
	
	keypad_init();
	accelerometer_init();
}
Exemple #16
0
irom void setup()
{
	uart_init(115200, 115200);

	os_printf("\r\nWelcom to Noduino MJYUN Demo!\r\n");
	os_printf("%s", noduino_banner);

	led_init();

	wifi_set_opmode(STATION_MODE);

	init_yun();
}
Exemple #17
0
int main( void ) {
  TCCR0A = _BV( WGM01 ); // CTC mode.
  TCCR0B = _BV( CS01 ) | _BV( CS00 ); // /256 prescaler.
  OCR0A = 121; // F_CPU / (256 * 256) - 1
  TIMSK0 = _BV( OCIE0A ); // Enable interrupt on counter match.

  DDRC &= ~_BV( PC0 ); // Set pin PC0 of DDRC to 0
  PORTC |= _BV( PC0 ); // Enable pull up resistor.

  // Enable pin change interrupt.
  PCICR = _BV( PCIE1 );
  PCMSK1 = _BV( PCINT8 );
  sei();


  // Init LED matrix.
  led_init();
  stdout = &led_str;

  printf( "Boot. " );

  do { 
    _delay_ms( 10 );
  } while( led_working() );


  while( 1 ) {
	printf( "Sleep. " );

	do { 
	  _delay_ms( 10 );
        } while( led_working() );

  	// Set up sleep mode.
  	set_sleep_mode( SLEEP_MODE_PWR_DOWN );

	// Go to sleep.
        cli();
	PORTB = 0x00;
	PORTD = 0x00;
        sleep_enable();
//        sleep_bod_disable();
        sei();
        sleep_cpu();
        sleep_disable();
        sei();

	printf( "Awake. " );
	_delay_ms( 50);
  }
}
Exemple #18
0
void pixyInit(uint32_t slaveRomStart, const unsigned char slaveImage[], uint32_t imageSize)
{
	platformInit();

	// button, SPI_SSEL
	LPC_GPIO_PORT->MASK[5] = 0;
	LPC_GPIO_PORT->PIN[5] = 0x20; // negate SPI_SS
	LPC_GPIO_PORT->DIR[5] = 0x20; // SPI_SS - output

	// deal with P4_1, GPIO2[1]
	LPC_GPIO_PORT->MASK[2] = 0;
	LPC_GPIO_PORT->DIR[2] = 0;

	// set timer so we count clock cycles
	LPC_TIMER1->IR = 0;
 	LPC_TIMER1->TCR = 1;
	LPC_TIMER1->PR = 0;

	// microsecond timer
	LPC_TIMER2->IR = 0;
 	LPC_TIMER2->TCR = 1;
	LPC_TIMER2->PR = CLKFREQ_US-1;

  	debug_frmwrk_init_clk(CLKFREQ);

	USB_UserInit();

	lpc_printf("M4 start\n");

	IPC_haltSlave();

	ADCInit();
   	SCTInit();
	CameraInit();

	// start slave
	IPC_downloadSlaveImage(slaveRomStart, slaveImage, imageSize);
	IPC_startSlave();

	// initialize chirp objects
	g_chirpUsb = new ChirpUsb();
  	g_chirpM0 = new ChirpM0();

	// initialize devices/modules
	pwr_init();
	spi_init();
	cam_init();
	rcs_init();
	led_init();
	//cc_init();
}
void
initialize(void)
{
  watchdog_init();
  watchdog_start();
  
#if STACKMONITOR
  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
   * loop. In conjuction with TESTRTIMER, never-used stack will be printed
   * every STACKMONITOR seconds.
   */
{
extern uint16_t __bss_end;
uint16_t p=(uint16_t)&__bss_end;
    do {
      *(uint16_t *)p = 0x4242;
      p+=4;
    } while (p<SP-4); //don't overwrite our own stack
}
#endif

  /* rtimers needed for radio cycling */
  rtimer_init();

  rs232_init(RS232_PORT_0, BAUD_RATE(38400), USART_DATA_BITS_8 | USART_PARITY_NONE | USART_STOP_BITS_1);
  rs232_redirect_stdout(RS232_PORT_0);

  clock_init();
  sei();

  /* Initialize drivers and event kernel */
  process_init();
 
  led_init();

#if 0
  procinit_init();
#else
  process_start(&etimer_process, NULL);
  process_start(&led_process, NULL);
  process_start(&led2_process, NULL);
#endif

  PRINTA(CONTIKI_VERSION_STRING " started\r\n");

  /* Comment this out if autostart_processes not defined at link */
  /* Note AUTOSTART_PROCESSES(...) is only effective in the .co module */
  autostart_start(autostart_processes);
  
}
Exemple #20
0
int main(void)
{
	int ret;
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
	delay_init(162);//延时初始化
	tim3_init(162);//时钟初始化
	sram_init();//SRAM初始化
	ads1271_init(0);//ad初始化 参数为0 高速模式
	
	led_init();//LED初始化
	read_device_config();//读取flash中设备配置
	current_source_init();//恒流源初始化
	
	ethernet_init();//网络初始化
	tcp_sever();//建立tcp服务器
	while(!is_con());//等待连接
	led_link(1);//开启连接灯

	while(1)
	{
		//INT处理部分
		ret = deal_int();
		if((ret == NET_ERR) || (ret == NET_DISCONNECT))
			sys_restart();//重启
		
		//PRE处理部分
		ret = deal_pre();
		if((ret == NET_ERR) || (ret == NET_DISCONNECT))
			sys_restart();//重启
		
		//DIV处理
		ret = deal_div();
		if((ret == NET_ERR) || (ret == NET_DISCONNECT))
			sys_restart();//重启
		
		//STA处理
		ret = deal_sta();
		if((ret == NET_ERR) || (ret == NET_DISCONNECT))
			sys_restart();//重启
		
		//数据传输
		while(1)
		{
			ret = deal_data();
			if((ret == NET_ERR) || (ret == NET_DISCONNECT))
				sys_restart();//重启
		}
	}
}
int main()
{
	led_init();
	LPC_GPIO1->IEV |= (1<<9); // 设置P1.9上升沿触发
	LPC_GPIO1->IEV |= (1<<10); // 设置P1.10上升沿触发
	LPC_GPIO1->IE |= (1<<9); //
	LPC_GPIO1->IE |= (1<<10);
	NVIC_EnableIRQ(EINT1_IRQn);
	
	while(1)
	{
		;
	}
}
Exemple #22
0
static void setup_hardware(void)
{
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	clock_prescale_set(clock_div_1);

	ptt_init();
	USB_Init();
	led_init();

	/* Initialize SPI */
	spi_init_config(SPI_SLAVE | SPI_MSB_FIRST);
}
Exemple #23
0
int main(void) {
    // leds:
    led_init();

    // init clock sources:
    clocksource_init();

    // init ios
    io_init();

    // init debug
    debug_init();

    // init wdt timer
    wdt_init();

    // enable timeout routines
    timeout_init();

    // init storage
    storage_init();

    // init frsky core
    frsky_init();

    // init adc
    adc_init();

    // init output
#ifdef SBUS_ENABLED
    sbus_init();
#else  // SBUS_ENABLED
    ppm_init();
#endif  // SBUS_ENABLED

    // init failsafe
    failsafe_init();

    // init telemetry
    telemetry_init();

    // run main
    debug("main: init done\n");

    // frsky_frame_sniffer();
    frsky_main();

    debug("main: frsky main ended?! THIS SHOULD NOT HAPPEN!");
    while (1) {}
}
Exemple #24
0
/*
	Intializes the LED, sets the default value, and loops.
 */
void main(void)
{
	init_buttons();
	led_init();
	led_display_text("Hello World from ZNEO");

	//enable interrupts
	EI();

	//run forever
	while(1) {
		//do nothing while responding to interrupts
	}
}
Exemple #25
0
int main()
{
	int i;
	clock_init();
	led_init();
	while(1){
		for(i=0;i<4;i++){
			led_on(i);
			delay(5);
			led_off(i);	
			delay(5);	
		}
	}
}
Exemple #26
0
int main(int argc, char *argv[]) {
    clock_init();

    uart_init();

    led_init();
    motor_controller_init();
    commander_init();

    interrupt_init();

    cmd_t cmd = 0;

    while (1) {
        cmd = get_cmd();
        if (cmd != CMD_NONE) {
            VERBOSE("motor_test", "Command recieved: [%i]", cmd);
        }
        switch (cmd) {
            case CMD_STOP:
                motor_set_movement(VERT_STOPPED, HORIZ_STOPPED);
                led_display(0);
                break;
            case CMD_FORWARD:
                motor_set_movement(VERT_FORWARD, HORIZ_STOPPED);
                led_display(1);
                break;
            case CMD_BACK:
                motor_set_movement(VERT_BACKWARD, HORIZ_STOPPED);
                led_display(2);
                break;
            case CMD_LEFT:
                motor_set_movement(VERT_STOPPED, HORIZ_LEFT);
                led_display(3);
                break;
            case CMD_RIGHT:
                motor_set_movement(VERT_STOPPED, HORIZ_RIGHT);
                led_display(4);
                break;
            case CMD_NONE:
                // Ignore it
                break;
            default:
                led_display(cmd);
                break;
        }
    }

    return 0;
}
Exemple #27
0
void board_init(void)
{
	clock_init();

	uart_init();	
	uart_register();
	rt_console_set_device("uart");

	led_init();

	timer_init();
	
	rt_hw_mmu_init();
}
Exemple #28
0
int main(void)
{
    led_init();
    key_init();
 // timer0_init();
    watchdog_init();

    led_on(LED0);

    /* feed dog, otherwise will reset when watchdog time expire */
    watchdog_feed();

    return 0;
}
Exemple #29
0
/*******************************************************************************
 *  function :    hw_init
 ******************************************************************************/
void
hw_init(void) {

	#if CONFIG_SYSCLOCK == CONFIG_SYSCLOCK_16MHZ
		hw_initSysclock();
	#endif
	systick_init(CONFIG_SYSTICK_1MS);


    RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

    led_init();
    btn_init();
}
int main()
{
	led_init();
	LPC_GPIO1->IS |= (1<<9); // 设置P1.9电平触发
	LPC_GPIO1->IS |= (1<<10); // 设置P1.10电平触发
	LPC_GPIO1->IE |= (1<<9); // 允许P1.9产生中断
	LPC_GPIO1->IE |= (1<<10); // 允许P1.10产生中断
	NVIC_EnableIRQ(EINT1_IRQn);
	
	while(1)
	{
		;
	}
}