PICSim 0.8.1
PICsim - PIC Simulator
All Data Structures Files Functions Variables Typedefs Macros Modules Pages
bitbang_uart.h
1/* ########################################################################
2
3 PICsimLab - PIC laboratory simulator
4
5 ########################################################################
6
7 Copyright (c) : 2020-2022 Luis Claudio Gamboa Lopes
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#ifdef __cplusplus
27extern "C" {
28#endif
29
30#ifndef BB_UART
31#define BB_UART
32
33#include <stdio.h>
34
35typedef struct {
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 long tcountr; // clock counter read
41 unsigned int bcw; // bit counter write
42 unsigned long tcountw; // clock counter write
43 unsigned long speed; // serial speed (baud)
44 unsigned int cycle_count; // speed /clock cycle counter
45 unsigned int rxc; // rc clock counter
46 unsigned int leds; // rx tx leds status
47 unsigned char datar; // data received
48 unsigned char data_recv; // flag data received
49 unsigned char dataw; // data to write
50 unsigned char data_to_send; // flag data to write
51 unsigned long freq;
52} bb_uart_t;
53
54void bb_uart_rst(bb_uart_t *bu);
55void bb_uart_init(bb_uart_t *bu);
56void bb_uart_end(bb_uart_t *bu);
57void bb_uart_set_clk_freq(bb_uart_t *bu, unsigned long freq);
58void bb_uart_set_speed(bb_uart_t *bu, unsigned int speed);
59unsigned char bb_uart_transmitting(bb_uart_t *bu);
60void bb_uart_send(bb_uart_t *bu, unsigned char data);
61unsigned char bb_uart_data_available(bb_uart_t *bu);
62unsigned char bb_uart_recv(bb_uart_t *bu);
63void bb_uart_open(bb_uart_t *bu);
64unsigned char bb_uart_io(bb_uart_t *bu, unsigned char rx);
65
66#endif // BB_UART
67
68#ifdef __cplusplus
69}
70#endif
Definition bitbang_uart.h:35