mirror of
https://github.com/pine64/bl_iot_sdk.git
synced 2024-09-02 21:19:20 +00:00
83 lines
3.1 KiB
C
83 lines
3.1 KiB
C
/*
|
|
* Copyright (c) 2020 Bouffalolab.
|
|
*
|
|
* This file is part of
|
|
* *** Bouffalolab Software Dev Kit ***
|
|
* (see www.bouffalolab.com).
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
* are permitted provided that the following conditions are met:
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
* and/or other materials provided with the distribution.
|
|
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <cli.h>
|
|
#include <bl602_glb.h>
|
|
#include <blog.h>
|
|
#include <FreeRTOS.h>
|
|
#include <task.h>
|
|
|
|
typedef struct _para_div {
|
|
int hdiv;
|
|
int bdiv;
|
|
} para_div;
|
|
|
|
static void clk(void *para)
|
|
{
|
|
para_div *p = (para_div *)para;
|
|
int hdiv = p->hdiv;
|
|
int bdiv = p->bdiv;
|
|
blog_info("hdiv:%d, bdiv:%d\r\n", hdiv, bdiv);
|
|
|
|
vTaskEnterCritical();
|
|
__disable_irq();
|
|
GLB_Set_System_CLK_Div(hdiv, bdiv);
|
|
__enable_irq();
|
|
vTaskExitCritical();
|
|
vTaskDelete(NULL);
|
|
}
|
|
|
|
static void cmd_clk_change(char *buf, int len, int argc, char **argv)
|
|
{
|
|
para_div clk_div;
|
|
if (3 != argc) {
|
|
blog_info("please input para!\r\n");
|
|
return;
|
|
} else {
|
|
clk_div.hdiv = atoi(argv[1]);
|
|
clk_div.bdiv = atoi(argv[2]);
|
|
xTaskCreate(clk, (char*)"clk", 512, &clk_div, 20, NULL );
|
|
}
|
|
}
|
|
|
|
const static struct cli_command cmds_user[] STATIC_CLI_CMD_ATTRIBUTE = {
|
|
{ "clk", "change hdiv and bdiv", cmd_clk_change},
|
|
};
|
|
|
|
int bl_sys_cli_init(void)
|
|
{
|
|
// static command(s) do NOT need to call aos_cli_register_command(s) to register.
|
|
// However, calling aos_cli_register_command(s) here is OK but is of no effect as cmds_user are included in cmds list.
|
|
// XXX NOTE: Calling this *empty* function is necessary to make cmds_user in this file to be kept in the final link.
|
|
//return aos_cli_register_commands(cmds_user, sizeof(cmds_user)/sizeof(cmds_user[0]));
|
|
return 0;
|
|
}
|