示例#1
0
// *************************************************************************************************
// @fn          start_altitude_measurement
// @brief       Start altitude measurement
// @param       none
// @return      none
// *************************************************************************************************
void start_altitude_measurement(void)
{
    // Show warning if pressure sensor was not initialised properly
    if (!ps_ok)
    {
        display_chars(LCD_SEG_L1_2_0, (u8*)"ERR", SEG_ON);
        return;
    }

    // Start altitude measurement if timeout has elapsed
    if (sAlt.timeout == 0)
    {
        // Enable DRDY IRQ on rising edge
        PS_INT_IFG &= ~PS_INT_PIN;
        PS_INT_IE |= PS_INT_PIN;

        // Start pressure sensor
        ps_start();

        // Set timeout counter only if sensor status was OK
        sAlt.timeout = ALTITUDE_MEASUREMENT_TIMEOUT;

        // Get updated altitude
        while((PS_INT_IN & PS_INT_PIN) == 0);
        do_altitude_measurement(FILTER_OFF);
    }
}
示例#2
0
// *************************************************************************************************
// @fn          process_requests
// @brief       Process requested actions outside ISR context.
// @param       none
// @return      none
// *************************************************************************************************
void process_requests(void)
{
    // Do temperature measurement
    if (request.flag.temperature_measurement)
        temperature_measurement(FILTER_ON);

    // Do pressure measurement
    if (request.flag.altitude_measurement)
        do_altitude_measurement(FILTER_ON);

    // Do acceleration measurement
    if (request.flag.acceleration_measurement)
        do_acceleration_measurement();

    // Do voltage measurement
    if (request.flag.voltage_measurement)
        battery_measurement();

    // Generate alarm (two signals every second)
    if (request.flag.buzzer)
        start_buzzer(2, BUZZER_ON_TICKS, BUZZER_OFF_TICKS);

    // Reset request flag
    request.all_flags = 0;
}
示例#3
0
// *************************************************************************************************
// @fn          process_requests
// @brief       Process requested actions outside ISR context.
// @param       none
// @return      none
// *************************************************************************************************
void process_requests(void)
{
	// Do temperature measurement
	if (request.flag.temperature_measurement) temperature_measurement(FILTER_ON);
	
	// Do pressure measurement
#ifdef CONFIG_ALTITUDE
  	if (request.flag.altitude_measurement) do_altitude_measurement(FILTER_ON);
#endif
	
	#ifdef FEATURE_PROVIDE_ACCEL
	// Do acceleration measurement
	if (request.flag.acceleration_measurement) do_acceleration_measurement();
	#endif
	
	// Do voltage measurement
	if (request.flag.voltage_measurement) battery_measurement();
	
	// Generate alarm (two signals every second)
	if (request.flag.buzzer) start_buzzer(2, BUZZER_ON_TICKS, BUZZER_OFF_TICKS);
	
#ifdef CONFIG_STRENGTH
	if (request.flag.strength_buzzer && strength_data.num_beeps != 0) 
	{
		start_buzzer(strength_data.num_beeps, 
			     STRENGTH_BUZZER_ON_TICKS, 
			     STRENGTH_BUZZER_OFF_TICKS);
		strength_data.num_beeps = 0;
	}
#endif

	// Reset request flag
	request.all_flags = 0;
}
示例#4
0
// *************************************************************************************************
// @fn          process_requests
// @brief       Process requested actions outside ISR context.
// @param       none
// @return      none
// *************************************************************************************************
void process_requests(void)
{
#ifdef ECO_DISPLAY
	// Change display freq when needed
	if (request.flag.eco_display) eco_display();
#endif	
	// Do temperature measurement
	if (request.flag.temperature_measurement) temperature_measurement(FILTER_ON);
	
	// Do pressure measurement
#ifdef CONFIG_ALTITUDE
  	if (request.flag.altitude_measurement) do_altitude_measurement(FILTER_ON);
#endif
#ifdef CONFIG_ALTI_ACCUMULATOR
	if (request.flag.altitude_accumulator) altitude_accumulator_periodic();
#endif
	
	#ifdef FEATURE_PROVIDE_ACCEL
	// Do acceleration measurement
	if (request.flag.acceleration_measurement) do_acceleration_measurement();
	#endif
	
	#ifdef CONFIG_BATTERY
	// Do voltage measurement
	if (request.flag.voltage_measurement) battery_measurement();
	#endif
	
	#ifdef CONFIG_ALARM
	// Generate alarm (two signals every second)
	if (request.flag.alarm_buzzer) start_buzzer(2, BUZZER_ON_TICKS, BUZZER_OFF_TICKS);
	#endif
	
#ifdef CONFIG_EGGTIMER
	// Generate alarm (two signals every second)
	if (request.flag.eggtimer_buzzer) start_buzzer(2, BUZZER_ON_TICKS, BUZZER_OFF_TICKS);
#endif
	
	
#ifdef CONFIG_STRENGTH
	if (request.flag.strength_buzzer && strength_data.num_beeps != 0) 
	{
		start_buzzer(strength_data.num_beeps, 
			     STRENGTH_BUZZER_ON_TICKS, 
			     STRENGTH_BUZZER_OFF_TICKS);
		strength_data.num_beeps = 0;
	}
#endif

	// Reset request flag
	request.all_flags = 0;
}
// *************************************************************************************************
// @fn          process_requests
// @brief       Process requested actions outside ISR context.
// @param       none
// @return      none
// *************************************************************************************************
void process_requests(void)
{
    // Do temperature and pressure measurement
    if (request.flag.altitude_measurement)
        do_altitude_measurement(FILTER_ON);

    // Add data to datalog buffer
    if (request.flag.datalog)
        do_datalog();

    // Do voltage measurement
    if (request.flag.voltage_measurement)
        battery_measurement();

    // Reset request flag
    request.all_flags = 0;
}
示例#6
0
文件: altitude.c 项目: alkin/tidecc
// *************************************************************************************************
// @fn          start_altitude_measurement
// @brief       Start altitude measurement
// @param       none
// @return      none
// *************************************************************************************************
void start_altitude_measurement(void)
{
   u8 timeout = 15;

   // Already on?
   if (sAlt.on)
      return;

   // Show warning if pressure sensor was not initialised properly
   if (!ps_ok)
   {
      display_chars(LCD_SEG_L1_2_0, (u8 *) "ERR", SEG_ON);
      return;
   }

   // Enable DRDY IRQ on rising edge
   PS_INT_IFG &= ~PS_INT_PIN;
   PS_INT_IE |= PS_INT_PIN;

   // Start pressure sensor
   ps_start();

   // Set altitude measurement flag
   sAlt.on = 1;

   // Get updated altitude
   while (((PS_INT_IN & PS_INT_PIN) == 0) && (timeout > 0))
   {
      Timer0_A4_Delay(CONV_MS_TO_TICKS(100));
      timeout--;
   }

   // Failed to start?
   if (timeout == 0)
   {
      sAlt.on = 0;
   }

   do_altitude_measurement(FILTER_OFF);
}
示例#7
0
// *************************************************************************************************
// @fn          start_altitude_measurement
// @brief       Start altitude measurement
// @param       none
// @return      none
// *************************************************************************************************
void start_altitude_measurement(void)
{
    // Show warning if pressure sensor was not initialised properly
    
    //TODO libs should not display errors on their own
    /*
    if (!ps_ok)
    {
        display_chars(0, LCD_SEG_L1_2_0, "ERR", SEG_SET);
        return;
    }
    */

    // Start altitude measurement if timeout has elapsed
    if (sAlt.timeout == 0)
    {
        // Enable EOC IRQ on rising edge
        PS_INT_IFG &= ~PS_INT_PIN;
        PS_INT_IE |= PS_INT_PIN;

        // Start pressure sensor
        if (bmp_used)
        {
            bmp_ps_start();
        }
        else
        {
            cma_ps_start();
        }

        // Set timeout counter only if sensor status was OK
        sAlt.timeout = ALTITUDE_MEASUREMENT_TIMEOUT;

        // Get updated altitude
        while ((PS_INT_IN & PS_INT_PIN) == 0) ;
        do_altitude_measurement();
    }
}
示例#8
0
文件: test.c 项目: lieb005/My_Stuff
// *************************************************************************************************
// @fn          test_mode
// @brief       Manual test mode. Activated by holding buttons STAR and UP simultaneously. 
//				Cancelled by any other button press.
// @param      	none
// @return      none
// *************************************************************************************************
void test_mode(void)
{
	u8 test_step, start_next_test;
	u8 * str;
	u8 i;
	
	// Disable timer - no need for a clock tick
	Timer0_Stop();
	
	// Disable LCD charge pump while in standby mode 
	// This reduces current consumption by ca. 5?A to ca. 10?A
	LCDBVCTL = 0;
	
	// Show welcome screen 
	display_chars(LCD_SEG_L1_3_0, (u8*)"0430", SEG_ON);
	display_chars(LCD_SEG_L2_4_0, (u8*)"CC430", SEG_ON);
	display_symbol(LCD_SEG_L1_COL, SEG_ON);
	display_symbol(LCD_ICON_HEART, SEG_ON);
	display_symbol(LCD_ICON_STOPWATCH, SEG_ON);
	display_symbol(LCD_ICON_RECORD, SEG_ON);
	display_symbol(LCD_ICON_ALARM, SEG_ON);
	display_symbol(LCD_ICON_BEEPER1, SEG_ON);
	display_symbol(LCD_ICON_BEEPER2, SEG_ON);
	display_symbol(LCD_ICON_BEEPER3, SEG_ON);
	display_symbol(LCD_SYMB_ARROW_UP, SEG_ON);
	display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON);
	display_symbol(LCD_SYMB_AM, SEG_ON);

	// Hold watchdog
	WDTCTL = WDTPW + WDTHOLD;

	// Wait for button press 
	_BIS_SR(LPM3_bits + GIE); 
	__no_operation();

	// Clear display
	display_all_off();
	
#ifdef USE_LCD_CHARGE_PUMP
	// Charge pump voltage generated internally, internal bias (V2-V4) generation
	// This ensures that the contrast and LCD control is constant for the whole battery lifetime
	LCDBVCTL = LCDCPEN | VLCD_2_72;
#endif
	
	// Renenable timer
	Timer0_Start();
	
	// Debounce button press
	Timer0_A4_Delay(CONV_MS_TO_TICKS(100));
		
	while(1)
	{
		// Check button event
		if (BUTTON_STAR_IS_PRESSED && BUTTON_UP_IS_PRESSED)
		{
			// Start with test #0
			test_step = 0;
			start_next_test = 1;
			while(1)
			{
				if (start_next_test)
				{
					// Clean up previous test display
					display_all_off();
					
					start_next_test = 0;

					switch (test_step)
					{
						case 0: // All LCD segments on
								display_all_on(); 
								// Wait until buttons are off
								while (BUTTON_STAR_IS_PRESSED && BUTTON_UP_IS_PRESSED);
								break;
						case 1:	// Altitude measurement
#ifdef CONFIG_ALTITUDE
								display_altitude(LINE1, DISPLAY_LINE_UPDATE_FULL);
								for (i=0; i<2; i++)
								{
									while((PS_INT_IN & PS_INT_PIN) == 0); 
									do_altitude_measurement(FILTER_OFF);
									display_altitude(LINE1, DISPLAY_LINE_UPDATE_PARTIAL);
								}
								stop_altitude_measurement();	
#endif
								break;
						case 2: // Temperature measurement
								display_temperature(LINE1, DISPLAY_LINE_UPDATE_FULL);
								for (i=0; i<4; i++)
								{
									Timer0_A4_Delay(CONV_MS_TO_TICKS(250));
									temperature_measurement(FILTER_OFF);
									display_temperature(LINE1, DISPLAY_LINE_UPDATE_PARTIAL);
								}
								break;
						case 3: // Acceleration measurement
								as_start();
								for (i=0; i<4; i++)
								{
									Timer0_A4_Delay(CONV_MS_TO_TICKS(250));
									as_get_data(sAccel.xyz);
									str = itoa( sAccel.xyz[0], 3, 0);
									display_chars(LCD_SEG_L1_2_0, str, SEG_ON);
									str = itoa( sAccel.xyz[2], 3, 0);
									display_chars(LCD_SEG_L2_2_0, str, SEG_ON);
								}
								as_stop();
								break;
						//pfs
						#ifndef ELIMINATE_BLUEROBIN
						case 4:	// BlueRobin test
								button.flag.up = 1;
								sx_bluerobin(LINE1);
								Timer0_A4_Delay(CONV_MS_TO_TICKS(100));
								get_bluerobin_data();
								display_heartrate(LINE1, DISPLAY_LINE_UPDATE_FULL);
								stop_bluerobin();
								break;
						#endif
					}
					
					// Debounce button
					Timer0_A4_Delay(CONV_MS_TO_TICKS(200));
				}
				
				// Check button event
				if (BUTTON_STAR_IS_PRESSED) 
				{
					test_step = 1;
					start_next_test = 1;
				}
				else if (BUTTON_NUM_IS_PRESSED) 
				{
					test_step = 2;
					start_next_test = 1;
				}
				else if (BUTTON_UP_IS_PRESSED) 
				{
					test_step = 3;
					start_next_test = 1;
				}
				else if (BUTTON_DOWN_IS_PRESSED) 
				{
					test_step = 4;
					start_next_test = 1;
				}
				else if (BUTTON_BACKLIGHT_IS_PRESSED) 
				{
					// Wait until button has been released (avoid restart)
					while (BUTTON_BACKLIGHT_IS_PRESSED);

					// Disable LCD and LCD charge pump
					LCDBCTL0 &= ~BIT0;
					LCDBVCTL  = 0;
					
					// Debounce button press
					Timer0_A4_Delay(CONV_MS_TO_TICKS(500));

					// Disable timer - no need for a clock tick
					Timer0_Stop();
					
					// Hold watchdog
					WDTCTL = WDTPW + WDTHOLD;
					
					// Sleep until button is pressed (ca. 4?A current consumption)
					_BIS_SR(LPM4_bits + GIE);
					__no_operation();
				
					// Force watchdog reset for a clean restart 
					WDTCTL = 1; 
				}
				
#ifdef USE_WATCHDOG		
				// Service watchdog
				WDTCTL = WDTPW + WDTIS__512K + WDTSSEL__ACLK + WDTCNTCL;
#endif
				// To LPM3
				_BIS_SR(LPM3_bits + GIE);  
				__no_operation();
			}
		}
		else
		{
			// Debounce button
			Timer0_A4_Delay(CONV_MS_TO_TICKS(100));
			button.all_flags = 0;
			break;
		}
	}
}