Пример #1
0
/*-------------------------------   ----------------------------*/
void system_battery_detect()
{
    static uint32_t detect_count = 0;
    uint8_t battery_level;
    
    // check every 2 minutes 
     if(detect_count == 1)
     {
         battery_detect_start();
     }
     
     if(battery_is_available() == true)
     {         
         battery_level = get_battery_value();
         battery_detect_stop();
         set_battery_level(battery_level);
         xprintf("             level = %d \r\n", battery_level);
         
         if(get_battery_level() < 20)
             system_low_battery();
                  
     }
         
    if(detect_count > 1500000*120)
    {
        xprintf(" time on..\r\n");
        detect_count = 0;
    }
    detect_count++;
}
Пример #2
0
/*---------------------------  -----------------------*/
void system_module_init()
{
    // uart init
    simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, 0); 
    xprintf("start up..\r\n");
    
    //  
    system_HFCLK_init();

    //  
    if(!system_battery_self_test())
    {
        system_low_battery();
    }
    //  
     system_bootloader_check();
    //   
    system_led_flicker_init();
    nrf_gpio_pin_set(RED_LED);
    //  
    system_parameter_init();
    //  
    system_I2C_init();
    //  
    system_gpio_LoToHi_INT_init(ACCE_TAP_PIN_NUMBER);
    
    nrf_delay_ms(2000);
    nrf_gpio_pin_clear(RED_LED);
    
    
}
Пример #3
0
/**@brief Function for application main entry.
 */
int main(void)
{
	system_HFCLK_init();
	// uart init
    simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, 0); 
    xprintf("APP start up..\r\n");
	
	mcu_bootloader_check();
    // Initialize.
    app_trace_init();
    leds_init();
    buttons_init();
    ble_stack_init();
    device_manager_init();
    timers_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_sim_init();
    conn_params_init();
	
	//I2C and sensor initial
	system_I2C_init();
	OLED_Init();
	sensor_init();
	enter_pedo_mode();	
	
	GPIO_HiToLo_INT_config(BUTTON_2);
	
	// Test battery
	if(!battery_self_detect())
    {
        system_low_battery();
    }
	
	// Start execution.
    application_timers_start();
    advertising_start();
	
	// Enter main loop.
    for (;;)
    {
        power_manage();
    }
}