Annotation of gforth/engine/io-nxt.c, revision 1.3

1.1       pazsan      1: /* direct key io driver for NXT brick
                      2: 
                      3:   Copyright (C) 2007 Free Software Foundation, Inc.
                      4: 
                      5:   This file is part of Gforth.
                      6: 
                      7:   Gforth is free software; you can redistribute it and/or
                      8:   modify it under the terms of the GNU General Public License
                      9:   as published by the Free Software Foundation; either version 2
                     10:   of the License, or (at your option) any later version.
                     11: 
                     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.
                     16: 
                     17:   You should have received a copy of the GNU General Public License
                     18:   along with this program; if not, write to the Free Software
                     19:   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
                     20: 
                     21:   The following is stolen from the readline library for bash
                     22: */
                     23: 
                     24: #include "config.h"
                     25: #include "forth.h"
                     26: #include "../arch/arm/nxt/AT91SAM7.h"
1.2       pazsan     27: #include "../arch/arm/nxt/bt.h"
1.3     ! pazsan     28: #include "../arch/arm/nxt/display.h"
        !            29: #include "../arch/arm/nxt/aic.h"
        !            30: #include "../arch/arm/nxt/systick.h"
        !            31: #include "../arch/arm/nxt/sound.h"
        !            32: #include "../arch/arm/nxt/interrupts.h"
        !            33: #include "../arch/arm/nxt/nxt_avr.h"
        !            34: #include "../arch/arm/nxt/nxt_motors.h"
        !            35: #include "../arch/arm/nxt/i2c.h"
1.1       pazsan     36: 
1.3     ! pazsan     37: int terminal_prepped = 0;
        !            38: 
        !            39: void
        !            40: show_splash(U32 milliseconds)
1.1       pazsan     41: {
1.3     ! pazsan     42:   display_clear(0);
        !            43:   display_goto_xy(6, 6);
        !            44:   display_string("Gforth");
        !            45:   display_update();
1.1       pazsan     46: 
1.3     ! pazsan     47:   systick_wait_ms(milliseconds);
1.1       pazsan     48: }
                     49: 
                     50: void prep_terminal ()
                     51: {
1.2       pazsan     52:   aic_initialise();
                     53:   interrupts_enable();
                     54:   systick_init();
1.3     ! pazsan     55:   sound_init();
        !            56:   nxt_avr_init();
1.2       pazsan     57:   display_init();
1.3     ! pazsan     58:   nxt_motor_init();
        !            59:   i2c_init();
1.2       pazsan     60:   bt_init();
1.3     ! pazsan     61:   display_goto_xy(0,0);
        !            62:   display_clear(1);
1.2       pazsan     63: 
1.1       pazsan     64:   terminal_prepped = 1;
                     65: }
                     66: 
                     67: void deprep_terminal ()
                     68: {
                     69:   terminal_prepped = 0;
                     70: }
                     71: 
1.3     ! pazsan     72: long key_avail ()
        !            73: {
        !            74:   if(!terminal_prepped) prep_terminal();
        !            75:   return bt_avail();
        !            76: }
        !            77: 
        !            78: Cell getkey()
        !            79: {
        !            80:   if(!terminal_prepped) prep_terminal();
        !            81:   return bt_getkey();
        !            82: }
        !            83: 
1.1       pazsan     84: void emit_char(char x)
                     85: {
1.3     ! pazsan     86:   if(!terminal_prepped) prep_terminal();
        !            87:   display_char(x);
        !            88:   display_update();
1.2       pazsan     89:   bt_send(&x, 1);
1.1       pazsan     90: }
                     91: 
                     92: void type_chars(char *addr, unsigned int l)
                     93: {
1.2       pazsan     94:   int i;
                     95:   for(i=0; i<l; i++)
1.3     ! pazsan     96:     emit_char(addr[i]);
1.1       pazsan     97: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>