2020-09-04 10:23:08 +08:00
|
|
|
/*
|
2021-03-14 15:33:55 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2020-09-04 10:23:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2020-07-27 thread-liu first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "board.h"
|
2020-10-24 11:59:21 +08:00
|
|
|
|
2020-09-04 10:23:08 +08:00
|
|
|
//#define DRV_DEBUG
|
|
|
|
#define LOG_TAG "drv.rcc"
|
|
|
|
#include <drv_log.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
static void enable_clock(void)
|
|
|
|
{
|
2020-10-24 11:59:21 +08:00
|
|
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
2020-09-04 10:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void disable_clock(void)
|
|
|
|
{
|
2020-10-24 11:59:21 +08:00
|
|
|
__HAL_RCC_GPIOH_CLK_DISABLE();
|
2020-09-04 10:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rcc_sample(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[1], "enable"))
|
2021-03-14 15:33:55 +08:00
|
|
|
{
|
2020-09-04 10:23:08 +08:00
|
|
|
enable_clock();
|
|
|
|
return RT_EOK;
|
|
|
|
}
|
|
|
|
else if (!strcmp(argv[1], "disable"))
|
|
|
|
{
|
|
|
|
disable_clock();
|
|
|
|
return RT_EOK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
goto _exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_exit:
|
|
|
|
{
|
|
|
|
rt_kprintf("Usage:\n");
|
2020-10-24 11:59:21 +08:00
|
|
|
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");
|
2020-09-04 10:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return -RT_ERROR;
|
|
|
|
}
|
|
|
|
MSH_CMD_EXPORT(rcc_sample, rcc use sample);
|