Revision: 1348
Author: [email protected]
Date: Sat Sep 26 23:02:16 2009
Log: added hard disk lib procedures for same easy usage as sd card lib.
pata_hd_start_read, pata_hd_read_data, pata_hd_stop_read, also added 18f452
example
http://code.google.com/p/jallib/source/detail?r=1348
Modified:
/trunk/include/external/storage/harddisk/pata_hard_disk.jal
=======================================
--- /trunk/include/external/storage/harddisk/pata_hard_disk.jal Fri Sep 25
22:56:26 2009
+++ /trunk/include/external/storage/harddisk/pata_hard_disk.jal Sat Sep 26
23:02:16 2009
@@ -298,52 +298,6 @@
pata_hd_iord = low ^ PATA_HD_NO_INVERTER -- end read pulse
end procedure
---
----------------------------------------------------------------------------
--- Send a number of write pulses to data register sending 0's as data.
--- Used to get to the end of a sector or to get to a certain
--- location in a sector.
--- Increment pata_hd_word_count
---
----------------------------------------------------------------------------
-procedure pata_hd_write_pulse( byte in z ) is begin
- pata_hd_data_low = 0
- pata_hd_data_high = 0
-
- -- send write pulse z number of times
- for z loop
- pata_hd_word_count = pata_hd_word_count + 1 -- increment
pata_hd_word_count
- pata_hd_iowr = high ^ PATA_HD_NO_INVERTER -- send write pulse
- pata_hd_iowr = low ^ PATA_HD_NO_INVERTER
- end loop
-end procedure
-
---
----------------------------------------------------------------------------
--- Send a number of read pulses to data register without getting any data.
--- Used to get to the end of a sector or to get to a certain
--- location in a sector.
--- Increment pata_hd_word_count
---
----------------------------------------------------------------------------
-procedure pata_hd_read_pulse(dword in z) is
- if pata_hd_word_count == 0 & pata_hd_sector_count == 0 then
- pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_READ_SECTOR) --
send the read command to the command register
-
pata_hd_data_request(PATA_HD_WAIT_READ)
-- wait till the drive has data for you
- elsif pata_hd_word_count == 0 then
- pata_hd_data_request(PATA_HD_WAIT_READ)
- end if
-
- if pata_hd_word_count == 255 then
- pata_hd_sector_count = pata_hd_sector_count + 1
- end if
-
- ;pata_hd_word_count = pata_hd_word_count + 1 -- increment
pata_hd_word_count
-
- -- send read pulse z number of times
- for z loop
- pata_hd_word_count = pata_hd_word_count + 1
- pata_hd_iord = high ^ PATA_HD_NO_INVERTER -- send read pulse
- pata_hd_iord = low ^ PATA_HD_NO_INVERTER
- end loop
-end procedure
-
--
----------------------------------------------------------------------------
-- Go to a specific sector, select lba/chs mode and master/slave drive
-- Max sector number is 0x0F_FF_FF_FF or the number of sectors the drive
has.
@@ -395,7 +349,7 @@
-- Get drive ready for reading at specified address
--
----------------------------------------------------------------------------
procedure pata_hd_start_read(dword in address) is
- pata_hd_go_to_sector (address,0)
+ pata_hd_sector_select = address -- set the users selected sector
pata_hd_word_count = 0 -- reset number of words read from
sector
pata_hd_sector_count = 0 -- reset number of sectors read
end procedure
@@ -404,14 +358,16 @@
-- Read two bytes from disk.
--
----------------------------------------------------------------------------
procedure pata_hd_read_data(byte out low_byte, byte out high_byte) is
- if pata_hd_word_count == 0 & pata_hd_sector_count == 0 then
-- if we are at beginning of read
- pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_READ_SECTOR)
-- send the read command to the command register
+ if (pata_hd_word_count == 0) & (pata_hd_sector_count) == 0 then
-- if we are at beginning of read
+ pata_hd_go_to_sector(pata_hd_sector_select,0)
-- go to the selected sector
+ pata_hd_register_write(PATA_HD_COMMAND_REG,PATA_HD_READ_SECTOR)
-- send the read command to the command register
pata_hd_data_request(PATA_HD_WAIT_READ)
-- wait till the drive has data for you
elsif pata_hd_word_count == 0 then
-- if we are at beginning of a sector
pata_hd_data_request(PATA_HD_WAIT_READ)
-- wait for data to be ready for read
end if
if pata_hd_word_count == 255 then
-- if we are at end of current sector
+ pata_hd_sector_select = pata_hd_sector_select + 1
-- increment the users selected sector
pata_hd_sector_count = pata_hd_sector_count + 1
-- increase sector count
end if
@@ -424,6 +380,19 @@
pata_hd_iord = low ^ PATA_HD_NO_INVERTER -- end read pulse
end procedure
+--
----------------------------------------------------------------------------
+-- Send a number of read pulses to data register without getting any data.
+-- Used to get to the end of a sector or to get to a certain
+-- location in a sector.
+-- Increment pata_hd_word_count
+--
----------------------------------------------------------------------------
+procedure pata_hd_read_pulse(dword in z) is
+ var byte x,y
+ for z loop
+ pata_hd_read_data (x,y)
+ end loop
+end procedure
+
--
----------------------------------------------------------------------------
-- Tell drive you are done reading
--
----------------------------------------------------------------------------
@@ -446,7 +415,7 @@
--
----------------------------------------------------------------------------
procedure pata_hd_write_data(byte in low_byte, byte in high_byte) is
if pata_hd_word_count == 0 then --
if we are at beginning of write
- pata_hd_go_to_sector (pata_hd_sector_select,1) --
go to the uers selected sector, set to write 1 sector
+ pata_hd_go_to_sector (pata_hd_sector_select,1) --
go to the correct sector, set to write 1 sector
pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_WRITE_SECTOR) --
send the write command to the command register
pata_hd_data_request(PATA_HD_WAIT_WRITE) --
wait till data is ready to be read
end if
@@ -465,6 +434,18 @@
pata_hd_iowr = low ^ PATA_HD_NO_INVERTER
end procedure
+--
----------------------------------------------------------------------------
+-- Send a number of write pulses to data register sending 0's as data.
+-- Used to get to the end of a sector or to get to a certain
+-- location in a sector.
+-- Increment pata_hd_word_count
+--
----------------------------------------------------------------------------
+procedure pata_hd_write_pulse( byte in z ) is begin
+ for z loop -- send write pulse z number of times
+ pata_hd_write_data (0,0)
+ end loop
+end procedure
+
--
----------------------------------------------------------------------------
-- Tell drive you are done writing
--
----------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---