status has been added for polling function.

This commit is contained in:
matsutsuka 2007-09-19 12:47:19 +00:00
parent 8d7bb2119c
commit c99b7dc827
3 changed files with 20 additions and 13 deletions

View file

@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: rs232.c,v 1.2 2007/09/11 12:03:20 matsutsuka Exp $ * $Id: rs232.c,v 1.3 2007/09/19 12:47:55 matsutsuka Exp $
* *
*/ */
/* /*
@ -48,7 +48,7 @@ PROCESS_THREAD(rs232_process, ev, data)
{ {
static struct etimer timer; static struct etimer timer;
char ch; char ch;
unsigned char i; unsigned char i, stat;
PROCESS_BEGIN(); PROCESS_BEGIN();
rs232_arch_init(RS232_BAUD_RATE); rs232_arch_init(RS232_BAUD_RATE);
@ -59,8 +59,8 @@ PROCESS_THREAD(rs232_process, ev, data)
if (etimer_expired(&timer)) { if (etimer_expired(&timer)) {
for (i = 0; i < RS232_BUFSIZE; i++) { for (i = 0; i < RS232_BUFSIZE; i++) {
ch = rs232_arch_poll(); ch = rs232_arch_poll(&stat);
if (ch == 0) { if (stat == 0) {
break; break;
} }
/* We have an input data */ /* We have an input data */

View file

@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: rs232.h,v 1.2 2007/09/11 12:03:20 matsutsuka Exp $ * $Id: rs232.h,v 1.3 2007/09/19 12:47:55 matsutsuka Exp $
* *
*/ */
/* /*
@ -51,9 +51,9 @@ void rs232_arch_init(unsigned long ubr);
/* /*
* An architecture-depend implementation of RS-232C polling. * An architecture-depend implementation of RS-232C polling.
* @return character, zero if no input. * @return character, stat == zero if no input.
*/ */
unsigned char rs232_arch_poll(void); unsigned char rs232_arch_poll(unsigned char* stat);
/* /*
* An architecture-depend implementation of RS-232C writing a byte. * An architecture-depend implementation of RS-232C writing a byte.

View file

@ -7,7 +7,7 @@
;;; ;;;
;;; @author Takahide Matsutsuka <markn@markn.org> ;;; @author Takahide Matsutsuka <markn@markn.org>
;;; ;;;
;;; $Id: rs232-asm.S,v 1.1 2007/09/11 12:12:59 matsutsuka Exp $ ;;; $Id: rs232-asm.S,v 1.2 2007/09/19 12:47:19 matsutsuka Exp $
;;; ;;;
;; definitions of PC-6001 BIOS routines ;; definitions of PC-6001 BIOS routines
@ -37,18 +37,25 @@ _rs232_arch_writeb:
ret ret
;; --------------------------------- ;; ---------------------------------
;; unsigned char rs232_arch_poll(); ;; unsigned char rs232_arch_poll(unsigned char *stat);
;; Stack; retl reth ;; Stack; retl reth statl stath
;; AFBC__HL____ ;; AFBCDEHL____
;; return input byte (zero if no input) ;; return input byte (*stat == 0 if no input)
;; --------------------------------- ;; ---------------------------------
_rs232_arch_poll: _rs232_arch_poll:
ld hl, #2
add hl, sp
ld e, (hl)
inc hl
ld d, (hl)
ld a, #0x01 ld a, #0x01
ld (de), a
di di
call #_char_input_sub ; read from buffer call #_char_input_sub ; read from buffer
ei ei
jr nz, _rs232_arch_poll_ret jr nz, _rs232_arch_poll_ret
xor a ; we have no data in the buffer xor a ; we have no data in the buffer
ld (de), a
_rs232_arch_poll_ret: _rs232_arch_poll_ret:
ld l, a ld l, a
ret ret