SimAVR
AVR Simulator
avr_bitbang.h
Go to the documentation of this file.
1 /*
2  * avr_bitbang.h
3  *
4  * Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5  * 2011 Stephan Veigl <veig@gmx.net>
6  *
7  * This file is part of simavr.
8  *
9  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
10  * General Public License as published by the Free Software Foundation, either version 3 of the
11  * License, or (at your option) any later version.
12  *
13  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
14  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with simavr. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
41 #ifndef AVR_BITBANG_H_
42 #define AVR_BITBANG_H_
43 
44 #include "sim_avr.h"
45 #include "avr_ioport.h"
46 
48 typedef struct avr_bitbang_t
49 {
51 
52  uint8_t enabled;
53  uint8_t clk_generate;
54  uint8_t clk_pol;
55  uint8_t clk_phase;
56  uint32_t clk_cycles;
59  uint8_t data_order;
60 
63  uint8_t buffer_size;
64 
66  void (*callback_bit_read) (uint8_t bit, void *param);
67  void (*callback_bit_write) (uint8_t bit, void *param);
68  uint32_t (*callback_transfer_finished) (uint32_t data, void *param);
69 
73 
74  // private data
75  uint32_t data;
76  int8_t clk_count;
80 
88 
98 
107 
108 #endif /* AVR_BITBANG_H_ */
109 
void(* callback_bit_read)(uint8_t bit, void *param)
anonymous parameter for callback functions
Definition: avr_bitbang.h:66
uint32_t(* callback_transfer_finished)(uint32_t data, void *param)
callback function to notify about a complete transfer (read received data and write new output data) ...
Definition: avr_bitbang.h:68
pin structure
Definition: avr_ioport.h:89
uint32_t data
data buffer
Definition: avr_bitbang.h:75
uint8_t buffer_size
size of buffer in bits (1...32)
Definition: avr_bitbang.h:63
avr_t * avr
Definition: run_avr.c:54
void(* callback_bit_write)(uint8_t bit, void *param)
callback function to notify about bit write
Definition: avr_bitbang.h:67
SPI Module initialization and state structure.
Definition: avr_bitbang.h:48
uint8_t enabled
bit-bang enabled flag
Definition: avr_bitbang.h:52
uint8_t clk_phase
clock phase / data sampling edge
Definition: avr_bitbang.h:55
avr_iopin_t p_clk
clock pin (optional)
Definition: avr_bitbang.h:70
uint8_t clk_generate
generate clock and write to clock pin (if available) -> master / slave mode
Definition: avr_bitbang.h:53
avr_iopin_t p_in
data in pin
Definition: avr_bitbang.h:71
uint32_t clk_cycles
cycles per clock period - must be multiple of 2! (used if clk_generate is enabled) ...
Definition: avr_bitbang.h:58
void avr_bitbang_stop(avr_bitbang_t *p)
stop bitbang transfer
Definition: avr_bitbang.c:234
void avr_bitbang_reset(avr_t *avr, avr_bitbang_t *p)
reset bitbang sub-module
Definition: avr_bitbang.c:176
avr_iopin_t p_out
data out pin
Definition: avr_bitbang.h:72
void avr_bitbang_start(avr_bitbang_t *p)
start bitbang transfer
Definition: avr_bitbang.c:201
void * callback_param
Definition: avr_bitbang.h:65
avr_t * avr
avr we are attached to
Definition: avr_bitbang.h:50
struct avr_bitbang_t avr_bitbang_t
SPI Module initialization and state structure.
Main AVR instance.
Definition: sim_avr.h:142
uint8_t clk_pol
clock polarity, base (inactive) value of clock
Definition: avr_bitbang.h:54
uint8_t data_order
data order / shift
Definition: avr_bitbang.h:59
int8_t clk_count
internal clock edge count
Definition: avr_bitbang.h:78