gba_sio.pas 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. (*
  2. gba_sio.pas 18/06/2006 4.23.01
  3. ------------------------------------------------------------------------------
  4. This lib is a raw porting of libgba library for gba (you can find it at
  5. http://www.devkitpro.org).
  6. As this is a direct port from c, I'm pretty sure that something could not work
  7. as you expect. I am even more sure that this code could be written better, so
  8. if you think that I have made some mistakes or you have some better
  9. implemented functions, let me know [francky74 (at) gmail (dot) com]
  10. Enjoy!
  11. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  12. (http://www.freepascal.org)
  13. Copyright (C) 2006 Francesco Lombardi
  14. This library is free software; you can redistribute it and/or
  15. modify it under the terms of the GNU Lesser General Public
  16. License as published by the Free Software Foundation; either
  17. version 2.1 of the License, or (at your option) any later version.
  18. This library is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. Lesser General Public License for more details.
  22. You should have received a copy of the GNU Lesser General Public
  23. License along with this library; if not, write to the Free Software
  24. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. ------------------------------------------------------------------------------
  26. *)
  27. unit gba_sio;
  28. {$i def.inc}
  29. interface
  30. uses
  31. gba_types;
  32. const
  33. SIO_8BIT = $0000; // Normal 8-bit communication mode
  34. SIO_32BIT = $1000; // Normal 32-bit communication mode
  35. SIO_MULTI = $2000; // Multi-play communication mode
  36. SIO_UART = $3000; // UART communication mode
  37. SIO_IRQ = $4000; // Enable serial irq
  38. //---------------------------------------------------------------------------------
  39. // baud rate settings
  40. //---------------------------------------------------------------------------------
  41. SIO_9600 = $0000;
  42. SIO_38400 = $0001;
  43. SIO_57600 = $0002;
  44. SIO_115200 = $0003;
  45. SIO_CLK_INT = (1 shl 0); // Select internal clock
  46. SIO_2MHZ_CLK = (1 shl 1); // Select 2MHz clock
  47. SIO_RDY = (1 shl 2); // Opponent SO state
  48. SIO_SO_HIGH = (1 shl 3); // Our SO state
  49. SIO_START = (1 shl 7);
  50. //---------------------------------------------------------------------------------
  51. // SIO modes set with REG_RCNT
  52. //---------------------------------------------------------------------------------
  53. R_NORMAL = $0000;
  54. R_MULTI = $0000;
  55. R_UART = $0000;
  56. R_GPIO = $8000;
  57. R_JOYBUS = $C000;
  58. //---------------------------------------------------------------------------------
  59. // General purpose mode control bits used with REG_RCNT
  60. //---------------------------------------------------------------------------------
  61. GPIO_SC = $0001; // Data
  62. GPIO_SD = $0002;
  63. GPIO_SI = $0004;
  64. GPIO_SO = $0008;
  65. GPIO_SC_IO = $0010; // Select I/O
  66. GPIO_SD_IO = $0020;
  67. GPIO_SI_IO = $0040;
  68. GPIO_SO_IO = $0080;
  69. GPIO_SC_INPUT = $0000; // Input setting
  70. GPIO_SD_INPUT = $0000;
  71. GPIO_SI_INPUT = $0000;
  72. GPIO_SO_INPUT = $0000;
  73. GPIO_SC_OUTPUT = $0010; // Output setting
  74. GPIO_SD_OUTPUT = $0020;
  75. GPIO_SI_OUTPUT = $0040;
  76. GPIO_SO_OUTPUT = $0080;
  77. implementation
  78. end.