Exemplo n.º 1
0
/**
 * \brief  Initializes the DBGU and ISO7816 driver, and starts some tests.
 *
 * \return Unused (ANSI-C compatibility)
 */
int main(void)
{
	uint8_t p_atr[MAX_ATR_SIZE];
	uint8_t uc_size;
	uint8_t i;

	/* Initialize the SAM system. */
	sysclk_init();
	board_init();

	/* Configure UART for debug message output. */
	configure_console();

	/* Output example information. */
	puts(STRING_HEADER);

	/* Initialize Atr buffer. */
	for (i = 0; i < sizeof(p_atr); i++) {
		p_atr[i] = 0;
	}

	/* Configure IT on Smart Card. */
	puts("-I- Smartcard detection not supported.\r\n");

	/* Enable peripheral clock. */
	sysclk_enable_peripheral_clock(ISO7816_USART_ID);

	/* Configure ISO7816 driver. */
	iso7816_init(&conf_iso7816_t, sysclk_get_cpu_hz(), PIN_ISO7816_RST_IDX);

	/* Read ATR. */
	iso7816_warm_reset();

	iso7816_data_block_atr(p_atr, &uc_size);

	/* Decode ATR. */
	iso7816_decode_atr(p_atr);

	/* Allow user to send some commands. */
	send_receive_cmd();

	while (1) {
	}
}
Exemplo n.º 2
0
/**
 * Initializes the DBGU and ISO7816 driver, and starts some tests.
 * \return Unused (ANSI-C compatibility)
 */
extern int main( void )
{
    uint8_t Atr[MAX_ATR_SIZE] ;
    uint8_t size ;

	/* Disable watchdog */
	wdt_disable();

	/* Disable all PIO interrupts */
	pio_reset_all_it();

	/* Configure console */
	board_cfg_console();
	console_clear_screen();
	console_reset_cursor();

	/* Configure PIT. Must be always ON, used for delay */
	printf("Configure PIT \n\r");
	timer_configure(BLINK_PERIOD);

    printf( "-- USART ISO7816 Example %s --\n\r", SOFTPACK_VERSION ) ;
    printf( "-- %s\n\r", BOARD_NAME ) ;
    printf( "-- Compiled: %s %s --\n\r", __DATE__, __TIME__ ) ;

#ifdef CONFIG_HAVE_PMIC_ACT8945A
	pio_configure(act8945a_pins, ARRAY_SIZE(act8945a_pins));
	if (act8945a_configure(&act8945a, &act8945a_twid)) {
		act8945a_set_regulator_voltage(&act8945a, 6, 2500);
		act8945a_enable_regulator(&act8945a, 6, true);
	} else {
		printf("--E-- Error initializing ACT8945A PMIC\n\r");
	}
#endif

	/* PIO configuration for LEDs */
	printf("Configure LED PIOs.\n\r");
	_configure_leds();
	led_set(LED_BLUE);
	timer_wait(500);
	led_clear(LED_BLUE);
	led_status[LED_BLUE] = 1;

	/* PIO configuration for Button, use to simulate card detection. */
	printf("Configure buttons with debouncing.\n\r");
	_configure_buttons();

	/* Configure Pios usart*/
	pio_configure(&pins_com2[0], ARRAY_SIZE(pins_com2));

	/* Init ISO7816 interface */
    iso7816_init(&iso7816_desc, &iso7816_opt);

	/* Warm reset */
    iso7816_warm_reset(&iso7816_desc);
	/*  Read ATR */
    memset( Atr, 0, sizeof(Atr) ) ;
    iso7816_get_data_block_ATR(&iso7816_desc, Atr, &size );
    /*  Decode ATR */
    iso7816_decode_ATR(Atr);

    /*  Allow user to send some commands */
    _send_receive_commands(&iso7816_desc);

	printf("\n\r Exit App \n\r");
    while (1) ;
}