drv_rcc.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. * 2020-07-27 thread-liu first version
  9. */
  10. #include "board.h"
  11. //#define DRV_DEBUG
  12. #define LOG_TAG "drv.rcc"
  13. #include <drv_log.h>
  14. #include <string.h>
  15. #include <stdlib.h>
  16. static void enable_clock(void)
  17. {
  18. __HAL_RCC_GPIOH_CLK_ENABLE();
  19. }
  20. static void disable_clock(void)
  21. {
  22. __HAL_RCC_GPIOH_CLK_DISABLE();
  23. }
  24. static int rcc_sample(int argc, char *argv[])
  25. {
  26. if (argc > 1)
  27. {
  28. if (!strcmp(argv[1], "enable"))
  29. {
  30. enable_clock();
  31. return RT_EOK;
  32. }
  33. else if (!strcmp(argv[1], "disable"))
  34. {
  35. disable_clock();
  36. return RT_EOK;
  37. }
  38. else
  39. {
  40. goto _exit;
  41. }
  42. }
  43. _exit:
  44. {
  45. rt_kprintf("Usage:\n");
  46. rt_kprintf("rcc_sample enable - enable GPIOH clock, the LD7 will blink '\n");
  47. rt_kprintf("rcc_sample disable - disable GPIOH clock, the LD7 will stop blink'\n");
  48. }
  49. return -RT_ERROR;
  50. }
  51. MSH_CMD_EXPORT(rcc_sample, rcc use sample);