?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.     MODULE Uart
  2. UART_RxD  equ #143B       ; Also used to set the baudrate
  3. UART_TxD  equ #133B       ; Also reads status
  4. UART_SetBaud equ UART_RxD ; Sets baudrate
  5. UART_GetStatus equ UART_TxD
  6.  
  7. UART_TX_BUSY       equ %00000010
  8. UART_RX_DATA_READY equ %00000001
  9. UART_FIFO_FULL     equ %00000100
  10.  
  11. init:
  12.     ld bc, #703B, a, 5 : out (c), a
  13.     inc b
  14.     ld a, 1 : out (c), a
  15.     ret
  16.  
  17. read:
  18.     ld bc, UART_GetStatus
  19. .wait
  20.     in a, (c)
  21.     rrca : jr nc, .wait
  22.     ld bc, UART_RxD
  23.     in a, (c)
  24.     ret
  25.  
  26. ; Write single byte to UART
  27. ; A - byte to write
  28. ; BC will be wasted
  29. write:    
  30.     ld d, a
  31.     ld bc, UART_GetStatus
  32. .wait  
  33.     in a, (c) : and UART_TX_BUSY : jr nz, .wait
  34.     out (c), d
  35.     ret
  36.  
  37.     ENDMODULE