drv_rcc.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2006-2022, 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_GPIOD_CLK_ENABLE();
  19. }
  20. static void disable_clock(void)
  21. {
  22. __HAL_RCC_GPIOD_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 GPIOD clock, the LD8 will blink '\n");
  47. rt_kprintf("rcc_sample disable - disable GPIOD clock, the LD8 will stop blink'\n");
  48. }
  49. return -RT_ERROR;
  50. }
  51. MSH_CMD_EXPORT(rcc_sample, rcc use sample);