示例#1
0
static void setup(void)
{
	//setup_uart();
	setup_button();
	setup_led();
	setup_timers();

	sei();
}
示例#2
0
文件: main.c 项目: Jimmy-Dinis/flm02
int main(void)
{
	uint8_t i;

	cli();
	MCUSR = 0;
	wdt_disable();

	//TODO replace by an ana comp polling loop
	_delay_ms(10);

	setup_datastructs();
	setup_led();
	setup_ar_uart();
	setup_adc();
	setup_pulse_input();
	setup_analog_comparator();
	setup_timer0();
	setup_timer1();
	
	// initialize the CTRL buffers
	ctrlInit();
	// initialize the SPI in slave mode
	setup_spi(SPI_MODE_0, SPI_MSB, SPI_INTERRUPT, SPI_SLAVE);

	// initialize the Si4421/RFM12 radio and buffers
	rfm12_init();

	// the clk/8 fuse bit is set
	clock_prescale_set(clock_div_1);
	FLAG_CLR_ICF1();
	sei();


	for(;;) {
		if (spi_status & SPI_NEW_CTRL_MSG) {
			ctrlDecode();
			spi_status &= ~SPI_NEW_CTRL_MSG;
		}

		for (i = 0; i < max_analog_sensors; i++) {
			if (state[i].flags & STATE_POWER_CALC) {
				calculate_power(&state[i]);
				state[i].flags &= ~STATE_POWER_CALC;
				state[i].flags |= STATE_POWER;
			}
		}

		rfm12_tick();
	}

	return 0;
}
示例#3
0
void configure_serial()
{

  setup_led( );
  GREEN_LED = 1;
  GREEN_LED = 0;
  usb_init( );
  usb_enable( );
  usb_up( );
  usb_flush( );
  /// GREEN_LED = 1;

}
示例#4
0
文件: serial.c 项目: ps2/subg_rfspy
void configure_serial()
{

  setup_led( );
//  led_set_state(0,1);
//  led_set_state(0,0);
  usb_init( );
  usb_enable( );
  usb_up( );
  usb_flush( );
  /// GREEN_LED = 1;

}
void spl_board_init(void)
{
	struct udevice *pinctrl;
	int ret;

	ret = setup_led();

	if (ret) {
		debug("LED ret=%d\n", ret);
		hang();
	}

	ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
	if (ret) {
		debug("%s: Cannot find pinctrl device\n", __func__);
		goto err;
	}

#ifdef CONFIG_SPL_MMC_SUPPORT
	ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
	if (ret) {
		debug("%s: Failed to set up SD card\n", __func__);
		goto err;
	}
	ret = configure_emmc(pinctrl);
	if (ret) {
		debug("%s: Failed to set up eMMC\n", __func__);
		goto err;
	}
#endif

	/* Enable debug UART */
	ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG);
	if (ret) {
		debug("%s: Failed to set up console UART\n", __func__);
		goto err;
	}

	preloader_console_init();
#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
	back_to_bootrom(BROM_BOOT_NEXTSTAGE);
#endif
	return;
err:
	printf("spl_board_init: Error %d\n", ret);

	/* No way to report error here */
	hang();
}
示例#6
0
文件: main.c 项目: jgoller/flm02
int main(void)
{
	uint8_t i;

	cli();

	// RS-485: Configure PD5=DE as output pin with low as default
	DDRD |= (1<<DDD5);
	// set high to transmit
	//PORTD |= (1<<PD5);

	setup_datastructs();
	setup_led();
	setup_adc();
	setup_pulse_input();
	setup_analog_comparator();
	setup_timer1();
	
	// initialize the CTRL buffers
	ctrlInit();
	// initialize the UART hardware and buffers
	uartInit();
	// initialize the SPI in slave mode
	setup_spi(SPI_MODE_2, SPI_MSB, SPI_INTERRUPT, SPI_SLAVE);

	sei();


	for(;;) {
		if (spi_status & SPI_NEW_CTRL_MSG) {
			ctrlDecode();
			spi_status &= ~SPI_NEW_CTRL_MSG;
		}

		for (i = 0; i < MAX_ANALOG_SENSORS; i++) {
			if (state[i].flags & STATE_POWER_CALC) {
				calculate_power(&state[i]);
				state[i].flags &= ~STATE_POWER_CALC;
				state[i].flags |= STATE_POWER;
			}
		}
	}

	return 0;
}
int
manipulate_led(UInt32 whichLED, UInt32 value)
{
	setup_led();
	
    IOReturn               ioReturnValue = kIOReturnError;
    IOHIDElementCookie     theCookie = (IOHIDElementCookie)0;
    IOHIDEventStruct       theEvent;
	
	
    if (whichLED == kHIDUsage_LED_NumLock) {
        theCookie = numlock_cookie;
    } else if (whichLED == kHIDUsage_LED_CapsLock) {
        theCookie = capslock_cookie;
    }
	
    if (theCookie == 0) {
        fprintf(stderr, "Bad or missing LED cookie.\n");
        goto out;
    }
	
    ioReturnValue = (*hidDeviceInterface)->getElementValue(hidDeviceInterface,
														   theCookie, &theEvent);
    if (ioReturnValue != kIOReturnSuccess) {
        (void)(*hidDeviceInterface)->close(hidDeviceInterface);
        goto out;
    }
	
//    fprintf(stdout, "current: %s\n", (theEvent.value) ? "on" : "off");
    if (value != (UInt32)-1) {
		theEvent.value = value;
		ioReturnValue = (*hidDeviceInterface)->setElementValue(
															   hidDeviceInterface, theCookie,
															   &theEvent, 0, 0, 0, 0);
		if (ioReturnValue == kIOReturnSuccess) {
//			fprintf(stdout, "new: %s\n", (theEvent.value) ? "on" : "off");
		}
    }
	
out:
	return ioReturnValue;
}
示例#8
0
int main(void) {
  irq_initialize_vectors();
  cpu_irq_enable();
  sleepmgr_init();
  system_init();
  log_init();
  l("configure_pins");
  setup_led();
  l("ui_init");
  ui_init();

  l("ui_powerdown");
  ui_powerdown();

  // Start USB stack to authorize VBus monitoring
  l("udc_start");
  udc_start();

  while (true) {
    sleepmgr_enter_sleep();
  }
}