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