예제 #1
0
/**
 * rtc_init - initializes the real time clock chip
 */
void rtc_init()
{
	EICRA |= (1 << ISC11) | (1 << ISC10); /* rising edge at int1 causes an interrupt */
	interrupt_was_enabled = TRUE;
	rtc_enable_avr_interrupt();

	rtc_set_alarm_polarity(RTC_POLARITY_ACTIVE_HIGH);

	rtc_clear_alarm0_interrupt_flag();
	rtc_enable_alarm0();

	rtc_clear_alarm1_interrupt_flag();
	rtc_enable_alarm1();

	rtc_load_configuration();
}
예제 #2
0
/*
 * EXPORTED FUNCTION DEFINITIONS
 ****************************************************************************************
 */
void app_display_init(void)
{
/* ***********************************************************************/
/*                              Screen Allocation                        */
/* ***********************************************************************/

    //Level 1
    uint8_t s_prof = display_screen_alloc();            //Profiles
    uint8_t s_app_mgmt = display_screen_alloc();        //Application Management
    uint8_t s_info = display_screen_alloc();            //Platform Information


    //Level 2 - Features
    uint8_t s_feat_top;
    #if (BLE_APP_HT)
    uint8_t s_ht = display_screen_alloc();              //Health Thermometer
    #endif //BLE_APP_HT
    #if (BLE_APP_ACCEL)
    uint8_t s_accel = display_screen_alloc();           //Accelerometer
    #endif //BLE_APP_ACCEL

    //Level 2 - Application Management
    uint8_t s_adv = display_screen_alloc();             //Advertising
    uint8_t s_con = display_screen_alloc();             //Connection State
    uint8_t s_pin = display_screen_alloc();             //PIN Code
    #if RTC_SUPPORT
    uint8_t s_rtc = display_screen_alloc();             //RTC
    struct rtc_time alarm = {0,0,0,0,0,0,0,0};
    #endif //RTC_SUPPORT

    #if (BLE_APP_HT)
    //Level 3 - Health Thermometer
    uint8_t s_ht_value = display_screen_alloc();        //Temperature Value
    uint8_t s_ht_type = display_screen_alloc();         //Temperature Type
    uint8_t s_ht_unit = display_screen_alloc();         //Unit
    #endif //BLE_APP_HT

    app_display_env.screen_id_adv = s_adv;
    app_display_env.screen_id_con = s_con;
    app_display_env.screen_id_pin = s_pin;
    #if RTC_SUPPORT
    app_display_env.screen_id_rtc = s_rtc;
    #endif //RTC_SUPPORT

    #if (BLE_APP_HT)
    app_display_env.screen_id_ht_value = s_ht_value;
    app_display_env.screen_id_ht_type = s_ht_type;
    app_display_env.screen_id_ht_unit = s_ht_unit;
    #endif //BLE_APP_HT

/* ***********************************************************************/
/*                              Screen Insertion                         */
/* ***********************************************************************/

    //Level 1
    display_screen_insert(s_app_mgmt, s_prof);
    display_screen_insert(s_info, s_prof);

    //Level 2 - Features
    #if (BLE_APP_HT)
    s_feat_top = s_ht;
    #elif BLE_APP_ACCEL
    s_feat_top = s_accel;
    #else
    //No profile
    s_feat_top = display_screen_alloc();
    display_screen_set(s_feat_top, NULL, "< NO PROFILE", "");
    #endif

    #if (BLE_APP_HT)
    display_screen_insert(s_ht, s_feat_top);
    #endif //BLE_APP_HT
    #if (BLE_APP_ACCEL)
    display_screen_insert(s_accel, s_feat_top);
    #endif //BLE_APP_ACCEL

    //Level 2 - Application Management
    display_screen_insert(s_con, s_adv);
    display_screen_insert(s_pin, s_adv);
    #if RTC_SUPPORT
    display_screen_insert(s_rtc, s_adv);
    #endif //RTC_SUPPORT

    //Level 3 - Health Thermometer
    #if (BLE_APP_HT)
    display_screen_insert(s_ht_type, s_ht_value);
    display_screen_insert(s_ht_unit, s_ht_value);
    #endif //BLE_APP_HT

/* ***********************************************************************/
/*                              Screen List Link                         */
/* ***********************************************************************/

    //Link Level 1 - Feature with Level 2
    display_screen_link(s_prof, s_feat_top);

    //Link Level 1 - Application Management with Level 2
    display_screen_link(s_app_mgmt, s_adv);

    //Link Level 1 - Platform Information with Level 2
    display_screen_link(s_info, 0);

    #if (BLE_APP_HT)
    //Link Level 2 - Health Thermometer with Level 3
    display_screen_link(s_ht, s_ht_value);
    #endif //BLE_APP_HT

/* ***********************************************************************/
/*                              Screen Set Content                       */
/* ***********************************************************************/

    //Level 1
    display_screen_set(s_prof, NULL, " PROFILES      >", "");
    display_screen_set(s_app_mgmt, NULL, " APPLICATION   >", " MANAGEMENT");
    display_screen_set(s_info, NULL, " PLATFORM      >", " INFORMATION");

    //Level 2 - Features
    #if (BLE_APP_HT)
    display_screen_set(s_ht, NULL, "< HEALTH       >", "  THERMOMETER");
    #endif //BLE_APP_HT
    #if (BLE_APP_ACCEL)
    display_screen_set(s_accel, NULL, "< ACCEL.        >", "");
    #endif //BLE_APP_ACCEL

    //Level 2 - Application Management
    display_screen_set(s_adv, &app_display_hdl_adv, "< ADVERTISING", "s OFF");
    display_screen_set(s_con, NULL, "< CONNECTED", "  NO");
    display_screen_set(s_pin, NULL, "< PIN CODE", "  ------");
    #if RTC_SUPPORT
    display_screen_set(s_rtc, NULL, "< No time", "");
    #endif //RTC_SUPPORT

    #if (BLE_APP_HT)
    //Level 3 - Health Thermometer
    display_screen_set(s_ht_value, &app_display_hdl_ht_temp_value, "< TEMP VALUE", "s --.--");
    display_screen_set(s_ht_type, &app_display_hdl_ht_temp_type, "< TEMP TYPE", "s NONE");
    display_screen_set(s_ht_unit, NULL, "< TEMP UNIT", "  CELCIUS");
    #endif //BLE_APP_HT

    // Start with Profile screen
    display_start(s_prof);

    #if RTC_SUPPORT
    // Register event to handle 1sec tick
    ke_event_callback_set(KE_EVENT_RTC_1S_TICK, &app_display_sec_tick_evt_hdl);
    // Start the periodic RTC interrupt
    rtc_enable_alarm0(RTC_ALARM_SEC, &alarm , &app_display_sec_tick_cbck);
    #endif //RTC_SUPPORT
}