Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Regard whitespace Rev 385 → Rev 375

/programy/Atmel32_C/SFR08/SFR08.cpp
File deleted
/programy/Atmel32_C/cmps03/main.cpp
File deleted
/programy/Atmel32_C/cmps03/compass.c
File deleted
/programy/Atmel32_C/compass/compass.c
0,0 → 1,114
/* compass.c
*
* Software to read from the CMPS03 magnetic compass.
*
* By Josh Marshall, joshua dot marshall at studentmail dot newcastle dot edu dot au
* October 15, 2004.
*
* Adapted from code for the SP03 speech synthesiser
* By Bram Stolk, b.stolk at chello.nl
*
* Bram Stolk's notes:
* In linux, you can do I2C stuff in user-space, if you enable
* the device-interface to i2c. You can use plain read() and
* write() calls on your /dev/i2c-0 file.
*
* NOTE: Check if you have an i2c adapter active by doing:
* cat /proc/bus/i2c
* If this comes up empty, then you have no adapters. If the
* file does not exist at all, you probably lack i2c kernel
* support alltogether.
*/
 
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
 
/* Note that the documentation for the compass states its address as 0xC0.
* However, this includes the low bit which specifies read or write.
* Linux i2c does not include this bit in this address, so the actual
* address is 0xC0 shifted down, 0x60.
*/
#define CMPS03_ADDR 0x60
#define I2C_SLAVE 0x0B /* Change slave address
 
/* The important registers on the compass. Internal/test registers omitted. */
#define CMPS03_SOFTWARE_REVISION 0x0
#define CMPS03_BEARING_BYTE 0x1
#define CMPS03_BEARING_WORD_HIGH 0x2
#define CMPS03_BEARING_WORD_LOW 0x3
#define CMPS03_CALIBRATE_CMD 0xF
 
int main(int argc, char *argv[]) {
char *end;
int res,file;
int error;
char filename[20] ;
long funcs;
int heading_byte, heading_word_h, heading_word_l;
int bearing_long, bearing_degrees;
sprintf(filename,"/dev/i2c-0");
file = open(filename,O_RDWR);
if (errno != 0)
{
switch (errno)
{
case EACCES:
fprintf(stderr,"Run as root? \n");
break;
default:
fprintf(stderr,"Error: Could not open file '%s' : %s \n", filename, strerror(errno));
break;
}
}
if (ioctl(file,I2C_SLAVE,CMPS03_ADDR) < 0) {
switch (errno)
{
case EBUSY:
printf("device is busy \n");
break;
 
default:
printf("Got error: %s \n", strerror(errno));
exit(0);
}
}
/* Get software revision number */
res = read(file, CMPS03_SOFTWARE_REVISION,1);
if (res < 0) {
printf("Cannot read software revision level \n");
} else {
printf("Software revision level: %02x \n", res);
}
/* Loop and read from the compass. */
while (1) {
/* The heading byte is 0-255 for the 360 degrees. */
heading_byte = read(file, CMPS03_BEARING_BYTE,1);
if (heading_byte < 0) { printf("Error reading from compass. \n"); exit(1);}
/* The high resolution heading is given in two registers, and is 10 * the
* heading in degrees, ie 359.9 degrees reads as 3599. */
heading_word_h = read(file, CMPS03_BEARING_WORD_HIGH,1);
if (heading_word_h < 0) { printf("Error reading from compass. \n"); exit(1);}
heading_word_l = read(file, CMPS03_BEARING_WORD_LOW,1);
if (heading_word_l < 0) { printf("Error reading from compass. \n"); exit(1);}
/* Combine the two bytes, and get the heading in degrees. */
bearing_long = heading_word_h * 256 + heading_word_l;
bearing_degrees = bearing_long / 10;
printf("Bearing: %d \n", bearing_degrees);
/* Wait for a while. */
usleep(200000);
}
}
/programy/ASM/blik/DELAY.$$$
0,0 → 1,57
;--- Macro na spozdeni 1ms az 255ms ---
Delay macro ms
movlw ms
movwf CT2
call Delay1ms
endm
 
;--- Macro na spozdeni 0,1ms az 2,5ms (10-250) ---
Delay01 macro us
movlw us
movwf CT1
call us10
nop
nop ; Z duvodu vyrovnani poctu potrebnych taktu jako na Delay1ms
nop
return
endm
;--- Spozdeni v nasobcich 1ms+2us ----
 
Delay1ms:
movlw 99 ; 1 ms
movwf CT1 ; goto 2 takty decfsz 1 kdyz 1 jinak 2
call us10
 
decfsz CT2, f
goto Delay1ms
nop
;---------------------------------
return ;2us
 
;--- Spozdeni v nasobcich 10us ----
us10: ; Prodleva (CT1 * 10us)
nop
nop
nop
nop
nop
nop
nop
decfsz CT1, f
goto us10
nop
return
;-------------------------
 
;----------------------------
; Definice promenych
;----------------------------
 
cblock
 
CT1
CT2
 
endc
 
/programy/ASM/blik/OVLAD.$$$
0,0 → 1,147
#include 16C84.INC
 
org 0
 
goto Start
;--------------------
org 4
;--------------------
goto Start
 
#include Delay.asm
Start:
page1
movlw 00000000B ; inicializace citace a prescaleru
movwf TMR0
movlw 00000000B ; konfigurace preruseni
movwf INTCON
 
page1
movlw 00000000B ; nastaveni portu na vstup nebo vystup
movwf PORTA ; 1=vstup 0=vystup
movlw 01000011B
movwf PORTB
 
bsf TMR0, 7 ; vypni pull-up na PORTB (OPTION registr)
 
page0
 
clrw ; vynulovani portu
movwf PORTA
movwf PORTB
 
MainLoop:
movlw 255
movwf CT1
movlw 252
movwf CT2
rozj:
 
decf CT1, f
 
bsf PORTA, 0
bcf PORTA, 1 ;100
bcf PORTA, 2
call zap
 
bsf PORTA, 0 ;110
bsf PORTA, 1
bcf PORTA, 2
call zap
 
bcf PORTA, 0 ;010
bsf PORTA, 1
bcf PORTA, 2
call zap
 
decfsz CT2, f
goto ble
goto rychle
 
ble: bcf PORTA, 0 ;011
bsf PORTA, 1
bsf PORTA, 2
call zap
 
bcf PORTA, 0 ;001
bcf PORTA, 1
bsf PORTA, 2
call zap
 
bsf PORTA, 0 ;101
bcf PORTA, 1
bsf PORTA, 2
call zap
 
zap:
movf CT1, w
movwf xxx ;xxx promena z delay.asm
call Delay1ms
 
;----------------------------------------------------
rychle:
bsf PORTA, 0
bcf PORTA, 1 ;100
bcf PORTA, 2
Delay 3
 
; bsf PORTA, 0 ;110
; bsf PORTA, 1
; bcf PORTA, 2
; Delay
 
bcf PORTA, 0 ;010
bsf PORTA, 1
bcf PORTA, 2
Delay 3
 
; bcf PORTA, 0 ;011
; bsf PORTA, 1
; bsf PORTA, 2
; Delay 2
 
bcf PORTA, 0 ;001
bcf PORTA, 1
bsf PORTA, 2
Delay 3
 
; bsf PORTA, 0 ;101
; bcf PORTA, 1
; bsf PORTA, 2
; Delay 2
goto rychle
;______________________________________________________________
 
bcf PORTA, 2
bcf PORTA, 1
 
smycka:
btfss PORTB, 0
goto LEDon
goto smycka
LEDon:
bsf PORTA, 3 ;Rozsvit LED
Delay 250
bcf PORTA, 3 ;Zhasni LED
Delay 250
goto smycka
;---------------
 
 
 
 
 
;----------------------------
; Definice promenych
;----------------------------
 
cblock
 
CT1
CT2
 
endc
 
end
/programy/INPOUT32.DLL
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/INPOUT32.TXT
0,0 → 1,72
Documentation for inpout32.zip
Inpout32.zip contains a DLL that enables direct reading and writing to I/O ports in 32-bit Visual-Basic programs running under Windows 95.
 
by Jan Axelson
Lakeview Research
Email: jaxelson@lvr.com
WWW: http://www.lvr.com
 
Important information and cautions:
 
1. Use this DLL at your own risk. Writing directly to hardware ports can result in system crashes, loss of data, and even permanent damage. Inpout32 was developed to allow access to parallel ports and other ports on custom hardware, but you can use it to attempt to access any hardware that is mapped as an I/O port. You've been warned!
2. Use this DLL only with 32-bit programs. 16-bit programs require a 16-bit DLL (inpout16.dll).
3. Windows 95 allows direct port reads and writes unless a VxD has control of the port and blocks access. Under Windows NT, direct port access is not allowed, and you must use a kernel-mode device driver.
4. For the latest parallel-port programming and interfacing information and tools, visit Parallel Port Central at:
http://www.lvr.com
 
***
Inpout32.zip contains the following files:
 
inpout32.txt
This file
 
inpout32.dll
A DLL that enables the use of Inp and Out routines in 32-bit Visual Basic 4 and Visual Basic 5 programs.
inpout32.bas
Visual-Basic declarations for Inp and Out
 
inpout32.vbp
Visual Basic 4 test project for inpout32. The project will also load into and run under Visual Basic 5.
 
inpout32.frm
Startup form for the test project
inpout32.dpr
Source code for inpout32.dll. The DLL was compiled with Borland's Delphi 2.0 Object Pascal compiler.
 
***
 
How to run the test program (inpout32.vbp):
1. Copy inpout32.dll to one of these locations: your default Windows directory (usually \Windows), your Windows system directory (usually \Windows\system), or your application's working directory. In the VB programming environment, the working directory is the default VB directory.
2. Open the project inpout32.vbp.
3. In the Form_Load subroutine, set PortAddress equal to the port address you want to test.
3. Clicking the command button causes the program to do the following: write a value to the port, read the port, and display the result. The value increments with each click, resetting to 0 at 255.
 
***
 
How to use inpout32 in your programs:
 
1. Copy inpout32.dll to your default Windows directory (or other directory as described above).
 
2. Add inpout32.bas to your Visual-Basic project (File menu, Add File).
 
3. Use this syntax to write to a port:
Out PortAddress, ValueToWrite
 
Example:
Out &h378, &h55
 
Use this syntax to read a port:
ValueRead = Inp(PortAddress)
 
Example:
ValueRead = Inp(&h378)
(The syntax is identical to QuickBasic's Inp and Out).
/programy/INPOUT32.VBP
0,0 → 1,30
Type=Exe
Form=inpout32.frm
Module=inpout; Inpout32.bas
IconForm="inpout32"
Startup="inpout32"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="doma"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
/programy/INPOUT32.vbw
0,0 → 1,2
inpout32 = 25, -2, 354, 453, , -2, -9, 554, 447, C
inpout = 66, 66, 317, 328, C
/programy/Inpout32.bas
0,0 → 1,29
Attribute VB_Name = "inpout"
 
'Inp and Out declarations for direct port I/O
'in 32-bit Visual Basic 4 programs.
 
Public Declare Function Input32 Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Output Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Sub out(ByVal Value As Integer)
Output &H3BC, Value
End Sub
Function inp() As Integer
inp = Input32(&H3BD)
End Function
 
Function inp11() As Boolean
inp11 = ((inp And &H80) = 0)
End Function
Function inp10() As Boolean
inp10 = Not ((inp And &H40) = 0)
End Function
Function inp12() As Boolean
inp12 = Not ((inp And &H20) = 0)
End Function
Function inp13() As Boolean
inp13 = Not ((inp And &H10) = 0)
End Function
 
/programy/bak/Inpout32.bas
0,0 → 1,29
Attribute VB_Name = "inpout"
 
'Inp and Out declarations for direct port I/O
'in 32-bit Visual Basic 4 programs.
 
Public Declare Function Input32 Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Output Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Sub out(ByVal Value As Integer)
Output &H3BC, Value
End Sub
Function inp() As Integer
inp = Input32(&H3BD)
End Function
 
Function inp11() As Boolean
inp11 = ((inp And &H80) = 0)
End Function
Function inp10() As Boolean
inp10 = Not ((inp And &H40) = 0)
End Function
Function inp12() As Boolean
inp12 = Not ((inp And &H20) = 0)
End Function
Function inp13() As Boolean
inp13 = Not ((inp And &H10) = 0)
End Function
 
/programy/bak/vssver.scc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/inpout32.frm
0,0 → 1,271
VERSION 5.00
Begin VB.Form inpout32
Caption = "Form1"
ClientHeight = 4710
ClientLeft = 915
ClientTop = 1410
ClientWidth = 4770
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 4710
ScaleWidth = 4770
Begin VB.Timer Timer2
Left = 2400
Top = 3480
End
Begin VB.HScrollBar HScroll1
Height = 375
Left = 240
Max = 500
TabIndex = 17
Top = 3000
Value = 5
Width = 1695
End
Begin VB.Timer Timer1
Left = 360
Top = 3480
End
Begin VB.CommandButton Command11
Caption = "8"
Height = 195
Left = 4320
TabIndex = 16
Top = 2280
Width = 135
End
Begin VB.CommandButton Command10
Caption = "7"
Height = 195
Left = 4080
TabIndex = 15
Top = 2280
Width = 135
End
Begin VB.CommandButton Command9
Caption = "6"
Height = 195
Left = 3840
TabIndex = 14
Top = 2280
Width = 135
End
Begin VB.CommandButton Command8
Caption = "5"
Height = 195
Left = 3600
TabIndex = 13
Top = 2280
Width = 135
End
Begin VB.CommandButton Command7
Caption = "4"
Height = 195
Left = 3240
TabIndex = 12
Top = 2280
Width = 135
End
Begin VB.CommandButton Command6
Caption = "3"
Height = 195
Left = 3000
TabIndex = 11
Top = 2280
Width = 135
End
Begin VB.CommandButton Command5
Caption = "2"
Height = 195
Left = 2760
TabIndex = 10
Top = 2280
Width = 135
End
Begin VB.CommandButton Command4
Caption = "1"
Height = 195
Left = 2520
TabIndex = 9
Top = 2280
Width = 135
End
Begin VB.TextBox Text13
Height = 285
Left = 3240
TabIndex = 4
Top = 1680
Width = 495
End
Begin VB.TextBox Text12
Height = 285
Left = 3240
TabIndex = 3
Top = 1200
Width = 495
End
Begin VB.TextBox Text10
Height = 285
Left = 3240
TabIndex = 2
Top = 240
Width = 495
End
Begin VB.TextBox Text11
Height = 285
Left = 3240
TabIndex = 1
Top = 720
Width = 495
End
Begin VB.Timer Timer_input
Left = 1680
Top = 120
End
Begin VB.TextBox Text1
Height = 372
Left = 960
TabIndex = 0
Top = 120
Width = 615
End
Begin VB.Label Label13
Caption = "13"
Height = 375
Left = 3840
TabIndex = 8
Top = 1680
Width = 375
End
Begin VB.Label Label3
Caption = "12"
Height = 375
Left = 3840
TabIndex = 7
Top = 1200
Width = 375
End
Begin VB.Label Label2
Caption = "10"
Height = 375
Left = 3840
TabIndex = 6
Top = 240
Width = 375
End
Begin VB.Label Label1
Caption = "11"
Height = 255
Left = 3840
TabIndex = 5
Top = 720
Width = 255
End
End
Attribute VB_Name = "inpout32"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim pocitadlo
Dim stare_cislo
 
Private Sub Command10_Click()
out &H40
End Sub
 
Private Sub Command11_Click()
out &H80
End Sub
 
Private Sub Command2_Click()
out &HFF
Timer1.Enabled = True
End Sub
 
Private Sub Command3_Click()
out 3
Timer1.Enabled = True
End Sub
 
Private Sub Command4_Click()
out &H1
End Sub
 
Private Sub Command5_Click()
out &H2
End Sub
 
Private Sub Command6_Click()
out &H4
End Sub
 
Private Sub Command7_Click()
out &H8
End Sub
 
Private Sub Command8_Click()
out &H10
End Sub
 
Private Sub Command9_Click()
out &H20
End Sub
 
Private Sub Form_Load()
Timer_input.Interval = 100
Timer_input.Enabled = True
stare_cislo = HScroll1.Value
End Sub
 
Private Sub HScroll1_Change()
If HScroll1.Value < stare_cislo Then
Timer1.Interval = 1
Timer1.Enabled = True
End If
If HScroll1.Value > stare_cislo Then
Timer2.Interval = 1
Timer2.Enabled = True
End If
stare_cislo = HScroll1.Value
End Sub
 
Private Sub Timer_input_Timer()
Text1.Text = inp
Text10.Text = inp10
Text11.Text = inp11
Text12.Text = inp12
Text13.Text = inp13
End Sub
 
Private Sub Timer1_Timer()
Select Case pocitadlo
Case 1
Call Command8_Click
Case 2
Call Command10_Click
Case 3
Call Command9_Click
Case 4
Call Command11_Click
Timer1.Enabled = False
pocitadlo = 0
End Select
pocitadlo = pocitadlo + 1
End Sub
 
Private Sub Timer2_Timer()
Select Case pocitadlo
Case 1
Call Command11_Click
Case 2
Call Command9_Click
Case 3
Call Command10_Click
Case 4
Call Command8_Click
Timer2.Enabled = False
pocitadlo = 0
End Select
pocitadlo = pocitadlo + 1
End Sub
/programy/mssccprj.scc
0,0 → 1,5
SCC = This is a Source Code Control file
 
[INPOUT32.VBP]
SCC_Aux_Path = "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\COMMON\VSS"
SCC_Project_Name = "$/programy", HNAAAAAA
/programy/vssver.scc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property