1
0

cpu.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * File : cpu.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2010-07-09 Bernard first version
  13. * 2010-09-11 Bernard add CPU reset implementation
  14. */
  15. #include <rtthread.h>
  16. #include <jz4755.h>
  17. /* Watchdog definitions */
  18. #define WDT_CLK_PRESCALE_CLK1 ( 0x0 << 3)
  19. #define WDT_CLK_PRESCALE_CLK4 ( 0x1 << 3)
  20. #define WDT_CLK_PRESCALE_CLK16 ( 0x2 << 3)
  21. #define WDT_CLK_PRESCALE_CLK64 ( 0x3 << 3)
  22. #define WDT_CLK_PRESCALE_CLK256 ( 0x4 << 3)
  23. #define WDT_CLK_PRESCALE_CLK1024 ( 0x5 << 3)
  24. #define WDT_CLK_PRESCALE_MASK ( 0x3F << 3)
  25. #define WDT_CLK_EXTAL ( 0x1 << 2)
  26. #define WDT_CLK_RTC ( 0x1 << 1)
  27. #define WDT_CLK_PCLK ( 0x1 << 0)
  28. #define WDT_CLK_MASK ( 7 )
  29. #define WDT_ENABLE ( 1 << 0 )
  30. /**
  31. * @addtogroup Jz47xx
  32. */
  33. /*@{*/
  34. /**
  35. * this function will reset CPU
  36. *
  37. */
  38. void rt_hw_cpu_reset()
  39. {
  40. /* open the watch-dog */
  41. WDT_TCSR = WDT_CLK_EXTAL;
  42. WDT_TCSR |= WDT_CLK_PRESCALE_CLK1024;
  43. WDT_TDR = 0x03;
  44. WDT_TCNT = 0x00;
  45. WDT_TCER |= WDT_ENABLE;
  46. rt_kprintf("reboot system...\n");
  47. while (1);
  48. }
  49. /**
  50. * this function will shutdown CPU
  51. *
  52. */
  53. void rt_hw_cpu_shutdown()
  54. {
  55. rt_kprintf("shutdown...\n");
  56. while (1);
  57. }
  58. /*@}*/