mass_storage_example.c File Reference


Detailed Description

Main file of the USB mass-storage example.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file mass_storage_example.c.

#include <stdio.h>
#include "compiler.h"
#include "preprocessor.h"
#include "mass_storage_example.h"
#include "board.h"
#include "print_funcs.h"
#include "intc.h"
#include "power_clocks_lib.h"
#include "gpio.h"
#include "ctrl_access.h"
#include "FreeRTOS.h"
#include "task.h"
#include "conf_usb.h"
#include "usb_task.h"
#include "device_mass_storage_task.h"
#include "host_mass_storage_task.h"
#include "ushell_task.h"

Go to the source code of this file.

Functions

Hmatrix bus configuration
void init_hmatrix (void)
int main (void)
 Main function. Execution starts here.

Variables

System Clock Frequencies
static pcl_freq_param_t pcl_freq_param


Function Documentation

void init_hmatrix ( void   ) 

Definition at line 273 of file mass_storage_example.c.

Referenced by main().

00274 {
00275   union
00276   {
00277     unsigned long                 scfg;
00278     avr32_hmatrix_scfg_t          SCFG;
00279   } u_avr32_hmatrix_scfg;
00280 
00281   // For the internal-flash HMATRIX slave, use last master as default.
00282   u_avr32_hmatrix_scfg.scfg = AVR32_HMATRIX.scfg[AVR32_HMATRIX_SLAVE_FLASH];
00283   u_avr32_hmatrix_scfg.SCFG.defmstr_type = AVR32_HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT;
00284   AVR32_HMATRIX.scfg[AVR32_HMATRIX_SLAVE_FLASH] = u_avr32_hmatrix_scfg.scfg;
00285 }

int main ( void   ) 

Main function. Execution starts here.

Return values:
42 Fatal error.

Definition at line 506 of file mass_storage_example.c.

References device_mass_storage_task(), device_mass_storage_task_init(), host_mass_storage_task(), host_mass_storage_task_init(), init_hmatrix(), pcl_freq_param, ushell_task(), and ushell_task_init().

00507 {
00508   // Configure system clocks.
00509   if (pcl_configure_clocks(&pcl_freq_param) != PASS)
00510     return 42;
00511 
00512   // Initialize USART link.
00513   init_dbg_rs232(pcl_freq_param.pba_f);
00514 
00515 #if (defined AT45DBX_MEM) && (AT45DBX_MEM == ENABLE)
00516   at45dbx_resources_init();
00517 #endif
00518 #if SD_MMC_SPI_MEM == ENABLE
00519   sd_mmc_spi_resources_init();
00520 #endif
00521 #if ((defined SD_MMC_MCI_0_MEM) && (SD_MMC_MCI_0_MEM == ENABLE)) || ((defined SD_MMC_MCI_1_MEM) && (SD_MMC_MCI_1_MEM == ENABLE))
00522   sd_mmc_mci_resources_init();
00523 #endif
00524 #ifdef FREERTOS_USED
00525   if (!ctrl_access_init())
00526   {
00527     portDBG_TRACE("The module CTRL_ACCESS could not be initialized.");
00528     return 42;
00529   }
00530 #endif  // FREERTOS_USED
00531 
00532   // Init Hmatrix bus
00533   init_hmatrix();
00534   
00535   // Initialize USB clock.
00536   pcl_configure_usb_clock();
00537 
00538   // Initialize USB tasks.
00539   usb_task_init();
00540 #if USB_DEVICE_FEATURE == ENABLED
00541   device_mass_storage_task_init();
00542 #endif
00543 #if USB_HOST_FEATURE == ENABLED
00544   host_mass_storage_task_init();
00545 #endif
00546   ushell_task_init(pcl_freq_param.pba_f);
00547 
00548 #ifdef FREERTOS_USED
00549   vTaskStartScheduler();
00550   portDBG_TRACE("FreeRTOS returned.");
00551   return 42;
00552 #else
00553   while (TRUE)
00554   {
00555     usb_task();
00556   #if USB_DEVICE_FEATURE == ENABLED
00557     device_mass_storage_task();
00558   #endif
00559   #if USB_HOST_FEATURE == ENABLED
00560     host_mass_storage_task();
00561   #endif
00562     ushell_task();
00563   }
00564 #endif  // FREERTOS_USED
00565 }


Variable Documentation

pcl_freq_param_t pcl_freq_param [static]

Initial value:

{
  .cpu_f        = FCPU_HZ,
  .pba_f        = FPBA_HZ,
  .osc0_f       = FOSC0,
  .osc0_startup = OSC0_STARTUP
}

Definition at line 262 of file mass_storage_example.c.

Referenced by main().


Generated on Fri Feb 19 02:33:37 2010 for AVR32 - USB Mass-Storage on FreeRTOS Example by  doxygen 1.5.5