card.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. (*
  2. $Id: card.inc 25 2007-12-10 21:06:46Z p4p3r0 $
  3. ------------------------------------------------------------------------------
  4. Copyright (C) 2005
  5. Jason Rogers (dovoto)
  6. Dave Murphy (WinterMute)
  7. This software is provided 'as-is', without any express or implied
  8. warranty. In no event will the authors be held liable for any
  9. damages arising from the use of this software.
  10. Permission is granted to anyone to use this software for any
  11. purpose, including commercial applications, and to alter it and
  12. redistribute it freely, subject to the following restrictions:
  13. 1. The origin of this software must not be misrepresented; you
  14. must not claim that you wrote the original software. If you use
  15. this software in a product, an acknowledgment in the product
  16. documentation would be appreciated but is not required.
  17. 2. Altered source versions must be plainly marked as such, and
  18. must not be misrepresented as being the original software.
  19. 3. This notice may not be removed or altered from any source
  20. distribution.
  21. ------------------------------------------------------------------------------
  22. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  23. (http://www.freepascal.org)
  24. Copyright (C) 2006 Francesco Lombardi
  25. Check http://sourceforge.net/projects/libndsfpc for updates
  26. ------------------------------------------------------------------------------
  27. $Log$
  28. *)
  29. {$ifdef NDS_INTERFACE}
  30. const
  31. // Card bus
  32. CARD_CR1 : pcuint16 = pointer($040001A0);
  33. CARD_CR1H : pcuint8 = pointer($040001A1);
  34. CARD_EEPDATA : pcuint8 = pointer($040001A2);
  35. CARD_CR2 : pcuint32 = pointer($040001A4);
  36. CARD_COMMAND : pcuint8 = pointer($040001A8);
  37. CARD_DATA_RD : pcuint32 = pointer($04100010);
  38. CARD_1B0 : pcuint32 = pointer($040001B0);
  39. CARD_1B4 : pcuint32 = pointer($040001B4);
  40. CARD_1B8 : pcuint16 = pointer($040001B8);
  41. CARD_1BA : pcuint16 = pointer($040001BA);
  42. CARD_CR1_ENABLE = $80; // in byte 1, i.e. 0x8000
  43. CARD_CR1_IRQ = $40; // in byte 1, i.e. 0x4000
  44. // CARD_CR2 register:
  45. CARD_ACTIVATE = (1 shl 31); // when writing, get the ball rolling
  46. // 1<<30
  47. CARD_nRESET = (1 shl 29); // value on the /reset pin (1 = high out, not a reset state, 0 = low out = in reset)
  48. CARD_28 = (1 shl 28); // when writing
  49. CARD_27 = (1 shl 27); // when writing
  50. CARD_26 = (1 shl 26);
  51. CARD_22 = (1 shl 22);
  52. CARD_19 = (1 shl 19);
  53. CARD_ENCRYPTED = (1 shl 14); // when writing, this command should be encrypted
  54. CARD_13 = (1 shl 13); // when writing
  55. CARD_4 = (1 shl 4); // when writing
  56. // 3 bits in b10..b8 indicate something
  57. // read bits
  58. CARD_BUSY = (1 shl 31); // when reading, still expecting incomming data?
  59. CARD_DATA_READY = (1 shl 23); // when reading, CARD_DATA_RD or CARD_DATA has another word of data and is good to go
  60. procedure cardWriteCommand(const command: pcuint8); cdecl; external;
  61. procedure cardPolledTransfer(flags: cuint32; destination: pcuint32; length: cuint32; const command: pcuint8); cdecl; external;
  62. procedure cardStartTransfer(const command: pcuint8; destination: pcuint32; channel: cint; flags: cuint32); cdecl; external;
  63. function cardWriteAndRead(const command: pcuint8; flags: cuint32): cuint32; cdecl; external;
  64. procedure cardRead00(address: cuint32; destination: pcuint32; length: cuint32; flags: cuint32); cdecl; external;
  65. procedure cardReadHeader(header: pcuint8); cdecl; external;
  66. function cardReadID(flags: cuint32): cint; cdecl; external;
  67. procedure cardReadEeprom(address: cuint32; data: pcuint8; length: cuint32; addrtype: cuint32); cdecl; external;
  68. procedure cardWriteEeprom(address: cuint32; data: pcuint8; length: cuint32; addrtype: cuint32); cdecl; external;
  69. function cardEepromReadID(i: cuint8): cuint8; cdecl; external;
  70. function cardEepromCommand(command: cuint8; address: cuint32): cuint8; cdecl; external;
  71. function cardEepromGetType({void}): cint; cdecl; external;
  72. function cardEepromGetSize(): cuint32; cdecl; external;
  73. procedure cardEepromChipErase({void}); cdecl; external;
  74. procedure cardEepromSectorErase(address: cuint32); cdecl; external;
  75. {$endif NDS_INTERFACE}