reset.c 924 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-01-13 weety modified from mini2440
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "at91sam9g45.h"
  13. /**
  14. * @addtogroup AT91SAM926X
  15. */
  16. /*@{*/
  17. void machine_reset(void)
  18. {
  19. AT91C_BASE_RSTC->RSTC_RCR = AT91C_RSTC_KEY | AT91C_RSTC_PROCRST | AT91C_RSTC_PERRST;
  20. }
  21. void machine_shutdown(void)
  22. {
  23. AT91C_BASE_SHDWC->SHDWC_SHCR = AT91C_SHDWC_KEY | AT91C_SHDWC_SHDW;
  24. }
  25. #ifdef RT_USING_FINSH
  26. #include <finsh.h>
  27. #ifdef FINSH_USING_MSH
  28. int cmd_reset(int argc, char** argv)
  29. {
  30. rt_hw_cpu_reset();
  31. return 0;
  32. }
  33. MSH_CMD_EXPORT_ALIAS(cmd_reset, reset, restart the system);
  34. int cmd_shutdown(int argc, char** argv)
  35. {
  36. rt_hw_cpu_shutdown();
  37. return 0;
  38. }
  39. MSH_CMD_EXPORT_ALIAS(cmd_shutdown, shutdown, shutdown the system);
  40. #endif
  41. #endif
  42. /*@}*/