[style] format files by clang-format

This commit is contained in:
jzlv 2021-06-20 12:25:46 +08:00
parent 47ce9f871c
commit d427e7fdda
1131 changed files with 7338846 additions and 422042 deletions

View file

@ -1,24 +1,24 @@
/**
* @file main.c
* @brief
*
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*
*/
#include "hal_timer.h"
@ -30,51 +30,48 @@ int main(void)
bflb_platform_init(0);
timer_user_cfg_t timer_user_cfg0;
timer_user_cfg0.timeout_val = 1000*10; /* us */
timer_user_cfg0.comp_it = TIMER_COMP0_IT;
timer_user_cfg0.timeout_val = 1000 * 10; /* us */
timer_user_cfg0.comp_it = TIMER_COMP0_IT;
timer_user_cfg_t timer_user_cfg1;
timer_user_cfg1.timeout_val = 1000*100; /* us */
timer_user_cfg1.comp_it = TIMER_COMP1_IT;
timer_user_cfg1.timeout_val = 1000 * 100; /* us */
timer_user_cfg1.comp_it = TIMER_COMP1_IT;
timer_user_cfg_t timer_user_cfg2;
timer_user_cfg2.timeout_val = 1000*1000; /* us */
timer_user_cfg2.comp_it = TIMER_COMP2_IT;
timer_user_cfg2.timeout_val = 1000 * 1000; /* us */
timer_user_cfg2.comp_it = TIMER_COMP2_IT;
timer_register(TIMER_CH1_INDEX, "timer_ch1", DEVICE_OFLAG_RDWR);
struct device* timer_ch1 = device_find("timer_ch1");
struct device *timer_ch1 = device_find("timer_ch1");
if(timer_ch1)
{
if (timer_ch1) {
device_open(timer_ch1, DEVICE_OFLAG_POLL);
device_control(timer_ch1, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg0));
device_control(timer_ch1, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg1));
device_control(timer_ch1, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg2));
}
else
{
} else {
MSG("timer device open failed! \n");
}
while(1)
{
if(SET == device_control(timer_ch1,DEVICE_CTRL_GET_MATCH_STATUS,(void*)TIMER_EVENT_COMP2))
{
while (1) {
if (SET == device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP2)) {
MSG("Comparator 2 match, timer reload\n");
device_control(timer_ch1, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg0));
device_control(timer_ch1, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg1));
device_control(timer_ch1, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg2));
MSG("Counter value=%d,M0=%d, M1=%d,M2=%d \n", device_control(timer_ch1, DEVICE_CTRL_GET_CONFIG,NULL),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void*)TIMER_EVENT_COMP0),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void*)TIMER_EVENT_COMP1),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void*)TIMER_EVENT_COMP2));
MSG("Counter value=%d,M0=%d, M1=%d,M2=%d \n", device_control(timer_ch1, DEVICE_CTRL_GET_CONFIG, NULL),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP0),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP1),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP2));
break;
}
MSG("Counter value=%d,M0=%d, M1=%d,M2=%d \n", device_control(timer_ch1, DEVICE_CTRL_GET_CONFIG,NULL),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void*)TIMER_EVENT_COMP0),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void*)TIMER_EVENT_COMP1),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void*)TIMER_EVENT_COMP2));
MSG("Counter value=%d,M0=%d, M1=%d,M2=%d \n", device_control(timer_ch1, DEVICE_CTRL_GET_CONFIG, NULL),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP0),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP1),
device_control(timer_ch1, DEVICE_CTRL_GET_MATCH_STATUS, (void *)TIMER_EVENT_COMP2));
}
BL_CASE_SUCCESS;
}

View file

@ -1,47 +1,43 @@
/**
* @file main.c
* @brief
*
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*
*/
#include "hal_timer.h"
#include "bflb_platform.h"
struct device* timer_ch0;
struct device *timer_ch0;
volatile uint32_t cnt = 0;
void timer_ch0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
{
MSG("timer ch0 interrupt! \n");
if(state == TIMER_EVENT_COMP0)
{
cnt ++;
if (state == TIMER_EVENT_COMP0) {
cnt++;
MSG("timer event comp0! cnt=%d\n", cnt);
}
else if(state == TIMER_EVENT_COMP1)
{
} else if (state == TIMER_EVENT_COMP1) {
MSG("timer event comp1! \n");
}
else if(state == TIMER_EVENT_COMP2)
{
} else if (state == TIMER_EVENT_COMP2) {
MSG("timer event comp2! \n");
}
}
@ -51,33 +47,27 @@ int main(void)
bflb_platform_init(0);
timer_user_cfg_t timer_user_cfg;
timer_user_cfg.timeout_val = 1000*1000; /* us */
timer_user_cfg.timeout_val = 1000 * 1000; /* us */
timer_user_cfg.comp_it = TIMER_COMP0_IT;
timer_register(TIMER_CH0_INDEX, "timer_ch0", DEVICE_OFLAG_RDWR);
timer_ch0 = device_find("timer_ch0");
if(timer_ch0)
{
if (timer_ch0) {
device_open(timer_ch0, DEVICE_OFLAG_INT);
device_set_callback(timer_ch0, timer_ch0_irq_callback);
device_control(timer_ch0, DEVICE_CTRL_SET_INT,NULL);
device_control(timer_ch0, DEVICE_CTRL_SET_INT, NULL);
device_control(timer_ch0, DEVICE_CTRL_TIMER_CH_START, (void *)(&timer_user_cfg));
}
else
{
} else {
MSG("timer device open failed! \n");
}
while(1)
{
if(cnt == 10)
{
while (1) {
if (cnt == 10) {
device_control(timer_ch0, DEVICE_CTRL_TIMER_CH_STOP, (void *)(&timer_user_cfg));
MSG("timer test over! \n");
BL_CASE_SUCCESS;
}
}
}