/*! \brief Main function. Execution starts here.
 *
 * \retval 42 Fatal error.
 */
int main(void)
{
#ifndef FREERTOS_USED
  Enable_global_exception();
  INTC_init_interrupts();
#endif
  pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
  init_dbg_rs232(FOSC0);
  pcl_configure_usb_clock();
  usb_task_init();
#if USB_DEVICE_FEATURE == true
  device_template_task_init();
#endif
#if USB_HOST_FEATURE == true
  host_template_task_init();
#endif

#ifdef FREERTOS_USED
  vTaskStartScheduler();
  portDBG_TRACE("FreeRTOS returned.");
  return 42;
#else
  while (true)
  {
    usb_task();
  #if USB_DEVICE_FEATURE == true
    device_template_task();
  #endif
  #if USB_HOST_FEATURE == true
    host_template_task();
  #endif
  }
#endif  // FREERTOS_USED
}
Ejemplo n.º 2
0
/*! \brief Main function. Execution starts here.
 *
 * \retval 42 Fatal error.
 */
int main(void)
{
  // Configure system clocks.
  if (pcl_configure_clocks(&pcl_freq_param) != PASS)
    return 42;

  // Initialize USB clock (on PLL1)
  pcl_configure_usb_clock();

  // Initialize usart comm
  init_dbg_rs232(pcl_freq_param.pba_f);

#if BOARD == EVK1105
  Disable_global_interrupt();
  /* Register interrupt handler to the interrupt controller
   * up, down buttons on PB22, PB23 -> GPIO_IRQ_6
   */
  INTC_register_interrupt(&touch_button_isr, AVR32_GPIO_IRQ_6, 0);
  /* all gpios between PB23 - PB31) */
  INTC_register_interrupt(&touch_button_isr, AVR32_GPIO_IRQ_7, 0);
  Enable_global_interrupt();
#endif

  // Initialize USB task
  usb_task_init();

#if USB_DEVICE_FEATURE == true
  // Initialize device mouse USB task
  device_mouse_hid_task_init();
#endif
#if USB_HOST_FEATURE == true
  //host_keyboard_hid_task_init();

  // Initialize host mouse USB task
  host_mouse_hid_task_init();
#endif

#ifdef FREERTOS_USED
  // Start OS scheduler
  vTaskStartScheduler();
  portDBG_TRACE("FreeRTOS returned.");
  return 42;
#else
  // No OS here. Need to call each task in round-robin mode.
  while (true)
  {
    usb_task();
  #if USB_DEVICE_FEATURE == true
    device_mouse_hid_task();
  #endif
  #if USB_HOST_FEATURE == true
    //host_keyboard_hid_task();
    host_mouse_hid_task();
  #endif
  }
#endif  // FREERTOS_USED
}
Ejemplo n.º 3
0
int main( void )
{
	/* Start the crystal oscillator 0 and switch the main clock to it. */
	pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);

	portDBG_TRACE("Starting the FreeRTOS AVR32 UC3 Demo...");

	/* Setup the LED's for output. */
	vParTestInitialise();

	/* Start the standard demo tasks.  See the WEB documentation for more
	information. */
	vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
	vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
	vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
	vStartIntegerMathTasks( tskIDLE_PRIORITY );
	vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
	vStartDynamicPriorityTasks();
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
	vStartMathTasks( tskIDLE_PRIORITY );

	/* Start the demo tasks defined within this file, specifically the check
	task as described at the top of this file. */
	xTaskCreate(
		vErrorChecks
		,  (const signed portCHAR *)"ErrCheck"
		,  configMINIMAL_STACK_SIZE
		,  NULL
		,  mainCHECK_TASK_PRIORITY
		,  NULL );

	/* Start the scheduler. */
	vTaskStartScheduler();

	/* Will only get here if there was insufficient memory to create the idle
	task. */

	return 0;
}
Ejemplo n.º 4
0
/*! \brief Main function. Execution starts here.
 *
 * \retval 42 Fatal error.
 */
int main(void)
{
    init_hmatrix();

    // Configure standard I/O streams as unbuffered.
#if (defined __GNUC__) && (defined __AVR32__)
    setbuf(stdin, NULL);
#endif
    setbuf(stdout, NULL);

#if (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_EXT_CLOCK_SYNTHESIZER)
    // Initialize the TWI using the internal RCOSC
    init_twi_CS2200(AVR32_PM_RCOSC_FREQUENCY);

    // Initialize the CS2200 and produce a default 11.2896 MHz frequency
    cs2200_setup(11289600, FOSC0);
#endif

    // Initializes the MCU system clocks
    init_sys_clocks();

    // Initialize the TWI
    init_twi(FPBA_HZ);

    audio_mixer_enable_dacs(DEFAULT_DACS);
    audio_mixer_dacs_start(DEFAULT_DAC_SAMPLE_RATE_HZ,
                           DEFAULT_DAC_NUM_CHANNELS,
                           DEFAULT_DAC_BITS_PER_SAMPLE,
                           DEFAULT_DAC_SWAP_CHANNELS);

    // Initialize the display
    et024006_Init(  FCPU_HZ, FHSB_HZ);

    // Set Backlight
    gpio_set_gpio_pin(ET024006DHU_BL_PIN);

    // Clear the display
    et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE );

    // Display a logo.
    et024006_PutPixmap(avr32_logo, AVR32_LOGO_WIDTH, 0, 0
                       ,(ET024006_WIDTH - AVR32_LOGO_WIDTH)/2
                       ,(ET024006_HEIGHT - AVR32_LOGO_HEIGHT)/2, AVR32_LOGO_WIDTH, AVR32_LOGO_HEIGHT);

    et024006_PrintString(AUDIO_DEMO_STRING, (const unsigned char *)&FONT8x16, 30, 5, BLACK, -1);
    et024006_PrintString("Please plug the USB.", (const unsigned char *)&FONT8x8, 30, 30, BLACK, -1);

    // Initialize USB task
    usb_task_init();

    // Initialize Controller
    controller_init(FCPU_HZ, FHSB_HZ, FPBB_HZ, FPBA_HZ);

#if USB_DEVICE_FEATURE == true
    // Initialize device audio USB task
    device_audio_task_init();

    // Initialize the HID USB task
    device_hid_task_init();
#endif
#if USB_HOST_FEATURE == true
    // Initialize host audio USB task
    host_audio_task_init();
#endif

#ifdef FREERTOS_USED
    // Start OS scheduler
    vTaskStartScheduler();
    portDBG_TRACE("FreeRTOS returned.");
    return 42;
#else
    // No OS here. Need to call each task in round-robin mode.
    while (true)
    {
        usb_task();
#if USB_DEVICE_FEATURE == true
        device_audio_task();
        device_hid_task();
#endif
#if USB_HOST_FEATURE == true
        host_audio_task();
#endif
    }
#endif  // FREERTOS_USED
}
Ejemplo n.º 5
0
/*! \brief Main function. Execution starts here.
 *
 * \retval 42 Fatal error.
 */
int main(void)
{
  // Configure system clocks.
  if (pcl_configure_clocks(&pcl_freq_param) != PASS)
    return 42;

  // Initialize usart comm
  init_dbg_rs232(pcl_freq_param.pba_f);

#ifndef FREERTOS_USED
# if (defined __GNUC__)
  // Give the used CPU clock frequency to Newlib, so it can work properly.
  set_cpu_hz(pcl_freq_param.pba_f);
# endif
#endif

  // Initialize USB clock.
  pcl_configure_usb_clock();

  // Initialize USB task
  usb_task_init();

  // Display a welcome banner on USART
  printf("                                                       ......       ......     \r\n");
  printf("       IIIIII  IIIII        IIII   IIIIIIIIIII      IIIIIIIIIII. .IIIIIIIIII.  \r\n");
  printf("      IIIIIII   IIIII      IIIII  IIIIIIIIIIIII     IIIIIIIIIIII..IIIIIIIIIII. \r\n");
  printf("     IIIIIIIII  IIIII     IIIII   IIIII   IIIII     I.      IIIII.:.     IIIII \r\n");
  printf("     IIII IIIII  IIIII    IIII   IIIII    IIIII            .IIII.        IIIII \r\n");
  printf("    IIIII  IIII   IIII   IIIII  IIIIIIIIIIIIII         IIIIIIII          IIII. \r\n");
  printf("    IIII   IIIII  IIIII IIIII   IIIIIIIIIIIII          IIIIIIII.       .IIII:  \r\n");
  printf("   IIIII    IIIII  IIIIIIIII   IIIIIIIIIII                 .IIIII     IIIII.   \r\n");
  printf("  IIIIIIIIIIIIIII   IIIIIIII   IIIII IIIII                  .IIII   .IIII:     \r\n");
  printf("  IIIIIIIIIIIIIIII  IIIIIII   IIIII   IIII         II:.    .IIIII .IIIII.      \r\n");
  printf(" IIIII        IIIII  IIIIII  IIIII    IIIII        IIIIIIIIIIIII.IIIIIIIIIIIIII\r\n");
  printf(" IIIII        IIIII  IIIII   IIIII    IIIII        :IIIIIIIIII.  IIIIIIIIIIIIII\r\n");
  printf("                      III                                                      \r\n");
  printf("                       II                                                      \r\n");

#if USB_DEVICE_FEATURE == true
  // Initialize device CDC USB task
  device_cdc_task_init();
#endif
#if USB_HOST_FEATURE == true
  // Initialize host CDC USB task
  host_cdc_task_init();
#endif

#ifdef FREERTOS_USED
  // Start OS scheduler
  vTaskStartScheduler();
  portDBG_TRACE("FreeRTOS returned.");
  return 42;
#else
  // No OS here. Need to call each task in round-robin mode.
  while (true)
  {
    usb_task();
  #if USB_DEVICE_FEATURE == true
    device_cdc_task();
  #endif
  #if USB_HOST_FEATURE == true
    host_cdc_task();
  #endif
  }
#endif  // FREERTOS_USED
}
Ejemplo n.º 6
0
int main( void )
{
#if UC3L
	/*! \name Clock frequencies
	 */
	//! @{
	#define EXAMPLE_TARGET_DFLL_FREQ_HZ     96000000  // DFLL target frequency, in Hz
	#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ   12000000  // MCU clock target frequency, in Hz
	#define EXAMPLE_TARGET_PBACLK_FREQ_HZ   12000000  // PBA clock target frequency, in Hz
	//! @}

	/*! \name Parameters to pcl_configure_clocks().
	 */
	//! @{
	static scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false};
	static pcl_freq_param_t pcl_dfll_freq_param = {
		.main_clk_src = PCL_MC_DFLL0,
		.cpu_f        = EXAMPLE_TARGET_MCUCLK_FREQ_HZ,
		.pba_f        = EXAMPLE_TARGET_PBACLK_FREQ_HZ,
		.pbb_f        = EXAMPLE_TARGET_PBACLK_FREQ_HZ,
		.dfll_f       = EXAMPLE_TARGET_DFLL_FREQ_HZ,
		.pextra_params = &gc_dfllif_ref_opt
	};
	//! @}

	// Note: on the AT32UC3L-EK and UC3-L0-Xplained board, there are no crystal/external
	// clock connected to the OSC0 pinout XIN0/XOUT0. We shall then program the DFLL and
	// switch the main clock source to the DFLL.
	pcl_configure_clocks(&pcl_dfll_freq_param);
	// Note: since it is dynamically computing the appropriate field values of the
	// configuration registers from the parameters structure, this function is not
	// optimal in terms of code size. For a code size optimal solution, it is better
	// to create a new function from pcl_configure_clocks_dfll0() and modify it
	// to use preprocessor computation from pre-defined target frequencies.

#else
	// Configure Osc0 in crystal mode (i.e. use of an external crystal source, with
	// frequency FOSC0) with an appropriate startup time then switch the main clock
	// source to Osc0.
	pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
#endif

	portDBG_TRACE("Starting the FreeRTOS AVR32 UC3 Demo...");

	/* Setup the LED's for output. */
	vParTestInitialise();

	/* Start the standard demo tasks.  See the WEB documentation for more
	information.
	Note that the UC3L and UC3B parts do not have enough internal RAM to launch all the tasks of this example.
	That's why some of them are commented out using respectively #if (BOARD != UC3L_EK) or #if (BOARD != EVK1101)
	compiler directives. */
	vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
	vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
	vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
	#if (BOARD != UC3L_EK)
		vStartIntegerMathTasks( tskIDLE_PRIORITY );
		vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
		vStartDynamicPriorityTasks();
	#endif

	#if (BOARD != EVK1101) && (BOARD != UC3L_EK)
		vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
		vStartMathTasks( tskIDLE_PRIORITY );
	#endif

	/* Start the demo tasks defined within this file, specifically the check
	task as described at the top of this file. */
	xTaskCreate(
		vErrorChecks
		,  (const signed portCHAR *)"ErrCheck"
		,  configMINIMAL_STACK_SIZE
		,  NULL
		,  mainCHECK_TASK_PRIORITY
		,  NULL );

	/* Start the scheduler. */
	vTaskStartScheduler();

	/* Will only get here if there was insufficient memory to create the idle
	task. */

	return 0;
}