PICSimLab - Programmable IC Simulator Laboratory
0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
bitbang_spi.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_SPI
27
#define BITBANG_SPI
28
29
class
board
;
30
31
// operation status
32
#define SPI_DATA 0x01
33
#define SPI_BIT 0x02
34
35
typedef
struct
{
36
unsigned
char
aclk;
37
unsigned
int
insr;
38
unsigned
int
outsr;
39
unsigned
char
bit;
40
unsigned
int
byte;
41
unsigned
short
status;
42
unsigned
int
data;
43
unsigned
char
ret;
44
unsigned
char
lenght;
45
unsigned
int
outbitmask;
46
unsigned
int
inmask;
47
// Controller
48
board
* pboard;
49
int
TimerID;
50
unsigned
char
ctrl_on;
51
unsigned
char
sck_pin;
52
unsigned
char
sck_value;
53
unsigned
char
copi_pin;
54
unsigned
char
copi_value;
55
unsigned
char
cipo_pin;
56
unsigned
char
cipo_value;
57
unsigned
char
cs_pin[3];
58
unsigned
char
cs_value[3];
59
unsigned
char
clkpc;
// clock phase counter
60
unsigned
char
transmitting;
61
}
bitbang_spi_t
;
62
63
void
bitbang_spi_init(
bitbang_spi_t
* spi,
const
unsigned
char
lenght = 8);
64
void
bitbang_spi_rst(
bitbang_spi_t
* spi);
65
unsigned
char
bitbang_spi_get_status(
bitbang_spi_t
* spi);
66
void
bitbang_spi_send16(
bitbang_spi_t
* spi,
const
unsigned
int
data);
67
void
bitbang_spi_send8(
bitbang_spi_t
* spi,
const
unsigned
char
data);
68
69
// peripheral
70
unsigned
char
bitbang_spi_io(
bitbang_spi_t
* spi,
const
unsigned
char
clk,
const
unsigned
char
din,
71
const
unsigned
char
cs);
72
unsigned
char
bitbang_spi_io_(
bitbang_spi_t
* spi,
const
unsigned
char
** pins_value);
73
74
// controller
75
void
bitbang_spi_ctrl_init(
bitbang_spi_t
* spi,
board
* pboard,
const
unsigned
char
lenght = 8);
76
void
bitbang_spi_ctrl_end(
bitbang_spi_t
* spi);
77
78
void
bitbang_spi_ctrl_write(
bitbang_spi_t
* spi,
const
unsigned
char
data);
79
80
#endif
// BITBANG_SPI
board
Board class.
Definition
board.h:111
bitbang_spi_t
Definition
bitbang_spi.h:35
src
devices
bitbang_spi.h
Generated by
1.9.8