Beispiel #1
0
void user_init(void)
{
    hw_timer_init(1);
    hw_timer_set_func(hw_test_timer_cb);
    hw_timer_arm(100);
}
void time_init(void)
{
	hw_timer_init();
}
Beispiel #3
0
// We use a hardware-supplied timer module for the "find tempo"
// processing.  PebbleOS 1.12.1 doesn't provide any kind of
// high-resolution timer/counter facility, so we have no accurate way
// of measuring time.
//
// I tried setting up a timer to run at 10ms and just count
// ticks... but this was incredibly inaccurate and noisy.  Using TIM5,
// a 32-bit counter, is much better.
void find_tempo_win_appear( Window* win )
{
   measuring_tempo = false;
   hw_timer_init( 1000 );
   timer_stack_push( &handle_tempo_tap_timers );
}
Beispiel #4
0
void ICACHE_FLASH_ATTR user_init(void)
{
    hw_timer_init(FRC1_SOURCE, 1);
    hw_timer_set_func(hw_test_timer_cb);
    hw_timer_arm(100);
}
Beispiel #5
0
int main(void)
{	
	//uint8_t status;
	
	#if SAMG55
	/* Initialize the SAM system. */
	sysclk_init();
	board_init();
	#elif SAM0
	system_init();
	#endif

	//button_init();
	
	platform_driver_init();
	acquire_sleep_lock();
	
	/* Initialize serial console */
	serial_console_init();

	/* Initialize button */
	//button_init(button_cb);

	/* Initialize the hardware timer */
	hw_timer_init();

	/* Register the callback */
	hw_timer_register_callback(timer_callback_handler);

	/* initialize the BLE chip  and Set the device mac address */
	ble_device_init(NULL);
	
	/* Initialize the battery service */
	//bat_init_service(&bas_service_handler, &battery_level);	

	/* Define the primary service in the GATT server database */
	/*if((status = bat_primary_service_define(&bas_service_handler))!= AT_BLE_SUCCESS)
	{
		DBG_LOG("defining battery service failed %d", status);
	}*/
	
	//battery_set_advertisement_data();
	
	/* Register callbacks for gap related events */ 
	/*ble_mgr_events_callback_handler(REGISTER_CALL_BACK,
									BLE_GAP_EVENT_TYPE,
									battery_app_gap_cb);*/
									
	/* Register callbacks for gatt server related events */
	/*ble_mgr_events_callback_handler(REGISTER_CALL_BACK,
									BLE_GATT_SERVER_EVENT_TYPE,
									battery_app_gatt_server_cb);*/
	
	pxp_monitor_init(NULL);

	DBG_LOG("Initializing Perception Central Application");

	/* Initialize the pxp service */
	pxp_app_init();
	
	register_hw_timer_start_func_cb((hw_timer_start_func_cb_t)hw_timer_start);
	register_hw_timer_stop_func_cb(hw_timer_stop);
	//register_peripheral_state_cb(peripheral_advertising_cb);

	while (1) {
		/* BLE Event Task */
		ble_event_task(BLE_EVENT_TIMEOUT);
		
		/*if (button_pressed)
		{
			uint8_t idx;
			uint8_t connected_to_central = false;
			for (idx = 0; idx < BLE_MAX_DEVICE_CONNECTED; idx++ )
			{
				if(ble_check_iscentral(ble_dev_info[idx].conn_info.handle))
				{
					at_ble_disconnect(ble_dev_info[idx].conn_info.handle, AT_BLE_TERMINATED_BY_USER);
					connected_to_central = true;
					break;
				}
			}
			if (connected_to_central == false)
			{
				at_ble_scan_stop();
				pxp_monitor_start_scan();
			}
			button_pressed = false;
						
		}*/
		
		//battery_simulation_task(NULL);

		/* Application Task */
		if (app_timer_done) {
			if (pxp_connect_request_flag == PXP_DEV_CONNECTING) {
				at_ble_disconnected_t pxp_connect_request_fail;
				pxp_connect_request_fail.reason
					= AT_BLE_TERMINATED_BY_USER;
				pxp_connect_request_fail.handle = ble_dev_info[0].conn_info.handle;
				pxp_connect_request_flag = PXP_DEV_UNCONNECTED;
				if (at_ble_connect_cancel() == AT_BLE_SUCCESS) {
					DBG_LOG("Connection Timeout");
					pxp_disconnect_event_handler(
							&pxp_connect_request_fail);
				} else {
					DBG_LOG(
							"Unable to connect with device");
				}
			} /*else if (pxp_connect_request_flag == PXP_DEV_SERVICE_FOUND) {
				rssi_update(ble_dev_info[0].conn_info.handle);
				hw_timer_start(PXP_RSSI_UPDATE_INTERVAL);
			}*/ /*else if (pxp_connect_request_flag == PXP_DEV_UNCONNECTED) {
				if(	peripheral_state == PERIPHERAL_ENCRYPTION_STATE 
					||peripheral_state == PERIPHERAL_PAIRED_STATE) {
					hw_timer_start(BATTERY_UPDATE_INTERVAL);
					DBG_LOG("BATTERY_UPDATE_INTERVAL TIMER");
				}
			}*/

			app_timer_done = false;
		}
	}
}