Small extension to 86duino GPIO Demo

git-svn-id: svn://kolibrios.org@7298 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2018-07-01 10:48:38 +00:00
parent 9e23672659
commit afdec23ff9

View File

@ -57,8 +57,6 @@ proc START c, state:dword, cmdline:dword
and eax, not (1 shl 28) and eax, not (1 shl 28)
invoke PciWrite32, [bus], [dev], 0xBC, eax invoke PciWrite32, [bus], [dev], 0xBC, eax
DEBUGF 1,"1\n"
; Set ADC base address ; Set ADC base address
mov ebx, [dev] mov ebx, [dev]
inc ebx inc ebx
@ -68,15 +66,11 @@ proc START c, state:dword, cmdline:dword
invoke PciWrite32, [bus], ebx, 0xE0, 0x00500000 or ADC_ADDR invoke PciWrite32, [bus], ebx, 0xE0, 0x00500000 or ADC_ADDR
DEBUGF 1,"2\n"
; set up ADC ; set up ADC
mov dx, ADC_ADDR + 1 mov dx, ADC_ADDR + 1
xor al, al xor al, al
out dx, al out dx, al
DEBUGF 1,"3\n"
; Empty FIFO ; Empty FIFO
@@: @@:
mov dx, ADC_ADDR + 2 ; Status register mov dx, ADC_ADDR + 2 ; Status register
@ -88,8 +82,6 @@ proc START c, state:dword, cmdline:dword
jmp @r jmp @r
@@: @@:
DEBUGF 1,"4\n"
; Enable GPIO0-9 ; Enable GPIO0-9
mov dx, GPIO_PORT_CONFIG_ADDR + 0 ; General-Purpose I/O Data & Direction Decode Enable mov dx, GPIO_PORT_CONFIG_ADDR + 0 ; General-Purpose I/O Data & Direction Decode Enable
mov eax, 0x000001ff mov eax, 0x000001ff
@ -111,8 +103,8 @@ proc START c, state:dword, cmdline:dword
dec ecx dec ecx
jnz .gpio_init jnz .gpio_init
; Set GPIO0 pin 0 as output ; Set GPIO0 pin 0-7 as output
mov al, 0x01 mov al, 0xff
mov dx, GPIO_DATA_ADDR + 0*4 + 2 mov dx, GPIO_DATA_ADDR + 0*4 + 2
out dx, al out dx, al
@ -153,15 +145,20 @@ proc service_proc stdcall, ioctl:dword
xor eax, eax xor eax, eax
ret ret
.no_gpiowrite: .no_gpiowrite:
cmp eax, 3 ; read ADC channel 0 cmp eax, 3 ; read single ADC channel
jne .no_adcread jne .no_adcread
mov ecx, [ebx + IOCTL.input]
cmp ecx, 8
jae .fail
mov dx, ADC_ADDR + 1 mov dx, ADC_ADDR + 1
mov al, 1 shl 3 ; Power down ADC mov al, 1 shl 3 ; Power down ADC
out dx, al out dx, al
mov dx, ADC_ADDR + 0 ; AUX channel select register mov dx, ADC_ADDR + 0 ; AUX channel select register
mov al, 1 shl 0 ; Enable AUX0 scan mov al, 1
shl ax, cl
out dx, al out dx, al
mov dx, ADC_ADDR + 1 mov dx, ADC_ADDR + 1
@ -175,8 +172,7 @@ proc service_proc stdcall, ioctl:dword
jz @r jz @r
mov dx, ADC_ADDR + 4 mov dx, ADC_ADDR + 4
in ax, dx ; read the data and return to user call in ax, dx ; read the data from the FIFO and return to user call
DEBUGF 1, "ADC read: 0x%x\n", eax:4
ret ret
.no_adcread: .no_adcread:
.fail: .fail: