4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
28 int avr_ioctl(avr_t *avr, uint32_t ctl, void * io_param)
30 avr_io_t * port = avr->io_port;
32 while (port && res == -1) {
34 res = port->ioctl(port, ctl, io_param);
40 void avr_register_io(avr_t *avr, avr_io_t * io)
42 io->next = avr->io_port;
47 void avr_register_io_read(avr_t *avr, uint8_t addr, avr_io_read_t readp, void * param)
49 avr->ior[AVR_DATA_TO_IO(addr)].param = param;
50 avr->ior[AVR_DATA_TO_IO(addr)].r = readp;
53 void avr_register_io_write(avr_t *avr, uint8_t addr, avr_io_write_t writep, void * param)
55 avr->iow[AVR_DATA_TO_IO(addr)].param = param;
56 avr->iow[AVR_DATA_TO_IO(addr)].w = writep;
59 struct avr_irq_t * avr_io_getirq(avr_t * avr, uint32_t ctl, int index)
61 avr_io_t * port = avr->io_port;
63 if (port->irq && port->irq_ioctl_get == ctl && port->irq_count > index)
64 return port->irq + index;