OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [lwIP_AVR32_UC3/] [main.c] - Blame information for rev 636

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 jeremybenn
/*This file has been prepared for Doxygen automatic documentation generation.*/
2
/*! \file *********************************************************************
3
 *
4
 * \brief FreeRTOS and lwIP example for AVR32 UC3.
5
 *
6
 * - Compiler:           GNU GCC for AVR32
7
 * - Supported devices:  All AVR32 devices can be used.
8
 * - AppNote:
9
 *
10
 * \author               Atmel Corporation: http://www.atmel.com \n
11
 *                       Support and FAQ: http://support.atmel.no/
12
 *
13
 *****************************************************************************/
14
 
15
/* Copyright (c) 2007, Atmel Corporation All rights reserved.
16
 *
17
 * Redistribution and use in source and binary forms, with or without
18
 * modification, are permitted provided that the following conditions are met:
19
 *
20
 * 1. Redistributions of source code must retain the above copyright notice,
21
 * this list of conditions and the following disclaimer.
22
 *
23
 * 2. Redistributions in binary form must reproduce the above copyright notice,
24
 * this list of conditions and the following disclaimer in the documentation
25
 * and/or other materials provided with the distribution.
26
 *
27
 * 3. The name of ATMEL may not be used to endorse or promote products derived
28
 * from this software without specific prior written permission.
29
 *
30
 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
31
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
33
 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
34
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
39
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
 */
41
 
42
 
43
/* Environment include files. */
44
#include <stdlib.h>
45
#include <string.h>
46
#include "pm.h"
47
#include "flashc.h"
48
 
49
/* Scheduler include files. */
50
#include "FreeRTOS.h"
51
#include "task.h"
52
 
53
/* Demo file headers. */
54
#include "partest.h"
55
#include "serial.h"
56
#include "ethernet.h"
57
#include "netif/etharp.h"
58
#include "flash.h"
59
 
60
/* Priority definitions for most of the tasks in the demo application. */
61
#define mainLED_TASK_PRIORITY     ( tskIDLE_PRIORITY + 1 )
62
#define mainETH_TASK_PRIORITY     ( tskIDLE_PRIORITY + 1 )
63
 
64
/* Baud rate used by the serial port tasks. */
65
#define mainCOM_BAUD_RATE      ( ( unsigned portLONG ) 57600 )
66
#define mainCOM_BUFFER_LEN     ( ( unsigned portLONG ) 70 )
67
 
68
/* An address in the internal Flash used to count resets.  This is used to check that
69
the demo application is not unexpectedly resetting. */
70
#define mainRESET_COUNT_ADDRESS     ( ( void * ) 0xC0000000 )
71
 
72
 
73
//!
74
//! \fn     main
75
//! \brief  start the software here
76
//!         1) Initialize the microcontroller and the shared hardware resources
77
//!         of the board.
78
//!         2) Launch the IP modules.
79
//!         3) Start FreeRTOS.
80
//! \return 42, which should never occur.
81
//! \note
82
//!
83
int main( void )
84
{
85
volatile avr32_pm_t* pm = &AVR32_PM;
86
 
87
        /* 1) Initialize the microcontroller and the shared hardware resources of the board. */
88
 
89
        /* Switch to external oscillator 0 */
90
        pm_switch_to_osc0( pm, FOSC0, OSC0_STARTUP );
91
 
92
        /* Setup PLL0 on OSC0, mul+1=16 ,divisor by 1, lockcount=16, ie. 12Mhzx16/1 = 192MHz output.
93
           Extra div by 2 => 96MHz */
94
        pm_pll_setup(pm,        /* volatile avr32_pm_t* pm */
95
                                0,               /* unsigned int pll */
96
                                15,             /* unsigned int mul */
97
                                1,              /* unsigned int div, Sel Osc0/PLL0 or Osc1/Pll1 */
98
                                0,               /* unsigned int osc */
99
                                16);            /* unsigned int lockcount */
100
 
101
        pm_pll_set_option( pm, 0,   // pll0
102
                               0,   // Choose the range 160-240MHz.
103
                               1,   // div2
104
 
105
 
106
        /* Enable PLL0 */
107
        pm_pll_enable(pm,0);
108
 
109
        /* Wait for PLL0 locked */
110
        pm_wait_for_pll0_locked(pm) ;
111
 
112
        /* Setup generic clock number 2 on PLL, with OSC0/PLL0, no divisor */
113
        pm_gc_setup(pm,
114
                                0,
115
                                1, /* Use Osc (=0) or PLL (=1) */
116
                                0, /* Sel Osc0/PLL0 or Osc1/Pll1 */
117
                                0,
118
                                1);
119
 
120
        /* Enable Generic clock 0*/
121
        pm_gc_enable(pm, 0);
122
 
123
        /* switch to clock */
124
        pm_cksel( pm, 1, 1, 1, 0, 1, 0 );
125
        flashc_set_wait_state( 1 );
126
        pm_switch_to_clock( pm, AVR32_PM_MCCTRL_MCSEL_PLL0 );
127
 
128
        /* Setup the LED's for output. */
129
        vParTestInitialise();
130
 
131
        /* Start the flash tasks just to provide visual feedback that the demo is
132
        executing. */
133
        vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
134
 
135
        /* 2) Start ethernet task. */
136
        vStartEthernetTask( mainETH_TASK_PRIORITY );
137
 
138
        /* 3) Start FreeRTOS. */
139
        vTaskStartScheduler();
140
 
141
        /* Will only reach here if there was insufficient memory to create the idle task. */
142
 
143
        return 0;
144
}
145
/*-----------------------------------------------------------*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.