00001
00193
00194
00195 #ifndef FREERTOS_USED
00196 #if __GNUC__
00197 #include "nlao_cpu.h"
00198 #include "nlao_usart.h"
00199 #endif
00200 #else
00201 #include <stdio.h>
00202 #endif
00203 #include "compiler.h"
00204 #include "board.h"
00205 #include "print_funcs.h"
00206 #include "intc.h"
00207 #include "power_clocks_lib.h"
00208 #include "cdc_example.h"
00209 #ifdef FREERTOS_USED
00210 #include "FreeRTOS.h"
00211 #include "task.h"
00212 #endif
00213 #include "conf_usb.h"
00214 #include "usb_task.h"
00215 #if USB_DEVICE_FEATURE == ENABLED
00216 #include "device_cdc_task.h"
00217 #endif
00218 #if USB_HOST_FEATURE == ENABLED
00219 #include "host_cdc_task.h"
00220 #endif
00221 #include <stdio.h>
00222
00223
00224
00225
00226
00227
00228
00231
00232 pcl_freq_param_t pcl_freq_param =
00233 {
00234 .cpu_f = APPLI_CPU_SPEED,
00235 .pba_f = APPLI_PBA_SPEED,
00236 .osc0_f = FOSC0,
00237 .osc0_startup = OSC0_STARTUP
00238 };
00240
00241
00242 #ifndef FREERTOS_USED
00243
00244 #if __GNUC__
00245
00257 int _init_startup(void)
00258 {
00259
00260 extern void _evba;
00261
00262
00263 Set_system_register(AVR32_EVBA, (int)&_evba);
00264
00265
00266 Enable_global_exception();
00267
00268
00269 INTC_init_interrupts();
00270
00271
00272 set_usart_base( ( void * ) DBG_USART );
00273
00274
00275 return 1;
00276 }
00277
00278 #elif __ICCAVR32__
00279
00283 int __low_level_init(void)
00284 {
00285
00286 Enable_global_exception();
00287
00288
00289 INTC_init_interrupts();
00290
00291
00292 extern volatile avr32_usart_t *volatile stdio_usart_base;
00293 stdio_usart_base = DBG_USART;
00294
00295
00296 return 1;
00297 }
00298
00299 #endif // Compiler
00300
00301 #endif // FREERTOS_USED
00302
00303
00308 int main(void)
00309 {
00310
00311 if (pcl_configure_clocks(&pcl_freq_param) != PASS)
00312 return 42;
00313
00314
00315 init_dbg_rs232(pcl_freq_param.pba_f);
00316
00317 #ifndef FREERTOS_USED
00318 # if __GNUC__
00319
00320 set_cpu_hz(pcl_freq_param.pba_f);
00321 # endif
00322 #endif
00323
00324
00325 pcl_configure_usb_clock();
00326
00327
00328 usb_task_init();
00329
00330
00331 printf(" ...... ...... \r\n");
00332 printf(" IIIIII IIIII IIII IIIIIIIIIII IIIIIIIIIII. .IIIIIIIIII. \r\n");
00333 printf(" IIIIIII IIIII IIIII IIIIIIIIIIIII IIIIIIIIIIII..IIIIIIIIIII. \r\n");
00334 printf(" IIIIIIIII IIIII IIIII IIIII IIIII I. IIIII.:. IIIII \r\n");
00335 printf(" IIII IIIII IIIII IIII IIIII IIIII .IIII. IIIII \r\n");
00336 printf(" IIIII IIII IIII IIIII IIIIIIIIIIIIII IIIIIIII IIII. \r\n");
00337 printf(" IIII IIIII IIIII IIIII IIIIIIIIIIIII IIIIIIII. .IIII: \r\n");
00338 printf(" IIIII IIIII IIIIIIIII IIIIIIIIIII .IIIII IIIII. \r\n");
00339 printf(" IIIIIIIIIIIIIII IIIIIIII IIIII IIIII .IIII .IIII: \r\n");
00340 printf(" IIIIIIIIIIIIIIII IIIIIII IIIII IIII II:. .IIIII .IIIII. \r\n");
00341 printf(" IIIII IIIII IIIIII IIIII IIIII IIIIIIIIIIIII.IIIIIIIIIIIIII\r\n");
00342 printf(" IIIII IIIII IIIII IIIII IIIII :IIIIIIIIII. IIIIIIIIIIIIII\r\n");
00343 printf(" III \r\n");
00344 printf(" II \r\n");
00345
00346 #if USB_DEVICE_FEATURE == ENABLED
00347
00348 device_cdc_task_init();
00349 #endif
00350 #if USB_HOST_FEATURE == ENABLED
00351
00352 host_cdc_task_init();
00353 #endif
00354
00355 #ifdef FREERTOS_USED
00356
00357 vTaskStartScheduler();
00358 portDBG_TRACE("FreeRTOS returned.");
00359 return 42;
00360 #else
00361
00362 while (TRUE)
00363 {
00364 usb_task();
00365 #if USB_DEVICE_FEATURE == ENABLED
00366 device_cdc_task();
00367 #endif
00368 #if USB_HOST_FEATURE == ENABLED
00369 host_cdc_task();
00370 #endif
00371 }
00372 #endif // FREERTOS_USED
00373 }