nuthwinit.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2004 by Jan Dubiec. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY JAN DUBIEC AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JAN DUBIEC
  21. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. /*
  30. * $Log$
  31. * Revision 1.1 2004/03/16 16:48:26 haraldkipp
  32. * Added Jan Dubiec's H8/300 port.
  33. *
  34. */
  35. /*
  36. * Hardware initialisation routine. It is called before .text and .data
  37. * sections are initialised. Bus controller and other essential hardware
  38. * setup code should be placed here.
  39. *
  40. * The code is partially based on an example distributed with H8 gcc.
  41. *
  42. * Author: Jan Dubiec <jdx@slackware.pl>
  43. *
  44. */
  45. /* definition of the bus & wait-state controller register addresses */
  46. #include <h83068f.h>
  47. __attribute__ ((section(".init")))
  48. void NutHWInit(void)
  49. {
  50. /*
  51. * disable system clock output; switch peripherials (except SCI1,SCI2, DMAC
  52. * and 16 bit timer) into standby mode
  53. */
  54. MSTCR.WORD = 0xf9ad;
  55. /* Area 4 accessed without wait states */
  56. BSC.WCR.BIT.W4 = 0;
  57. /* enable /CS4 signal */
  58. BSC.CSCR.BYTE = 0x1f;
  59. /* Enable /WAIT pin */
  60. BSC.BCR.BIT.WAITE = 1;
  61. /* set P1 to be address bus */
  62. P1DDR = 0xff;
  63. /* set P2 to be address bus */
  64. P2DDR = 0xff;
  65. /* set P5 to be address bus */
  66. P5DDR = 0xff;
  67. /* P6.2 is output pin (ReaDY LED) */
  68. P6DDR = 0x82;
  69. /* set up port 8 */
  70. P8DDR = 0xee;
  71. /* set up port 9 */
  72. P9DDR = 0xc2;
  73. /* set up port A */
  74. PADDR = 0x0e;
  75. /* set up port B */
  76. PBDDR = 0x63;
  77. /* disable IRQ0 */
  78. INTC.IER.BIT.IRQ0E = 0;
  79. /* disable IMIA0 interrupt */
  80. ITU.TISRA.BIT.IMIEA0 = 0;
  81. /* stop timer 0 */
  82. ITU.TSTR.BIT.STR0 = 0;
  83. /* Initially the ReaDY LED is off */
  84. P6DR.BIT.B1 = 1; /* just for testing; will be removed soon */
  85. }