Skip to content

Commit

Permalink
Fixed case sensitive identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Aug 7, 2021
1 parent e19ec3b commit 4ef5539
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 38 deletions.
6 changes: 3 additions & 3 deletions com.serial.spin
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PUB StartRxTx(rxpin, txpin, mode, baudrate) : okay
Returns : True (non-zero) if cog started, or False (0) if no cog is available.
}}

stop
Stop
longfill(@rx_head, 0, 4)
longmove(@rx_pin, @rxpin, 3)
bit_ticks := clkfreq / baudrate
Expand All @@ -87,14 +87,14 @@ PUB Count
}}

result := rx_head - rx_tail
result -= BUFFER_LENGTH*(count < 0)
result -= BUFFER_LENGTH*(Count < 0)

PUB Flush
{{
Flush receive buffer.
}}

repeat while rxcheck => 0
repeat while RxCheck => 0

PUB Char(ch)
{{
Expand Down
50 changes: 25 additions & 25 deletions i2c.spin
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ CON
' i2c bus contants
_i2cNAK = 1
_i2cACK = 0
_PinHigh = 1
_PinLow = 0
_pinHigh = 1
_pinLow = 0
_i2cByteAddress = 8
_i2cWordAddress = 16

Expand All @@ -93,7 +93,7 @@ VAR
word i2cSDA, i2cSCL
long ErrorState
long i2cStarted
long lastackbit
long lastAckBit
byte driveLines

'' ******************************************************************************
Expand All @@ -108,9 +108,9 @@ PUB Start : okay
dira[i2cSDA] ~
dira[i2cSCL] ~
' init the last ack bit
lastackbit := 1 ' default to NAK
lastAckBit := 1 ' default to NAK
' init no error state
ErrorState := _none
ErrorState := _None


PUB Stop : okay
Expand All @@ -121,7 +121,7 @@ PUB Stop : okay
dira[i2cSDA] ~
dira[i2cSCL] ~
' init no error state
ErrorState := _none
ErrorState := _None


PUB getLastAckBit : ackbit
Expand All @@ -145,7 +145,7 @@ PUB init(_i2cSDA, _i2cSCL, _driveSCLLine): okay
dira[i2cSCL] ~~

' init no error state
ErrorState := _none
ErrorState := _None
i2cStarted := true
else
ErrorState := _ObjNotInit
Expand All @@ -162,7 +162,7 @@ PUB getError : errorCode

PUB clearError
' clear the error state variable
ErrorState := _none
ErrorState := _None


PUB isStarted : i2cState
Expand All @@ -173,7 +173,7 @@ PUB isStarted : i2cState
PUB testBus : errorCode
' put both lines to input
' they should both go high from the resistor pullup's
ErrorState := _none
ErrorState := _None
dira[i2cSDA] ~
dira[i2cSCL] ~
if ina[i2cSDA] <> _pinHigh
Expand Down Expand Up @@ -223,7 +223,7 @@ PUB eeprom_read(deviceRegister, dataBuffer, dataSize) : ackbit
else
ackbit := _i2cNAK
' set the last i2cACK bit
lastackbit := ackbit
lastAckBit := ackbit
return ackbit


Expand All @@ -233,7 +233,7 @@ PUB eeprom_write(deviceRegister, dataBuffer, dataSize) : ackbit
ackbit := _i2cACK

if i2cStarted == true
i2cstart
i2cStart
ackbit := (ackbit << 1) | i2cWrite(EEPROM | 0, 8)

' send a 16 bit deviceRegister
Expand Down Expand Up @@ -285,7 +285,7 @@ PUB readLocation(deviceAddress, deviceRegister, addressbits, databits) : i2cData
else
ackbit := _i2cNAK
' set the last i2cACK bit
lastackbit := ackbit
lastAckBit := ackbit
' return the data
return i2cData

Expand All @@ -296,7 +296,7 @@ PUB writeLocation(deviceAddress, deviceRegister, i2cDataValue, addressbits,datab
ackbit := _i2cACK

if i2cStarted == true
i2cstart
i2cStart
ackbit := (ackbit << 1) | i2cWrite(deviceAddress | 0,8)

' cope with bigger than 8 bit deviceRegisters, i.e. EEPROM's use 16 bit or more
Expand Down Expand Up @@ -365,29 +365,29 @@ PUB i2cWrite(i2cData, i2cBits) : ackbit
dira[i2cSCL] ~~

' init the clock line
outa[i2cSCL] := _PinLow
outa[i2cSCL] := _pinLow

' send the data
i2cData <<= (32 - i2cbits)
i2cData <<= (32 - i2cBits)
repeat 8
' set the SDA while the SCL is LOW
outa[i2cSDA] := (i2cData <-= 1) & 1
' toggle SCL HIGH
outa[i2cSCL] := _PinHigh
outa[i2cSCL] := _pinHigh
' toogle SCL LOW
outa[i2cSCL] := _PinLow
outa[i2cSCL] := _pinLow

' setup for ACK - pin to input
dira[i2cSDA] ~

' read in the ACK
outa[i2cSCL] := _PinHigh
outa[i2cSCL] := _pinHigh
ackbit := ina[i2cSDA]
outa[i2cSCL] := _PinLow
outa[i2cSCL] := _pinLow

' leave the SDA pin LOW
dira[i2cSDA] ~~
outa[i2cSDA] := _PinLow
outa[i2cSDA] := _pinLow

' return the ackbit
return ackbit
Expand All @@ -400,20 +400,20 @@ PUB i2cRead(ackbit): i2cData
' set the SCL to output and the SDA to input
dira[i2cSCL] ~~
dira[i2cSDA] ~
outa[i2cSCL] := _PinLow
outa[i2cSCL] := _pinLow

' clock in the byte
i2cData := 0
repeat 8
outa[i2cSCL] := _PinHigh
outa[i2cSCL] := _pinHigh
i2cData := (i2cData << 1) | ina[i2cSDA]
outa[i2cSCL] := _PinLow
outa[i2cSCL] := _pinLow

' send the ACK or NAK
dira[i2cSDA] ~~
outa[i2cSCL] := _PinHigh
outa[i2cSCL] := _pinHigh
outa[i2cSDA] := ackbit
outa[i2cSCL] := _PinLow
outa[i2cSCL] := _pinLow

' return the data
return i2cData
46 changes: 36 additions & 10 deletions vt100.spin
Original file line number Diff line number Diff line change
Expand Up @@ -379,23 +379,23 @@ PRI keyPressed(k, mod) | c, i, ptr
case c
"A".."Z":
if (usb_report[0] & %00010001) ' CTRL
ser.char(c - "A" + 1)
ser.Char(c - "A" + 1)
elseif (usb_led & LED_CAPS_LOCK)
ser.char(c ^ $20)
ser.Char(c ^ $20)
else
ser.char(c)
ser.Char(c)
"a".."z":
if (usb_report[0] & %00010001) ' CTRL
ser.char(c - "a" + 1)
ser.Char(c - "a" + 1)
elseif (usb_led & LED_CAPS_LOCK)
ser.char(c ^ $20)
ser.Char(c ^ $20)
else
ser.char(c)
ser.Char(c)
0..$FF:
repeat i from 0 to 11
if c == byte[kb_nrcs_table][i]
c := byte[@nrcs][i]
ser.char(c)
ser.Char(c)

kb#KeyNumLock:
usb_led ^= LED_NUM_LOCK
Expand All @@ -410,7 +410,7 @@ PRI keyPressed(k, mod) | c, i, ptr
kb#KeySpace..kb#KeyMaxCode:
ptr := @@word[kb_str_table][c - kb#KeySpace]
repeat strsize(ptr)
ser.char(byte[ptr])
ser.Char(byte[ptr])
ptr++


Expand Down Expand Up @@ -1326,8 +1326,34 @@ _vt_end fit $1F0

CON

#1, CTRL_A, CTRL_B, CTRL_C, CTRL_D, CTRL_E, CTRL_F, CTRL_G, CTRL_H, CTRL_I, CTRL_J, CTRL_K, CTRL_L, CTRL_M, CTRL_N, CTRL_O, CTRL_P, CTRL_Q, CTRL_R, CTRL_S, CTRL_T, CTRL_U, CTRL_V, CTRL_W, CTRL_X, CTRL_Y, CTRL_Z, ESC

#1
CTRL_A
CTRL_B
CTRL_C
CTRL_D
CTRL_E
CTRL_F
CTRL_G
CTRL_H
CTRL_I
CTRL_J
CTRL_K
CTRL_L
CTRL_M
CTRL_N
CTRL_O
CTRL_P
CTRL_Q
CTRL_R
CTRL_S
CTRL_T
CTRL_U
CTRL_V
CTRL_W
CTRL_X
CTRL_Y
CTRL_Z
ESC

DAT

Expand Down

0 comments on commit 4ef5539

Please sign in to comment.