Commit 41a17a23 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Add two more targets to the GPIO table, and other improvements

Docs/GPIO: StrongHelp updated
Resources/!PiLed/!Run: RMEnsure the GPIO module first
Resources/!PiLed/!RunImage: Clarifications and improvements
hdr/Reals: Make space for the Mk2 model B and model A+
s/I2CSWIs: Improvements to error reporting
s/InitModule: Add an API version check against the HAL
s/PiSWIs; s/SupportCode: Resolve some TODO's
s/Tables: The two extra tables for the two extra boards

Submission from Tank. Built, and module loaded, but no runtime testing.

Version 0.60. Tagged as 'GPIO-0_60'
parent cd245510
No preview for this file type
|wimpslot -min 32K -max 32K
|run <obey$dir>.!RunImage
RMEnsure GPIO 0.58 Error GPIO Module is not loaded
TaskWindow <obey$dir>.!RunImage -wimpslot 32K
\ No newline at end of file
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.59"
Module_Version SETA 59
Module_MajorVersion SETS "0.60"
Module_Version SETA 60
Module_MinorVersion SETS ""
Module_Date SETS "13 Oct 2014"
Module_ApplicationDate SETS "13-Oct-14"
Module_Date SETS "25 Feb 2015"
Module_ApplicationDate SETS "25-Feb-15"
Module_ComponentName SETS "GPIO"
Module_ComponentPath SETS "bsd/RiscOS/Sources/ThirdParty/TankStage/HWSupport/GPIO"
Module_FullVersion SETS "0.59"
Module_HelpVersion SETS "0.59 (13 Oct 2014)"
Module_FullVersion SETS "0.60"
Module_HelpVersion SETS "0.60 (25 Feb 2015)"
END
/* (0.59)
/* (0.60)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.59
#define Module_MajorVersion_CMHG 0.60
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Oct 2014
#define Module_Date_CMHG 25 Feb 2015
#define Module_MajorVersion "0.59"
#define Module_Version 59
#define Module_MajorVersion "0.60"
#define Module_Version 60
#define Module_MinorVersion ""
#define Module_Date "13 Oct 2014"
#define Module_Date "25 Feb 2015"
#define Module_ApplicationDate "13-Oct-14"
#define Module_ApplicationDate "25-Feb-15"
#define Module_ComponentName "GPIO"
#define Module_ComponentPath "bsd/RiscOS/Sources/ThirdParty/TankStage/HWSupport/GPIO"
#define Module_FullVersion "0.59"
#define Module_HelpVersion "0.59 (13 Oct 2014)"
#define Module_LibraryVersionInfo "0:59"
#define Module_FullVersion "0.60"
#define Module_HelpVersion "0.60 (25 Feb 2015)"
#define Module_LibraryVersionInfo "0:60"
......@@ -883,6 +883,7 @@ PDcambitmap * 2_00000000000000000000000000000000
;***************************** Raspberry ****************************************
;pi_GPIO_Base * &7E200000
pi_GPIO_Base * &20200000
piMk2_GPIO_Base * &3F200000
^ 0
pi_GPSEL0 # 4
pi_GPSEL1 # 4
......@@ -1044,7 +1045,7 @@ hal_rev_dev # GPIORevision_DevKit8000_Unknown+1
hal_rev_igep # GPIORevision_IGEPv2_C+1
hal_rev_pandora # GPIORevision_Pandora_Unknown+1
hal_rev_panda # GPIORevision_PandaES+1
hal_rev_pi # GPIORevision_RaspberryPi_C_1+1
hal_rev_pi # GPIORevision_RaspberryPi_Mk2_B_1+1
;offsets into table
^ 0
......
......@@ -35,8 +35,8 @@ i2c_Read_Data
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r6,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
AND r0,r0,r5 ;mask pin
CMP r0,#0 ;
......@@ -55,6 +55,7 @@ i2c_Write_Data
MOV r6,r0 ;
MOV r7,r1 ;
BL i2c_Read_Data ;
Pull "r1-r8,pc",VS ;restore registers and exit if error
MOV r0,r6 ;
ADD r4,r12,#i2creturn ;
LDRB r6,[r4] ;
......@@ -63,7 +64,6 @@ i2c_Write_Data
CMP r7,#0 ;
BICEQ r2,r6,r5 ;
ORRNE r2,r6,r5 ;
MOV r4,#0 ;report swi error
BL i2c_write ;
Pull "r0-r8,pc" ; restore registers and exit
;---------------------------------------------
......@@ -77,8 +77,8 @@ i2c_Read_OE
BL i2c_get_things
MOV r2,#1 ;
ADD r1,r4,#mcpiodira ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r6,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
AND r0,r0,r5 ;mask pin
CMP r0,#0 ;
......@@ -105,7 +105,6 @@ i2c_Write_OE
CMP r7,#0 ;
BICEQ r2,r6,r5 ;
ORRNE r2,r6,r5 ;
MOV r4,#0 ;report swi error
BL i2c_write ;
Pull "r1-r7,pc" ; restore registers and exit
;r0=old value or -1 if not there
......@@ -136,15 +135,15 @@ i2c_ReadBlock
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r9,pc",VS ;restore registers and exit if error
LDRB r8,[r1] ;
MOV r0,r9 ;get second port readings
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r9,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
MOV r0,r0,LSL#8 ;move up
ORR r0,r0,r8 ;add in 0-7 bits
......@@ -164,13 +163,12 @@ i2c_WriteBlock
MOV r7,r1 ;save for later
BL i2c_get_things ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
AND r2,r7,#&FF ;just bottom 8
BL i2c_write ;
Pull "r0-r8,pc",VS ;restore registers and exit if error
MOV r0,r8 ;do next 8
BL i2c_get_things ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
MOV r7,r7,LSR #8 ;move down
AND r2,r7,#&FF ;just bottom 8
BL i2c_write ;
......@@ -188,15 +186,15 @@ i2c_ReadBlockOE
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpiodira ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r9,pc",VS ;restore registers and exit if error
LDRB r8,[r1] ;
MOV r0,r9 ;get second port readings
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpiodira ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r9,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
MOV r0,r0,LSL#8 ;move up
ORR r0,r0,r8 ;add in 0-7 bits
......@@ -216,13 +214,12 @@ i2c_WriteBlockOE
MOV r7,r1 ;save for later
BL i2c_get_things ;
ADD r1,r4,#mcpiodira ;
MOV r4,#0 ;report swi error
AND r2,r7,#&FF ;just bottom 8
BL i2c_write ;
Pull "r0-r8,pc",VS ;restore registers and exit if error
MOV r0,r8 ;do next 8
BL i2c_get_things ;
ADD r1,r4,#mcpiodira ;
MOV r4,#0 ;report swi error
MOV r7,r7,LSR #8 ;move down
AND r2,r7,#&FF ;just bottom 8
BL i2c_write ;
......@@ -239,8 +236,8 @@ i2c_ReadByte
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r9,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
Pull "r1-r9,pc" ; restore registers and exit
;r0=8 bits from chip or -1 if not there
......@@ -257,7 +254,6 @@ i2c_WriteByte
MOV r7,r1 ;save for later
BL i2c_get_things ;
ADD r1,r4,#mcpgpioa ;
MOV r4,#0 ;report swi error
AND r2,r7,#&FF ;just bottom 8
BL i2c_write ;
Pull "r0-r8,pc" ; restore registers and exit
......@@ -273,8 +269,8 @@ i2c_ReadByteOE
BL i2c_get_things ;
MOV r2,#1 ;
ADD r1,r4,#mcpiodira ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r9,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
Pull "r1-r9,pc" ; restore registers and exit
;r0=8 bits from chip
......@@ -291,7 +287,6 @@ i2c_WriteByteOE
MOV r7,r1 ;save for later
BL i2c_get_things ;
ADD r1,r4,#mcpipola ;
MOV r4,#0 ;report swi error
AND r2,r7,#&FF ;just bottom 8
BL i2c_write ;
Pull "r0-r8,pc" ; restore registers and exit
......@@ -304,8 +299,8 @@ i2c_Read_Polarity
BL i2c_get_things
MOV r2,#1 ;
ADD r1,r4,#mcpipola ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r6,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
AND r0,r0,r5 ;mask pin
CMP r0,#0 ;
......@@ -329,7 +324,6 @@ i2c_Write_Polarity
CMP r7,#0 ;
BICEQ r2,r6,r5 ;
ORRNE r2,r6,r5 ;
MOV r4,#0 ;report swi error
BL i2c_write ;
Pull "r1-r7,pc" ; restore registers and exit
;r0=old value or -1 if not there
......@@ -342,8 +336,8 @@ i2c_Read_Pull
BL i2c_get_things
MOV r2,#1 ;
ADD r1,r4,#mcpgppua ;
MOV r4,#0 ;report swi error
BL i2c_read ;
Pull "r1-r6,pc",VS ;restore registers and exit if error
LDRB r0,[r1] ;
AND r0,r0,r5 ;mask pin
CMP r0,#0 ;
......@@ -367,7 +361,6 @@ i2c_Write_Pull
CMP r7,#0 ;
BICEQ r2,r6,r5 ;
ORRNE r2,r6,r5 ;
MOV r4,#0 ;report swi error
BL i2c_write ;
Pull "r1-r7,pc" ; restore registers and exit
;r0=old value or -1 if not there
......
......@@ -76,6 +76,10 @@ RM_Init
STREQ r1,[r12,#halrevision] ;
MOVEQ r0,#hal_rev_dummy ;board type default
BEQ %FT100 ;
;check API matches our assumption
LDR r1,[r2,#HALDevice_Version]
TEQ r1,#0
BNE initerror1 ;want API 0.00
;find real board type
LDR r1,[r2,#HALDevice_GPIORevision]
STR r1,[r12,#halrevision] ;
......@@ -124,7 +128,7 @@ RM_Init
ADR r2,bcm2835_gpio_tables ;pointer to board table
CMP r0,#GPIOType_BCM2835_RaspberryPi
BNE %FT28
CMP r1,#GPIORevision_RaspberryPi_C_1
CMP r1,#GPIORevision_RaspberryPi_Mk2_B_1
BLE %FT99 ;
28 ADR r2,dummy_gpio_table ;pointer to board table
MOV r0,#hal_rev_dummy ;board type default if it falls through
......
......@@ -210,6 +210,7 @@ Pi_Write_Mode
MOV r8,r1 ;keep setting
BL check_protect_i2c ;
CMP r0,#-1 ;
; BEQ pwmout ;
BEQ %FT10 ;
SWI XOS_IntOff
BL pi_setup ;
......@@ -247,6 +248,7 @@ Pi_Write_Mode
MOV r0,#0 ;
10
Pull "r1-r10,pc" ; restore registers and exit
;pwmout Pull "r1-r10,pc" ; restore registers and exit
;r0=0 if OK -1 if protected
delay
......
......@@ -108,7 +108,7 @@ check_protect_i2c
ADD r1,r1,r2, LSL #tablesize ;offset
LDR r2,[r1,#i2c_pins] ;get list of registers
CMP r2,#-1 ;
BEQ %FT20
BEQ %FT10
LDR r4,[r2] ;
AND r1,r4,#&FF ;mask bottom
MOV r2,r4,LSR #8 ;move to lower
......@@ -213,7 +213,7 @@ get_i2c_info
LDR r0,[r0] ;check which error
LDR r1,noack ;
CMP r0,r1 ;no ack error number
; BNE displayerror ;another problem get out
; Pull "r0-r8,pc",NE ;another problem restore registers and exit
B %BT10 ;no ack, try next chip
19 STR r7,[r12,#i2clowgpio] ;
20 MOV r0,r8 ;gpio number
......@@ -228,14 +228,10 @@ get_i2c_info
LDR r0,[r0] ;check which error
LDR r1,noack ;
CMP r0,r1 ;
; BNE displayerror ;another problem get out
; Pull "r0-r8,pc",NE ;another problem restore registers and exit
STR r7,[r12,#i2chighgpio] ;
Pull "r0-r8,pc" ; restore registers and exit
displayerror
; SWI OS_GenerateError
Pull "r0-r8,pc"
noack DCD &20300
;---------------------------------------------
i2c_get_things
......@@ -284,15 +280,10 @@ i2c_read
STR r2,[r5,#20] ;width of data returned
MOV r0,r5 ;
ADD r1,r3,#2 ;
CMP r4,#1 ;
! 0, "SWIs corrupt flags, what is the intent here?"
SWIEQ XOS_IICOp ;
SWINE OS_IICOp ;
SWI XOS_IICOp ;
ADD r1,r12,#i2creturn ;iic return block pointer
Pull "r2-r5,pc"
;r0=error pointer (-1 if no error)
;r1=pointer to data if no error
;r1=pointer to data (if no error)
;---------------------------------------------
;r0=address of chip
;r1=register to read
......@@ -311,10 +302,7 @@ i2c_write
STR r0,[r5,#8] ;transfers
MOV r0,r5 ;
ADD r1,r3,#1 ;
CMP r4,#1 ;
! 0, "SWIs corrupt flags, what is the intent here?"
SWIEQ XOS_IICOp ;
SWINE OS_IICOp ;
SWI XOS_IICOp ;
Pull "r0-r5,pc"
;---------------------------------------------
;r0=GPIO
......
......@@ -335,6 +335,40 @@ rpicompute_table ;Compute module
DCD -1 ;map
DCD RPIphysical_table;
DCD name6_4 ;
rpiAP_table ;Raspberry Pi A+
DCD RPItable1 ;control reg
DCD RPItable2BP ;exp pins
DCD -1 ;aux pins
DCD -1 ;camera pins
DCD RPItable5Comp ;user pins
DCD RPItable6R2 ;i2c
DCD -1 ;widebit pins
DCD RPItable8 ;uart
DCD -1 ;usb
DCD -1 ;
DCD RPItable11 ;mmc/spio
DCD -1 ;
DCD -1 ;sram base
DCD -1 ;map
DCD RPIphysical_table;
DCD name6_5 ;
rpiMk2B_table ;Raspberry Pi Mk2 B rev 1
DCD RPItable1 ;control reg
DCD RPItable2BP ;exp pins
DCD -1 ;aux pins
DCD -1 ;camera pins
DCD RPItable5Comp ;user pins
DCD RPItable6R2 ;i2c
DCD -1 ;widebit pins
DCD RPItable8 ;uart
DCD -1 ;usb
DCD -1 ;
DCD RPItable11 ;mmc/spio
DCD -1 ;
DCD -1 ;sram base
DCD -1 ;map
DCD RPIMk2physical_table;
DCD name6_6 ;
;add as needed
;position in this table is the same as the tables used for mapping machine specific.
......@@ -357,6 +391,8 @@ convert_internal_to_external
DCB 13 ;A Pi rev2
DCB 17 ;B+ Pi
DCB 18 ;compute rev1
DCB 16 ;A+ Pi
DCB 19 ;Pi Mk2 B rev1
;add as needed
ALIGN
......@@ -372,12 +408,14 @@ name3_0 = "IGEPv2 B/C",13
name3_1 = "IGEPv2 C",13
name4_0 = "Pandora",13
name5_0 = "PandaBoard",13
name5_1 = "PandaBoardES",13
name6_0 = "RasberryPi B Rev1",13
name6_1 = "RasberryPi B Rev2",13
name6_2 = "RasberryPi A Rev2",13
name6_3 = "RasperryPi B Plus",13
name5_1 = "PandaBoard ES",13
name6_0 = "RaspberryPi B Rev1",13
name6_1 = "RaspberryPi B Rev2",13
name6_2 = "RaspberryPi A Rev2",13
name6_3 = "RaspberryPi B Plus",13
name6_4 = "Compute Module",13
name6_5 = "RaspberryPi A Plus",13
name6_6 = "RaspberryPi Mk2 B Rev1",13
;add as needed
ALIGN
......@@ -396,11 +434,13 @@ i2c_bus_nos
DCB i2cbus ;panda
DCB i2cbus ;pandaes
DCB i2cbus ;pandaes
DCB pi_i2cbusr1 ;pi rev1
DCB pi_i2cbusr2 ;pi rev2
DCB pi_i2cbusr1 ;pi b rev1
DCB pi_i2cbusr2 ;pi b rev2
DCB pi_i2cbusr2 ;pi a rev2
DCB pi_i2cbusr2 ;pi b+
DCB pi_i2cbusr2 ;pi compute
DCB pi_i2cbusr2 ;pi a+
DCB pi_i2cbusr2 ;pi Mk2 b rev1
;add as needed
ALIGN
......@@ -1210,6 +1250,9 @@ PDtable10
RPIphysical_table
DCD pi_GPIO_Base
DCD -1
RPIMk2physical_table
DCD piMk2_GPIO_Base
DCD -1
;Function Select register table
RPItable1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment