Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / ports / pic14 / support.c
blob2370a6172ae8c2c5b02adba3d3bfc3253dead95b
1 /*-------------------------------------------------------------------------
2 support.c - startup for PIC14 regression tests with gpsim
4 Copyright (c) 2006-2010 Borut Razem
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
23 -------------------------------------------------------------------------*/
25 #pragma preproc_asm -
27 #include <pic16f877.h>
29 static unsigned int __at(0x2007) _config = _WDT_OFF;
31 void
32 _putchar(char c)
34 while (!TXIF)
36 TXREG = c;
37 /* wait until the transmit buffer is empty */
38 while (!TRMT)
43 void
44 _initEmu(void)
46 /* load and configure the libgpsim_modules module */
47 __asm
48 ;; Set frequency to 20MHz
49 .direct "e", ".frequency=20e6"
51 ;; Load the USART library and module
52 .direct "e", "module library libgpsim_modules"
53 .direct "e", "module load usart U1"
55 ;; Define a node
56 .direct "e", "node PIC_tx"
58 ;; Tie the USART module to the PIC
59 .direct "e", "attach PIC_tx portc6 U1.RXPIN"
61 ;; Set the USART module's Baud Rate
62 .direct "e", "U1.rxbaud = 9600"
64 ;; Display the received character on terminal
65 .direct "e", "U1.console = true"
66 __endasm;
68 /* USART initialization */
69 PORTC |= 0x40; // Set TX pin to 1
70 TRISC &= ~0x40; // TX pin is output
72 //1. Initialize the SPBRG register for the appropriate
73 // baud rate. If a high speed baud rate is desired,
74 // set bit BRGH (Section 16.1).
75 BRGH = 1;
76 SPBRG = 129;
78 //2. Enable the asynchronous serial port by clearing
79 // bit SYNC and setting bit SPEN.
80 CREN = 1;
81 SPEN = 1;
83 //3. If interrupts are desired, set enable bit TXIE.
84 //4. If 9-bit transmission is desired, set transmit bit
85 // TX9. Can be used as address/data bit.
86 //5. Enable the transmission by setting bit TXEN,
87 // which will also set bit TXIF.
88 TXEN = 1;
90 //6. If 9-bit transmission is selected, the ninth bit
91 // should be loaded in bit TX9D.
92 //7. Load data to the TXREG register (starts
93 // transmission).
97 void
98 _exitEmu(void)
100 /* set the breakpoint */
101 __asm
102 .direct "a", "\"PASSED\""
103 goto $
104 __endasm;