new facade system: manec and manei, removed manager
[quarnos.git] / resources / rs232.cpp
blob888e2ed25fcf97ce9a7c14f33155879b55b0dfa7
1 /* Quarn OS
3 * RS232
5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "rs232.h"
24 #include "arch/low/rs232.h"
25 #include "libs/delegate.h"
26 #include "spinlock.h"
27 #include "manes/manec.h"
29 using namespace resources;
31 void rs232::read_bytes(char *data, int count) {
35 void rs232::write_dwords(const int *data, int count) {
39 void rs232::write_bytes(const char *data, int count) {
40 //access_write();
41 for (int i = 0; i < count; i++) {
42 if (data[i] == '\n')
43 arch::rs232_send(isaaddr, '\r');
44 arch::rs232_send(isaaddr, data[i]);
46 //release();
49 void rs232::received(const char a) {
50 write_bytes(&a,1);
53 void rs232::set_ondatareceived(delegate<void>){}
55 resource_result *rs232_impl::configure(rs232_mode mode, int speed, int bits,
56 parity_check parity, int stop) {
57 arch::rs232_configure(isaaddr, mode, speed, bits, parity, stop);
58 }*/
60 bool rs232::init_device(did *iadr) {
61 isaaddr = *dynamic_cast<isa_did*>(iadr);
63 delegate<void, const char> sp_hndl;
64 sp_hndl.method(this,&rs232::received);
66 arch::rs232_init(isaaddr, sp_hndl);
68 inited = true;
70 return inited;
73 void rs232::register_type() {
74 manes::manec::get()->register_type<rs232>("rs232", "isa", manes::type::device);
77 extern "C" void module_init() {
78 resources::rs232::register_type();