Beispiel #1
0
void scanf_cmd(char *argv[], int argc) {
	int n;
	char vec[SCANF_MAX_STR_BUFFER];

	printf("Welcome to scanf user test:\n ");
	printf("And so, the trial begins...\n");
	printf("Please type in a number: \n");
	scanf("%d", &n);
	printf("You typed in: %d\n\n", n);
	reset_vect(vec);
	
	printf("Trial number 2...type in a short text: ");
	scanf("%s", vec);
	printf("You typed in: %s\n\n", vec);
	reset_vect(vec);

	printf("Trial number 3...Please type in a single character: ");
	scanf("%c", vec);
	printf("\nYou typed: %c\n\n", vec[0]);
	reset_vect(vec);

	printf("And so, the final trial begins:\n");
	printf("Are you ready? Type in Y or N\n");
	scanf("%s", vec);
	reset_vect(vec);
	printf(" Actually your response was irrelevant, proceeding with last trial...\n ");
	printf("Type in string format, your credit card number followed by verification code\n" );
	scanf("%s", vec);
	printf("\nYour fake card data was: %s\n\n", vec);
	reset_vect(vec);
}
Beispiel #2
0
int main(void){
	// Pull up pin to test if it's being pulled low
	CHECK_PORT.DIR = 0;
	CHECK_PORT.PINCTRL(CHECK_PIN) = PORT_OPC_PULLUP_gc;
	
	_delay_us(100);

	if (!(CHECK_PORT.IN & (1<<CHECK_PIN)) // If the specified pin is pulled LOW
	|| pgm_read_word(0) == 0xFFFF // Get the value of the reset vector. If it's unprogrammed, we know
	                               // there's nothing useful in app flash
	|| (RST.STATUS & RST_SRF_bm && bootloaderflag == BOOTLOADER_MAGIC) // If the app code reset into the bootloader
	){
		bootloaderflag = 0;
		runBootloader();
	}
	
	// Otherwise, clean up and jump to the app
	RST.STATUS = RST_SRF_bm;
	bootloaderflag = 0;
	//CHECK_PORT.PIN0CTRL = 0;
	CHECK_PORT.PINCTRL(CHECK_PIN) = 0;
	LED_PORT.PIN0CTRL = 0;
	EIND = 0x00;
	void (*reset_vect)( void ) = 0x000000;
    reset_vect();
}