]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/HCS12_GCC_banked/startup.c
Update version numbers in preparation for a new release.
[freertos] / FreeRTOS / Demo / HCS12_GCC_banked / startup.c
1 /*\r
2  * FreeRTOS Kernel V10.1.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 \r
29 /*\r
30  * startup.c\r
31  * Author Jefferson L Smith, Robotronics Inc.\r
32  *\r
33  * __premain() is the startup code to init hardware and ram to execute the\r
34  *             C application.\r
35  *\r
36  */\r
37 \r
38 #include <sys/ports.h>\r
39 #include "cpu.h"\r
40 \r
41 void ATTR_NEAR __premain (void);\r
42 \r
43 void\r
44 __premain (void)\r
45 {\r
46         // in case special mode enabled, avoid conflict on PORTE\r
47         PEAR |= NECLK;\r
48         // bgnd mode stops COP and RTI clocks\r
49         COPCTL = RSBCK;\r
50         // stops TCNT counter when debugging stops\r
51         TSCR1 |= (1<<5);                        // TFRZ\r
52         \r
53         // PLL\r
54         CLKSEL = 0;                             // disable PLL to configure\r
55         // xtal 16MHz, bus 24MHz\r
56         SYNR  = 3 - 1;\r
57         REFDV = 2 - 1;\r
58         while (!(CRGFLG & 0x08))    // wait for PLL LOCK\r
59         cop_optional_reset();\r
60         CLKSEL |= 0x80;             // use PLL\r
61 \r
62         // init switch inputs\r
63         PERH = 0xff;                            // pullups\r
64 \r
65         // outputs\r
66 #if PORT_LED==M6811_PORTB               //PORTB\r
67         DDRB = 0xff;    // init LED\r
68 #elif PORT_LED==M6811_PORTA             //PORTA\r
69         DDRA = 0xff;\r
70 #elif PORT_LED==M6811_PTT       //PTT\r
71         DDRT = 0xff;\r
72 #elif PORT_LED==M6811_PTM       //PTM\r
73         DDRM = 0xff;\r
74 #elif PORT_LED==M6811_PTP       //PTP\r
75         DDRP = 0xff;\r
76 #elif PORT_LED==M6811_PTH       //PTH\r
77         DDRH = 0xff;\r
78 #endif\r
79         \r
80 }\r
81 \r