drv_rcc.c 1.2 KB
Newer Older
T
thread-liu 已提交
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author            Notes
 * 2020-07-27     thread-liu        first version
 */

#include "board.h"
12

T
thread-liu 已提交
13 14 15 16 17 18 19 20
//#define DRV_DEBUG
#define LOG_TAG             "drv.rcc"
#include <drv_log.h>
#include <string.h>
#include <stdlib.h>

static void enable_clock(void)
{
21
    __HAL_RCC_GPIOH_CLK_ENABLE();
T
thread-liu 已提交
22 23 24 25
}

static void disable_clock(void)
{
26
    __HAL_RCC_GPIOH_CLK_DISABLE();
T
thread-liu 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
}

static int rcc_sample(int argc, char *argv[])
{
    if (argc > 1)
    {
        if (!strcmp(argv[1], "enable"))
        { 
           enable_clock();
           return RT_EOK;
        }
        else if (!strcmp(argv[1], "disable"))
        {
            disable_clock();
            return RT_EOK;
        }
        else
        {
            goto _exit;
        }
    }
_exit:
    {
        rt_kprintf("Usage:\n");
51 52
        rt_kprintf("rcc_sample enable        - enable GPIOH clock, the LD7 will blink '\n");
        rt_kprintf("rcc_sample disable       - disable GPIOH clock, the LD7 will stop blink'\n");
T
thread-liu 已提交
53 54 55 56 57
    }

    return -RT_ERROR;
}
MSH_CMD_EXPORT(rcc_sample, rcc use sample);