API of wbioslibmanu(c)



bi_getbtn [O] ... Read a button. 

    ***** Note *****
        Usually, use the  Keyin( ), EventCall( ) and EventExec( ) functions in the rupsys library.

    ***** Format *****
        int     bi_getbtn() {}  Normal: Button status
	        Function value: Button status
	                        The bit corresponding to the input button goes ON.
	                        Multiple bits may go ON simultaneously.

                 f e d c b a 9 8 7 6 5 4 3 2 1 0
                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                | | | | | | | | | | | | | | | | |
                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 | | | | | | | | | | | | | | | | 
                 | | | | | | | | | | | | | | | +-- K0 FILER/TIME button
                 | | | | | | | | | | | | | | +---- K1 MENU button
                 | | | | | | | | | | | | | +------ K2 EL button
                 | | | | | | | | | | | | +-------- K3 ENTER button
                 | | | | | | | | | | | +---------- K4 cursor pointer (Left key)
                 | | | | | | | | | | +------------ K5 cursor pointer (Up key)
                 | | | | | | | | | +-------------- K6 cursor pointer (Right key)
                 | | | | | | | | +---------------- K7 cursor pointer (Down key)
                 | | | | | | | |
                 | | | | | | | +--- /TEST   Key input for inspection at shipment from factory
                 | | | | | | +----- CHGSNS  Cell dismounted: 1 Cell mounted: 0
                 | | | | | +------- RXD     RS-232C connected but idle: 1  Others: 0
                 | | | | +--------- RXDL    RS-232 connected: 1 RS-232C not connected: 0
                 | | | +----------- HCLK    CPU clock 3.6MHz: 1 CPU clock 1.8MHz: 0
                 | | +-------------         Always 0.
                 | +---------------         Always 0.
                 +----------------- EVENT   Event number set at the address 0xf080 of the event register: 1
                (At event occurrence, an event number from 1 to 255 is set in b0 to b7.)

    ***** Function *****
        Gets the state of  button input from the button input buffer.
        When there is no data in the button data buffer, this function waits for button input.
        At this time, the CPU is halted or stopped.

    ***** Note *****
        When all buttons are released, the bits K0 to K7 are all set to 0.

            Example:   Button input=Hi, Button release=Low
                 K0=01h         +-------+            Hi
                       ---------+       +----------- Lo
                 K1=02h             +-------+        Hi
                       -------------+       +------- Lo
                                |   |   |   |
                                v   v   v   v
                 Return value  01h 03h 02h 00h

    ***** About event flag *****
        Like button input, this value can also be obtained when a code from 1 to 255 is set in the event register 0xf080.  This method is used to post an event from the interrupt routine so that the interrupt can be handled within the button handling routine. 
        This causes the CPU to be stopped or halted.

        Example
            #define EVENTREGSTER *(char *)0xf080 /* Already defined in rupsys.h */

            /********* Interrupt routine ********/
            void _Interrupt(void) {
            /* Writes to event register */
                EVENTREGSTER = 32;
            }

            /**********  Main routine  *********/
             :
            while(1) {
                btn = bi_getbtn();        /* Waits for button input or event */
                if (btn&0x8000) {
                    /* Event occurrence */
                    if (btn&0x00FF==32) {} /* Judgement for branch  */
                }
            }
             :

      ***** Tips *****
         Because the filer uses the event flag and the following value, care should be taken.

                EVENTREGSTER = 1
                Return value of bi_getbtn() = 0x8001

    Because the CPU clock is 3.68MHz, the return value (HCLK flag (0x1000)) of bi_getbtn() is always ON.




Lib-Index   API-Index

bi_sensbtn [O] ... Senses the button data buffer. 

    ***** Format *****
        int     bi_sensbtn(code) {}
            Function value: 1: Button input 0: No button input
            Parameter:
                int     *code;      Input button status (same as that of bi_gerbtn)

    ***** Function *****
        Returns the first button in the button data buffer.
        No button data buffer changes.




Lib-Index   API-Index

bi_scanbtn [O] ... Senses the button information. 

    ***** Format *****
        int     bi_scanbtn(void) {}
            Function value: Button status
                 f e d c b a 9 8 7 6 5 4 3 2 1 0
                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                | | | | | | | | | | | | | | | | |
                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 | | | | | | | | | | | | | | | | 
                 | | | | | | | | | | | | | | | +-- K0 FILER/TIME button
                 | | | | | | | | | | | | | | +---- K1 MENU button
                 | | | | | | | | | | | | | +------ K2 EL button
                 | | | | | | | | | | | | +-------- K3 ENTER button
                 | | | | | | | | | | | +---------- K4 cursor pointer (Left key)
                 | | | | | | | | | | +------------ K5 cursor pointer (Up key)
                 | | | | | | | | | +-------------- K6 cursor pointer (Right key)
                 | | | | | | | | +---------------- K7 cursor pointer (Down key)
                 | | | | | | | |
                 | | | | | | | +--- /TEST   Key input for inspection at shipment from factory
                 | | | | | | +----- CHGSNS  Cell dismounted: 1 Cell mounted: 0
                 | | | | | +------- RXD     RS-232C connected but idle: 1  RS-232C not connected: 0
                 | | | | +--------- RXDL    RS-232C connected: 1 RS-232C not connected: 0
                 | | | +----------- HCLK    CPU clock 3.6MHz: 1 CPU clock 1.8MHz: 0
                 | | +-------------         Always 0.
                 | +---------------         Always 0.
                 +-----------------         Always 0.

    ***** Function *****
        Reads the I/O address 50h or 51h directly without calling the BIOS, namely, obtains the status of the button upon making a direct call without using the buffer.




Lib-Index   API-Index

bi_clrbtn [O] ... Clears the button data buffer. 

    ***** Format *****
        void    bi_clrbtn() {}

    ***** Function *****
        Clears the button data buffer.




Lib-Index   API-Index

bi_chatpsbtn [O] ... FILER/TIME,MENU,EL, and ENTER buttons 

                       The clock is set to prevent input chattering.
    ***** Format *****
        void        bi_chatpsbtn(clk) {}
	        Parameter:
	            int     clk;        Clock frequenct to prevent input chattering
                                        0: 16Hz
                                        1: 32Hz
                                        2: 64Hz
                                        3: 128Hz
                                        4: 256Hz
                                        5: 512Hz
                                        6: 1024Hz
                                        7: 2048Hz

    ***** Function *****
         Sets the clock frequency to prevent FILER/TIME, MENU, EL or ENTER button input chattering.

    ***** Tips *****
         The filer initial value is 1: 32Hz.




Lib-Index   API-Index

bi_chatjkbtn [O] ... Sets the clock to prevent cursor pointer input chattering. 

    ***** Format *****
        void        bi_chatjkbtn(clk) {}
            Parameter:
                int     clk;        Clock frequency to prevent chattering
                                        0: 16Hz
                                        1: 32Hz
                                        2: 64Hz
                                        3: 128Hz
                                        4: 256Hz
                                        5: 512Hz
                                        6: 1024Hz
                                        7: 2048Hz

    ***** Function *****
         Sets the clock frequency to prevent cursor pointer input chattering.

    ***** Tips *****
         The filer initial value is 1: 32Hz.




--------------------------------------------------------------------------------
2. Disk Control
   When the disk BIOS causes an error, one of the following values is set in BIOSerr.
    0x0000      Normal termination
    0x0001      ROM disk address specification error (parameter error)
    0x0003      Writing to the ROM disk
    0x0004      ROM disk area overflow (parameter error)
    0x0010      Invalid drive specification
    0x0020      Invalid memory ID
    0x0030      Not formatted yet
    0x0040      No alternate block
    0x0050      I/O error
    0x0060      Parameter error (Target function number not found)
    0xFFFE      Voltage drop (This error occurred in writing to flash memory.Writing itself completed.)
                The error code "0xFFFE" for voltage drop returns the value of normal termination.




Lib-Index   API-Index

bi_secread ... Reads a sector. 

    ***** Note *****
            Usually, use the bi_vsecread() function in the rupsys Library.

    ***** Format *****
        int     bi_secread(drv, head, cyl, secno, snum, rbuf) {}
            Function value: -1: Abnormal termination Others: Number of sectors read actually
            Parameter:
                int     drv;        Drive number (1=RAM disk)
                int     head;       Head number
                int     cyl;        Cylinder number
                int     secno;      Sector number
                int     snum;       Number of sectors to be read
                void    *rbuf;      Read buffer address

    ***** Function *****
        Reads the contents of the specified sector into the buffer.
        At abnormal termination, the error details are set in BIOSerr.




Lib-Index   API-Index

bi_secwrite ... Writes to a sector. 

    ***** Note *****
        Usually, use the bi_vsecwrite() function in the rupsys Library.

    ***** Format *****
        int     bi_secwrite(drv, head, cyl, secno, snum, wbuf) {}
	        Function value: -1: Abnormal termination Others: Number of sectors to which data has been written actually
	        Parameter:
	            int     drv;        Drive number (1=RAM disk)
	            int     head;       Head number
	            int     cyl;        Cylinder number
	            int     secno;      Sector number
	            int     snum;       Number of sectors to which data is written
	            void    *wbuf;      Write buffer address

    ***** Function ***** 
        Writes the contents of the buffer to the specified sector.
        At abnormal termination, error details are set in BIOSerr.




Lib-Index   API-Index

bi_format ... Formats a disk.                         ** Don't use this function usually ** 

    ***** Format *****
        int     bi_format(dno, level) {}
	        Function value: 0: Normal termination  -1: Abnormal termination
	        Parameter:
	            int     dno;        Drive number (=1: Flash memory)
	            int     level;      Format level
	                            1: "Level 1" -   Deletion only
	                            2: "Level 2" -  a) 0 is written to all blocks,then read for error check.
	                                            b) Deletion
	                            3: "Level 3" -  a) 0 is written to all blocks,then read for error check.
	                                            b) Deletion
	                                            c) All blocks are checked to confirm that 0xff has been written after deletion.
	                            (When other than the values 1, 2, and 3 is set, the default is 1.)

    ***** Function ***** 
        Formats the entire drive physically according to the format information set in bi_setdrfor.
        Error check is made at each level.
        At abnormal termination, the error details are set in BIOSerr.




Lib-Index   API-Index

bi_getdrform ... Gets format information. 

    ***** Format *****
        int     bi_getdrform(dno, inf) {}
	        Function value: 0: Normal termination, -1: Abnormal termination
	        Parameter:
	            int     dno;        Drive number (=1: Flash memory)
	            int     *inf;       Format information definition area The pointer of an area having the following structure is defined.
                    15                                  0
                    +-----------------------------------+
                    | Maximum cylinder number           |
                    |  (number of cylinders - 1)        |
                    +-----------------------------------+
                    | Maximum head number               |
                    |  (number of heads - 1)            |
                    +-----------------------------------+
                    | Maximum sector number             |
                    |  (number of sectors)              |
                    +-----------------------------------+
                    | Sector size                       |
                    +-----------------------------------+

                    Sector size = (0:128B 1:256B 2:512B)

    ***** Function *****
         Obtains various format information about the drive.
        At abnormal termination, the error details are set in BIOSerr.

        Example
             :
            int     secnum;                     /* Maximum number of sectors    */
            int     cylnum;                     /* Maximum number of cylinders  */
            int     headnum;                    /* Maximum number of heads      */
            int     inf[4];                     /* Format information           */

            err = bi_getdrform(RAMDISK, inf);
            if (err == FAILED) {
                return(FAILED);
            }
            cylnum  = inf[0] + 1;               /* Maximum cylinder number */
            headnum = inf[1] + 1;               /* Maximum head number     */
            secnum  = inf[2];                   /* Maximum sector number   */
             :

    ***** Tips *****The following lists the types of formats.

        Flash memory size     Block  Sector  Cluster  Header
                512KB      128   32      120   1
                512KB      256   16      120   1  << Default value
                512KB      512    8      120   1
               2048KB      256   16      240   2
               2048KB      512    8      240   2  << Default value
               4096KB      512   16      240   2  << Default value




Lib-Index   API-Index

bi_setdrform ... Sets the format information.            ** Don't use this function usually ** 

    ***** Format *****
        int     bi_setdrform(dno, cyl, hed, secnt, secsize) {}
            Function value: 0: Noraml termination, -1: Abnormal termination
            Parameter:
                int     dno;        Drive number (=1: Flash memory)
                int     cyl;        Maximum cylinder number (number of cylinders - 1)
                int     hed;        Maximum head number (number of heads -1)
                int     secnt;      Maximum sector number (number of sectors)
                int     secsize;	sector size = 0:128B 1:256B 2:512B

    ***** Function *****
         Sets the format information for a drive.
        At abnormal termination, the error details are set in BIOSerr.




Lib-Index   API-Index

bi_wrflush ... Writes to the block cache buffer. 

    ***** Note *****
        Usually, use the bi_vwrflush() function in the rupsys Library.

    ***** Format *****
        int     bi_wrflush(dno) {}
	        Function value: 0: Normal termination, -1: Abnormal termination
	        Parameter:
	            int     dno;        Drive number (=1: Flash memory)

    ***** Function ***** 
         Holds the flash memory block data.
        This function writes the contents of the write cache buffer into the flash memory.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Note *****
         This routine must be called at the end of the handling routine that performs the flash write operation "dos_write, dos_fwrite."

        Example
             :
            EVENTTABLE table;
            int fp;

            /* Routine for creating new files */
            if ( (fp = dos_fcrnew( ALARMINI ))<0 ) return;

            /* Initialization with \0 */
            memset( (char *)&table, '\0', sizeof(EVENTTABLE) );

            /* Routine for writing files */
            dos_fwrite( fp, (char *)&table ,sizeof(EVENTTABLE) );
            dos_fwrite( fp, (char *)&table ,sizeof(EVENTTABLE) );
            dos_fwrite( fp, (char *)&table ,sizeof(EVENTTABLE) );
            dos_fwrite( fp, (char *)&table ,sizeof(EVENTTABLE) );

            /* File handling closed */
            dos_fclose( fp );

            /* Flushing flash memory */
            bi_vwrflush();       /* bi_wrflush(1); + Voltage check function */
             :




--------------------------------------------------------------------------------
3. RS-232C, Ir
    Because communication uses the XMODEM protocol, its settings must be made as follows:
    - Data length=8 bits
    - Stop bit=1 bit
    - Parity=None
    - Character flow control=None
                                                    (Odd parity for ASK system)
    When communication uses the Ir port, it takes place in half duplex mode.
    At abnormal termination, the error details are set in BIOSerr.
                            b0: Overrun error               (0: None, 1: Found)
                            b1: Parity error                (0: None, 1: Found)
                            b2: Framing error               (0: None, 1: Found)
                            b3: Receive buffer overflow     (0: None, 1: Found)
                            b4: Time-out                    (0: None, 1: Found)
                            b5: Not open                    (0: None, 1: Found)
                            b7: Received data               (0: None, 1: Found)




Lib-Index   API-Index

bi_cominit ... Initializes the communication port. 

    ***** Format *****
        int     bi_cominit(comdev, baud, pulse, timout) {}
            Function value: 0: Normal termination, -1: Abnormal termination
            Parameter:
                int     comdev;     Communication system
                                    0: None
                                    1: SIR (Only the physical layer conforms to the IrDA1.0.)
                                    2: RS-232C
                                    3: ASK
                                    4: Remote control (receiving filter not provided)
                                    5: SIR adapter
                                    7: Remote control 2 (receiving filter provided)

                int     baud;       Baud rate
                                    1: 115200 bps
                                    2:  57600 bps
                                    3:  38400 bps
                                    4:  19200 bps
                                    5:   9600 bps
                                    6:   4800 bps
                                    7:   2400 bps
                                    8:   1200 bps
                                    9:    600 bps
                                    10:   300 bps
                                    
                int     pulse;      Pulse width.  Effective only when SIR is selected for communication.
                                        1: Sets a pulse width of 1.6usec.
                                        2: Sets a pulse width of 3/16 bit.

                int     timout;     Time-out value
                                        0: Immediate return
                                        -1: No timer monitoring takes place.
                                        Others: Time-out value in seconds

    ***** Function *****
        Initializes the designated communication channel and sets the baud rate, pulse width, and time-out value.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Communication system *****
        1.SIR    --- Only the physical layer conforms to the IrDA1.0(1.6usec and 3/16bit)
                     IrDA protocol not supported.

        2.RS232C --- 3-wire specification for TXD, RXD, and GND

        3.ASK    --- Transmission: Carrier frequency  Approx. 500kHz
                     Reception: Hi pass filter Approx. 368kHz -

        4.Remote control --- Transmission: Adequate carrier must be defined.
                                  Hi or Low data must be written to the port 0xffc4 directly.
                             Reception: Receiving filter not provided
                                  Hi or Low data in the carrier is obtained by reading the port 0xffd4.
                                       (Refer to the sample program.)

        5.SIR adapter --- Connects the RS232C port and Ir port in the gate array so that they can work as an SIR adapter.

        7.Remote control 2 --- Transmission: Same as 4. Remote control.
                               Reception: Receiving filter provided.-> Set the filter for the port 0x72.
                                  Hi or Low data in the carrier is obtained by reading the port 0xffd4.
                                       (Refer to the sample program.)

        Example  Settinsg required (settings for Sharp PDA ASK communication)
             :
            const COMDEV= 3;                  /* ASK                     */
            const BAUD  = 5;                  /* 9600bps                 */
            const PULSE = 1;                  /* Pulse width (setting is meaningless for ASK) */
            const TIMOUT= 10;                 /* Time-out  10 seconds    */

            if (bi_cominit(COMDEV,BAUD,PULSE,TIMOUT)) return;
            if (bi_comopen())   return;       /* Communication device power-on   */
            if (bi_comclr())    return;       /* Communication buffer cleared    */

            while (!(bi_scanbtn()&0xFF)) {
                /* Transmission and reception */
                 :
            }
            bi_comclose();                    /* Communication device power-off  */
            bi_cominit(0,0,0,0);              /* Return to the initial menu      */
            :




Lib-Index   API-Index

bi_comopen ... Opens the communication port. 

    ***** Format *****
        int     bi_comopen(void) {}
	        Function value: 0: Normal termination, 1: Abnormal termination
	        Parameter:

    ***** Function ***** 
        Opens the communication port.
        This function is provided to save the cell capacitance.  When the communication port is used actually, this function must be called before transmission or reception, then the bi_comclose( ) function must be called after termination of this function.




Lib-Index   API-Index

bi_comclose ... Closes the communication port. 

    ***** Format *****
        int     bi_comclose(void) {}
	        Function value: 0: Normal termination, -1: Abnormal termination
	        Parameter:

    ***** Function ***** 
        Closes the communication port.




Lib-Index   API-Index

bi_comwrite ... Transmits one character. 

    ***** Function *****
        int     bi_comwrite(cdat) {}
	        Function value: 0: Normal termination, -1: Abnormal termination  -2: Voltage drop
	        Parameter:
	            char    cdat;       Transmission data

    ***** Function ***** 
        Writes one character to a selected communication system device.
        This function returns control to the calling program after one character has been transmitted or when a time-out has occurred.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Remarks ***** 
        This function is not effective for communication using 4:Remote control, 5:SIR adapter or 7: Remote control 2.




Lib-Index   API-Index

bi_complwrite ... Transmits multuiple characters. 

    ***** Format *****
        int     bi_complwrite(cdat, clen, num) {}
	        Function value: 0: Normal termination -1: Abnormal termination -2: Voltage drop
	        Parameter:
	            char    *cdat;      Transmission data
	            int     clen;       Number of characters
	            int     *num;       Number of characters not transmitted (only at error occurrence)

    ***** Function *****
         Writes multiple characters to a selected communication system device.This function returns control to the calling program after transmitting a specified number of characters or when an error (time-out, etc.) has occurred.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Remarks ***** 
        This function is not effective for communication using 4: Remote control, 5: SIRadapter or 7: Remote control 2.




Lib-Index   API-Index

bi_comread ... Receives one character. 

    ***** Format *****
        int     bi_comread(cdat) {}
	        Function value: 0: Normal termination -1: Abnormal termination
	        Parameter:
	            char    *cdat;      Received data

    ***** Function ***** 
        Reads one character from a selected communication system device.

        This function returns control to the calling program after receiving one character or when an error (time-out, etc.) has occurred.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Note ***** 
        Because the LCD draw function stops the receive interrupt, avoid drawing during receive signal reception.  (If ignored, framing errors, etc. may occur.) 
        Because the capacity of the BIOS receive buffer is 150 characters, get them before an overflow occurs.
        When high-speed reception has been selected, it may cause the missing receive signals.

    ***** Note *****
        This function is not effective for communication using 4: Remote control, 5: SIR adapter or 7: Remote control 2.




Lib-Index   API-Index

bi_complread  ... Receives multiple characters. 

Lib-Index   API-Index

bi_complreadn ... Receives multiple characters (by getting the number of characters to be received) 

    ***** Format *****
        int     bi_complread(cdat, clen) {}
	        Function value: -1: Abnormal termination, Others: Number of characters received actually

        int     bi_complreadn(cdat, clen, num) {}
	        Function value: 0: Normal termination, -1: Abnormal termination
	        Parameter:
	            char    *cdat;      Received data
	            int     clen;       Number of characters
	            int     *num;       Number of characters received actually

    ***** Function ***** 
        Reads a specified number of characters from a selected communication system device.
        This function returns control to the calling program after receiving a specified number of characters or when an error (time-out, etc.) has occurred.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Note *****
         Because the LCD draw function stops the receive interrupt, avoid drawing during receive interrupt reception.  (If ignored, framing errors, etc. may occur.)
        The capacity of the BIOS receive buffer is 150 characters, get them before an overflow occurs.
        When high-speed reception has been selected, it may cause the missing receive signals.


    ***** Remarks ***** 
        This function is not effective for communication using 4: Remote control, 5: SIR adapter or 7: Remote control 2.

        Example  Coding for returning the number of received characters

             :
            while(1) {
                if (bi_complreadn(&read,100,rdnum)) {
                    break;          /* Error occurred */
                }
                else {
                    if (bi_complwrite(&read,rdnum,wrnum)) {
                        /* Unsuccessful echo-back */
                        bi_comclr();
                    }
                    else {
                        /* Successful echo-back */
                    }
                }
            }
             :




Lib-Index   API-Index

bi_comclr [O] ... Initializes the receive buffer. 

    ***** Format *****
        int     bi_comclr(void) {}
	        Function value: 0: Normal termination -1: Abnormal termination
	        Parameter:

    ***** Function *****
         Initializes the receive buffer.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Remarks *****
        This function is not effective for communication using 4: Remote control, 5: SIR adapter or 7: Remote control 2.




Lib-Index   API-Index

bi_comrnum [O] ... Gets the number of received characters. 

    ***** Format *****
        int     bi_comrnum(void) {}
	        Function value: -1 Abnormal termination Others: Number of received characters
	        Parameter:

    ***** Function *****
        Gets the number of characters remaining in the receive buffer.
        At abnormal termination, the error details are set in BIOSerr.

    ***** Note ***** 
        This function is not effective for communication using 4: Remote control, 5: SIR adapter or 7: Remote control 2.




--------------------------------------------------------------------------------
4. RTC

Lib-Index   API-Index

bi_tmread ... Reads the time. 

    ***** Format *****
        int     bi_tmread(hour, minute, second) {}
	        Function value: 0: Normal termination -1: Abnormal termination
	        Parameter:
	            char    *hour;      Hour (BCD)
	            char    *minute;    Minute (BCD)
	            char    *second;    Second (BCD)

    ***** Function *****
         Reads the current time (hour, minute and second).
        At abnormal termination, the error details are set in BIOSerr.

    ***** Tips *****
        This time is obtained by directly calling the real-time clock IC.
        This time must be synchronized with the system time of the filer.




Lib-Index   API-Index

bi_tmwrite ... Writes the time. 

    ***** Format *****
        int     bi_tmwrite(hour, minute, second) {}
	        Function value: 0: Normal termination -1: Abnormal termination
	        Parameter:
	            char    hour;       Hour (BCD)
	            char    minute;     Minute (BCD)
	            char    second;     Second (BCD)

    ***** Function ***** 
        Sets the current time (hour, minute and second).
        At abnormal termination, the error details are set in BIOSerr.

    ***** Tips *****
        This time is directly written to the real-time clock IC.
        This time must be synchronized with the system time of the filer.




Lib-Index   API-Index

bi_dtread ... Reads the date. 

    ***** Format *****
        int     bi_dtread(year, month, day) {}
	        Function value: 0: Normal termination -1: Abnormal termination
	        Parameter:
	            char    *year;      Year (BCD)
	            char    *month;     Month (BCD)
	            char    *day;       Day (BCD)

    ***** Function *****
         Reads the current date (year, month and day).
        At abnormal termination, the error details are set in BIOSerr.

    ***** Tips *****
         This time is directly written to the real-time clock IC.
        This time must be synchronized with the system time of the filer. 




Lib-Index   API-Index

bi_dtwrite ... Writes the date. 

    ***** Format *****
        int     bi_dtwrite(year, month, day) {}
	        Function value: 0: Normal termination -1: Abnormal termination
	        Parameter:
	            char    year;       Year (BCD)
	            char    month;      Month (BCD)
	            char    day;        Day (BCD)

    ***** Function *****
         Sets the current date (year, month and day).
        At abnormal termination, the error details are set in BIOSerr.

    ***** Tips ***** 
        This time is directly written to the real-time clock IC.
        This time must be synchronized with the system time of the filer.




--------------------------------------------------------------------------------
5. Timer

Lib-Index   API-Index

bi_tmset ... Sets the timer. 

    ***** Format *****
        int *   bi_tmset(timkind, priority, cnt, func) {}
	        Function value: -1: Abnormal termination (no free timer) Others: Timer ID
	        Parameter:
	            int     timkind;    Timer ID
	                                    0: 1Hz timer
	                                    1: 4Hz timer
	                                    2: 64Hz timer
	            int     priority;   Priority (0-255)
                                        0 is the top priority.
                                        The same priority of timers must not be specified.
                                        When 255 has been specified, the top of free timers is selected.
	            int     cnt;        Timer count 
                                        1Hz timer=count every second
                                        4Hz timer=count every 1/4 second
                                        64Hz timer=count every 1/64 second
	            void    (*func)();  Timer routine address

    ***** Function ***** 
        Calls the func function after a specified time has elapsed.
        Because the timer routine is called as a 1Hz, 64Hz or 4Hz interrupt handler subroutine, it asynchronously operates in parallel with the normal programs.
        For this reason, system calls from the timer routine and some BIOS calls (without the mark [O]) cannot be issued.
        When there is already the same priority, it is overwritten.

    ***** Tips *****
        Usually, specify 255 for priority.
        Timer resources are used as follows.
        Applications can set the timer routines as many as free timers.

                    A   B   C   D
              1Hz   6   1   3   2
              4Hz   6   3   2   1
             64Hz   4   1   2   1

                    A : Number of timers
                    B : OS reservation
                    C : Filer reservation
                    D : Free (Available with applications)



Lib-Index   API-Index

bi_tmdel [O] ... Deletes the timer.  

    ***** Format *****
        int     bi_tmdel(timid) {}
	        Function value: 0: Normal termination Others: Abnormal termination (always terminates normally)
	        Parameter:
	            int     *timid;     Timer ID
                            (Specify an ID obtained as the function value of bi_tmset.)

	***** Note *****
 The timer routine can be temporarily stopped or restarted at any time by using (int*) that can be obtained by bi_tmset().  The timid[0] is a decrement counter used by the system.  The routine to be called is that specified when this counter changes from 1 to 0.  When this area (counter) is already zero, the counter is not decremented, and the timer routine is not called.  In addition, if a non-zero value is set in this area (counter), the counter is decremented from the value.  This function enables the timer function to be turned on or off at very high speed without additional overheads such as BIOS call, etc.

            Example  Setting the timer routine

                /********* Interrupt routine ********/
                void _Interrupt(void) {
                    /* Interrupt handling (this example shows the value of the counter is displayed) */
                    volatile static int cnt=0;  /* Counter */
                    char str[4]={0,0,0,0};

                    str[0]=(cnt/100)%10 +'0';
                    str[1]=(cnt/ 10)%10 +'0';
                    str[2]=(cnt    )%10 +'0';
                    gv_kput(10,10,str,0,0,0);   /* 3-digit display */

                    cnt++;                      /* Count-up */
                }


                /********** Main routine *********/
                 :
                int btn=0;
                int *tm;        /* Timer ID */

                /* Setting the timer 1Hz*2 = every 2 seconds */
                if ((tm=bi_tmset(0,255,2,Interrupt))==-1)
                    return;

                while(btn) {
                    btn=bi_getbtn();    /* Usually, waiting occurs here. */

                    if ((btn&0xFF)==0x02) {
                        /* For example, menu button handling */

                        tm[0]=0;        /* Timer temporary halt */
                        gv_kput(10,10,"PushMenu",0,0,0);
                         :
                        tm[0]=2;        /* Timer restart */
                    }
                }

                /* Timer deletion */
                if (tm!=(int*)-1)
                    bi_tmdel(tm);
                 :




--------------------------------------------------------------------------------
6. Others

Lib-Index   API-Index

bi_reboot [O] ... Reboot 

    ***** Format *****
        void    bi_reboot() {}

    ***** Function ***** 
        Reboots the system.  This function does not return control to the calling program.




Lib-Index   API-Index

bi_buzzinit ... Initializes the buzzer. 

    ***** Format *****
        void    bi_buzzinit(volume, tempo) {}
	        Parameter:
	            int     volume;     Volume 2 (small)- 9 (large)
	            int     tempo;      Tempo

    ***** Function ***** 
        Designates the tempo and volume of the bi_buzzer and bi_melody functions to be called later.




Lib-Index   API-Index

bi_buzzer ... Beeps the buzzer once. 

    ***** Format *****
        int     bi_buzzer( tone, length) {}
	        Function value: 0: Normal termination Others: Abnormal termination (voltage drop)
	        Parameter:
	            unsigned char   tone;   Scale number (0=A1# - 86=C9)
	            unsigned char   length; Musical note length
	                                b3-b0   Musical note length (0=16, 1=1, 2=2,...., 15=15)
	                                b7-b4   Envelope 0000   Pause
	                                                 0011   3/4 note (without envelope)
	                                                 0100   4/4 note (without envelope)
	                                                 Others With envelope

    ***** Function *****
         Sets the frequency (scale number) and beeps the buzzer with the volume specified in bu_buzzinit in the following duration (time) .

                Time = tempo * length / 64 (sec)

        However, tempo must be the value specified in bi_buzzinit.
        This function does not return control to the calling program unless beeping terminates.




Lib-Index   API-Index

bi_melody ... Plays the melody. 

    ***** Format *****
        void        bi_melody( melody ) {}
	        Parameter:
	            unsigned int    *melody;     melody table
                    Pointer for a table containing the musical notes of melodies for which b7-b0 contains the scale numbers (0-86) and b15-b8 the musical note lengths (musical note length + envelope).
                    0xffff must be set at the end.
                    Refer to bi_buzzer for the musical note and musical note length.

    ***** Function ***** 
        Beeps multiple musical notes continuously as a melody.
        This function returns control to the calling program immediately.  To synchronize with the calling program, this function increments a one-word area at the address 0xf27c each time it beeps one musical note and sets this area to 0xfff after playing al musical notes.  In addition, when detecting a voltage drop during a beep, this function sets 0xfffe and stops the beep immediately.  The melody table must be held by the calling program until processing terminates.

        Example
            /*  Buzzer beep subroune    */
            void Beeps(unsigned int *Src)
            {
                volatile int *buzz=(int *)0xf27c;

                bi_canmelody();     /* Refer to the next function "bi_canmelody" */

                while( *buzz!=0xfffe && *buzz!=0xffff );/* Wait until beeping terminates */

                bi_buzzinit(9,1);   /* Initializes the buzzer */
                bi_melody(Src);     /* Plays the melody */
            }

            /* Calling program (for Pipi) */
            void Pipi(void)
            {
                static unsigned int STARTbuzz[]={0x4345,0x0700,0x4345,0xffff};
                Beeps(STARTbuzz);
            }
            /* Calling program (for Boo) */
            void Boo(void)
            {
                static unsigned int STARTbuzz[]={0x4F24,0x4F24,0x0700,0xffff};
                Beeps(STARTbuzz);
            }




Lib-Index   API-Index

bi_canmelody ... Forcibly stops the melody play. 

    ***** Format *****
        void        bi_canmelody() {}

    ***** Function *****
         Forcibly stops the current melody play.  Even after control returns to the calling program, melody play may continue.  To synchronize with actual stop, the contents at the address 0xf27c must be used for confirmation.  In this case, 0xffe (voltage drop) is always set in the address 0xf27c.




Lib-Index   API-Index

bi_cpususp ... Stops the CPU. 

    ***** Format *****
        void        bi_cpususp() {}

    ***** Function *****
         Stops the CPU.




Lib-Index   API-Index

bi_powerread [O]  ... Reads a supply voltage. 

Lib-Index   API-Index

bi_powerread2 [O] ... Reads a supply voltage with a heavy load. 

    ***** Format *****
        int     bi_powerread() {}
        int     bi_powerread2() {}
	        Function value: Voltage (0-255: Values more than 255 and negative values indicate errors.)

    ***** Function *****
         Reads a supply voltage.  (Value obtained from the A/D converter)
        When this function has already been called by the other program, a value of 255 is returned forcibly.
        The bi_powerread2() function sets a dummy heavy load and reads a supply voltage.

    ***** Tips ***** 
        Relation between the A.D values and cell voltage (ambient temperature)
            Cell voltage [V] : 7.0  6.5  6.0  5.5  5.0  4.5  4.0
            A/D value :        169  151  135  118  102   85   70

            Cell voltage [V] : 3.8  3.6  3.5  3.4  3.3  3.2  3.1  3.0 
            A/D value :         63   60   57   55   53   51   50   48 




Lib-Index   API-Index

bi_current ... Reads the current.                          ** Don't use this function usually ** 

    ***** Format *****
        int     bi_current() {}
	        Function value: Current (0-255: Values more than 255 and negative values indicate errors.)

    ***** Function ***** 
        Reads the charging/discharging current.




Lib-Index   API-Index

bi_getpower ... Gets the charging/discharging count value. 

    ***** Format *****
        unsigned long       bi_getpower() {}
	        Function value: Charging/discharging count value

    ***** Function *****
         Subtracts the consumption current for various loads from the value accumulated during charging to obtain the remaining cell capacitance, then returns the value indicating the current cell capacitance.
        The following shows the relation between the remaining cell capacitance (%) and the charging/discharging count value.

        Remaining cell capacitance  Charging/discharging count value
                100%                160000000 (Decimal)
                  0%                 32000000 (Decimal)




Lib-Index   API-Index

bi_setpower ... Sets a charging/discharging count value.            ** Don't use this function usually ** 

    ***** Format *****
        void        bi_setpower(count) {}
	        Function value: Charging/discharging count value
	        Parameter:
	            unsigned long   count;      Charging/discharging value

    ***** Function *****
         Sets a charging/discharging count value.



Lib-Index   API-Index

bi_el ... Lights or lights out the EL. 

    ***** Format *****
        void        bi_el(sec) {}
	        Parameter:
	            int     sec;        Light time (0-20: second)
	                    If 0 is specified, the LE is forcibly lit out.
                        
    ***** Function ***** 
        Lights the EL in a duration specified in sec.  Control returns to the calling program immediately (regardless of the EL light-out time).




Lib-Index   API-Index

bi_27Verror ... Checks the cell voltage. 

    ***** Format *****
        int     bi_27Verror(void) {}
	        Function value: 1=Low voltage detected 0=Low voltage not detected

    ***** Function ***** 
        Checks a low voltage where a heavy load is inhibited.  This voltage (3.9V) is usually managed by BIOS.




Lib-Index   API-Index

bi_setvect [O] ... Sets an interrut vector. 

    ***** Format *****
        void    bi_setvect(ino, func) {}
	        Parameter:
	            int     ino;        Interrupt number
	            void    (*func)();  Handling routine address

    ***** Function ***** 
        Sets an interrupt vector.

    ***** Interrupt number *****
         The numbers 0-19 are for CPU hardware interrupts.
                 0  GROUP0      NMI
                 1  GROUP0      Watchdog timer
                 2  GROUP0      Undefined instruction
                 3  GROUP0      Unused
                 4  GROUP1      1Hz
                 5  GROUP1      Stopwatch (32Hz)
                 6  GROUP1      End of A/D conversion
                 7  GROUP1      Software interrupt
                 8  GROUP2      64Hz
                 9  GROUP2      Stopwatch 1Hz
                10  GROUP2      Unused
                11  GROUP2      Unused
                12  GROUP3      4Hz
                13  GROUP3      Unused
                14  GROUP3      Unused
                15  GROUP3      Unused
                16  GROUP4      Button (key)
                17  GROUP4      Unused
                18  GROUP4      Unused
                19  GROUP4      Receive interrupt
            Interrupts have the following priority in descending order:
            Group0 -> Group4 -> Group3 -> Group2 -> Group1

            The numbers 20-31 are for software interrupts.
                20  Software interrupt  PsDOS call
                21  Software interrupt  Routine for setting or getting vectors
                22  Software interrupt  
                23  Software interrupt  W-BIOS button input (key input)
                24  Software interrupt  W-BIOS disk control
                25  Software interrupt  W-BIOS RS-232C, Ir
                26  Software interrupt  W-BIOS RTC
                27  Software interrupt  
                28  Software interrupt  W-BIOS timer
                29  Software interrupt  W-BIOS others
                30  Software interrupt  
                31  Software interrupt  

        ***** Tips *****
         The following shows an example of definition in the filer initialization routine.
            :
            /* setvect process at initialization                                */
            bi_setvect(1,errVECT);      /*  Watchdog timer                      */
            bi_setvect(2,errVECT);      /*  Undefined instruction               */
            bi_setvect(3,errVECT);      /*  Unused                              */
            bi_setvect(5,errVECT);      /*  Stopwatch (32Hz)                    */
            bi_setvect(7,errVECT);      /*  Software interrupt entry            */
            bi_setvect(9,stw_co);       /*  Stopwatch (1Hz) interrupt setting   */
            bi_setvect(10,errVECT);     /*  Unused                              */
            bi_setvect(11,errVECT);     /*  Unused                              */
            bi_setvect(13,errVECT);     /*  Unused                              */
            bi_setvect(14,errVECT);     /*  Unused                              */
            bi_setvect(15,errVECT);     /*  Unused                              */
            bi_setvect(17,errVECT);     /*  Unused                              */
            :




Lib-Index   API-Index

bi_getvect [O] ... Gets an interrupt vector. 

    ***** Format *****
        void    *bi_getvect(ino) {}
	        Function value: Handling routine address

        Parameter:
            int     ino;        Interrupt number

    ***** Function *****
         Gets the details of the interrupt vector.




Lib-Index   API-Index

bi_sysread ... Reads the system area.          ** Don't use this function usually ** 

    ***** Format *****
        int     bi_sysread(rbuf) {}
	        Function value: 0: Normal termination, -1: Abnormal termination
	        Parameter:
	            void    *rbuf;      Read buffer address

    ***** Function *****
         Reads the contents (512 bytes fixed) of the system area into the buffer.
        At abnormal termination, the error details are set in BIOSerr.




Lib-Index   API-Index

bi_syswrite ... Writes to the system area.          ** Don't use this function usually ** 

    ***** Format *****
        int     bi_syswrite(wbuf) {}
	        Function value: -: Normal termination, -1: Abnormal termination
	        Parameter:
	            void    *wbuf;      Write buffer address

    ***** Function *****
         Writes the contents (512 bytes fixed) of the buffer into the system area of the flash memory, and also updates the contents of SRAM for three kinds of data: low voltage inhibiting a heavy load, accounting and scale.
         At abnormal termination, the error details are set in BIOSerr.

===========================================================================
      Copyright (c) Seiko Instruments Inc. 1998-1999. All rights reserved. 
===========================================================================

l
Lib-Index   API-Index