示例#1
0
文件: db.c 项目: Curbfeeler/freewpc
/**
 * Handle a breakpoint.  The system is stopped until the user forces it
 * to continue, either by pressing 'p' in the debug console, or presses
 * the Escape Button.  Interrupt-level functions continue to run while
 * paused; only regular task scheduling is paused.  In order to poll for
 * the continue, we have to invoke the switch and debugger periodic
 * functions.
 */
void bpt_hit (void)
{
	U8 key;

	db_paused = 1 - db_paused;
	if (db_paused == 1)
	{
		callset_invoke (debug_enter);
		db_tilt_flag = in_tilt;
		in_tilt = FALSE;
		bpt_display ();
	}
	else
	{
		in_tilt = db_tilt_flag;
		callset_invoke (debug_exit);
	}

	while (db_paused == 1)
	{
		if ((key = button_check (SW_ENTER)))
		{
			/* Enter = change active field */
			bpt_display ();
		}
		else if ((key = button_check (SW_UP)))
		{
			/* Up = increase field value */
			bpt_mem_addr += key * 4;
			bpt_mem_addr = (void *) (((U16)bpt_mem_addr) & 0x1FFFUL);
			bpt_display ();
		}
		else if ((key = button_check (SW_DOWN)))
		{
			/* Down = decrease field value */
			bpt_mem_addr -= key * 4;
			bpt_mem_addr = (void *) (((U16)bpt_mem_addr) & 0x1FFFUL);
			bpt_display ();
		}
		else
		{
			switch_periodic ();
			db_periodic ();
			task_runs_long ();
		}
	}
#ifdef CONFIG_DMD_OR_ALPHA
	dmd_alloc_low_clean ();
	dmd_show_low ();
#endif
}
示例#2
0
int
main()
{
  Button button;

  struct counter_data data = {
    (ShiftRegister){12, 10, 11},
    0
  };

  shift_register_init(&data.reg);
  shift_register_set(&data.reg, 1);
  button_init(&button);

  button.pin = 7;
  button.closed_on = LOW;
  button.debounce_delay = 10;
  button.hold_delay = 250;
  button.toggle_callback = &toggled;
  button.hold_callback = &hold;
  button.data = &data;

  pin_set_mode(7, INPUT);
  pin_set_value(7, PULLUP); // enable the internal pull-up resistor

  while(true) {
    button_check(&button);
    delay_ms(1); // TODO do not depend on delaying
  }

  return 0;
}
示例#3
0
文件: db.c 项目: Curbfeeler/freewpc
/** Check for debug input periodically */
void db_periodic (void)
{
#ifdef CONFIG_BPT
	if (!in_test && button_check (SW_ESCAPE))
		bpt_stop ();
#endif

#ifdef CONFIG_DEBUG_INPUT
	if (pinio_debug_read_ready ())
	{
		char c = pinio_debug_read ();
		puts_handler = puts_debug;
		switch (c)
		{
#ifdef DEBUGGER
			case 'a':
				/* Dump all debugging information */
				db_dump_all ();
				break;
#endif

#ifdef CONFIG_BPT
			case 'p':
				/* Stop the system */
				bpt_stop ();
				break;
#endif

			default:
				break;
		}
	}
#endif /* DEBUGGER */
}
int main(void)
{
	
	serial_initialise();

	button_t button_1 = debounce_init("PB0");
	button_t button_2 = debounce_init("PB2");
	
	button_auto_acknowledge(button_2);
	
	sei();

	serial_send_data("Off we go\r\n");
	
    while (1) 
    {

		if(button_check(button_1) == BUTTON_PRESS_SHORT) {
			serial_send_data("Button 1 short");
			button_acknowledge(button_1);
		}

		if(button_check(button_1) == BUTTON_PRESS_LONG) {
			serial_send_data("Button 1 long");
			button_acknowledge(button_1);
		}
		
		switch (button_check(button_2)) {
			case BUTTON_PRESS_SHORT:	
				serial_send_data("Button 2 short");
				break;

			case BUTTON_PRESS_LONG:
				serial_send_data("Button 2 long");
				break;
		}
		
		_delay_ms(200);

		serial_send_data("Canary\r\n");

 }
}
示例#5
0
// State of motor callibration
FLY_STATE func_motor_callibration(void)
{
	FLY_STATE mode = FLY_STATE_CALIB;
	
	if(fly_param.length > 0)
	{
		if(fly_param.motor[2] != 0)	// release calibration mode
		{
			update_calib_data();		// 
			mode = FLY_STATE_NORMAL;
			func_normal();
		}
		{							// calibration mode
			float acc[3];				// sensor data;
			
			button_func(button_check((unsigned char)fly_param.motor[3]));
			
			update_motor_data();
			// センサーデータ取得
			kx022.get_val(acc);
			// センサーデータの送信
			Print.init(tx_data,sizeof(tx_data));
			Print.p("SensorData,");
			Print.f(acc[0],1);
			Print.p(",");
			Print.f(acc[1],1);
			Print.p(",");
			Print.f(acc[2],1);
			Print.p(",");
	//		digitalWrite(BLUE_LED,LOW);
	//		P56D=0;
			SubGHz.send(SUBGHZ_PANID,SUBGHZ_TXADDR, (unsigned char *)&tx_data, Print.len(),NULL);
	//		digitalWrite(BLUE_LED,HIGH);
	//		P56D=1;
		}
	}
	else
	{
		if((fly_param.current_time-fly_param.last_recv_time)>500)
		{
			func_waiting_zero();
			mode = FLY_STATE_DETECTING_ZERO;
		}
	}
	
	return mode;
}
示例#6
0
文件: db.c 项目: SonnyJim/freewpc
/** Check for debug input periodically */
void db_periodic (void)
{
	extern void MACHINE_DEBUGGER_HOOK (U8);

#ifdef CONFIG_BPT
	if (!in_test && button_check (SW_ESCAPE))
		bpt_stop ();
#endif

#ifdef DEBUGGER
	if (wpc_debug_read_ready ())
	{
		char c = wpc_debug_read ();
		db_puts = db_puts_orkin;
		switch (c)
		{
			case 'a':
				/* Dump all debugging information */
				db_dump_all ();
				break;

#ifdef CONFIG_BPT
			case 'p':
				/* Stop the system */
				bpt_stop ();
				break;
#endif

			default:
#ifdef MACHINE_DEBUGGER_HOOK
				/* Allow the machine to define additional commands.
				 * This function must reside in the system page. */
				MACHINE_DEBUGGER_HOOK (c);
#endif
				break;
		}
	}
#endif /* DEBUGGER */
}