void TIMER1_IRQHandler() { if((NRF_TIMER1->EVENTS_COMPARE[0] == 1) && (NRF_TIMER1->INTENSET & TIMER_INTENSET_COMPARE0_Msk)) { NRF_TIMER1->EVENTS_COMPARE[0] = 0; NRF_TIMER1->TASKS_CLEAR = 1; if(get_work_switch_state()) { work_switch_clear(); switch(get_work_mode()) { case SYSTEM_PEDOMETER_MODE: system_default_work_mode_init(); set_led_flicker(2); break; case SYSTEM_USER_SLEEP_MODE : system_user_sleep_mode_init(); set_led_flicker(3); break; case SYSTEM_BLE_WORK_MODE : system_ble_work_mode_init(); set_led_flicker(4); break; } } else { switch(get_work_mode()) { case SYSTEM_PEDOMETER_MODE: system_default_work_mode_operate(); break; case SYSTEM_USER_SLEEP_MODE : system_user_sleep_mode_operate(); break; case SYSTEM_BLE_WORK_MODE : system_ble_work_mode_operate(); break; case SYSTEM_MCU_SLEEP_MODE : system_mcu_sleep_mode_operate(); break; } system_idle_operate(); } } }
int main (int argc, char ** argv ) { setvbuf(stdin, buff_stdin, _IOFBF, 0x1000); setvbuf(stdout, buff_stdout, _IOFBF, 0x1000); char *real_obj_name = NULL; Input_Obj_Type tMode; tMode = get_work_mode (argc, argv); if ( save_settings_to_fs () < 0 ) return -1; if ( ( real_obj_name = prepare_object (tMode)) == NULL ) { return -1; } docs_to_xml( TEMP_DIR, tMode ); do_index_xml (); save_index (); //mylistdir( "/" ); return 0; }
int main (int argc, char ** argv ) { // setvbuf(stdin, buff_stdin, _IOFBF, 0x1000); // setvbuf(stdout, buff_stdout, _IOFBF, 0x1000); char *real_obj_name = NULL; int mode = 0; mode = get_work_mode (argc, argv); if ( save_settings_to_fs () < 0 ) return -1; if ( ( real_obj_name = prepare_object (mode)) == NULL ) { return -1; } test_read_dir( "/docs/list.txt" ); docs_to_xml( TEMP_DIR, mode ); do_index_xml (); save_index (); mylistdir( "/" ); return 0; }
/* 获取运行的基本信息输出到指定的缓冲区 */ void get_info(char * output) { int pos = 0; char line_buffer[512]; sprintf(line_buffer,"======= mproxy (v0.1) ========\n"); int len = strlen(line_buffer); memcpy(output,line_buffer,len); pos += len ; sprintf(line_buffer,"%s\n",get_work_mode()); len = strlen(line_buffer); memcpy(output + pos,line_buffer,len); pos += len; if(strlen(remote_host) > 0) { sprintf(line_buffer,"start server on %d and next hop is %s:%d\n",local_port,remote_host,remote_port); } else { sprintf(line_buffer,"start server on %d\n",local_port); } len = strlen(line_buffer); memcpy(output+ pos,line_buffer,len); pos += len ; output[pos] = '\0'; }
/**@brief Function for handling the Running Speed and Cadence measurement timer timeout. * * @details This function will be called each time the running speed and cadence * measurement timer expires. * * @param[in] p_context Pointer used for passing some arbitrary information (context) from the * app_start_timer() call to the timeout handler. */ static void rsc_meas_timeout_handler(void * p_context) { static uint8_t i; uint32_t err_code; ble_rscs_meas_t rscs_measurement; ak8963_cmps *cmps; UNUSED_PARAMETER(p_context); if(get_work_mode() == SYSTEM_PEDOMETER_MODE) pedometer_startup(); if(++i >= 100) //100 * 10ms = 1s { i = 0; if(get_work_mode() == SYSTEM_PEDOMETER_MODE) { rsc_sim_measurement(&rscs_measurement); err_code = ble_rscs_measurement_send(&m_rscs, &rscs_measurement); } else if(get_work_mode() == SYSTEM_TEMP_MODE) { temperature_measurement_send(); } else if(get_work_mode() == SYSTEM_COMPASS_MODE) { cmps = ak8963_get_value(); oled_update_cmps(cmps); } if ( (err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE) && (err_code != BLE_ERROR_NO_TX_BUFFERS) && (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) ) { // APP_ERROR_HANDLER(err_code); } } }
/*--------------------------- -------------------------*/ void system_sleep_countdown_detect() { // 5min sleep 5*60 = 300 *1s if(( get_sleep_countdown() >= SYSTEM_SLEEP_DEADLINE) && (get_work_mode() == SYSTEM_DEFAULT_MODE)) { clear_sleep_countdown(); system_mcu_sleep_mode_operate(); } }
void GPIOTE_IRQHandler() { if((NRF_GPIOTE->EVENTS_IN[0] == 1) && (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_IN0_Msk) ) { NRF_GPIOTE->EVENTS_IN[0] = 0; //NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Disabled << GPIOTE_INTENSET_IN0_Pos; switch(get_work_mode()) { // tap cyclical case SYSTEM_PEDOMETER_MODE : if(get_pedo_slice_handle_state() == true) pedo_data_end_handle(); clear_sleep_countdown(); work_mode_switch(); work_switch_set(); break; // case SYSTEM_USER_SLEEP_MODE: work_mode_switch(); work_switch_set(); break; case SYSTEM_BLE_WORK_MODE: if(BL.E.CONNECT_STATE == false) // ble is not paired with phone { ble_close(); } break; } } // Event causing the interrupt must be cleared. if((NRF_GPIOTE->EVENTS_IN[1] == 1) && (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_IN1_Msk) ) { NRF_GPIOTE->EVENTS_IN[1] = 0; xprintf("GPIO INT.\r\n"); } }