-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathp16e_uart.c
81 lines (68 loc) · 3.57 KB
/
p16e_uart.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ########################################################################
PICsim - PIC simulator
########################################################################
Copyright (c) : 2019-2020 Luis Claudio Gamboa Lopes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
For e-mail suggestions : lcgamboa@yahoo.com
######################################################################## */
#include <stdio.h>
#include "../../include/periferic16e.h"
#include "../../include/picsim.h"
void p16e_uart_rst(_pic* pic, int nser) {
pic->serial[nser].serial_PIR = pic->P16Emap.PIR1;
pic->serial[nser].serial_PIE = pic->P16Emap.PIE1;
pic->serial[nser].RXIF_mask = 0x20;
pic->serial[nser].TXIF_mask = 0x10;
pic->serial[nser].serial_TXSTA = pic->P16Emap.TXSTA;
pic->serial[nser].serial_RCSTA = pic->P16Emap.RCSTA;
pic->serial[nser].serial_SPBRG = pic->P16Emap.SP1BRGL;
pic->serial[nser].serial_SPBRGH = pic->P16Emap.SP1BRGH;
pic->serial[nser].serial_BAUDCTL = pic->P16Emap.BAUDCON1;
pic->serial[nser].serial_RCREG = pic->P16Emap.RCREG;
pic->serial[nser].serial_TXREG = pic->P16Emap.TXREG;
pic->serial[nser].serial_TXREG_ADDR = sfr_addr(pic->P16Emap.TXREG);
pic->serial[nser].serial_RCSTA_ADDR = sfr_addr(pic->P16Emap.RCSTA);
pic->serial[nser].serial_RCREG_ADDR = sfr_addr(pic->P16Emap.RCREG);
pic->serial[nser].serial_TRIS_RX = &pic->ram[sfr_addr(pic->pins[pic->usart_rx[0] - 1].port) +
(sfr_addr(pic->P16Emap.TRISA) - sfr_addr(pic->P16Emap.PORTA))];
pic->serial[nser].serial_TRIS_RX_MASK = (0x01 << pic->pins[pic->usart_rx[0] - 1].pord);
pic->serial[nser].s_open = 1;
bb_uart_rst(&pic->serial[nser].bbuart);
}
void p16e_uart_rst_2(_pic* pic, int nser) {
pic->serial[nser].serial_PIR = pic->P16Emap.PIR1;
pic->serial[nser].serial_PIE = pic->P16Emap.PIE1;
pic->serial[nser].RXIF_mask = 0x20;
pic->serial[nser].TXIF_mask = 0x10;
pic->serial[nser].serial_TXSTA = pic->P16Emap.TX1STA;
pic->serial[nser].serial_RCSTA = pic->P16Emap.RC1STA;
pic->serial[nser].serial_SPBRG = pic->P16Emap.SP1BRGL;
pic->serial[nser].serial_SPBRGH = pic->P16Emap.SP1BRGH;
pic->serial[nser].serial_BAUDCTL = pic->P16Emap.BAUDCON1;
pic->serial[nser].serial_RCREG = pic->P16Emap.RC1REG;
pic->serial[nser].serial_TXREG = pic->P16Emap.TX1REG;
pic->serial[nser].serial_TXREG_ADDR = sfr_addr(pic->P16Emap.TX1REG);
pic->serial[nser].serial_RCSTA_ADDR = sfr_addr(pic->P16Emap.RC1STA);
pic->serial[nser].serial_RCREG_ADDR = sfr_addr(pic->P16Emap.RC1REG);
pic->serial[nser].serial_TRIS_RX = &pic->ram[sfr_addr(pic->pins[pic->usart_rx[0] - 1].port) +
(sfr_addr(pic->P16Emap.TRISA) - sfr_addr(pic->P16Emap.PORTA))];
pic->serial[nser].serial_TRIS_RX_MASK = (0x01 << pic->pins[pic->usart_rx[0] - 1].pord);
pic->serial[nser].s_open = 1;
bb_uart_rst(&pic->serial[nser].bbuart);
}
/*
void
p16e_uart(void)
{
}
*/