main.c File Reference


Detailed Description

Basic SSL (FreeRTOS, lwIP, XYSSL) example for AVR32 UC3.

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

Definition in file main.c.

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "pm.h"
#include "flashc.h"
#include "sdramc.h"
#include "FreeRTOS.h"
#include "task.h"
#include "partest.h"
#include "serial.h"
#include "ethernet.h"
#include "netif/etharp.h"
#include "flash.h"
#include "gpio.h"
#include "print_funcs.h"

Go to the source code of this file.

Defines

#define mainCOM_BAUD_RATE   ( ( unsigned portLONG ) 57600 )
#define mainCOM_BUFFER_LEN   ( ( unsigned portLONG ) 70 )
#define mainETH_TASK_PRIORITY   ( tskIDLE_PRIORITY + 1 )
#define mainLED_TASK_PRIORITY   ( tskIDLE_PRIORITY + 1 )
#define mainRESET_COUNT_ADDRESS   ( ( void * ) 0xC0000000 )

Functions

void local_start_pll (void)
int main (void)
 local_start_pll Initialize the microcontroller to it opertational frequency
void print_lwip_dbg (const char *format,...)


Define Documentation

#define mainCOM_BAUD_RATE   ( ( unsigned portLONG ) 57600 )

Definition at line 99 of file main.c.

#define mainCOM_BUFFER_LEN   ( ( unsigned portLONG ) 70 )

Definition at line 100 of file main.c.

#define mainETH_TASK_PRIORITY   ( tskIDLE_PRIORITY + 1 )

Definition at line 96 of file main.c.

#define mainLED_TASK_PRIORITY   ( tskIDLE_PRIORITY + 1 )

Definition at line 95 of file main.c.

Referenced by main().

#define mainRESET_COUNT_ADDRESS   ( ( void * ) 0xC0000000 )

Definition at line 104 of file main.c.


Function Documentation

void local_start_pll ( void   ) 

Definition at line 133 of file main.c.

Referenced by __low_level_init(), and _init_startup().

00133                            {
00134 
00135     volatile avr32_pm_t *pm = &AVR32_PM;
00136 
00137     // Switch the main clock to OSC0
00138     pm_switch_to_osc0(pm, FOSC0, OSC0_STARTUP);
00139     // Setup PLL0 on OSC0, mul=15 ,no divisor, lockcount=16, ie. 12Mhz x 11 = 132MHz output
00140     pm_pll_setup(pm,    // volatile avr32_pm_t *pm
00141             0,  // unsigned int pll
00142             10, // unsigned int mul
00143             1,  // unsigned int div, Sel Osc0/PLL0 or Osc1/Pll1
00144             0,  // unsigned int osc
00145             16);// unsigned int lockcount
00146 
00147 
00148     // set PLL options to run @ 96 Mhz
00149     pm_pll_set_option(pm, // volatile avr32_pm_t *pm
00150             0, // unsigned int pll
00151             1, // unsigned int  pll_freq
00152             1, // unsigned int  pll_div2
00153             0); // unsigned int  pll_wbwdisable
00154     // Enable PLL0
00155     pm_pll_enable(pm, 0);
00156     // Wait for PLL0 locked
00157     pm_wait_for_pll0_locked(pm) ;
00158     // Setup generic clock number 0 on PLL, with OSC0/PLL0, no divisor
00159     pm_gc_setup(pm, 0, 1, // Use Osc (=0) or PLL (=1)
00160             0,    // Sel Osc0/PLL0 or Osc1/Pll1
00161             0, 0);
00162 
00163     // Enable Generic clock 0*/
00164     pm_gc_enable(pm, 0);
00165 
00166     // set divider to 8 for PBA bus and 2 for PBB 0 for CPU
00167     pm_cksel(pm, 1, 1, 1, 0, 0, 0);
00168 
00169     // one wait state at 66 Mhz
00170     flashc_set_wait_state(1);
00171     /* Output the clock to a gpio(PA7) */
00172     gpio_enable_module_pin(AVR32_PM_GCLK_0_0_PIN, AVR32_PM_GCLK_0_0_FUNCTION);
00173 
00174     // switch to clock
00175     pm_switch_to_clock(pm, AVR32_PM_MCCTRL_MCSEL_PLL0);
00176     
00177     /* Initialize the SDRAM Controller and the external SDRAM chip. */
00178     sdramc_init(66000000);
00179     
00180 }

main ( void   ) 

local_start_pll Initialize the microcontroller to it opertational frequency

start the software here 1) Initialize the microcontroller and the shared hardware resources of the board.

Returns:
Note:
2) Launch the IP modules. 3) Start FreeRTOS.
Returns:
42, which should never occur.
Note:

Definition at line 192 of file main.c.

References configMAX_PRIORITIES, mainLED_TASK_PRIORITY, vParTestInitialise(), and vStartEthernetTaskLauncher().

00192                {
00193 
00194     /* Init rs232 with pba = FOSC0 */
00195     init_dbg_rs232(66000000/4);
00196     print_dbg("Init Done\n");
00197     
00198 
00199     /* Setup the LED's for output. */
00200     vParTestInitialise();
00201 
00202     /* Start the flash tasks just to provide visual feedback that the demo is
00203      executing. */
00204     vStartLEDFlashTasks( mainLED_TASK_PRIORITY);
00205     print_dbg("vStartLEDFlashTasks :Started\n");
00206 
00207     /* 2) Start the ethernet tasks launcher. */
00208     vStartEthernetTaskLauncher(configMAX_PRIORITIES);
00209     print_dbg("vStartEthernetTaskLauncher :Started\n");
00210 
00211     /* 3) Start FreeRTOS. */
00212     vTaskStartScheduler();
00213 
00214     /* Will only reach here if there was insufficient memory to create the idle task. */
00215 
00216     return 0;
00217 }

void print_lwip_dbg ( const char *  format,
  ... 
)

Definition at line 114 of file main.c.

00114                                              {
00115     va_list argp;
00116     static char str[80];
00117 
00118     va_start(argp, format);
00119     sprintf(str, format, argp);
00120     va_end(argp);
00121 
00122     print_dbg(str);
00123     print_dbg("\n");
00124 }


Generated on Mon Nov 2 11:38:47 2009 for AVR32 - PolarSSL - SSL Example by  doxygen 1.5.5