int main(void) { req_header_t req_header; U8 checksum; // Dummy access to force the link of this variable into the binary. *build_info; // Clocks configuration sys_clk_gen_start(); #if 0 #ifdef DEBUG_ON local_start_gc(); #endif #endif // Uart init uart_dfu_start(); // Main loop while(1) { // Get the command from the external programmer checksum = uart_get_dfu_command(&req_header); // Execute the command uart_execute_dfu_command(&req_header, &checksum); } }
/* \brief This is an example that shows how to do the following: * - start the RC120M RC Osc * - switch the main clock to RC120M/4 * - set-up a generic clock with the RC120M RC Osc as a source * - output a generic clock to : * - GCLK_1_0(STK600_RCUC3L0 & AT32UC3L-EK) * - GCLK_0 (STK600_RCUC3D) */ int main(void) { // Start RC120M, switch main clock to RC120M/4. local_set_main_clock_to_rc120m(); /* Set-up a generic clock from a high frequency clock and output it to a gpio pin. */ local_start_gc(); /* Now toggle LED0 using a GPIO */ while(1) { gpio_tgl_gpio_pin(LED0_GPIO); software_delay(); } }
/* \brief This is an example that shows how to do the following: * - start a high frequency clock * - switch the main clock to that high frequency clock * - set-up a generic clock with a high frequency clock as a source * - output a generic clock to GCLK_0_1(EVK1100) / GCLK_2_1 / GCLK_2(EVK1101) / * GCLK_1_0(EVK1104) / GCLK_0_2(UC3C_EK) / GCLK_1_0(STK600_RCUC3L0 & AT32UC3L-EK) * */ int main(void) { /* Start a high frequency clock and switch the main clock to that high frequency clock */ local_start_highfreq_clock(); /* Set-up a generic clock from a high frequency clock and output it to a gpio pin. */ local_start_gc(); /* Now toggle LED0 using a GPIO */ while(1) { gpio_tgl_gpio_pin(LED0_GPIO); software_delay(); } }
/* \brief This is an example that shows how to do the following: * - configure and start the OSC32K 32kHz oscillator, * - set-up a generic clock at 32kHz with the OSC32K osc as a source, * - output the generic clock to a pin, * - toggle all four leds 10 times, * - then switch the device into the static sleep mode (while still maintaining * the OSC32 32kHz oscillator). * */ int main(void) { //! OSC32K config. scif_osc32_opt_t osc32Conf = { SCIF_OSC_MODE_2PIN_CRYSTAL_HICUR, // 2-pin Crystal and high current mode. Crystal is connected to XIN32/XOUT32. OSC32_STARTUP, // oscillator startup time true, // select the alternate xin32_2 and xout32_2 for the 32kHz crystal oscillator false, // disable the 1kHz output true // enable the 32kHz output }; volatile int i,j; // - configure and start the OSC32K 32kHz oscillator, if(PASS != scif_start_osc32(&osc32Conf, true)) { // Error while(1) { gpio_tgl_gpio_pin(LED3_GPIO); for(i=1000; i; i--); } } // - set-up a generic clock at 32kHz with the OSC32K osc as a source, // - output the generic clock to a pin. local_start_gc(); // - toggle all four leds 10 times, for(i=25;i;i--) { gpio_tgl_gpio_pin(LED0_GPIO); gpio_tgl_gpio_pin(LED1_GPIO); gpio_tgl_gpio_pin(LED2_GPIO); gpio_tgl_gpio_pin(LED3_GPIO); for(j=1000;j;j--); } // - then switch the device into the static sleep mode (while still maintaining // the OSC32 32kHz oscillator). // If there is a chance that any PB write operations are incomplete, the CPU // should perform a read operation from any register on the PB bus before // executing the sleep instruction. AVR32_INTC.ipr[0]; // Dummy read SLEEP(AVR32_PM_SMODE_STATIC); // Note: in static sleep mode, the GCLK output is not maintained but the OSC32K // oscillator is still active (check the XIN32_2 pin (500mv peek-to-peek amplitude)). while(1); }
/* \brief This is an example that shows how to do the following: * - generate a high frequency clock (~22MHz) with a DFLL in closed-loop mode * - set-up a generic clock with a DFLL as a source * - output the generic clock to GCLK_1_0 * - go into the frozen sleep mode (while still maintaining GCLK output) * */ int main(void) { // Generate a high frequency clock (~22MHz) with a DFLL in closed-loop mode local_start_dfll_clock(); // Set-up a generic clock from a high frequency clock and output it to a gpio pin. local_start_gc(); //*** Sleep mode // If there is a chance that any PB write operations are incomplete, the CPU // should perform a read operation from any register on the PB bus before // executing the sleep instruction. AVR32_INTC.ipr[0]; // Dummy read // - Go into a sleep mode (while still maintaining GCLK output) SLEEP(AVR32_PM_SMODE_FROZEN); while(1); }