extern "C" void init( void ) { SystemInit(); // Set Systick to 1ms interval, common to all SAM3 variants if (SysTick_Config(SystemCoreClock / 1000)) { // Capture error while (true); } UrgentInit(); // initialise anything in the main application that can't wait // Initialize C library __libc_init_array(); // Initialize Serial port U(S)ART pins ConfigurePin(g_APinDescription[APINS_USART0]); setPullup(APIN_USART0_RXD, true); // Enable pullup for RXD // Initialize USB pins ConfigurePin(g_APinDescription[APINS_USB]); // Initialize Analog Controller AnalogInInit(); // Initialize analogOutput module AnalogOutInit(); // Initialize TRNG pmc_enable_periph_clk(ID_TRNG); TRNG->TRNG_IDR = TRNG_IDR_DATRDY; // Disable all interrupts TRNG->TRNG_CR = TRNG_CR_KEY(0x524e47) | TRNG_CR_ENABLE; // Enable TRNG with security key (required) }
extern "C" void init( void ) { SystemInit(); // Set Systick to 1ms interval, common to all SAM3 variants if (SysTick_Config(SystemCoreClock / 1000)) { // Capture error while (true); } UrgentInit(); // initialise anything in the main application that can't wait // Initialize C library (I think this calls C++ constructors for static data too) __libc_init_array(); // We no longer disable pullups on all pins here, better to leave them enabled until the port is initialised // Initialize Serial port U(S)ART pins ConfigurePin(g_APinDescription[APINS_UART0]); setPullup(APIN_UART0_RXD, true); // Enable pullup for RX0 ConfigurePin(g_APinDescription[APINS_UART1]); setPullup(APIN_UART1_RXD, true); // Enable pullup for RX1 // No need to initialize the USB pins on the SAM4E because they are USB by default // Initialize Analog Controller AnalogInInit(); // Initialize analogOutput module AnalogOutInit(); // Initialize HSMCI pins ConfigurePin(g_APinDescription[APIN_HSMCI_CLOCK]); ConfigurePin(g_APinDescription[APINS_HSMCI_DATA]); // Start the USB udc_start(); }