예제 #1
0
파일: qdebug.c 프로젝트: AndreyMostovov/asf
/**
 * @brief Transmits the channel delta values to QTouch Studio
 * @ingroup  QDebug-Remote
 * The value is equal to signal-reference
 */
void Transmit_Delta(void)
{
   uint8_t c;
   uint16_t delta;
   PutChar(QT_DELTAS);
   for (c=0; c < num_sensors; c++)
   {
      delta=qt_get_sensor_delta(c);
      PutChar(delta >> 8);
      PutChar(delta & 0xFF);
   }
   Send_Message();
}
예제 #2
0
파일: main.c 프로젝트: yoosofpiran/my-ihome
int main( void )
{

   /* initialize host app, pins, watchdog, etc */
    // init_system();

    /* configure timer ISR to fire regularly */
    // init_timer_isr();
	
	// Configure CPU and peripherals clock
	xmega_set_cpu_clock_to_32MHz();
	
	// Enable interrupts
	PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm;
	
	// Power management - configure sleep mode to IDLE
	set_sleep_mode(SLEEP_SMODE_IDLE_gc);
	// Enable sleep mode
	sleep_enable();

#ifdef MMSN_DEBUG
	// Initialize serial communication terminal
	// usartCommTerminalInit();
	
	// Configure and initialize communication bus usart
	xmega_usart_configure();
		
	/* RS-485 PHYSICAL DEVICE CONFIGURATION */
	// Initialize GPIO related to RS-485 interface
	rs485_driver_gpio_initialize();
		
	// Enable driver to be able to send data
	rs485_driver_enable();

	// Redirect stream to standard output
	stdout = &mystdout;

	/* Print out welcome message */
	printf_P(PSTR("\nGeneric Board ver 1.00\n"));
#endif

	// Heartbeat timer - 8MHz prescales by 8 => 1MHz
	// Thus 1ms equals to 1000 ticks
	xmega_timer_config(&TIMER_HEARTBEAT, TC_CLKSEL_DIV8_gc, (TICKS_PER_MS * qt_measurement_period_msec));

	/* Initialize Touch sensors */
	touch_init();

	// Configure PIN6 as input
	PORT_DIRCLR(POWER_SUPPLY_MEASUREMENT_IO);
	
	// ADC conversion on pin 6
	uint16_t u16ConvResult = xmega_generate_adc_random_value(&ADCA, ADC_REFSEL_INT1V_gc | 0x02, ADC_CH_MUXPOS_PIN6_gc);
	printf("Power meter = %u\n", u16ConvResult);
	
	// Configure PIN5 as input
	PORT_DIRCLR(OPTO_IO);
	
	u16ConvResult = xmega_generate_adc_random_value(&ADCA, ADC_REFSEL_INT1V_gc | 0x02, ADC_CH_MUXPOS_PIN5_gc);
	printf("Opto = %u\n", u16ConvResult);

    /* loop forever */
    for(;;)
    {
        touch_measure();
		
		// Test every 2s
		if(gCounter >= 40)
		{
			printf("\n");
			printf("\nSensor[0]: %d - ", GET_SENSOR_STATE(0));
			printf("Sensor[1]: %d - ", GET_SENSOR_STATE(1));
			printf("Sensor[2]: %d - ", GET_SENSOR_STATE(2));
			printf("Sensor[3]: %d\n", GET_SENSOR_STATE(3));
			printf("Sensor[4]: %d - ", GET_SENSOR_STATE(4));
			printf("Sensor[5]: %d - ", GET_SENSOR_STATE(5));
			printf("Sensor[6]: %d - ", GET_SENSOR_STATE(6));
			printf("Sensor[7]: %d\n", GET_SENSOR_STATE(7));
			printf("Sensor[8]: %d - ", GET_SENSOR_STATE(8));
			printf("Sensor[9]: %d - ", GET_SENSOR_STATE(9));
			printf("Sensor[10]: %d - ", GET_SENSOR_STATE(10));
			printf("Sensor[11]: %d\n", GET_SENSOR_STATE(11));
			printf("Sensor[12]: %d - ", GET_SENSOR_STATE(12));
			printf("Sensor[13]: %d - ", GET_SENSOR_STATE(13));
			printf("Sensor[14]: %d - ", GET_SENSOR_STATE(14));
			printf("Sensor[15]: %d\n", GET_SENSOR_STATE(15));
			
			printf("Sensor[16]: %d - ", GET_SENSOR_STATE(16));
			printf("Sensor[17]: %d - ", GET_SENSOR_STATE(17));
			printf("Sensor[18]: %d - ", GET_SENSOR_STATE(18));
			printf("Sensor[19]: %d\n", GET_SENSOR_STATE(19));
			printf("Sensor[20]: %d - ", GET_SENSOR_STATE(20));
			printf("Sensor[21]: %d - ", GET_SENSOR_STATE(21));
			printf("Sensor[22]: %d - ", GET_SENSOR_STATE(22));
			printf("Sensor[23]: %d\n", GET_SENSOR_STATE(23));
			printf("Sensor[24]: %d - ", GET_SENSOR_STATE(24));
			printf("Sensor[25]: %d - ", GET_SENSOR_STATE(25));
			printf("Sensor[26]: %d - ", GET_SENSOR_STATE(26));
			printf("Sensor[27]: %d\n", GET_SENSOR_STATE(27));
			printf("Sensor[28]: %d - ", GET_SENSOR_STATE(28));
			printf("Sensor[29]: %d - ", GET_SENSOR_STATE(29));
			printf("Sensor[30]: %d - ", GET_SENSOR_STATE(30));
			printf("Sensor[31]: %d\n", GET_SENSOR_STATE(31));
			printf("\n");
			
			u16ConvResult = xmega_generate_adc_random_value(&ADCA, ADC_REFSEL_INT1V_gc, ADC_CH_MUXPOS_PIN5_gc);
			printf("Opto = %i\n", u16ConvResult);
			/*
			printf("\nCh_Sig[0]: %u	", qt_measure_data.channel_signals[0]);
			printf("Ch_Sig[1]: %u	", qt_measure_data.channel_signals[1]);
			printf("Ch_Sig[2]: %u	", qt_measure_data.channel_signals[2]);
			printf("Ch_Sig[3]: %u", qt_measure_data.channel_signals[3]);
			printf("\nCh_Sig[4]: %u	", qt_measure_data.channel_signals[4]);
			printf("Ch_Sig[5]: %u	", qt_measure_data.channel_signals[5]);
			printf("Ch_Sig[6]: %u	", qt_measure_data.channel_signals[6]);
			printf("Ch_Sig[7]: %u", qt_measure_data.channel_signals[7]);
			printf("\nCh_Sig[8]: %u	", qt_measure_data.channel_signals[8]);
			printf("Ch_Sig[9]: %u	", qt_measure_data.channel_signals[9]);
			
			printf("Ch_Sig[10]: %u	", qt_measure_data.channel_signals[10]);
			printf("Ch_Sig[11]: %u", qt_measure_data.channel_signals[11]);
			printf("\nCh_Sig[12]: %u	", qt_measure_data.channel_signals[12]);
			printf("Ch_Sig[13]: %u	", qt_measure_data.channel_signals[13]);
			printf("Ch_Sig[14]: %u	", qt_measure_data.channel_signals[14]);
			printf("Ch_Sig[15]: %u", qt_measure_data.channel_signals[15]);
			printf("\nCh_Sig[16]: %u	", qt_measure_data.channel_signals[16]);
			printf("Ch_Sig[17]: %u	", qt_measure_data.channel_signals[17]);
			printf("Ch_Sig[18]: %u	", qt_measure_data.channel_signals[18]);
			printf("Ch_Sig[19]: %u", qt_measure_data.channel_signals[19]);
			printf("\nCh_Sig[20]: %u	", qt_measure_data.channel_signals[20]);
			
			printf("Ch_Sig[21]: %u	", qt_measure_data.channel_signals[21]);
			printf("Ch_Sig[22]: %u	", qt_measure_data.channel_signals[22]);
			printf("Ch_Sig[23]: %u", qt_measure_data.channel_signals[23]);
			printf("\nCh_Sig[24]: %u	", qt_measure_data.channel_signals[24]);
			printf("Ch_Sig[25]: %u	", qt_measure_data.channel_signals[25]);
			printf("Ch_Sig[26]: %u	", qt_measure_data.channel_signals[26]);
			printf("Ch_Sig[27]: %u", qt_measure_data.channel_signals[27]);
			printf("\nCh_Sig[28]: %u	", qt_measure_data.channel_signals[28]);
			printf("Ch_Sig[29]: %u	", qt_measure_data.channel_signals[29]);
			printf("Ch_Sig[30]: %u	", qt_measure_data.channel_signals[30]);
			printf("Ch_Sig[31]: %u", qt_measure_data.channel_signals[31]); */
			
			printf("\ndelta[0]: %i	", qt_get_sensor_delta(0));
			printf("delta[1]: %i	", qt_get_sensor_delta(1));
			printf("delta[2]: %i	", qt_get_sensor_delta(2));
			printf("delta[3]: %i", qt_get_sensor_delta(3));
			printf("\ndelta[4]: %i	", qt_get_sensor_delta(4));
			printf("delta[5]: %i	", qt_get_sensor_delta(5));
			printf("delta[6]: %i	", qt_get_sensor_delta(6));
			printf("delta[7]: %i", qt_get_sensor_delta(7));
			printf("\ndelta[8]: %i	", qt_get_sensor_delta(8));
			printf("delta[9]: %i	", qt_get_sensor_delta(9));
			
			printf("delta[10]: %i	", qt_get_sensor_delta(10));
			printf("delta[11]: %i", qt_get_sensor_delta(11));
			printf("\ndelta[12]: %i	", qt_get_sensor_delta(12));
			printf("delta[13]: %i	", qt_get_sensor_delta(13));
			printf("delta[14]: %i	", qt_get_sensor_delta(14));
			printf("delta[15]: %i", qt_get_sensor_delta(15));
			printf("\ndelta[16]: %i	", qt_get_sensor_delta(16));
			printf("delta[17]: %i	", qt_get_sensor_delta(17));
			printf("delta[18]: %i	", qt_get_sensor_delta(18));
			printf("delta[19]: %i", qt_get_sensor_delta(19));
			printf("\ndelta[20]: %i	", qt_get_sensor_delta(20));
			
			printf("delta[21]: %i	", qt_get_sensor_delta(21));
			printf("delta[22]: %i	", qt_get_sensor_delta(22));
			printf("delta[23]: %i", qt_get_sensor_delta(23));
			printf("\ndelta[24]: %i	", qt_get_sensor_delta(24));
			printf("delta[25]: %i	", qt_get_sensor_delta(25));
			printf("delta[26]: %i	", qt_get_sensor_delta(26));
			printf("delta[27]: %i", qt_get_sensor_delta(27));
			printf("\ndelta[28]: %i	", qt_get_sensor_delta(28));
			printf("delta[29]: %i	", qt_get_sensor_delta(29));
			printf("delta[30]: %i	", qt_get_sensor_delta(30));
			printf("delta[31]: %i", qt_get_sensor_delta(31));
			
			gCounter = 0;
		}

    /*  Time Non-critical host application code goes here  */
    }
}