@@ -68,23 +68,26 @@ lcd_Init:
68
68
ld (.refcount) , hl
69
69
ret c
70
70
; Initialize if the old refcount was 0
71
- ld hl , (( 9 - 1 ) shl 16 ) or ( 2 - 1 )
72
- ld (ti.mpSpiCtrl1) , hl
73
- ; Only fully initialize once per program invocation
71
+ ; Always fully initialize on the first call per program invocation
74
72
ld hl , .fullinit
75
73
srl (hl)
76
- jr nc , .fastinit
74
+ jr c , .checkPython
75
+ ; Additionally, fully initialize if an APD reset the SPI state to something other than LCD
76
+ ld a , (ti.mpSpiCtrl0)
77
+ cp a , ti.bmSpiMasterMono or ti.bmSpiClkPhase or ti.bmSpiClkPolarity
78
+ jr z , .fastinit
79
+ .checkPython:
77
80
; Check certificate for Python model
78
81
ld de , $ 0330
79
82
call ti.FindFirstCertField
80
- jr nz , .magicinit
83
+ jr nz , .notPython
81
84
call ti.GetFieldSizeFromType
82
85
ld de , $ 0430
83
86
call ti.FindField
87
+ jr nz , .notPython
84
88
; Reinitializes Python hardware, probably (routine available on rev M+ boot code)
85
89
; Without this, LCD SPI transfers start failing a short time after init
86
- call z , $ 000654
87
- .magicinit:
90
+ call $ 000654
88
91
; Magic SPI initialization sequence to work on Python models
89
92
ld de , ti.spiSpiFrFmt or ti.bmSpiFlash or ti.bmSpiFsPolarity or ti.bmSpiMasterMono
90
93
. loop :
@@ -100,12 +103,15 @@ lcd_Init:
100
103
bit ti.bSpiClkPolarity , e
101
104
ld e , ti.bmSpiFsPolarity or ti.bmSpiMasterMono or ti.bmSpiClkPhase or ti.bmSpiClkPolarity
102
105
jr z , . loop
103
- .fastinit:
104
106
ld hl , $ 21
105
107
ld (ti.mpSpiIntCtrl) , hl
106
- ld l , ti.bmSpiChipEn
107
- assert ti.bmSpiTxEn = (ti.bmSpiChipEn shl 8 )
108
- ld h , l
108
+ .notPython:
109
+ ld a , ti.bmSpiMasterMono or ti.bmSpiClkPhase or ti.bmSpiClkPolarity
110
+ ld (ti.mpSpiCtrl0) , a
111
+ .fastinit:
112
+ ld hl , (( 9 - 1 ) shl 16 ) or ( 2 - 1 )
113
+ ld (ti.mpSpiCtrl1) , hl
114
+ ld hl , ti.bmSpiTxEn or ti.bmSpiTxClr or ti.bmSpiRxClr or ti.bmSpiChipEn
109
115
ld (ti.mpSpiCtrl2) , hl
110
116
ret
111
117
0 commit comments