00001
00072
00073 #include <stdlib.h>
00074 #include <string.h>
00075 #include <stdarg.h>
00076 #include <stdio.h>
00077 #include "pm.h"
00078 #include "flashc.h"
00079 #include "sdramc.h"
00080
00081
00082 #include "FreeRTOS.h"
00083 #include "task.h"
00084
00085
00086 #include "partest.h"
00087 #include "serial.h"
00088 #include "ethernet.h"
00089 #include "netif/etharp.h"
00090 #include "flash.h"
00091 #include "gpio.h"
00092 #include "print_funcs.h"
00093
00094
00095 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
00096 #define mainETH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
00097
00098
00099 #define mainCOM_BAUD_RATE ( ( unsigned portLONG ) 57600 )
00100 #define mainCOM_BUFFER_LEN ( ( unsigned portLONG ) 70 )
00101
00102
00103
00104 #define mainRESET_COUNT_ADDRESS ( ( void * ) 0xC0000000 )
00105
00114 void print_lwip_dbg(const char *format, ...) {
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 }
00125
00133 void local_start_pll(void) {
00134
00135 volatile avr32_pm_t *pm = &AVR32_PM;
00136
00137
00138 pm_switch_to_osc0(pm, FOSC0, OSC0_STARTUP);
00139
00140 pm_pll_setup(pm,
00141 0,
00142 10,
00143 1,
00144 0,
00145 16);
00146
00147
00148
00149 pm_pll_set_option(pm,
00150 0,
00151 1,
00152 1,
00153 0);
00154
00155 pm_pll_enable(pm, 0);
00156
00157 pm_wait_for_pll0_locked(pm) ;
00158
00159 pm_gc_setup(pm, 0, 1,
00160 0,
00161 0, 0);
00162
00163
00164 pm_gc_enable(pm, 0);
00165
00166
00167 pm_cksel(pm, 1, 1, 1, 0, 0, 0);
00168
00169
00170 flashc_set_wait_state(1);
00171
00172 gpio_enable_module_pin(AVR32_PM_GCLK_0_0_PIN, AVR32_PM_GCLK_0_0_FUNCTION);
00173
00174
00175 pm_switch_to_clock(pm, AVR32_PM_MCCTRL_MCSEL_PLL0);
00176
00177
00178 sdramc_init(66000000);
00179
00180 }
00181
00192 int main(void) {
00193
00194
00195 init_dbg_rs232(66000000/4);
00196 print_dbg("Init Done\n");
00197
00198
00199
00200 vParTestInitialise();
00201
00202
00203
00204 vStartLEDFlashTasks( mainLED_TASK_PRIORITY);
00205 print_dbg("vStartLEDFlashTasks :Started\n");
00206
00207
00208 vStartEthernetTaskLauncher(configMAX_PRIORITIES);
00209 print_dbg("vStartEthernetTaskLauncher :Started\n");
00210
00211
00212 vTaskStartScheduler();
00213
00214
00215
00216 return 0;
00217 }
00218