Difference between revisions of "84PCE:Ports:D000"

From WikiTI
Jump to: navigation, search
(Add closer matching datasheet for the LCD controller)
(Add more descriptions to SPI controller registers)
Line 8: Line 8:
  
 
This appears to be an FTSSP010 or compatible SPI controller that interfaces with the LCD.  The command set seems to closely match the Sitronix ST7789 family [https://www.rhydolabz.com/documents/33/ST7789.pdf].
 
This appears to be an FTSSP010 or compatible SPI controller that interfaces with the LCD.  The command set seems to closely match the Sitronix ST7789 family [https://www.rhydolabz.com/documents/33/ST7789.pdf].
 +
 +
Note that the SPI controller may also be configured to interface with the ARM coprocessor on Python models, via some ports in the 00xx range. The state of this configuration should be considered unknown when starting a program in TI-OS. In order to reliably use the LCD interface, the _boot_InitializeHardware routine should be called at the start of a program to select the LCD interface and reset its configuration to the default.
  
  
Line 24: Line 26:
 
|0000182B
 
|0000182B
 
|007FFFFF
 
|007FFFFF
|CR1: Boot code initializes to 02000B. Bits 0-15 are clock divider - 1, bits 16-23 are data length - 1, and bits 24-31 are padding length.
+
|CR1: Boot code initializes to 02000B. Bits 0-15 are clock divider - 1, bits 16-23 are data length - 1, and bits 24-31 are padding length.<br/>Base clock is likely 12 MHz (unconfirmed whether this changes with CPU speed).<br/>Sending with a clock divider of 1 seems to be within the LCD controller specs, but receiving may require a larger divider.
 
|-
 
|-
 
|D008<br/>F80008
 
|D008<br/>F80008
 
|0002000B
 
|0002000B
 
|00000F8F
 
|00000F8F
|CR2: Boot code initializes to 010C.<br/>Bit 0 is set to transfer data.<br/>Bit 7 is set/reset for reading/writing.
+
|CR2: Boot code initializes to 010C.<br/>Bit 0 is set to transfer data and activate the SPI chip select signal.<br/>Writing a 1 to Bit 2 clears the receive FIFO and writing a 1 to Bit 3 clears the send FIFO. Writing a 1 to Bit 6 resets the SPI controller.<br/>Bit 7 is set to enable receiving, Bit 8 is set to enable sending.
 
|-
 
|-
 
|D00C<br/>F8000C
 
|D00C<br/>F8000C
 
|
 
|
 
|000007F6
 
|000007F6
|Status bits.<br/>Bit 2 is set if data is being sent or received and bits 12-15 are the number of bits queued.<br/>Boot code waits for bits 2 and 12-15 to be 0 before/after reading/writing.
+
|Status bits.<br/>Bit 0 is set if the receive FIFO is full, and Bit 1 is set if the send FIFO is <i>not</i> full (can accept more writes).<br/>Bit 2 is set if data is being sent or received and bits 12-15 are the number of queued FIFO entries.<br/>Boot code waits for bits 2 and 12-15 to be 0 before/after reading/writing.
 
|-
 
|-
 
|D010<br/>F80010
 
|D010<br/>F80010
Line 49: Line 51:
 
|
 
|
 
|
 
|
|FIFO in/out.
+
|FIFO in/out. Supports up to a 32-bit data length according to spec, but the eZ80 can only read/write up to 8 bits per FIFO entry.
 
|-
 
|-
 
|D01C<br/>F8001C
 
|D01C<br/>F8001C
Line 64: Line 66:
 
|0E0F0F1F
 
|0E0F0F1F
 
|
 
|
|Features (read-only): 32-bit data width, 16-bit FIFOs, list of extra protocols supported.
+
|Features (read-only): 32-bit data width, 16-entry send/receive FIFOs, list of extra protocols supported.
 
|}
 
|}
  

Revision as of 11:37, 17 March 2022

Synopsis

Port Number: D000

Memory-mapped Address: F80000

Function: LCD Interface

This appears to be an FTSSP010 or compatible SPI controller that interfaces with the LCD. The command set seems to closely match the Sitronix ST7789 family [1].

Note that the SPI controller may also be configured to interface with the ARM coprocessor on Python models, via some ports in the 00xx range. The state of this configuration should be considered unknown when starting a program in TI-OS. In order to reliably use the LCD interface, the _boot_InitializeHardware routine should be called at the start of a program to select the LCD interface and reset its configuration to the default.


Port    Default    Bits    Information   
D000
F80000
0000F38C CR0: Boot code writes 180B/09 before/after turning on/off the lcd.
D004
F80004
0000182B 007FFFFF CR1: Boot code initializes to 02000B. Bits 0-15 are clock divider - 1, bits 16-23 are data length - 1, and bits 24-31 are padding length.
Base clock is likely 12 MHz (unconfirmed whether this changes with CPU speed).
Sending with a clock divider of 1 seems to be within the LCD controller specs, but receiving may require a larger divider.
D008
F80008
0002000B 00000F8F CR2: Boot code initializes to 010C.
Bit 0 is set to transfer data and activate the SPI chip select signal.
Writing a 1 to Bit 2 clears the receive FIFO and writing a 1 to Bit 3 clears the send FIFO. Writing a 1 to Bit 6 resets the SPI controller.
Bit 7 is set to enable receiving, Bit 8 is set to enable sending.
D00C
F8000C
000007F6 Status bits.
Bit 0 is set if the receive FIFO is full, and Bit 1 is set if the send FIFO is not full (can accept more writes).
Bit 2 is set if data is being sent or received and bits 12-15 are the number of queued FIFO entries.
Boot code waits for bits 2 and 12-15 to be 0 before/after reading/writing.
D010
F80010
00002100 Interrupt control.
D014
F80014
00000008 Interrupt status.
D018
F80018
FIFO in/out. Supports up to a 32-bit data length according to spec, but the eZ80 can only read/write up to 8 bits per FIFO entry.
D01C
F8001C
0E0F0F1F Inside reserved range. Appears to be a copy of the feature register at D064.
D060
F80060
00012100 Revision (read-only)
D064
F80064
0E0F0F1F Features (read-only): 32-bit data width, 16-entry send/receive FIFOs, list of extra protocols supported.

Known Commands

Hex
Defaults
Command Details
01 Software Reset
10
10
Enable Sleep Mode Turns pixels black, low power mode?
11
11
Disable Sleep Mode
12 Enable Partial Mode Resets vertical scrolling start to 0.
13 Disable Partial Mode Also disables vertical scrolling mode and resets vertical scrolling start to 0.
20 Uninvert Colors
21 Invert Colors
26 <8:GC>
26 00
26 02
Set Gamma Selects between 4 preset gamma curves: Valid values are 1, 2, 4, 8, invalid values appear to use 1.
28 Turn Off Display Turns all pixels white.
29
29
Turn On Display Restore GRAM pixels.
2A <BE16:StartCol> <BE16:EndCol>
2A 0000 013F
Set Window Columns Set the pixel update window from StartCol to EndCol inclusive.
2B <BE16:StartLine> <BE16:EndRow>
2B 0000 00EF
Set Window Rows Set the pixel update window from StartRow to EndRow inclusive.
30 <BE16:StartRow> <BE16:EndRow> Set Partial Area Rows Only displays from StartRow to EndRow inclusive, other lines white.
33 <BE16:TopArea> <BE16:ScrollArea> <BE16:BottomArea> Vertical Scrolling Definition TopArea/BottomArea are static (non-scrolling) line counts before and after the ScrollArea whose value is ignored.
36 <8:MAC>
36 08
Memory Address Control Bit 2: Horizontal Refresh Order
Bit 3: BGR Order
Bit 4: Vertical Refresh Order
Bit 5: Column Major Update
Bit 6: Column Update Order
Bit 7: Row Update Order
37 <BE16:VSP> Vertical Scrolling Start Position First line of ScrollArea starts at this GRAM line.
38 Disable Idle Mode Restore 18bpp mode.
39 Enable Idle Mode 3bpp 8 color mode (only uses msb of each color component).
3A ?
3A 66
Interface Pixel Format Upper and lower nibbles are modes for the two interfaces: 3 is 12bpp, 5 is 16bpp, 6 is 18bpp (msb is ignored, invalid uses 18bpp).
B0 ? ?
B0 11 F0
Interface Control First Param:
Bit 0: Use lcd controller clocks instead of internal clocks.
Bit 4: Get GRAM data from lcd controller instead of spi interface.
Bit 7: Bypass GRAM and output directly to lcd.
Second Param:
Polarity of clocks?
B1 ? ? ?
B1 01 05 14
B1 01 15 14
Unknown?
B2 ? ? ? ? ?
B2 0C 0C 00 33 33
Unknown?
B7 ?
B7 35
Unknown?
BB ?
BB 17
BB 1B
Unknown?
C0 ?
C0 2C
C0 22
Unknown?
C2 ?
C2 01
Unknown?
C3 ?
C3 03
C3 15
Unknown?
C4 ?
C4 20
Unknown?
C6 ?
C6 0F
Unknown?
D0 ? ?
D0 AF A1
Unknown?
D2 ?
D2 00
Unknown?
DC Unknown? One parameter "read" and checked if equal to 0x35, but reading doesn't appear to work in the first place...
E0 ? ? ? ? ? ? ? ? ? ? ? ? ? ?
E0 D0 00 00 10 0F 1A 2D 54 3F 3B 18 17 13 17
E0 D0 00 00 10 0F 1A 2D 54 3F 3B 18 17 13 17
Positive Gamma Correction Definitely affects gamma, parameters unknown and don't match docs.
E1 ? ? ? ? ? ? ? ? ? ? ? ? ? ?
E1 D0 00 00 10 0F 09 2B 43 40 3B 18 17 13 17
E1 D0 00 00 10 0F 09 2B 43 40 3B 18 17 13 17
Negative Gamma Correction Definitely affects gamma, parameters unknown and don't match docs.
E9 ? ? ?
E9 08 08 08
Unknown?
EB Something!
F0 Gamma?
F1 Gamma?
F2 Gamma?

Example

Sending

 ld a,036h ; Flips the lcd horizontally, vertically, and swaps the b and r components
 call spiCmd
 ld a,0C0h
 call spiParam

 ld a,002h ; Resetting the lcd on exit
 call spiCmd
 jp boot_InitializeHardware

; Input: A = parameter
spiParam:
 scf ; First bit is set for data
 .db 030h ; jr nc,? ; skips over one byte
; Input: A = command
spiCmd:
 or a,a ; First bit is clear for commands
 ld hl,0F80818h
 call spiWrite
 ld l,h
 ld (hl),001h
spiWait:
 ld l,00Dh
spiWait1:
 ld a,(hl)
 and a,0F0h
 jr nz,spiWait1
 dec l
spiWait2:
 bit 2,(hl)
 jr nz,spiWait2
 ld l,h
 ld (hl),a
 ret
spiWrite:
 ld b,3
spiWriteLoop:
 rla
 rla
 rla
 ld (hl),a ; send 3 bits
 djnz spiWriteLoop
 ret

Receiving

This does not appear to work, always returning 0 on the calcs I've tested, due to either a TI bug or hardware issue.

; Input: A = command
; Ouput: A = data
spiRead:
 ld hl,0F80808
 ld (hl),00Ch
 ld l,018h
 or a,a
 call spiWrite
 xor a,a ; not sure what this is for
 call spiWrite
 ld l,009h
 ld (hl),001h
 dec l
 ld (hl),081h
 call spiWait
 ld l,$18
 ld a,(hl) ; dummy read
 ld a,(hl)
 ld a,(hl) ; Why is there no wait after dummy read?
 ld a,(hl)
 rla
 rla
 rla
 rla
 rla
 and a,0E0h
 ld c,a
 ld a,(hl)
 rla
 rla
 and a,01Ch
 or a,c
 ld c,a
 ld a,(hl)
 rra ; why are we throwing away the lsb instead of the msb
 and a,003h
 or a,c
 ret