void test_adc (void)
{
	uint8_t i = 0;

	while (1)
	{
		/* ADC software trigger per 100ms */
		if (_test_mode.trigger_mode == TRIGGER_MODE_SOFTWARE) {
			if (timer_timeout_reached(&timeout) && !_data.done) {
				adc_start_conversion();
				timer_start_timeout(&timeout, 250);
			}
		}
		if (_test_mode.trigger_mode == TRIGGER_MODE_ADTRG) {
			if (pio_get_output_data_status(&pin_adtrg[0]))
				pio_clear(&pin_adtrg[0]);
			else
				pio_set(&pin_adtrg[0]);
		}
		/* Check if ADC sample is done */
		if (_data.done & ADC_DONE_MASK) {
			for (i = 0; i < NUM_CHANNELS; ++i) {
				printf(" CH%02d: %04d ", _data.channel[i],
					   (_data.value[i]* VREF/MAX_DIGITAL) );
			}
			printf("\r");
			_data.done = 0;
		}
	}
}
Beispiel #2
0
void TC0_Handler(void)
{
	volatile uint32_t ul_dummy;

	/* Clear status bit to acknowledge interrupt */
	ul_dummy = tc_get_status(TC0,0);

	/* Avoid compiler warning */
	UNUSED(ul_dummy);
	
	/** Muda o estado do LED */
	
	if(pio_get_output_data_status(PORT_LED_BLUE , MASK_LED_BLUE) == 0)
	{
		pio_set(PORT_LED_BLUE, (1 << PIN_LED_BLUE));
	}
	else
	{
		pio_clear(PORT_LED_BLUE, (1 << PIN_LED_BLUE));
	}
	
	if(pio_get_output_data_status(PORT_LED_GREEN , MASK_LED_GREEN) == 0)
	{
		pio_set(PORT_LED_GREEN, (1 << PIN_LED_GREEN));
	}
	else
	{
		pio_clear(PORT_LED_GREEN, (1 << PIN_LED_GREEN));
	}
	
	
	if(pio_get_output_data_status(PORT_LED_RED , MASK_LED_RED) == 0)
	{
		pio_set(PORT_LED_RED, (1 << PIN_LED_RED));
	}
	else
	{
		pio_clear(PORT_LED_RED, (1 << PIN_LED_RED));
	}
	
}
Beispiel #3
0
/**
 *  Toggles the current state of a LED.
 *
 *  \param dwLed  Number of the LED to toggle.
 *  \return 1 if the LED has been toggled; otherwise 0.
 */
extern uint32_t led_toggle(uint32_t led)
{
#ifdef PINS_LEDS
	/* Check if LED exists */
	if (led >= numLeds) {
		return 0;
	}
	/* Toggle LED */
	if (pio_get_output_data_status(&pinsLeds[led])) {
		pio_clear(&pinsLeds[led]);
	} else {
		pio_set(&pinsLeds[led]);
	}
	return 1;
#else
	return 0;
#endif
}