PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
bitbang_uart.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2020-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#ifndef BITBANG_UART
27#define BITBANG_UART
28
29#include "../lib/board.h"
30
31class board;
32
33typedef struct bitbang_uart_t bitbang_uart_t;
34
36 unsigned char prx; // previous rx value
37 unsigned short insr; // input shift register
38 unsigned short outsr; // output shift register
39 unsigned int bcr; // bit counter read
40 unsigned int bcw; // bit counter write
41 unsigned long speed; // serial speed (baud)
42 unsigned int leds; // rx tx leds status
43 unsigned char datar; // data received
44 unsigned char data_recv; // flag data received
45 unsigned char dataw; // data to write
46 unsigned char data_to_send; // flag data to write
47 int TimerRXID;
48 int TimerTXID;
49 board* pboard;
50 void (*CallbackRX)(bitbang_uart_t* bu, void* arg);
51 void* ArgRX;
52 // Controller
53 unsigned char ctrl_on;
54 unsigned char tx_pin;
55 unsigned char tx_value;
56 unsigned char rx_pin;
57 unsigned char rx_value;
58};
59
60void bitbang_uart_rst(bitbang_uart_t* bu);
61void bitbang_uart_init(bitbang_uart_t* bu, board* pboard, void (*CallbackRX)(bitbang_uart_t* bu, void* argRX),
62 void* Arg);
63void bitbang_uart_end(bitbang_uart_t* bu);
64void bitbang_uart_set_speed(bitbang_uart_t* bu, const unsigned int speed);
65unsigned char bitbang_uart_transmitting(bitbang_uart_t* bu);
66void bitbang_uart_send(bitbang_uart_t* bu, const unsigned char data);
67unsigned char bitbang_uart_data_available(bitbang_uart_t* bu);
68unsigned char bitbang_uart_recv(bitbang_uart_t* bu);
69
70unsigned char bitbang_uart_io(bitbang_uart_t* bu, const unsigned char rx);
71
72#endif // BITBANG_UART
Board class.
Definition board.h:111
Definition bitbang_uart.h:35