2003-04-18 16:29:51 +00:00
|
|
|
;****************************************************************************
|
|
|
|
;* *
|
|
|
|
;* ser-kernel.inc *
|
|
|
|
;* *
|
|
|
|
;* Serial communication API *
|
|
|
|
;* *
|
|
|
|
;* *
|
|
|
|
;* *
|
2006-06-04 10:01:33 +00:00
|
|
|
;*(C) 2003-2006, Ullrich von Bassewitz *
|
2021-04-19 14:06:10 +00:00
|
|
|
;* Roemerstrasse 52 *
|
2006-06-04 10:01:33 +00:00
|
|
|
;* D-70794 Filderstadt *
|
|
|
|
;*EMail: uz@cc65.org *
|
2003-04-18 16:29:51 +00:00
|
|
|
;* *
|
|
|
|
;* *
|
|
|
|
;*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. *
|
|
|
|
;* *
|
|
|
|
;****************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2003-12-03 19:57:27 +00:00
|
|
|
; The driver header
|
2003-04-18 16:29:51 +00:00
|
|
|
|
2003-12-03 19:57:27 +00:00
|
|
|
.struct SER_HDR
|
|
|
|
ID .byte 3 ; Contains 0x73, 0x65, 0x72 ("ser")
|
|
|
|
VERSION .byte 1 ; Interface version
|
2013-06-01 09:03:14 +00:00
|
|
|
LIBREF .addr ; Library reference
|
2003-12-12 23:28:58 +00:00
|
|
|
JUMPTAB .struct
|
2018-11-26 20:36:22 +00:00
|
|
|
SER_INSTALL .addr ; SER_INSTALL routine
|
|
|
|
SER_UNINSTALL .addr ; SER_UNINSTALL routine
|
|
|
|
SER_OPEN .addr ; SER_OPEN routine
|
|
|
|
SER_CLOSE .addr ; SER_CLOSE routine
|
|
|
|
SER_GET .addr ; SER_GET routine
|
|
|
|
SER_PUT .addr ; SER_PUT routine
|
|
|
|
SER_STATUS .addr ; SER_STATUS routine
|
|
|
|
SER_IOCTL .addr ; SER_IOCTL routine
|
|
|
|
SER_IRQ .addr ; SER_IRQ routine
|
2003-12-03 19:57:27 +00:00
|
|
|
.endstruct
|
|
|
|
.endstruct
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
|
2003-12-12 23:28:58 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; The SER API version, stored SER_HDR::VERSION
|
|
|
|
|
2013-09-01 07:45:11 +00:00
|
|
|
SER_API_VERSION = $02
|
2003-12-12 23:28:58 +00:00
|
|
|
|
2003-04-18 16:29:51 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2003-12-03 19:57:27 +00:00
|
|
|
; ser_params
|
2003-04-18 16:29:51 +00:00
|
|
|
|
2003-12-03 19:57:27 +00:00
|
|
|
.struct SER_PARAMS
|
|
|
|
BAUDRATE .byte ; Baudrate
|
|
|
|
DATABITS .byte ; Number of data bits
|
|
|
|
STOPBITS .byte ; Number of stop bits
|
|
|
|
PARITY .byte ; Parity setting
|
|
|
|
HANDSHAKE .byte ; Type of handshake to use
|
|
|
|
.endstruct
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; Serial parameters
|
|
|
|
|
|
|
|
; Baudrate
|
|
|
|
SER_BAUD_45_5 = $00
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BAUD_50 = $01
|
2003-04-18 16:29:51 +00:00
|
|
|
SER_BAUD_75 = $02
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BAUD_110 = $03
|
|
|
|
SER_BAUD_134_5 = $04
|
2003-04-18 16:29:51 +00:00
|
|
|
SER_BAUD_150 = $05
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BAUD_300 = $06
|
|
|
|
SER_BAUD_600 = $07
|
|
|
|
SER_BAUD_1200 = $08
|
2003-04-18 16:29:51 +00:00
|
|
|
SER_BAUD_1800 = $09
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BAUD_2400 = $0A
|
2003-08-15 21:22:58 +00:00
|
|
|
SER_BAUD_3600 = $0B
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BAUD_4800 = $0C
|
2003-08-15 21:22:58 +00:00
|
|
|
SER_BAUD_7200 = $0D
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BAUD_9600 = $0E
|
|
|
|
SER_BAUD_19200 = $0F
|
|
|
|
SER_BAUD_38400 = $10
|
|
|
|
SER_BAUD_57600 = $11
|
|
|
|
SER_BAUD_115200 = $12
|
|
|
|
SER_BAUD_230400 = $13
|
|
|
|
SER_BAUD_31250 = $14
|
|
|
|
SER_BAUD_62500 = $15
|
2013-12-06 19:13:55 +00:00
|
|
|
SER_BAUD_56_875 = $16
|
2003-08-22 11:23:48 +00:00
|
|
|
|
2003-04-18 16:29:51 +00:00
|
|
|
; Data bit settings
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_BITS_5 = $00
|
|
|
|
SER_BITS_6 = $01
|
|
|
|
SER_BITS_7 = $02
|
|
|
|
SER_BITS_8 = $03
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
; Stop bit settings
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_STOP_1 = $00
|
|
|
|
SER_STOP_2 = $01
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
; Parity
|
2013-05-09 11:56:54 +00:00
|
|
|
SER_PAR_NONE = $00
|
|
|
|
SER_PAR_ODD = $01
|
|
|
|
SER_PAR_EVEN = $02
|
|
|
|
SER_PAR_MARK = $03
|
|
|
|
SER_PAR_SPACE = $04
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
; Handshake
|
|
|
|
SER_HS_NONE = $00 ; No handshake
|
|
|
|
SER_HS_HW = $01 ; Hardware (RTS/CTS) handshake
|
|
|
|
SER_HS_SW = $02 ; Software handshake
|
|
|
|
|
2012-11-01 20:43:28 +00:00
|
|
|
; Bit masks to mask out things from the status returned by ser_status
|
2013-05-09 11:56:54 +00:00
|
|
|
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
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; Variables
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.global _ser_drv ; Pointer to driver
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; Driver entry points
|
|
|
|
|
|
|
|
.global ser_install
|
|
|
|
.global ser_uninstall
|
2003-08-22 11:23:48 +00:00
|
|
|
.global ser_open
|
|
|
|
.global ser_close
|
2003-04-18 16:29:51 +00:00
|
|
|
.global ser_get
|
|
|
|
.global ser_put
|
|
|
|
.global ser_status
|
2003-04-20 22:49:32 +00:00
|
|
|
.global ser_ioctl
|
2013-05-09 11:56:54 +00:00
|
|
|
.global ser_irq
|
2003-04-18 16:29:51 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2006-06-04 10:01:33 +00:00
|
|
|
; C callable functions
|
2003-04-18 16:29:51 +00:00
|
|
|
|
2009-12-13 00:13:14 +00:00
|
|
|
.global _ser_load_driver
|
2003-04-18 16:29:51 +00:00
|
|
|
.global _ser_unload
|
|
|
|
.global _ser_install
|
|
|
|
.global _ser_uninstall
|
2003-08-22 11:23:48 +00:00
|
|
|
.global _ser_open
|
|
|
|
.global _ser_close
|
2003-04-18 16:29:51 +00:00
|
|
|
.global _ser_get
|
|
|
|
.global _ser_put
|
|
|
|
.global _ser_status
|
2003-04-20 22:49:32 +00:00
|
|
|
.global _ser_ioctl
|
2003-04-18 16:29:51 +00:00
|
|
|
|
2006-06-04 10:01:33 +00:00
|
|
|
.global _ser_clear_ptr
|