[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 "drv_mmheap.h"
#include "hal_uart.h"
@ -29,9 +29,9 @@ static uint8_t dma_tc_flag0 = 0;
void dma_ch2_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
{
if (!state)
{
if (!state) {
dma_tc_flag0 = 1;
MSG("dma transfer success\r\n");
}
}
@ -53,28 +53,28 @@ int main(void)
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
struct device *uart = device_find("uart1");
if (uart)
{
device_open(uart, DEVICE_OFLAG_DMA_TX);
if (uart) {
device_open(uart, DEVICE_OFLAG_DMA_TX);
}
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
struct device* dma_ch2 = device_find("ch2");
if (dma_ch2)
{
struct device *dma_ch2 = device_find("ch2");
if (dma_ch2) {
device_open(dma_ch2, 0);
device_set_callback(dma_ch2, dma_ch2_irq_callback);
device_control(dma_ch2, DEVICE_CTRL_SET_INT, NULL);
}
device_control(uart,DEVICE_CTRL_ATTACH_TX_DMA,dma_ch2);
while (1)
{
device_write(uart,0,src_buffer,4100);
while (dma_tc_flag0 == 0)
{
device_control(uart, DEVICE_CTRL_ATTACH_TX_DMA, dma_ch2);
while (1) {
device_write(uart, 0, src_buffer, 4100);
while (dma_tc_flag0 == 0) {
bflb_platform_delay_ms(1);
}
bflb_platform_delay_ms(1000);
}
}

View file

@ -1,36 +1,33 @@
/**
* @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_uart.h"
void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
{
if (state == UART_EVENT_RX_FIFO)
{
device_write(dev,0,(uint8_t *)args,size);
}
else if (state == UART_EVENT_RTO)
{
device_write(dev,0,(uint8_t *)args,size);
if (state == UART_EVENT_RX_FIFO) {
device_write(dev, 0, (uint8_t *)args, size);
} else if (state == UART_EVENT_RTO) {
device_write(dev, 0, (uint8_t *)args, size);
}
}
@ -40,15 +37,12 @@ int main(void)
struct device *uart = device_find("debug_log");
if (uart)
{
if (uart) {
device_set_callback(uart, uart_irq_callback);
device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT));
device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
}
while (1)
{
__asm volatile ("nop");
while (1) {
__asm volatile("nop");
}
}

View file

@ -1,42 +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_uart.h"
const uint8_t buffer[10]="12345678\r\n";
const uint8_t buffer[10] = "12345678\r\n";
int main(void)
{
bflb_platform_init(0);
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
struct device *uart1 = device_find("uart1");
if (uart1)
{
if (uart1) {
device_open(uart1, DEVICE_OFLAG_STREAM_TX);
MSG("device find success\r\n");
}
device_write(uart1,0,buffer,10);
while(1)
{
device_write(uart1, 0, buffer, 10);
while (1) {
MSG("\r\n uart0 and uart1 poll tx case\r\n");
bflb_platform_delay_ms(1000);
bflb_platform_delay_ms(1000);
}
}

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_mtimer.h"
#include "hal_uart.h"
@ -27,46 +27,41 @@ void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t s
{
uint8_t i = 0;
if (state == UART_EVENT_RX_FIFO)
{
if (state == UART_EVENT_RX_FIFO) {
MSG("rf\r\n");
for (i = 0; i < size; i++)
{
MSG("0x%x ", (*(uint8_t *)(args+i)));
for (i = 0; i < size; i++) {
MSG("0x%x ", (*(uint8_t *)(args + i)));
}
MSG("\r\n");
}
else if (state == UART_EVENT_RTO)
{
} else if (state == UART_EVENT_RTO) {
MSG("rto\r\n");
for (i = 0; i < size; i++)
{
MSG("0x%x ", (*(uint8_t *)(args+i)));
for (i = 0; i < size; i++) {
MSG("0x%x ", (*(uint8_t *)(args + i)));
}
MSG("\r\n");
}
}
const char* string = "uart1 poll tx and rx irq test\r\n";
const char *string = "uart1 poll tx and rx irq test\r\n";
int main(void)
{
bflb_platform_init(0);
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
struct device *uart1 = device_find("uart1");
if (uart1)
{
if (uart1) {
device_open(uart1, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX);
device_set_callback(uart1, uart_irq_callback);
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT));
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
}
while (1)
{
device_write(uart1,0,string,strlen(string));
while (1) {
device_write(uart1, 0, string, strlen(string));
bflb_platform_delay_ms(1000);
}
}