rt-thread-official/bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rcc.c

58 lines
1.2 KiB
C
Raw Permalink Normal View History

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-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)
{
__HAL_RCC_GPIOH_CLK_ENABLE();
2020-09-04 10:23:08 +08:00
}
static void disable_clock(void)
{
__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");
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);