Datasheet
LongIntToStr(size, fat_txt)
Write_Str(fat_txt)
for i=0 to 4999
Cf_Write_Sector(size, Buffer)
size = size+1
UART1_Write(".")
next i
end if
end sub'~
'-------------- Main. Uncomment the sub function(s) to test the
desired operation(s)
main:
FAT_TXT = "FAT16 not found"
file_contents = "XX CF FAT16 library by Anton Rieckert"
file_contents[37] = 10 ' newline
filename = "MIKRO00xTXT"
' we will use PORTC to signal test end
DDRC = 0xFF
PORTC = 0
UART1_Init(19200) ' Set up USART for file read-
ing
delay_ms(100)
UART1_Write_Text(":Start:")
' --- Init the FAT library
' --- use Cf_Fat_QuickFormat instead of init routine if a for-
mat is needed
if Cf_Fat_Init() = 0 then
'--- test sub functions
'----- test group #1
Create_New_File()
Create_Multiple_Files()
'----- test group #2
Open_File_Rewrite()
Open_File_Append()
Delete_File
'----- test group #3
Open_File_Read()
Test_File_Exist("F")
M_Create_Swap_File()
'--- Test termination
UART1_Write(0xAA)
else
UART1_Write_Text(FAT_TXT)
end if
'--- signal end-of-test
UART1_Write_Text(":End:")
end.'~!
209
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6