]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/uIP_Demo_IAR_ARM7/resource/at91sam7x-ek-flash.mac
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / uIP_Demo_IAR_ARM7 / resource / at91sam7x-ek-flash.mac
1 //  ----------------------------------------------------------------------------\r
2 //          ATMEL Microcontroller Software Support  -  ROUSSET  -\r
3 //  ----------------------------------------------------------------------------\r
4 //  DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
5 //  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
6 //  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
7 //  DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
8 //  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
9 //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
10 //  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
11 //  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
12 //  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
13 //  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
14 //  ----------------------------------------------------------------------------\r
15 //  File Name           : SAM7_FLASH.mac\r
16 //  Object              : Generic Macro File for IAR\r
17 //  1.0 17/Aug/05 FBr   : Creation\r
18 //  ----------------------------------------------------------------------------\r
19 \r
20 /*********************************************************************\r
21 *\r
22 *       _InitRSTC()\r
23 *\r
24 * Function description\r
25 *   Initializes the RSTC (Reset controller).\r
26 *   This makes sense since the default is to not allow user resets, which makes it impossible to\r
27 *   apply a second RESET via J-Link\r
28 */\r
29 _InitRSTC() {\r
30     __writeMemory32(0xA5000001, 0xFFFFFD08,"Memory");    // Allow user reset\r
31 }\r
32 \r
33 /*********************************************************************\r
34 *\r
35 *       _InitPLL()\r
36 * Function description\r
37 *   Initializes the PMC.\r
38 *   1. Enable the Main Oscillator\r
39 *   2. Configure PLL to 96MHz\r
40 *   3. Switch Master Clock (MCK) on PLL/2 = 48MHz\r
41 */\r
42 _InitPLL() {\r
43 \r
44     __message "Enable Main Oscillator";\r
45     __writeMemory32(0x00000601,0xFFFFFc20,"Memory");    // MOSC\r
46     while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x1)  );\r
47 \r
48     __message "Set PLL to 96MHz";\r
49     __writeMemory32(0x10191c05,0xFFFFFc2c,"Memory");    // LOCK\r
50     while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x4)  );\r
51 \r
52     __message "Set Master Clock to 48MHz";\r
53     __writeMemory32(0x00000004,0xFFFFFc30,"Memory");    // MCKRDY\r
54     while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x8)  );\r
55     __writeMemory32(0x00000007,0xFFFFFc30,"Memory");    // MCKRDY\r
56     while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x8)  );\r
57 \r
58     // Set 1 WS for Flash accesses on each EFC \r
59     __writeMemory32(0x00480100,0xFFFFFF60,"Memory");\r
60     __writeMemory32(0x00480100,0xFFFFFF70,"Memory");\r
61 }\r
62 \r
63 /*********************************************************************\r
64 *\r
65 *       execUserReset() : JTAG set initially to Full Speed\r
66 */\r
67 execUserReset() {\r
68     __message "execUserReset()";\r
69     __hwReset(0);                       // Hardware Reset: CPU is automatically halted after the reset (JTAG is already configured to 32kHz)\r
70     _InitPLL();                         // Allow to debug at JTAG Full Speed\r
71     _InitRSTC();                        // Enable User Reset to allow execUserReset() execution\r
72 }\r
73 \r