reset.c 790 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-08-30 Tao Huang The first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "hal_base.h"
  13. #include "hal_bsp.h"
  14. #ifdef RT_USING_RESET
  15. void rt_hw_cpu_reset(void)
  16. {
  17. #ifdef RT_USING_SND_GLB_RST
  18. HAL_CRU_SetGlbSrst(GLB_SRST_SND);
  19. #else
  20. HAL_CRU_SetGlbSrst(GLB_SRST_FST);
  21. #endif
  22. while (1);
  23. }
  24. #ifdef RT_USING_FINSH
  25. #include <finsh.h>
  26. static void reboot(uint8_t argc, char **argv)
  27. {
  28. if (argc >= 2 && !strncmp(argv[1], "loader", 6))
  29. {
  30. BSP_SetLoaderFlag();
  31. }
  32. rt_hw_cpu_reset();
  33. }
  34. MSH_CMD_EXPORT(reboot, Reboot System);
  35. #endif /* RT_USING_FINSH */
  36. #endif /* RT_USING_RESET */