]> git.sur5r.net Git - cc65/commitdiff
Working on new serial API
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 18 Apr 2003 16:29:51 +0000 (16:29 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 18 Apr 2003 16:29:51 +0000 (16:29 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2069 b7a2c559-68d2-44c3-8de9-860c34a00d81

14 files changed:
asminc/ser-error.inc [new file with mode: 0644]
asminc/ser-kernel.inc [new file with mode: 0644]
include/serial.h
libsrc/serial/.cvsignore [new file with mode: 0644]
libsrc/serial/Makefile
libsrc/serial/ser-kernel.s
libsrc/serial/ser_get.s [new file with mode: 0644]
libsrc/serial/ser_load.c
libsrc/serial/ser_params.s [new file with mode: 0644]
libsrc/serial/ser_pause.s [new file with mode: 0644]
libsrc/serial/ser_put.s [new file with mode: 0644]
libsrc/serial/ser_status.s [new file with mode: 0644]
libsrc/serial/ser_unload.s
libsrc/serial/ser_unpause.s [new file with mode: 0644]

diff --git a/asminc/ser-error.inc b/asminc/ser-error.inc
new file mode 100644 (file)
index 0000000..736846a
--- /dev/null
@@ -0,0 +1,50 @@
+;****************************************************************************
+;*                                                                          *
+;*                              ser-error.inc                               *
+;*                                                                          *
+;*                        Serial communication API                          *
+;*                                                                          *
+;*                                                                          *
+;*                                                                          *
+;*(C) 2003      Ullrich von Bassewitz                                       *
+;*              Römerstrasse 52                                             *
+;*              D-70794 Filderstadt                                         *
+;*EMail:        uz@cc65.org                                                 *
+;*                                                                          *
+;*                                                                          *
+;*This software is provided 'as-is', without any expressed or implied       *
+;*warranty.  In no event will the authors be held liable for any damages    *
+;*arising from the use of this software.                                    *
+;*                                                                          *
+;*Permission is granted to anyone to use this software for any purpose,     *
+;*including commercial applications, and to alter it and redistribute it    *
+;*freely, subject to the following restrictions:                            *
+;*                                                                          *
+;*1. The origin of this software must not be misrepresented; you must not   *
+;*   claim that you wrote the original software. If you use this software   *
+;*   in a product, an acknowledgment in the product documentation would be  *
+;*   appreciated but is not required.                                       *
+;*2. Altered source versions must be plainly marked as such, and must not   *
+;*   be misrepresented as being the original software.                      *
+;*3. This notice may not be removed or altered from any source              *
+;*   distribution.                                                          *
+;*                                                                          *
+;****************************************************************************
+
+
+
+;------------------------------------------------------------------------------
+; Error codes
+
+SER_ERR_OK                     =       $00     ; Not an error - relax
+SER_ERR_NO_DRIVER       =       $01     ; No driver available
+SER_ERR_CANNOT_LOAD     =       $02     ; Error loading driver
+SER_ERR_INV_DRIVER      =       $03     ; Invalid driver
+SER_ERR_NO_DEVICE       =       $04     ; Device (hardware) not found
+SER_ERR_BAUD_UNAVAIL           =       $05     ; Baud rate not available
+SER_ERR_NO_DATA                =       $06     ; Nothing to read
+SER_ERR_OVERFLOW               =       $07     ; No room in send buffer
+SER_ERR_INIT_FAILED     =       $08    ; Initialization failed
+
+
+
diff --git a/asminc/ser-kernel.inc b/asminc/ser-kernel.inc
new file mode 100644 (file)
index 0000000..66ce8ae
--- /dev/null
@@ -0,0 +1,148 @@
+;****************************************************************************
+;*                                                                          *
+;*                              ser-kernel.inc                              *
+;*                                                                          *
+;*                        Serial communication API                          *
+;*                                                                          *
+;*                                                                          *
+;*                                                                          *
+;*(C) 2003      Ullrich von Bassewitz                                       *
+;*              Römerstrasse 52                                             *
+;*              D-70794 Filderstadt                                         *
+;*EMail:        uz@cc65.org                                                 *
+;*                                                                          *
+;*                                                                          *
+;*This software is provided 'as-is', without any expressed or implied       *
+;*warranty.  In no event will the authors be held liable for any damages    *
+;*arising from the use of this software.                                    *
+;*                                                                          *
+;*Permission is granted to anyone to use this software for any purpose,     *
+;*including commercial applications, and to alter it and redistribute it    *
+;*freely, subject to the following restrictions:                            *
+;*                                                                          *
+;*1. The origin of this software must not be misrepresented; you must not   *
+;*   claim that you wrote the original software. If you use this software   *
+;*   in a product, an acknowledgment in the product documentation would be  *
+;*   appreciated but is not required.                                       *
+;*2. Altered source versions must be plainly marked as such, and must not   *
+;*   be misrepresented as being the original software.                      *
+;*3. This notice may not be removed or altered from any source              *
+;*   distribution.                                                          *
+;*                                                                          *
+;****************************************************************************
+
+
+
+;------------------------------------------------------------------------------
+; Offsets into the driver header
+
+SER_HDR_ID              = 0             ; Contains 0x73, 0x65, 0x72 ("ser")
+SER_HDR_VERSION         = 3             ; Interface version
+
+SER_HDR_JUMPTAB         = 4
+SER_HDR_INSTALL         = SER_HDR_JUMPTAB+0     ; INSTALL routine
+SER_HDR_UNINSTALL       = SER_HDR_JUMPTAB+2     ; UNINSTALL routine
+SER_HDR_PARAMS          = SER_HDR_JUMPTAB+4     ; PARAMS routine
+SER_HDR_GET             = SER_HDR_JUMPTAB+6     ; GET routine
+SER_HDR_PUT             = SER_HDR_JUMPTAB+8     ; PUT routine
+SER_HDR_PAUSE           = SER_HDR_JUMPTAB+10    ; PAUSE routine
+SER_HDR_UNPAUSE         = SER_HDR_JUMPTAB+12    ; UNPAUSE routine
+SER_HDR_STATUS          = SER_HDR_JUMPTAB+14    ; STATUS routine
+
+SER_HDR_JUMPCOUNT       = 8                     ; Number of jump vectors
+
+;------------------------------------------------------------------------------
+; Offsets into the struct passed to ser_params
+
+SER_PARAMS_BAUDRATE     =       0       ; Baudrate
+SER_PARAMS_DATABITS     =       1       ; Number of data bits
+SER_PARAMS_STOPBITS     =       2       ; Number of stop bits
+SER_PARAMS_PARITY       =       3       ; Parity setting
+SER_PARAMS_HANDSHAKE    =       4       ; Type of handshake to use
+
+;------------------------------------------------------------------------------
+; Serial parameters
+
+; Baudrate
+SER_BAUD_45_5           =       $00
+SER_BAUD_50                    =       $01
+SER_BAUD_75             =       $02
+SER_BAUD_110                   =       $03
+SER_BAUD_134_5                 =       $04
+SER_BAUD_150            =       $05
+SER_BAUD_300                   =       $06
+SER_BAUD_600                   =       $07
+SER_BAUD_1200                  =       $08
+SER_BAUD_1800           =       $09
+SER_BAUD_2400                  =       $0A
+SER_BAUD_4800                  =       $0B
+SER_BAUD_9600                  =       $0C
+SER_BAUD_19200                 =       $0D
+SER_BAUD_38400                 =       $0E
+SER_BAUD_57600                 =       $0F
+SER_BAUD_115200                =       $10
+SER_BAUD_230400                =       $11
+
+; Data bit settings
+SER_BITS_5                     =       $00
+SER_BITS_6                     =       $01
+SER_BITS_7                     =       $02
+SER_BITS_8                     =       $03
+
+; Stop bit settings
+SER_STOP_1                     =       $00
+SER_STOP_2                     =       $01
+
+; Parity
+SER_PAR_NONE                   =       $00
+SER_PAR_ODD                    =       $01
+SER_PAR_EVEN                   =       $02
+SER_PAR_MARK                   =       $03
+SER_PAR_SPACE                  =       $04
+
+; Handshake
+SER_HS_NONE             =       $00    ; No handshake
+SER_HS_HW               =       $01    ; Hardware (RTS/CTS) handshake
+SER_HS_SW               =       $02    ; Software handshake
+
+; Bit masks to mask out things from the status returned by rs232_status
+SER_STATUS_PE                  =       $01     ; Parity error
+SER_STATUS_FE                  =       $02     ; Framing error
+SER_STATUS_OE           =       $04    ; Overrun error
+SER_STATUS_DCD                 =       $20     ; NOT data carrier detect
+SER_STATUS_DSR                 =       $40     ; NOT data set ready
+
+;------------------------------------------------------------------------------
+; Variables
+
+               .global _ser_drv                         ; Pointer to driver
+
+;------------------------------------------------------------------------------
+; Driver entry points
+
+        .global ser_install
+        .global ser_uninstall
+        .global ser_params
+        .global ser_get
+        .global ser_put
+        .global ser_pause
+        .global ser_unpause
+        .global ser_status
+
+
+
+;------------------------------------------------------------------------------
+; ASM functions
+
+        .global _ser_unload
+        .global _ser_install
+        .global _ser_uninstall
+        .global _ser_params
+        .global _ser_get
+        .global _ser_put
+        .global _ser_pause
+        .global _ser_unpause
+        .global _ser_status
+
+
+
index 910c92f0bc59476d2603cb3cb826826d83e5bcec..8ccb5ac381c8e22fc2f1d1b267d993086aaf829d 100644 (file)
@@ -154,7 +154,7 @@ unsigned char __fastcall__ ser_pause (void);
 unsigned char __fastcall__ ser_unpause (void);
 /* Re-enable interrupts and release flow control */
 
-unsigned char __fastcall__ rs232_status (unsigned char* status);
+unsigned char __fastcall__ ser_status (unsigned char* status);
 /* Return the serial port status. */
 
 
diff --git a/libsrc/serial/.cvsignore b/libsrc/serial/.cvsignore
new file mode 100644 (file)
index 0000000..c81f22f
--- /dev/null
@@ -0,0 +1 @@
+ser_load.s
index ab723cf151cf6d8e370dd9f26581df40b25fc397..798dc101210576b0c23928da7b91d8395be97999 100644 (file)
 C_OBJS =        ser_load.o
 
 S_OBJS =               ser-kernel.o    \
-               ser_unload.o
+                ser_get.o       \
+                ser_params.o    \
+                ser_pause.o     \
+                ser_put.o       \
+                ser_status.o    \
+               ser_unload.o    \
+                ser_unpause.o
 
 
 #--------------------------------------------------------------------------
index a1ac462a8f778f89dbcbc9fa0e6e93b7b1760bd1..69c45df5e279b3bb28adeb917815c65ff4674ed0 100644 (file)
@@ -24,6 +24,12 @@ _ser_drv:       .res    2                    ; Pointer to driver
 ser_vectors:
 ser_install:           jmp     return0
 ser_uninstall:         jmp     return0
+ser_params:     jmp     return0
+ser_get:        jmp     return0
+ser_put:        jmp     return0
+ser_pause:      jmp     return0
+ser_unpause:    jmp     return0
+ser_status:     jmp     return0
 
 ; Driver header signature
 .rodata
diff --git a/libsrc/serial/ser_get.s b/libsrc/serial/ser_get.s
new file mode 100644 (file)
index 0000000..dccd920
--- /dev/null
@@ -0,0 +1,25 @@
+;
+; Ullrich von Bassewitz, 2003-04-18
+;
+; unsigned char __fastcall__ ser_get (char* b);
+; /* Get a character from the serial port. If no characters are available, the
+;  * function will return SER_ERR_NO_DATA, so this is not a fatal error.
+;  */
+
+
+        .importzp       ptr1
+
+        .include        "ser-kernel.inc"
+
+
+.proc   _ser_get
+
+        sta     ptr1
+        stx     ptr1+1                  ; Save pointer to char
+        jmp     ser_get                 ; Call the driver
+
+.endproc
+
+
+
+
index 580f826fe365e0980b641164fe377dcde96ce867..692a9cde379478bb4b7397fd4f22bbdde7c46ec6 100644 (file)
 #include <string.h>
 #include <fcntl.h>
 #include <modload.h>
-#include <ser.h>
-#include <ser/ser-kernel.h>
+#include <serial.h>
+
+
+
+/*****************************************************************************/
+/*                                          Data                                    */
+/*****************************************************************************/
+
+
+
+/* Pointer to serial driver, exported from ser-kernel.s */
+extern void* ser_drv;
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
 
 
 
@@ -79,4 +95,3 @@ unsigned char __fastcall__ ser_load_driver (const char* name)
 
 
 
-              
diff --git a/libsrc/serial/ser_params.s b/libsrc/serial/ser_params.s
new file mode 100644 (file)
index 0000000..58cf35e
--- /dev/null
@@ -0,0 +1,24 @@
+;
+; Ullrich von Bassewitz, 2003-04-18
+;
+; unsigned char __fastcall__ ser_params (const struct ser_params* params);
+; /* Set the port parameters. This will also enable the port. */
+
+
+        .importzp       ptr1
+
+        .include        "ser-kernel.inc"
+
+
+
+.proc   _ser_params
+
+        sta     ptr1
+        stx     ptr1+1                  ; Save pointer to params
+        jmp     ser_params              ; Call the driver
+
+.endproc
+
+
+
+
diff --git a/libsrc/serial/ser_pause.s b/libsrc/serial/ser_pause.s
new file mode 100644 (file)
index 0000000..c77d0ac
--- /dev/null
@@ -0,0 +1,12 @@
+;
+; Ullrich von Bassewitz, 2003-04-18
+;
+; unsigned char __fastcall__ ser_pause (void);
+; /* Assert flow control and disable interrupts. */
+
+
+
+        .include        "ser-kernel.inc"
+
+        _ser_pause      = ser_pause
+
diff --git a/libsrc/serial/ser_put.s b/libsrc/serial/ser_put.s
new file mode 100644 (file)
index 0000000..7bbdbde
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; Ullrich von Bassewitz, 2003-04-18
+;
+; unsigned char __fastcall__ ser_put (char b);
+; /* Send a character via the serial port. There is a transmit buffer, but
+;  * transmitting is not done via interrupt. The function returns
+;  * SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
+;  */
+
+
+        .include        "ser-kernel.inc"
+
+        _ser_put        = ser_put
+
diff --git a/libsrc/serial/ser_status.s b/libsrc/serial/ser_status.s
new file mode 100644 (file)
index 0000000..ac56daa
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 2003-04-18
+;
+; unsigned char __fastcall__ ser_status (unsigned char* status);
+; /* Return the serial port status. */
+
+
+        .importzp       ptr1
+
+        .include        "ser-kernel.inc"
+
+
+.proc   _ser_status
+
+        sta     ptr1
+        stx     ptr1+1                  ; Save pointer to status
+        jmp     ser_status              ; Call the driver
+
+.endproc
+
+
index 6dbad90cd0ab2033ab98a0f09b692d616a1d95a3..64ffb99bc77b441433c5acf0a463d0547ef884ff 100644 (file)
@@ -11,6 +11,7 @@
         .include        "ser-error.inc"
         .include        "modload.inc"
 
+
 _ser_unload:
        lda     _ser_drv
        ora     _ser_drv+1
diff --git a/libsrc/serial/ser_unpause.s b/libsrc/serial/ser_unpause.s
new file mode 100644 (file)
index 0000000..31ad422
--- /dev/null
@@ -0,0 +1,11 @@
+;
+; Ullrich von Bassewitz, 2003-04-18
+;
+; unsigned char __fastcall__ ser_unpause (void);
+; /* Re-enable interrupts and release flow control */
+
+
+        .include        "ser-kernel.inc"
+
+        _ser_unpause    = ser_unpause
+