$regfile = "m32def.dat"
$crystal = 8000000
$lib "Lcd-pcf8833.lbx "
$include "..\fonty\Color8x8.font"
$include "..\fonty\Color16x16.font"
$include "CONFIG_AVR-DOS.Bas"
$lib "MMC.LIB"
$external _mmc
'-------------------------------------------------------------------------------
Config Portc = Output
Config Portd = Input
'-------------------------------------------------------------------------------
Config Graphlcd = Color , Controlport = Porta , Rs = 7 , Sda = 6 , Scl = 5 , Cs = 4
Glcdcmd &H36
Glcddata &H48
Glcdcmd &H21
'-------------------------------------------------------------------------------
Const Blue = &B00000011
Const Yellow = &B11111100
Const Red = &B11100000
Const Green = &B00011100
Const Black = &B00000000
Const White = &B11111111
Const Brightgreen = &B00111110
Const Darkgreen = &B00010100
Const Darkred = &B10100000
Const Darkblue = &B00000010
Const Brightblue = &B00011111
Const Orange = &B11111000
'-------------------------------------------------------------------------------
Dim Rozmiar As Long
Dim Wolne As Long
Dim S As String * 20
Dim Tekst As String * 100
Dim Gbdriveerror As Byte
Dim Gbdriveerrorreg As Byte
Dim Gbdrivestatusreg As Byte
Dim Gbdrivedebug As Byte
Dim B As Word
Dim C As Word
Dim Ff As Byte
Dim Z(20) As String * 20
'-------------------------------------------------------------------------------
Declare Sub Zapisz
Declare Sub Czytaj
Declare Sub Wyswietl_1
'-------------------------------------------------------------------------------
Set Portd.0
Set Portd.1
Set Portd.2
Cls
Setfont Color8x8
Sound Portd.7 , 200 , 300
Const Cmmc_soft = 0
Config Pinb.4 = Output
Mmc_cs Alias Portb.4
Set Mmc_cs
Config Pinb.7 = Output
Spi_ss Alias Portb.7
Set Spi_ss
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
'Config Spi = Soft , Din = Pinb.3 , Dout = Portb.2 , Ss = Portb.0 , Clock = Portb.1
Spsr.0 = 1
Spiinit
Const Cperrdrivereset = 225 '
Const Cperrdriveinit = 226
Const Cperrdrivereadcommand = 227
Const Cperrdrivewritecommand = 228
Const Cperrdrivereadresponse = 229
Const Cperrdrivewriteresponse = 230
Const Cperrdrive = 231
Const Cperrdrivenotsupported = 232
Waitms 700
Gbdriveerror = Driveinit()
B = Initfilesystem(1)
C = Drivecheck()
Rozmiar = Disksize() \ 1000
Wolne = Diskfree() \ 1000
Call Wyswietl_1
Do
'*******************************************************************************
If Pind.0 = 0 Then
Waitms 100
Sound Portd.7 , 100 , 200
Call Czytaj
End If
If Pind.1 = 0 Then
Waitms 100
Sound Portd.7 , 100 , 200
Call Zapisz
End If
'*******************************************************************************
Loop
'-------------------------------------------------------------------------------
Sub Wyswietl_1:
Cls
Setfont Color8x8
Waitms 500
Lcdat , 10 , 2 , "AVR-DOS v " ; Ver() , Black , White
Lcdat , 20 , 2 , "Atmega 32-16PU " , Black , White
Lcdat , 30 , 2 , "CPU at 8 Mhz" , Black , White
Lcdat , 40 , 2 , "Ram size : 2 KB" , Black , White
Lcdat , 50 , 2 , "LCD PCF-8833" , Black , White
Lcdat , 60 , 2 , "Karta SD info" , Black , White
Lcdat , 70 , 2 , "Rozmiar: " ; Rozmiar ; " MB" , Black , White
Lcdat , 80 , 2 , "Wolne : " ; Wolne ; " MB" , Black , White
Lcdat , 90 , 2 , "System OK" , Black , White
Wait 2
Cls
End Sub
'---------------------------------
Sub Zapisz :
Tekst = "jakis tekst"
Open "plik.txt" For Append As #2
Write #2 , Tekst
Flush #2
Close #2
Waitms 30
Setfont Color8x8
Cls
Lcdat , 10 , 2 , "Zapis na SD:" , Black , White
Lcdat , 20 , 2 , Tekst , Black , White
End Sub
'---------------------------------
Sub Czytaj :
Local E As Byte
For E = 1 To 20
Z(e) = ""
Next E
E = 0
S = Dir( "*.txt")
Ff = Freefile()
Open S For Input As #ff
Do
Incr E
Line Input #ff , Z(e)
Waitus 10
Loop Until Eof(ff) <> 0
Close #ff
Waitms 30
Setfont Color8x8
Cls
Lcdat , 2 , 2 , "Odczyt z SD:" , Black , White
Lcdat , 10 , 2 , Z(1) , Black , White
Lcdat , 20 , 2 , Z(2) , Black , White
Lcdat , 30 , 2 , Z(3) , Black , White
Lcdat , 40 , 2 , Z(4) , Black , White
Lcdat , 50 , 2 , Z(5) , Black , White
Lcdat , 60 , 2 , Z(6) , Black , White
Lcdat , 70 , 2 , Z(7) , Black , White
Lcdat , 80 , 2 , Z(8) , Black , White
Lcdat , 90 , 2 , Z(9) , Black , White
Lcdat , 100 , 2 , Z(10) , Black , White
Lcdat , 110 , 2 , Z(11) , Black , White
Lcdat , 120 , 2 , Z(12) , Black , White
Lcdat , 130 , 2 , Z(13) , Black , White
End Sub
'-------------------------------------------------------------------------------
End