Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / ports / pic16 / support.c
blobe34ee33d5795987fa9d3f3b9d53fe076a18448a1
1 /*-------------------------------------------------------------------------
2 support.c - startup for PIC16 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 -
26 #pragma stack 0x200 255 /* set stack size to 255 bytes */
28 #include <pic18f452.h>
31 void
32 _putchar(char c)
34 while (!PIR1bits.TXIF)
36 TXREG = c;
40 void
41 _initEmu(void)
43 /* load and configure the libgpsim_modules module */
44 __asm
45 ;; Set frequency to 20MHz
46 .direct "e", ".frequency=20e6"
48 ;; Load the USART library and module
49 .direct "e", "module library libgpsim_modules"
50 .direct "e", "module load usart U1"
52 ;; Define a node
53 .direct "e", "node PIC_tx"
55 ;; Tie the USART module to the PIC
56 .direct "e", "attach PIC_tx portc6 U1.RXPIN"
58 ;; Set the USART module's Baud Rate
59 .direct "e", "U1.rxbaud = 9600"
61 ;; Display the received character on terminal
62 .direct "e", "U1.console = true"
63 __endasm;
65 /* USART initialization */
66 PORTCbits.TX = 1; // Set TX pin to 1
67 TRISCbits.TRISC6 = 0; // TX pin is output
69 TXSTA = 0; // Reset USART registers to POR state
70 RCSTA = 0;
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 TXSTAbits.BRGH = 1;
76 SPBRG = 129;
78 //2. Enable the asynchronous serial port by clearing
79 // bit SYNC and setting bit SPEN.
80 RCSTAbits.SPEN = 1;
82 //3. If interrupts are desired, set enable bit TXIE.
83 //4. If 9-bit transmission is desired, set transmit bit
84 // TX9. Can be used as address/data bit.
85 //5. Enable the transmission by setting bit TXEN,
86 // which will also set bit TXIF.
87 TXSTAbits.TXEN = 1;
89 //6. If 9-bit transmission is selected, the ninth bit
90 // should be loaded in bit TX9D.
91 //7. Load data to the TXREG register (starts
92 // transmission).
96 void
97 _exitEmu(void)
99 /* wait until the transmit buffer is empty */
100 while (!TXSTAbits.TRMT)
103 /* set the breakpoint */
104 __asm
105 .direct "a", "\"\""
106 __endasm;