Shop OBEX P1 Docs P2 Docs Learn Events
P2 - SD Driver (PASM) v2.50 Release (fastspin & pnut) — Parallax Forums

P2 - SD Driver (PASM) v2.50 Release (fastspin & pnut)

Cluso99Cluso99 Posts: 18,069
edited 2020-06-03 23:05 in Propeller 2
SD Driver (PASM) for fastspin and pnut

This release breaks my driver code into code blocks. They are brought together in one demo program. The SD Driver operates in its' own COG and is called by utilising a 4 long mailbox in HUB.

Since pnut does not have the #include function I had to copy all modules' code into the demo program SD_DEMO_pnut.spin2 whereas the demo program SD_Demo.spin2 is much cleaner because it uses the #include function to bring the modules together.

I will update this thread with more details as time permits.

The demo program uses the inbuilt ROM Serial/Debugger/Monitor to display the function of the demo program. The SD Driver is broken up into modules that can operate in COG or LUT (or untested probably HUB). The easiest way to describe their functions is for me to copy the comments in the routines.
'' +---------------------------------------------------------------------------+
'' +  This program demonstrates the use of the SD Driver modules by using the  +
'' +  inbuilt Serial/Monitor ROM in the P2.                                    +
'' +  My serial driver module could also be used and is left up to the user.   +
'' +---------------------------------------------------------------------------+
'' +  SD_DEMO       Demonstration user code for using the SD Driver objects    +
'' +  MON_CONST     Constants/Equates to use the Serial/Monitor ROM            +
'' +  SD_CONST      SD Driver: Constants/Equates used internally by drivers    +
'' +  SD_MBOX       SD Driver: Mailbox Server                                  +
'' +  SD_BASE       SD Driver: Server base code                                +
'' +                  Initialise, readFastSector, writeFastSector,             +
'' +                  readFastCSD, readFastCID                                 +
'' +  SD_WALK       SD Driver: Walks the SD Card FAT32 Directory tree          +
'' +                  SDWalk:  Walks the MBR/VOL/DIR tree, returns DIR_BEGIN   +
'' +                  searchDIR: Searches the Directory for a filename,        +
'' +                    returns the file start sector and file size (bytes)    +
'' +  SD_REGS       SD Driver: Internal COG Registers required by the Driver   +
'' +---------------------------------------------------------------------------+

The demo program initialises the SD Card, reads the FAT32 directory and then locates a number of files on the card. These are the files I use for Z80/CPM emulation. You can change these to ones that will be on your card. Just be sure to keep the exact string format. Currently there are 9 files that I search for, and there is no error handling. So if a file is not found you will receive an error message and the program will jump to the ROM Monitor where you can examine COG/LUT/HUB in your demo COG (note: this is not the driver COG).
This is what you should see if you have the files I search for, or the names you have changed.
C:\P2\Propeller_II_Latest\SDDriver_250>l420 sd_demo.binary -b115200 -t -SINGLE
( Entering terminal mode.  Press Ctrl-] to exit. )

P2 SD Demo v2.50 2020-06-04
Initialise
Find Directory
Find file(s)
  A: ZICOG_A2.DSK  sector 0000E580 size 00800000
  B: ZICOG_B .DSK  sector 00012580 size 00800000
  C: ZICOG_C .DSK  sector 00016580 size 02000000
  D: ZICOG_D .DSK  sector 00026580 size 00800000
  E: DRAC_A  .DSK  sector 000064C0 size 00800000
  F: DRAC_B  .DSK  sector 0000A4C0 size 00800000
  G: ZICOG_G .DSK  sector 00032580 size 00100000
  H: ZICOG_H .DSK  sector 00032D80 size 00100000
  Z: BOOTHDSK.ROM  sector 00006480 size 00000400
*
Note the demo program places these modules into a separate COG and starts that COG. All the org and orgh commands are placed in the demo program meaning that the modules' code can be placed in COG/LUT/HUB at your discretion.

You will note that these modules have been marked for PASM use only. They most likely will not work with any set of programs that use SPIN2. This is because the addressing is "broken" from my perspective so I have abandoned any software that requires spin. It's sad but this is reality.
This is why I did not use my other SD Driver thread.

Enjoy :sunglasses:

Comments

Sign In or Register to comment.