提交 590c84cf 编写于 作者: mysterywolf's avatar mysterywolf

[amebaz] auto & manual formatted

上级 1ba020f3
/* /*
* File : startup.c * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
* *
* The license and distribution terms for this file may be * SPDX-License-Identifier: Apache-2.0
* found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
......
/* /*
* File : smartconfig_demo.c * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
......
/* /*
* File : board.c * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 RT-Thread Develop Team
* *
* The license and distribution terms for this file may be * SPDX-License-Identifier: Apache-2.0
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
...@@ -44,7 +40,7 @@ void __wrap_rtl_printf(const char *fmt, ...) ...@@ -44,7 +40,7 @@ void __wrap_rtl_printf(const char *fmt, ...)
* length. */ * length. */
length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args); length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args);
if (length > RT_CONSOLEBUF_SIZE - 1) if (length > RT_CONSOLEBUF_SIZE - 1)
length = RT_CONSOLEBUF_SIZE - 1; length = RT_CONSOLEBUF_SIZE - 1;
rt_kprintf("%s", rt_log_buf); rt_kprintf("%s", rt_log_buf);
va_end(args); va_end(args);
} }
...@@ -89,11 +85,11 @@ void rt_hw_board_init(void) ...@@ -89,11 +85,11 @@ void rt_hw_board_init(void)
#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END); rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
#endif #endif
#ifdef RT_USING_COMPONENTS_INIT #ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init(); rt_components_board_init();
#endif #endif
#ifdef RT_USING_CONSOLE #ifdef RT_USING_CONSOLE
rt_hw_uart_init(); rt_hw_uart_init();
rt_console_set_device(RT_CONSOLE_DEVICE_NAME); rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
......
/* /*
* File : board.h * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * SPDX-License-Identifier: Apache-2.0
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
......
/* /*
* File : drv_uart.c * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
...@@ -125,7 +111,7 @@ static int ameba_uart_getc (struct rt_serial_device *serial) ...@@ -125,7 +111,7 @@ static int ameba_uart_getc (struct rt_serial_device *serial)
{ {
struct device_uart* uart = serial->parent.user_data; struct device_uart* uart = serial->parent.user_data;
if(!serial_readable(&uart->serial)) if(!serial_readable(&uart->serial))
return -1; return -1;
/* Receive Data Available */ /* Receive Data Available */
...@@ -140,13 +126,13 @@ static rt_size_t ameba_uart_dma_transmit (struct rt_serial_device *serial, rt_ui ...@@ -140,13 +126,13 @@ static rt_size_t ameba_uart_dma_transmit (struct rt_serial_device *serial, rt_ui
static void ameba_uart_irq(uint32_t id, SerialIrq event) static void ameba_uart_irq(uint32_t id, SerialIrq event)
{ {
struct rt_serial_device *serial = (struct rt_serial_device *)id; struct rt_serial_device *serial = (struct rt_serial_device *)id;
if(event == RxIrq) if(event == RxIrq)
{ {
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }
else if(event == TxIrq) else if(event == TxIrq)
{ {
} }
} }
static rt_err_t dbg_configure(struct rt_serial_device *serial, struct serial_configure *cfg); static rt_err_t dbg_configure(struct rt_serial_device *serial, struct serial_configure *cfg);
...@@ -155,7 +141,7 @@ static int dbg_putc(struct rt_serial_device *serial, char c); ...@@ -155,7 +141,7 @@ static int dbg_putc(struct rt_serial_device *serial, char c);
static int dbg_getc(struct rt_serial_device *serial); static int dbg_getc(struct rt_serial_device *serial);
static struct rt_serial_device ameba_dbg_serial; static struct rt_serial_device ameba_dbg_serial;
const struct rt_uart_ops _ambed_dbg_ops = const struct rt_uart_ops _ambed_dbg_ops =
{ {
dbg_configure, dbg_configure,
dbg_control, dbg_control,
...@@ -177,7 +163,7 @@ void dbg_uart_irq_handler(void * data) ...@@ -177,7 +163,7 @@ void dbg_uart_irq_handler(void * data)
DiagSetIsrEnReg(0); DiagSetIsrEnReg(0);
rt_hw_serial_isr(&ameba_dbg_serial, RT_SERIAL_EVENT_RX_IND); rt_hw_serial_isr(&ameba_dbg_serial, RT_SERIAL_EVENT_RX_IND);
DiagSetIsrEnReg(IrqEn); DiagSetIsrEnReg(IrqEn);
} }
...@@ -192,9 +178,9 @@ static rt_err_t dbg_control(struct rt_serial_device *serial, int cmd, void *arg) ...@@ -192,9 +178,9 @@ static rt_err_t dbg_control(struct rt_serial_device *serial, int cmd, void *arg)
case RT_DEVICE_CTRL_SET_INT: case RT_DEVICE_CTRL_SET_INT:
/* install interrupt */ /* install interrupt */
DIAG_UartReInit((IRQ_FUN) dbg_uart_irq_handler); DIAG_UartReInit((IRQ_FUN) dbg_uart_irq_handler);
/* Enable the UART Interrupt */ /* Enable the UART Interrupt */
NVIC_SetPriority(UART_LOG_IRQ, 10); /* this is rom_code_patch */ NVIC_SetPriority(UART_LOG_IRQ, 10); /* this is rom_code_patch */
break; break;
} }
...@@ -214,12 +200,12 @@ static int dbg_getc(struct rt_serial_device *serial) ...@@ -214,12 +200,12 @@ static int dbg_getc(struct rt_serial_device *serial)
if(!UART_Readable(UART2_DEV)) if(!UART_Readable(UART2_DEV))
return -1; return -1;
c = DiagGetChar(_FALSE); c = DiagGetChar(_FALSE);
return c; return c;
} }
/* /*
* UART Initiation * UART Initiation
*/ */
...@@ -231,7 +217,7 @@ int rt_hw_uart_init(void) ...@@ -231,7 +217,7 @@ int rt_hw_uart_init(void)
#ifdef BSP_USING_UART0 #ifdef BSP_USING_UART0
{ {
struct device_uart *uart; struct device_uart *uart;
serial = &serial0; serial = &serial0;
uart = &uart0; uart = &uart0;
...@@ -256,7 +242,7 @@ int rt_hw_uart_init(void) ...@@ -256,7 +242,7 @@ int rt_hw_uart_init(void)
serial->ops = &_ambed_dbg_ops; serial->ops = &_ambed_dbg_ops;
serial->config = config; serial->config = config;
rt_hw_serial_register(serial, rt_hw_serial_register(serial,
RT_CONSOLE_DEVICE_NAME, RT_CONSOLE_DEVICE_NAME,
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
......
/* /*
* File : drv_uart.h * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
......
/* /*
* File : drv_wifi.c * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
...@@ -115,7 +101,7 @@ void netif_pre_sleep_processing(void) ...@@ -115,7 +101,7 @@ void netif_pre_sleep_processing(void)
} }
unsigned char *rltk_wlan_get_ip(int idx) unsigned char *rltk_wlan_get_ip(int idx)
{ {
struct ameba_wifi *wifi; struct ameba_wifi *wifi;
wifi = rthw_wifi_get_dev(idx); wifi = rthw_wifi_get_dev(idx);
...@@ -130,7 +116,7 @@ unsigned char *rltk_wlan_get_ip(int idx) ...@@ -130,7 +116,7 @@ unsigned char *rltk_wlan_get_ip(int idx)
int netif_is_valid_IP(int idx, unsigned char *ip_dest) int netif_is_valid_IP(int idx, unsigned char *ip_dest)
{ {
LOG_D("F:%s L:%d is run ip: %d:%d:%d:%d", __FUNCTION__, __LINE__, LOG_D("F:%s L:%d is run ip: %d:%d:%d:%d", __FUNCTION__, __LINE__,
ip_dest[0], ip_dest[1], ip_dest[2], ip_dest[3]); ip_dest[0], ip_dest[1], ip_dest[2], ip_dest[3]);
return 1; return 1;
} }
...@@ -376,9 +362,9 @@ static rt_err_t rthw_wlan_join (struct rt_wlan_device *wlan, str ...@@ -376,9 +362,9 @@ static rt_err_t rthw_wlan_join (struct rt_wlan_device *wlan, str
ssid = &sta_info->ssid.val[0]; ssid = &sta_info->ssid.val[0];
if (sta_info->key.len > 0) if (sta_info->key.len > 0)
key = &sta_info->key.val[0]; key = &sta_info->key.val[0];
LOG_D("bssid connect bssid: %02x:%02x:%02x:%02x:%02x:%02x ssid:%s ssid_len:%d key:%s key_len%d", LOG_D("bssid connect bssid: %02x:%02x:%02x:%02x:%02x:%02x ssid:%s ssid_len:%d key:%s key_len%d",
sta_info->bssid[0],sta_info->bssid[1],sta_info->bssid[2],sta_info->bssid[3],sta_info->bssid[4],sta_info->bssid[5], sta_info->bssid[0],sta_info->bssid[1],sta_info->bssid[2],sta_info->bssid[3],sta_info->bssid[4],sta_info->bssid[5],
ssid, ssid,
sta_info->ssid.len, sta_info->ssid.len,
key, key,
sta_info->key.len sta_info->key.len
...@@ -608,7 +594,7 @@ exit: ...@@ -608,7 +594,7 @@ exit:
return RT_EOK; return RT_EOK;
} }
static const struct rt_wlan_dev_ops ops = static const struct rt_wlan_dev_ops ops =
{ {
.wlan_init = rthw_wlan_init , .wlan_init = rthw_wlan_init ,
.wlan_mode = rthw_wlan_mode , .wlan_mode = rthw_wlan_mode ,
......
/* /*
* File : drv_wifi.h * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2017-5-30 Bernard the first version * 2017-5-30 Bernard the first version
*/ */
#ifndef __DRV_WIFI_H__ #ifndef __DRV_WIFI_H__
#define __DRV_WIFI_H__ #define __DRV_WIFI_H__
......
/* /*
* File : drv_wlan.c * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
...@@ -151,20 +137,20 @@ int rthw_wifi_ap_start(char *ssid, char *password, int channel) ...@@ -151,20 +137,20 @@ int rthw_wifi_ap_start(char *ssid, char *password, int channel)
return -1; return -1;
} }
while(1) while(1)
{ {
char essid[33]; char essid[33];
if(wext_get_ssid(name, (unsigned char *) essid) > 0) if(wext_get_ssid(name, (unsigned char *) essid) > 0)
{ {
if(strcmp((const char *) essid, (const char *)ssid) == 0) if(strcmp((const char *) essid, (const char *)ssid) == 0)
{ {
rt_kprintf("%s started\n", ssid); rt_kprintf("%s started\n", ssid);
break; break;
} }
} }
if(timeout == 0) if(timeout == 0)
{ {
rt_kprintf("Start AP timeout\n"); rt_kprintf("Start AP timeout\n");
return -1; return -1;
} }
rt_thread_delay(1 * RT_TICK_PER_SECOND); rt_thread_delay(1 * RT_TICK_PER_SECOND);
...@@ -183,7 +169,7 @@ static int rthw_wifi_disconnect(char *name) ...@@ -183,7 +169,7 @@ static int rthw_wifi_disconnect(char *name)
if (name == RT_NULL) if (name == RT_NULL)
return -1; return -1;
if (wext_get_ssid(name, (unsigned char *) essid) < 0) if (wext_get_ssid(name, (unsigned char *) essid) < 0)
{ {
rt_kprintf("\nWIFI disconnected!\n"); rt_kprintf("\nWIFI disconnected!\n");
return -1; return -1;
...@@ -203,7 +189,7 @@ static int rthw_wifi_disconnect(char *name) ...@@ -203,7 +189,7 @@ static int rthw_wifi_disconnect(char *name)
break; break;
} }
if(timeout == 0) if(timeout == 0)
{ {
rt_kprintf("ERROR: Deassoc timeout!\n"); rt_kprintf("ERROR: Deassoc timeout!\n");
return -1; return -1;
...@@ -259,7 +245,7 @@ int rthw_wifi_ap_disconnect(void) ...@@ -259,7 +245,7 @@ int rthw_wifi_ap_disconnect(void)
int rthw_wifi_rssi_get(void) int rthw_wifi_rssi_get(void)
{ {
int rssi = 0; int rssi = 0;
wifi_get_rssi(&rssi); wifi_get_rssi(&rssi);
return rssi; return rssi;
} }
......
/* /*
* File : drv_wlan.h * Copyright (c) 2006-2021, RT-Thread Development Team
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * SPDX-License-Identifier: Apache-2.0
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
...@@ -25,14 +11,14 @@ ...@@ -25,14 +11,14 @@
#ifndef __DRV_WLAN_H__ #ifndef __DRV_WLAN_H__
#define __DRV_WLAN_H__ #define __DRV_WLAN_H__
typedef enum typedef enum
{ {
RTHW_MODE_NONE = 0, RTHW_MODE_NONE = 0,
RTHW_MODE_STA, RTHW_MODE_STA,
RTHW_MODE_AP, RTHW_MODE_AP,
RTHW_MODE_STA_AP, RTHW_MODE_STA_AP,
RTHW_MODE_PROMISC, RTHW_MODE_PROMISC,
RTHW_MODE_P2P RTHW_MODE_P2P
}rthw_mode_t; }rthw_mode_t;
#define SHARED_ENABLED 0x00008000 #define SHARED_ENABLED 0x00008000
...@@ -66,7 +52,7 @@ typedef enum { ...@@ -66,7 +52,7 @@ typedef enum {
typedef enum { typedef enum {
RTHW_WIFI_EVENT_CONNECT = 0, RTHW_WIFI_EVENT_CONNECT = 0,
RTHW_WIFI_EVENT_DISCONNECT = 1, RTHW_WIFI_EVENT_DISCONNECT = 1,
RTHW_WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2, RTHW_WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
RTHW_WIFI_EVENT_SCAN_RESULT_REPORT = 3, RTHW_WIFI_EVENT_SCAN_RESULT_REPORT = 3,
RTHW_WIFI_EVENT_SCAN_DONE = 4, RTHW_WIFI_EVENT_SCAN_DONE = 4,
RTHW_WIFI_EVENT_RECONNECTION_FAIL = 5, RTHW_WIFI_EVENT_RECONNECTION_FAIL = 5,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册