Ejemplo n.º 1
0
Archivo: main.c Proyecto: alexpriem/avr
uint8_t keypad_w_getch (void) {
 uint8_t c,c2,i;
 
 
  c=0xff;
  while (c==0xff) {   /* mainloop*/
	 c=*keypad_port;
	 test_switch();
	 }  
  
  delay(50);
  i=0;
  c2=*keypad_port;
  while (c!=c2) {  	 
  	 c2=*keypad_port;
  	 i++;
  	 if (i>10) return 0xfd;
  	 test_switch();
  	}
  
  for (i=0; i<17; i++) {
    if (mapping[i]==c) return i;
  }
  

  //uart_printf ("not in mapping:%x\r\n",c);
  return 0xfe;
}		  
Ejemplo n.º 2
0
void
call_switch ()
{
    switch_val += test_switch (1, 0);
    switch_val += test_switch (3, 0);
    switch_val += test_switch (3, 2);
    switch_val += test_switch (4, 0);
    switch_val += test_switch (16, 0);
    switch_val += switch_m;
}
Ejemplo n.º 3
0
static int
unit_main(void) {
    dcontext_t *dcontext = GLOBAL_DCONTEXT;

    standalone_init();
    /* keep in mind that not all units are properly initialized above */
    fragment_init();

    /* options have to be set on the command line since after
     * synchronization any overrides will be gone
     */
    EXPECT(dynamo_options.detect_mode, true);
    EXPECT(dynamo_options.rct_ind_call, 11);
    EXPECT(dynamo_options.rct_ind_jump, 11);

    /* FIXME: report_current_process calls is_couldbelinking()
     * maybe we should just set the TEB entry with a good context
     */
    EXPECT(dynamo_options.diagnostics, false);

    TESTRUN(test_indcalls());
    TESTRUN(test_switch());

    TESTRUN(test_lookup_delete(dcontext));
    TESTRUN(test_small_array(dcontext));

    TESTRUN(test_self_direct(dcontext));

    TESTRUN(test_rct_ind_branch_check());

    TESTRUN(test_loaddll());

    LOG(GLOBAL, LOG_ALL, 1, "DONE unit-rct.c:unit_main()\n");

    dynamo_exited = true;
    fragment_exit();
    standalone_exit();

    return 0;
}
Ejemplo n.º 4
0
/*******************************************************************************
* MAIN FUNCTION                                                                *
*******************************************************************************/
int main(void)
{	
	unsigned char test_no = 0;
	// Clear all ports.
	LATA = 0;
	LATB = 0;
	LATC = 0;
	LATD = 0;
	LATF = 0;
	
	// Initialize I/O directions.
	TRISA = 0;					// dsPIC30F4013 & 3014 have PORTA
	TRISAbits.TRISA11 = 1;		// SW1 is connected at RA11
	TRISB = 0;
	TRISC = 0;
	TRISD = 0;
	TRISDbits.TRISD8 = 1;		// SW2 is connected at RD8	
	TRISF = 0;
	
	// Wait 1ms before we start the loop.
	beep(2);
	delay_ms(200);	
	lcd_initialize();	// initialize LCD
	
	lcd_clear();
	lcd_putstr("     Cytron\n  Technologies");	//Buzzer and LED share same output pin	
	delay_ms(1500);
	
	lcd_clear();
	lcd_putstr("    SKds40A\n  dsPIC30F4013");	
	delay_ms(1500);	
	LED1 = 0;
	LED2 = 0;
		
	test_switch();	//need to ensure switches is working before other test
	
	test_no = 1;
// Testing LEDs, UARTs (1, 2 and Alternative)
	while(1){
		lcd_2ndline_msg("1-> +,  2->Test");	//display the message for test menu navigation
				
		switch (test_no) //start the switch case to check which test mode to execute
			{
			case 1:	
				lcd_1stline_msg("1. Test All");	//mode 1 is to run all test sequentially			
				if (SW2 == 0) 			// if SW2 is press, to select the mode and run
				{	while (SW2 == 0);	// waiting for SW3 to be let go
					test_led();			// Test LEDs					
					test_uart1();		// Test UART1
					test_uart2();		// Test UART2
					test_uart1a();		// Test UART1 Alternative
				}	
				break;
				
			case 2:		// mode 2, test LEDs on SKds40A												
				lcd_1stline_msg("2: Test LEDs");	
				if (SW2 == 0) 
				{
					while (SW2 == 0);
					test_led();			// Test LEDs
				}	
				break;
				
			case 3:		// mode 3, test UART1, ensure jumper at Tx and RX Selector is connected to TX1 and RX1 respectively
				lcd_1stline_msg("3: Test UART1");
				if (SW2 == 0) 
				{
					while (SW2 == 0);
					test_uart1();		// Test UART1
				}	
				break;
				
			case 4:		// mode 4, test UART2, ensure jumper at Tx and RX Selector is connected to TX2 and RX2 respectively
				lcd_1stline_msg("4: Test UART2");
				if (SW2 == 0) 
				{
					while (SW2 == 0);
					test_uart2();		// Test UART2
				}	
				break;	
				
			case 5:		// mode 5, test UART1A, ensure jumper at Tx and RX Selector is connected to TX1A and RX1A respectively
				lcd_1stline_msg("5: Test UART1A");
				if (SW2 == 0) 
				{
					while (SW2 == 0);
					test_uart1a();		// Test UART1A
				}	
				break;			
		}//switch (test_no)	
			
		
		// If SW1 is pressed...		
		if (SW1 == 0) 
		{
			if (++test_no > 5) // if SW1 is press increase the test number until it is max and loop back
			{
				test_no = 1;
			}				
			while (SW1 == 0);	//wait for SW1 to be released
			beep(1);
		}		
	} // while (1)
}