clock.inc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. (*
  2. $Id: clock.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. {$ifndef ARM7}
  30. {$error The clock is only available on the ARM7}
  31. {$endif ARM7}
  32. {$ifdef NDS_INTERFACE}
  33. const
  34. // RTC registers
  35. WRITE_STATUS_REG1 = $60;
  36. READ_STATUS_REG1 = $61;
  37. STATUS_POC = (1 shl 7); // read-only, cleared by reading (1 if just powered on)
  38. STATUS_BLD = (1 shl 6); // read-only, cleared by reading (1 if power dropped below the safety threshold)
  39. STATUS_INT2 = (1 shl 5); // read-only, INT2 has occured
  40. STATUS_INT1 = (1 shl 4); // read-only, INT1 has occured
  41. STATUS_SC1 = (1 shl 3); // R/W scratch bit
  42. STATUS_SC0 = (1 shl 2); // R/W scratch bit
  43. STATUS_24HRS = (1 shl 1); // 24 hour mode when 1, 12 hour mode when 0
  44. STATUS_RESET = (1 shl 0); // write-only, reset when 1 written
  45. WRITE_STATUS_REG2 = $62;
  46. READ_STATUS_REG2 = $63;
  47. STATUS_TEST = (1 shl 7); //
  48. STATUS_INT2AE = (1 shl 6); //
  49. STATUS_SC3 = (1 shl 5); // R/W scratch bit
  50. STATUS_SC2 = (1 shl 4); // R/W scratch bit
  51. STATUS_32kE = (1 shl 3); // Interrupt mode bits
  52. STATUS_INT1AE = (1 shl 2); //
  53. STATUS_INT1ME = (1 shl 1); //
  54. STATUS_INT1FE = (1 shl 0); //
  55. // full 7 bytes for time and date
  56. WRITE_TIME_AND_DATE = $64;
  57. READ_TIME_AND_DATE = $65;
  58. // last 3 bytes of current time
  59. WRITE_TIME = $66;
  60. READ_TIME = $67;
  61. WRITE_INT_REG1 = $68;
  62. READ_INT_REG1 = $69;
  63. READ_INT_REG2 = $6A;
  64. WRITE_INT_REG2 = $6B;
  65. READ_CLOCK_ADJUST_REG = $6C;
  66. WRITE_CLOCK_ADJUST_REG = $6D;
  67. // clock-adjustment register
  68. READ_FREE_REG = $6E;
  69. WRITE_FREE_REG = $6F;
  70. procedure rtcReset(); cdecl; external;
  71. procedure rtcTransaction(command: pcuint8; commandLength: cuint32; result: pcuint8; resultLength: cuint32); cdecl; external;
  72. procedure rtcGetTime(time: pcuint8); cdecl; external;
  73. procedure rtcSetTime(time: pcuint8); cdecl; external;
  74. procedure rtcGetData(data: pcuint8; size: cuint32); cdecl; external;
  75. procedure rtcGetTimeAndDate(time: pcuint8); cdecl; external;
  76. procedure rtcSetTimeAndDate(time: pcuint8); cdecl; external;
  77. procedure BCDToInteger(data: pcuint8; length: cuint32); cdecl; external;
  78. procedure integerToBCD(data: pcuint8; length: uint32); cdecl; external;
  79. procedure initClockIRQ(); cdecl; external;
  80. {$endif NDS_INTERFACE}