mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-30 11:08:49 +08:00
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
This commit is contained in:
+6
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* File : rt_low_level_iar.inc
|
||||
* File : rt_low_level_init.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
*
|
||||
@@ -19,8 +19,10 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-04-14 ArdaFu first version
|
||||
* 2018-06-04 ArdaFu first version
|
||||
*/
|
||||
#ifndef __RT_LOW_LEVEL_INIT_H__
|
||||
#define __RT_LOW_LEVEL_INIT_H__
|
||||
|
||||
/*-------- Stack size of CPU modes -------------------------------------------*/
|
||||
#define UND_STK_SIZE 512
|
||||
@@ -29,3 +31,5 @@
|
||||
#define IRQ_STK_SIZE 1024
|
||||
#define FIQ_STK_SIZE 1024
|
||||
#define SYS_STK_SIZE 512
|
||||
#define Heap_Size 512
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
;/*
|
||||
; * File : rt_low_level_keil.inc
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
; *
|
||||
; * This program is free software; you can redistribute it and/or modify
|
||||
; * 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:
|
||||
; * Date Author Notes
|
||||
; * 2015-04-14 ArdaFu first version
|
||||
; */
|
||||
|
||||
;/*-------- Stack size of CPU modes ------------------------------------------*/
|
||||
UND_STK_SIZE EQU 512
|
||||
SVC_STK_SIZE EQU 4096
|
||||
ABT_STK_SIZE EQU 512
|
||||
IRQ_STK_SIZE EQU 1024
|
||||
FIQ_STK_SIZE EQU 1024
|
||||
SYS_STK_SIZE EQU 512
|
||||
Heap_Size EQU 512
|
||||
END
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* File : rt_low_level_gcc.inc
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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:
|
||||
* Date Author Notes
|
||||
* 2015-04-14 ArdaFu first version
|
||||
*/
|
||||
|
||||
/*--------- Stack size of CPU modes ------------------------------------------*/
|
||||
.equ UND_STK_SIZE, 2048
|
||||
.equ SVC_STK_SIZE, 4096
|
||||
.equ ABT_STK_SIZE, 2048
|
||||
.equ IRQ_STK_SIZE, 4096
|
||||
.equ FIQ_STK_SIZE, 4096
|
||||
.equ SYS_STK_SIZE, 2048
|
||||
+6
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* File : rt_low_level_iar.inc
|
||||
* File : rt_low_level_init.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
*
|
||||
@@ -19,8 +19,10 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-04-14 ArdaFu first version
|
||||
* 2018-06-04 ArdaFu first version
|
||||
*/
|
||||
#ifndef __RT_LOW_LEVEL_INIT_H__
|
||||
#define __RT_LOW_LEVEL_INIT_H__
|
||||
|
||||
/*-------- Stack size of CPU modes -------------------------------------------*/
|
||||
#define UND_STK_SIZE 512
|
||||
@@ -29,3 +31,5 @@
|
||||
#define IRQ_STK_SIZE 1024
|
||||
#define FIQ_STK_SIZE 1024
|
||||
#define SYS_STK_SIZE 512
|
||||
#define Heap_Size 512
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
;/*
|
||||
; * File : rt_low_level_keil.inc
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
; *
|
||||
; * This program is free software; you can redistribute it and/or modify
|
||||
; * 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:
|
||||
; * Date Author Notes
|
||||
; * 2015-04-14 ArdaFu first version
|
||||
; */
|
||||
|
||||
;/*-------- Stack size of CPU modes ------------------------------------------*/
|
||||
UND_STK_SIZE EQU 512
|
||||
SVC_STK_SIZE EQU 4096
|
||||
ABT_STK_SIZE EQU 512
|
||||
IRQ_STK_SIZE EQU 1024
|
||||
FIQ_STK_SIZE EQU 1024
|
||||
SYS_STK_SIZE EQU 512
|
||||
END
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <platform.h>
|
||||
#include <encoding.h>
|
||||
#include <interrupt.h>
|
||||
#include <drv_led.h>
|
||||
|
||||
extern void use_default_clocks(void);
|
||||
extern void use_pll(int refsel, int bypass, int r, int f, int q);
|
||||
|
||||
@@ -434,6 +434,8 @@ rt_err_t lpc_emac_tx(rt_device_t dev, struct pbuf *p)
|
||||
ENET_Type *enet_base = lpc_emac_device.base;
|
||||
uint8_t * data;
|
||||
|
||||
uint16_t len;
|
||||
|
||||
RT_ASSERT(p != NULL);
|
||||
RT_ASSERT(enet_handle != RT_NULL);
|
||||
|
||||
@@ -454,11 +456,13 @@ rt_err_t lpc_emac_tx(rt_device_t dev, struct pbuf *p)
|
||||
}
|
||||
}
|
||||
|
||||
data = (uint8_t *)ENET_ALIGN(&lpc_emac_device.RxDataBuff[lpc_emac_device.txIdx * ENET_ALIGN(ENET_RXBUFF_SIZE)]);
|
||||
pbuf_copy_partial(p, data, p->tot_len, 0);
|
||||
// fix RxDataBuff -> TxDataBuff, ENET_RXBUFF_SIZE -> ENET_TXBUFF_SIZE
|
||||
data = (uint8_t *)ENET_ALIGN(&lpc_emac_device.TxDataBuff[lpc_emac_device.txIdx * ENET_ALIGN(ENET_TXBUFF_SIZE)]);
|
||||
len = pbuf_copy_partial(p, data, p->tot_len, 0);
|
||||
lpc_emac_device.txIdx = (lpc_emac_device.txIdx + 1) / ENET_TXBD_NUM;
|
||||
|
||||
result = ENET_SendFrame(enet_base, enet_handle, data, p->len);
|
||||
// fix 'p->len' to 'len', avoid send wrong partial packet.
|
||||
result = ENET_SendFrame(enet_base, enet_handle, data, len);
|
||||
|
||||
if ((result == kStatus_ENET_TxFrameFail) || (result == kStatus_ENET_TxFrameOverLen) || (result == kStatus_ENET_TxFrameBusy))
|
||||
{
|
||||
|
||||
@@ -408,6 +408,22 @@ rt_err_t mci_hw_init(const char *device_name)
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
follow the page: https://community.nxp.com/thread/454769
|
||||
|
||||
The issue concerns sdmmc library bug (I finally solved) in SD_Init() in the file sdmmc/src/fsl_sd.c:SD_SelectBusTiming()
|
||||
calls SD_SwitchFunction() which sets block size to 64bytes (512bits).Therefore SD_SetBlockSize(card, FSL_SDMMC_DEFAULT_BLOCK_SIZE)
|
||||
should be called again before SD_Init() exits.
|
||||
*/
|
||||
|
||||
if (kStatus_Success != SDMMC_SetBlockSize(_mci_device->card.host.base, _mci_device->card.host.transfer, FSL_SDMMC_DEFAULT_BLOCK_SIZE))
|
||||
{
|
||||
SD_Deinit(&_mci_device->card);
|
||||
memset(&_mci_device->card, 0U, sizeof(_mci_device->card));
|
||||
rt_kprintf("SD_Init failed!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* initialize mutex lock */
|
||||
rt_mutex_init(&_mci_device->lock, device_name, RT_IPC_FLAG_FIFO);
|
||||
/* create finish event */
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-11-02 勤为本 first version
|
||||
* 2017-11-02 勤为本 first version
|
||||
* 2018-06-09 zhuangwei add spi0 cs0 support,remove msd_init
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
@@ -69,28 +70,28 @@ static rt_err_t configure(struct rt_spi_device *device,
|
||||
spi_base = ls1c_spi_get_base(SPIx);
|
||||
|
||||
{
|
||||
// 使能SPI控制器,master模式,关闭中断
|
||||
// 使能SPI控制器,master模式,关闭中断
|
||||
reg_write_8(0x53, spi_base + LS1C_SPI_SPCR_OFFSET);
|
||||
|
||||
// 清空状态寄存器
|
||||
// 清空状态寄存器
|
||||
reg_write_8(0xc0, spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||
|
||||
// 1字节产生中断,采样(读)与发送(写)时机同时
|
||||
// 1字节产生中断,采样(读)与发送(写)时机同时
|
||||
reg_write_8(0x03, spi_base + LS1C_SPI_SPER_OFFSET);
|
||||
|
||||
// 关闭SPI flash
|
||||
// 关闭SPI flash
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SFC_PARAM_OFFSET);
|
||||
val &= 0xfe;
|
||||
reg_write_8(val, spi_base + LS1C_SPI_SFC_PARAM_OFFSET);
|
||||
|
||||
// spi flash时序控制寄存器
|
||||
// spi flash时序控制寄存器
|
||||
reg_write_8(0x05, spi_base + LS1C_SPI_SFC_TIMING_OFFSET);
|
||||
}
|
||||
|
||||
// baudrate
|
||||
ls1c_spi_set_clock(spi_base, configuration->max_hz);
|
||||
|
||||
// 设置通信模式(时钟极性和相位)
|
||||
// 设置通信模式(时钟极性和相位)
|
||||
if (configuration->mode & RT_SPI_CPOL) // cpol
|
||||
{
|
||||
cpol = SPI_CPOL_1;
|
||||
@@ -148,7 +149,7 @@ static rt_uint32_t xfer(struct rt_spi_device *device,
|
||||
ls1c_spi_set_cs(spi_base, cs, 0);
|
||||
}
|
||||
|
||||
// 收发数据
|
||||
// 收发数据
|
||||
send_ptr = message->send_buf;
|
||||
recv_ptr = message->recv_buf;
|
||||
while (size--)
|
||||
@@ -200,9 +201,9 @@ static struct rt_spi_bus spi1_bus;
|
||||
|
||||
|
||||
/*
|
||||
* 初始化并注册龙芯1c的spi总线
|
||||
* @SPI SPI总线,比如LS1C_SPI_0, LS1C_SPI_1
|
||||
* @spi_bus_name 总线名字
|
||||
* 初始化并注册龙芯1c的spi总线
|
||||
* @SPI SPI总线,比如LS1C_SPI_0, LS1C_SPI_1
|
||||
* @spi_bus_name 总线名字
|
||||
* @ret
|
||||
*/
|
||||
rt_err_t ls1c_spi_bus_register(rt_uint8_t SPI, const char *spi_bus_name)
|
||||
@@ -236,12 +237,14 @@ int ls1c_hw_spi_init(void)
|
||||
pin_set_purpose(80, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(83, PIN_PURPOSE_OTHER);//cs2 - SD card
|
||||
pin_set_purpose(82, PIN_PURPOSE_OTHER);//cs1
|
||||
pin_set_purpose(81, PIN_PURPOSE_OTHER);//cs0
|
||||
|
||||
pin_set_remap(78, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(79, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(80, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(83, PIN_REMAP_FOURTH);//cs2 - SD card
|
||||
pin_set_remap(82, PIN_REMAP_FOURTH);//cs1
|
||||
pin_set_remap(78, PIN_REMAP_DEFAULT);
|
||||
pin_set_remap(79, PIN_REMAP_DEFAULT);
|
||||
pin_set_remap(80, PIN_REMAP_DEFAULT);
|
||||
pin_set_remap(83, PIN_REMAP_DEFAULT);//cs2 - SD card
|
||||
pin_set_remap(82, PIN_REMAP_DEFAULT);//CS1
|
||||
pin_set_remap(81, PIN_REMAP_DEFAULT);//cs0
|
||||
ls1c_spi_bus_register(LS1C_SPI_0, "spi0");
|
||||
#endif
|
||||
|
||||
@@ -262,8 +265,10 @@ int ls1c_hw_spi_init(void)
|
||||
#ifdef RT_USING_SPI0
|
||||
/* attach cs */
|
||||
{
|
||||
static struct rt_spi_device spi_device0;
|
||||
static struct rt_spi_device spi_device1;
|
||||
static struct rt_spi_device spi_device2;
|
||||
static struct ls1c_spi_cs spi_cs0;
|
||||
static struct ls1c_spi_cs spi_cs1;
|
||||
static struct ls1c_spi_cs spi_cs2;
|
||||
|
||||
@@ -272,7 +277,8 @@ int ls1c_hw_spi_init(void)
|
||||
rt_spi_bus_attach_device(&spi_device2, "spi02", "spi0", (void *)&spi_cs2);
|
||||
spi_cs1.cs = LS1C_SPI_CS_1;
|
||||
rt_spi_bus_attach_device(&spi_device1, "spi01", "spi0", (void *)&spi_cs1);
|
||||
msd_init("sd0", "spi02");
|
||||
spi_cs0.cs = LS1C_SPI_CS_0;
|
||||
rt_spi_bus_attach_device(&spi_device0, "spi00", "spi0", (void *)&spi_cs0);
|
||||
}
|
||||
#endif
|
||||
#ifdef RT_USING_SPI1
|
||||
@@ -287,6 +293,7 @@ int ls1c_hw_spi_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
INIT_BOARD_EXPORT(ls1c_hw_spi_init);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -260,7 +260,7 @@ inline void ls1c_spi_clear(void *spi_base)
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||
if (LS1C_SPI_SPSR_WCOL_MASK & val)
|
||||
{
|
||||
rt_kprintf("[%s] clear register SPSR's wcol!\r\n"); // 手册和linux源码中不一样,加个打印看看
|
||||
rt_kprintf("[%s] clear register SPSR's wcol!\r\n",__FUNCTION__); // 手册和linux源码中不一样,加个打印看看
|
||||
reg_write_8(val & ~LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写0,linux源码中是写0
|
||||
// reg_write_8(val | LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写1,按照1c手册,应该写1
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static rt_err_t stm32f1_wdg_control(rt_watchdog_t *wdt, int cmd, void *arg)
|
||||
switch(cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
|
||||
timeout_ms = (rt_uint32_t) arg;
|
||||
timeout_ms = *((rt_uint32_t*) arg);
|
||||
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
|
||||
if(timeout_ms >= 13107)
|
||||
{
|
||||
|
||||
@@ -66,6 +66,10 @@ config RT_USING_PIN
|
||||
bool "Using generic GPIO device drivers"
|
||||
default y
|
||||
|
||||
config RT_USING_PWM
|
||||
bool "Using PWM device drivers"
|
||||
default n
|
||||
|
||||
config RT_USING_MTD_NOR
|
||||
bool "Using MTD Nor Flash device drivers"
|
||||
default n
|
||||
@@ -162,6 +166,24 @@ config RT_USING_WIFI
|
||||
bool "Using Wi-Fi network"
|
||||
default n
|
||||
|
||||
if RT_USING_WIFI
|
||||
config RT_USING_WLAN_STA
|
||||
bool "Using station mode"
|
||||
default y
|
||||
|
||||
config RT_USING_WLAN_AP
|
||||
bool "Using ap mode"
|
||||
default n
|
||||
|
||||
config WIFI_DEVICE_STA_NAME
|
||||
string "the wifi device name for station"
|
||||
default "w0"
|
||||
|
||||
config WIFI_DEVICE_AP_NAME
|
||||
string "the wifi device name for ap"
|
||||
default "ap"
|
||||
endif
|
||||
|
||||
config RT_USING_AUDIO
|
||||
bool "Using Audio device drivers"
|
||||
default n
|
||||
|
||||
@@ -54,6 +54,9 @@ int cortexm_cputime_init(void)
|
||||
/* check support bit */
|
||||
if ((DWT->CTRL & (1UL << DWT_CTRL_NOCYCCNT_Pos)) == 0)
|
||||
{
|
||||
/* enable trace*/
|
||||
CoreDebug->DEMCR |= (1UL << CoreDebug_DEMCR_TRCENA_Pos);
|
||||
|
||||
/* whether cycle counter not enabled */
|
||||
if ((DWT->CTRL & (1UL << DWT_CTRL_CYCCNTENA_Pos)) == 0)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* File : rt_drv_pwm.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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:
|
||||
* Date Author Notes
|
||||
* 2018-05-07 aozima the first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_PWM_H_INCLUDE__
|
||||
#define __DRV_PWM_H_INCLUDE__
|
||||
|
||||
#define PWM_CMD_ENABLE (128 + 0)
|
||||
#define PWM_CMD_DISABLE (128 + 1)
|
||||
#define PWM_CMD_SET (128 + 2)
|
||||
#define PWM_CMD_GET (128 + 3)
|
||||
|
||||
struct rt_pwm_configuration
|
||||
{
|
||||
rt_uint32_t channel; /* 0-n */
|
||||
rt_uint32_t period; /* unit:ns 1ns~4.29s:1Ghz~0.23hz */
|
||||
rt_uint32_t pulse; /* unit:ns (pulse<=period) */
|
||||
};
|
||||
|
||||
struct rt_device_pwm;
|
||||
struct rt_pwm_ops
|
||||
{
|
||||
rt_err_t (*control)(struct rt_device_pwm *device, int cmd, void *arg);
|
||||
};
|
||||
|
||||
struct rt_device_pwm
|
||||
{
|
||||
struct rt_device parent;
|
||||
const struct rt_pwm_ops *ops;
|
||||
};
|
||||
|
||||
extern rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data);
|
||||
|
||||
#endif /* __DRV_PWM_H_INCLUDE__ */
|
||||
@@ -112,6 +112,10 @@ extern "C" {
|
||||
#include "drivers/cputime.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_PWM
|
||||
#include "drivers/rt_drv_pwm.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,9 @@ group = []
|
||||
if GetDepend(['RT_USING_PIN']):
|
||||
src = src + ['pin.c']
|
||||
|
||||
if GetDepend(['RT_USING_PWM']):
|
||||
src = src + ['rt_drv_pwm.c']
|
||||
|
||||
if len(src):
|
||||
group = DefineGroup('DeviceDrivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* File : rt_drv_pwm.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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:
|
||||
* Date Author Notes
|
||||
* 2018-05-07 aozima the first version
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
|
||||
static rt_err_t _pwm_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev;
|
||||
|
||||
if (pwm->ops->control)
|
||||
{
|
||||
result = pwm->ops->control(pwm, cmd, args);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
pos: channel
|
||||
void *buffer: rt_uint32_t pulse[size]
|
||||
size : number of pulse, only set to sizeof(rt_uint32_t).
|
||||
*/
|
||||
static rt_size_t _pwm_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev;
|
||||
rt_uint32_t *pulse = (rt_uint32_t *)buffer;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
configuration.channel = pos;
|
||||
|
||||
if (pwm->ops->control)
|
||||
{
|
||||
result = pwm->ops->control(pwm, PWM_CMD_GET, &configuration);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
*pulse = configuration.pulse;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
pos: channel
|
||||
void *buffer: rt_uint32_t pulse[size]
|
||||
size : number of pulse, only set to sizeof(rt_uint32_t).
|
||||
*/
|
||||
static rt_size_t _pwm_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device_pwm *pwm = (struct rt_device_pwm *)dev;
|
||||
rt_uint32_t *pulse = (rt_uint32_t *)buffer;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
configuration.channel = pos;
|
||||
|
||||
if (pwm->ops->control)
|
||||
{
|
||||
result = pwm->ops->control(pwm, PWM_CMD_GET, &configuration);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
configuration.pulse = *pulse;
|
||||
|
||||
result = pwm->ops->control(pwm, PWM_CMD_SET, &configuration);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
memset(device, 0, sizeof(struct rt_device_pwm));
|
||||
|
||||
device->parent.type = RT_Device_Class_Miscellaneous;
|
||||
|
||||
device->parent.init = RT_NULL;
|
||||
device->parent.open = RT_NULL;
|
||||
device->parent.close = RT_NULL;
|
||||
device->parent.read = _pwm_read;
|
||||
device->parent.write = _pwm_write;
|
||||
device->parent.control = _pwm_control;
|
||||
|
||||
device->ops = ops;
|
||||
device->parent.user_data = (void *)user_data;
|
||||
|
||||
result = rt_device_register(&device->parent, name, RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_enable(int channel)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device *device = rt_device_find("pwm");
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
if (!device)
|
||||
{
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
configuration.channel = channel;
|
||||
result = rt_device_control(device, PWM_CMD_ENABLE, &configuration);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rt_pwm_set(int channel, rt_uint32_t period, rt_uint32_t pulse)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_device *device = rt_device_find("pwm");
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
if (!device)
|
||||
{
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
configuration.channel = channel;
|
||||
configuration.period = period;
|
||||
configuration.pulse = pulse;
|
||||
result = rt_device_control(device, PWM_CMD_SET, &configuration);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_pwm_enable, pwm_enable, enable pwm by channel.);
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_pwm_set, pwm_set, set pwm.);
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
static int pwm_enable(int argc, char **argv)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
rt_kprintf("Usage: pwm_enable 1\n");
|
||||
result = -RT_ERROR;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
result = rt_pwm_enable(atoi(argv[1]));
|
||||
|
||||
_exit:
|
||||
return result;
|
||||
}
|
||||
MSH_CMD_EXPORT(pwm_enable, pwm_enable 1);
|
||||
|
||||
static int pwm_set(int argc, char **argv)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
rt_kprintf("Usage: pwm_set 1 100 50\n");
|
||||
result = -RT_ERROR;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
result = rt_pwm_set(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
|
||||
|
||||
_exit:
|
||||
return result;
|
||||
}
|
||||
MSH_CMD_EXPORT(pwm_set, pwm_set 1 100 50);
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
|
||||
|
||||
#endif /* RT_USING_FINSH */
|
||||
@@ -216,6 +216,9 @@ sfud_err sfud_spi_port_init(sfud_flash *flash) {
|
||||
flash->spi.lock = spi_lock;
|
||||
flash->spi.unlock = spi_unlock;
|
||||
flash->spi.user_data = flash;
|
||||
if (RT_TICK_PER_SECOND < 1000) {
|
||||
rt_kprintf("[SFUD] Warning: The OS tick(%d) is less than 1000. So the flash write will take more time.\n", RT_TICK_PER_SECOND);
|
||||
}
|
||||
/* 100 microsecond delay */
|
||||
flash->retry.delay = retry_delay_100us;
|
||||
/* 60 seconds timeout */
|
||||
@@ -371,7 +374,7 @@ rt_err_t rt_sfud_flash_delete(rt_spi_flash_device_t spi_flash_dev) {
|
||||
|
||||
static void sf(uint8_t argc, char **argv) {
|
||||
|
||||
#define CMD_SETECT_INDEX 0
|
||||
#define CMD_PROBE_INDEX 0
|
||||
#define CMD_READ_INDEX 1
|
||||
#define CMD_WRITE_INDEX 2
|
||||
#define CMD_ERASE_INDEX 3
|
||||
@@ -384,7 +387,7 @@ static void sf(uint8_t argc, char **argv) {
|
||||
size_t i = 0;
|
||||
|
||||
const char* sf_help_info[] = {
|
||||
[CMD_SETECT_INDEX] = "sf probe [spi_device] - probe and init SPI flash by given 'spi_device'",
|
||||
[CMD_PROBE_INDEX] = "sf probe [spi_device] - probe and init SPI flash by given 'spi_device'",
|
||||
[CMD_READ_INDEX] = "sf read addr size - read 'size' bytes starting at 'addr'",
|
||||
[CMD_WRITE_INDEX] = "sf write addr data1 ... dataN - write some bytes 'data' to flash starting at 'addr'",
|
||||
[CMD_ERASE_INDEX] = "sf erase addr size - erase 'size' bytes starting at 'addr'",
|
||||
@@ -404,7 +407,7 @@ static void sf(uint8_t argc, char **argv) {
|
||||
|
||||
if (!strcmp(operator, "probe")) {
|
||||
if (argc < 3) {
|
||||
rt_kprintf("Usage: %s.\n", sf_help_info[CMD_SETECT_INDEX]);
|
||||
rt_kprintf("Usage: %s.\n", sf_help_info[CMD_PROBE_INDEX]);
|
||||
} else {
|
||||
char *spi_dev_name = argv[2];
|
||||
rtt_dev_bak = rtt_dev;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* File : wlan_cmd.c
|
||||
* Wi-Fi common commands
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2016, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -40,6 +40,13 @@ static char wifi_ssid[32] = {0};
|
||||
static char wifi_key[32] = {0};
|
||||
static int network_mode = WIFI_STATION;
|
||||
|
||||
#define WLAN_DEBUG 1
|
||||
#if WLAN_DEBUG
|
||||
#define WLAN_DBG(...) rt_kprintf("[WLAN]"),rt_kprintf(__VA_ARGS__)
|
||||
#else
|
||||
#define WLAN_DBG(...)
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_SETTING_FN
|
||||
#define WIFI_SETTING_FN "/appfs/setting.json"
|
||||
#endif
|
||||
@@ -397,6 +404,7 @@ int wifi(int argc, char** argv)
|
||||
/* TODO: use easy-join to replace */
|
||||
rt_wlan_info_init(&info, WIFI_STATION, SECURITY_WPA2_MIXED_PSK, argv[3]);
|
||||
rt_wlan_connect(wlan, &info, argv[4]);
|
||||
rt_wlan_info_deinit(&info);
|
||||
}
|
||||
else if (strcmp(argv[2], "up") == 0)
|
||||
{
|
||||
@@ -406,36 +414,28 @@ int wifi(int argc, char** argv)
|
||||
else if (strcmp(argv[2], "down") == 0)
|
||||
{
|
||||
rt_wlan_disconnect(wlan);
|
||||
rt_wlan_info_deinit(&info);
|
||||
}
|
||||
else if (strcmp(argv[2], "scan") == 0)
|
||||
{
|
||||
struct rt_wlan_info *infos;
|
||||
struct rt_wlan_scan_result *scan_result = RT_NULL;
|
||||
|
||||
infos = (struct rt_wlan_info*)rt_malloc(sizeof(struct rt_wlan_info) * 12);
|
||||
if (infos)
|
||||
rt_wlan_scan(wlan, &scan_result);
|
||||
if (scan_result)
|
||||
{
|
||||
int index, num;
|
||||
|
||||
memset(infos, 0x0, sizeof(struct rt_wlan_info) * 12);
|
||||
num = rt_wlan_scan(wlan, infos, 12);
|
||||
|
||||
num = scan_result->ap_num;
|
||||
rt_kprintf("----Wi-Fi APInformation----\n");
|
||||
for (index = 0; index < num; index ++)
|
||||
{
|
||||
rt_kprintf("----Wi-Fi AP[%d] Information----\n", index);
|
||||
rt_kprintf("SSID: %-.32s\n", infos[index].ssid);
|
||||
rt_kprintf("rssi: %d\n", infos[index].rssi);
|
||||
rt_kprintf(" chn: %d\n", infos[index].channel);
|
||||
rt_kprintf("rate: %d\n", infos[index].datarate);
|
||||
rt_kprintf("\n");
|
||||
rt_kprintf("SSID:%-.32s, ", scan_result->ap_table[index].ssid);
|
||||
rt_kprintf("rssi:%d, ", scan_result->ap_table[index].rssi);
|
||||
rt_kprintf("chn:%d, ", scan_result->ap_table[index].channel);
|
||||
rt_kprintf("rate:%d\n", scan_result->ap_table[index].datarate);
|
||||
}
|
||||
|
||||
/* de-initialize info */
|
||||
for (index = 0; index < num; index ++)
|
||||
{
|
||||
rt_wlan_info_deinit(&infos[index]);
|
||||
}
|
||||
rt_free(infos);
|
||||
}
|
||||
rt_wlan_release_scan_result(&scan_result);
|
||||
}
|
||||
else if (strcmp(argv[2], "rssi") == 0)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/*
|
||||
* File : wlan_cmd.h
|
||||
* Wi-Fi common commands
|
||||
* 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
|
||||
* 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:
|
||||
* Date Author Notes
|
||||
* 2018-06-05 RT-Thread first version
|
||||
*/
|
||||
|
||||
#ifndef WLAN_CMD_H__
|
||||
#define WLAN_CMD_H__
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RT-Thread Wi-Fi Device
|
||||
*
|
||||
* COPYRIGHT (C) 2014 - 2015, Shanghai Real-Thread Technology Co., Ltd
|
||||
* COPYRIGHT (C) 2014 - 2018, Shanghai Real-Thread Technology Co., Ltd
|
||||
*
|
||||
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||
*
|
||||
@@ -29,8 +29,6 @@
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include <lwip/netifapi.h>
|
||||
|
||||
#include "wlan_dev.h"
|
||||
#include "wlan_cmd.h"
|
||||
|
||||
@@ -71,6 +69,20 @@ int rt_wlan_init(struct rt_wlan_device* device, rt_wlan_mode_t mode)
|
||||
|
||||
if (device == RT_NULL) return 0;
|
||||
|
||||
if (device->info == RT_NULL)
|
||||
{
|
||||
struct rt_wlan_info *info;
|
||||
char *ssid;
|
||||
|
||||
info = rt_malloc(sizeof(struct rt_wlan_info));
|
||||
if (info)
|
||||
{
|
||||
ssid = rt_malloc(SSID_LENGTH_MAX_SIZE);
|
||||
info->ssid = ssid;
|
||||
}
|
||||
device->info = info;
|
||||
}
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_INIT, (void *)&mode);
|
||||
|
||||
return result;
|
||||
@@ -87,23 +99,9 @@ int rt_wlan_connect(struct rt_wlan_device* device, struct rt_wlan_info* info, ch
|
||||
rt_wlan_set_info(device, info);
|
||||
}
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_EASYJOIN, (void*)password);
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
struct netif *netif = device->parent.netif;
|
||||
|
||||
netifapi_netif_set_up(netif);
|
||||
eth_device_linkchange(&(device->parent), RT_TRUE);
|
||||
|
||||
#ifdef RT_LWIP_DHCP
|
||||
/* set DHCP flags */
|
||||
// netif->flags |= NETIF_FLAG_DHCP;
|
||||
/* start DHCP */
|
||||
dhcp_start(netif);
|
||||
#endif
|
||||
|
||||
rt_strncpy((char *)device->key, (char *)password, sizeof(device->key) - 1);
|
||||
}
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_EASYJOIN, (void *)password);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -119,16 +117,9 @@ int rt_wlan_softap(struct rt_wlan_device* device, struct rt_wlan_info* info, cha
|
||||
rt_wlan_set_info(device, info);
|
||||
}
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_SOFTAP, (void*)password);
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
rt_strncpy((char *)device->key, (char *)password, sizeof(device->key) - 1);
|
||||
|
||||
netifapi_netif_set_up(device->parent.netif);
|
||||
eth_device_linkchange(&(device->parent), RT_TRUE);
|
||||
|
||||
wifi_softap_setup_netif(device->parent.netif);
|
||||
}
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_SOFTAP, (void *)password);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -141,26 +132,23 @@ int rt_wlan_disconnect(struct rt_wlan_device* device)
|
||||
|
||||
/* save event handler */
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_DISCONNECT, RT_NULL);
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
netifapi_netif_set_down(device->parent.netif);
|
||||
eth_device_linkchange(&(device->parent), RT_FALSE);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int rt_wlan_set_info(struct rt_wlan_device *device, struct rt_wlan_info *info)
|
||||
{
|
||||
if (device->info == info) return RT_EOK; /* same info */
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
if (device->info == RT_NULL) return -RT_EIO;
|
||||
|
||||
if (device->info != RT_NULL)
|
||||
{
|
||||
rt_wlan_info_deinit(device->info);
|
||||
rt_free(device->info);
|
||||
}
|
||||
|
||||
device->info = info;
|
||||
device->info->mode = info->mode;
|
||||
device->info->security = info->security;
|
||||
memset(device->info->ssid, 0, SSID_LENGTH_MAX_SIZE);
|
||||
memcpy(device->info->ssid, info->ssid, strlen(info->ssid));
|
||||
memcpy(device->info->bssid, info->bssid, 6);
|
||||
device->info->datarate = info->datarate;
|
||||
device->info->channel = info->channel;
|
||||
device->info->rssi = info->rssi;
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -177,21 +165,13 @@ struct rt_wlan_info *rt_wlan_get_info(struct rt_wlan_device* device)
|
||||
return info;
|
||||
}
|
||||
|
||||
int rt_wlan_scan(struct rt_wlan_device* device, struct rt_wlan_info *infos, int item_sz)
|
||||
int rt_wlan_scan(struct rt_wlan_device *device, struct rt_wlan_scan_result **scan_result)
|
||||
{
|
||||
int result;
|
||||
struct rt_wlan_info_request request;
|
||||
|
||||
if (device == RT_NULL) return 0;
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_SCAN, scan_result);
|
||||
|
||||
request.req_number = item_sz;
|
||||
request.rsp_number = 0;
|
||||
request.infos = infos;
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_SCAN, (void*)&request);
|
||||
result = result; /* skip warning */
|
||||
|
||||
return request.rsp_number;
|
||||
return result;
|
||||
}
|
||||
|
||||
int rt_wlan_get_rssi(struct rt_wlan_device *device)
|
||||
@@ -234,13 +214,104 @@ int rt_wlan_enter_powersave(struct rt_wlan_device* device, int level)
|
||||
return result;
|
||||
}
|
||||
|
||||
void rt_wlan_set_event_callback(struct rt_wlan_device* device, rt_wlan_event_handler handler,
|
||||
void *user_data)
|
||||
int rt_wlan_register_event_handler(struct rt_wlan_device *device, rt_wlan_event_t event,
|
||||
rt_wlan_event_handler handler)
|
||||
{
|
||||
if (device == RT_NULL) return ;
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
if (event >= WIFI_EVT_MAX) return -RT_EINVAL;
|
||||
|
||||
device->handler = handler;
|
||||
device->user_data = user_data;
|
||||
device->handler[event] = handler;
|
||||
|
||||
return ;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
int rt_wlan_unregister_event_handler(struct rt_wlan_device *device, rt_wlan_event_t event)
|
||||
{
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
if (event >= WIFI_EVT_MAX) return -RT_EINVAL;
|
||||
|
||||
device->handler[event] = RT_NULL;
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
int rt_wlan_indicate_event_handle(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
if (event >= WIFI_EVT_MAX) return -RT_EINVAL;
|
||||
|
||||
if (device->handler[event] != RT_NULL)
|
||||
device->handler[event](device, event, user_data);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
int rt_wlan_cfg_monitor(struct rt_wlan_device *device, rt_wlan_monitor_opition_t opition)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_CFG_MONITOR, (void *)&opition);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int rt_wlan_set_monitor_callback(struct rt_wlan_device *device, rt_wlan_monitor_callback_t callback)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_SET_MONITOR_CALLBACK, (void *)callback);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int rt_wlan_set_channel(struct rt_wlan_device *device, int channel)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
|
||||
result = rt_device_control(RT_DEVICE(device), WIFI_SET_CHANNEL, (void *)&channel);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int rt_wlan_get_channel(struct rt_wlan_device *device)
|
||||
{
|
||||
int channel = 0;
|
||||
|
||||
if (device == RT_NULL) return -RT_EIO;
|
||||
|
||||
rt_device_control(RT_DEVICE(device), WIFI_GET_CHANNEL, &channel);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
void rt_wlan_release_scan_result(struct rt_wlan_scan_result **scan_result)
|
||||
{
|
||||
int i, ap_num;
|
||||
struct rt_wlan_scan_result *_scan_result;
|
||||
|
||||
if (*scan_result != RT_NULL)
|
||||
{
|
||||
_scan_result = *scan_result;
|
||||
ap_num = _scan_result->ap_num;
|
||||
for (i = 0; i < ap_num; i++)
|
||||
{
|
||||
if (_scan_result->ap_table[i].ssid != RT_NULL)
|
||||
{
|
||||
rt_free(_scan_result->ap_table[i].ssid);
|
||||
_scan_result->ap_table[i].ssid = RT_NULL;
|
||||
}
|
||||
}
|
||||
_scan_result->ap_num = 0;
|
||||
rt_free(_scan_result->ap_table);
|
||||
_scan_result->ap_table = RT_NULL;
|
||||
}
|
||||
rt_free(*scan_result);
|
||||
*scan_result = RT_NULL;
|
||||
scan_result = RT_NULL;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RT-Thread Wi-Fi Device
|
||||
*
|
||||
* COPYRIGHT (C) 2014 - 2015, Shanghai Real-Thread Technology Co., Ltd
|
||||
* COPYRIGHT (C) 2014 - 2018, Shanghai Real-Thread Technology Co., Ltd
|
||||
*
|
||||
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||
*
|
||||
@@ -25,6 +25,7 @@
|
||||
* Date Author Notes
|
||||
* 2014-09-11 Bernard the first verion
|
||||
*/
|
||||
|
||||
#ifndef WIFI_DEVICE_H__
|
||||
#define WIFI_DEVICE_H__
|
||||
|
||||
@@ -33,6 +34,7 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WIFI_NONE,
|
||||
WIFI_STATION,
|
||||
WIFI_AP,
|
||||
} rt_wlan_mode_t;
|
||||
@@ -47,6 +49,10 @@ typedef enum
|
||||
WIFI_DISCONNECT,
|
||||
WIFI_GET_RSSI, /* get sensitivity (dBm) */
|
||||
WIFI_ENTER_POWERSAVE,
|
||||
WIFI_CFG_MONITOR, /* start/stop minitor */
|
||||
WIFI_SET_CHANNEL,
|
||||
WIFI_GET_CHANNEL,
|
||||
WIFI_SET_MONITOR_CALLBACK,
|
||||
} rt_wlan_cmd_t;
|
||||
|
||||
typedef enum
|
||||
@@ -56,6 +62,12 @@ typedef enum
|
||||
WIFI_PWR_NORMAL
|
||||
} rt_wlan_powersave_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WIFI_MONITOR_START,
|
||||
WIFI_MONITOR_STOP
|
||||
} rt_wlan_monitor_opition_t;
|
||||
|
||||
#define SHARED_ENABLED 0x00008000
|
||||
#define WPA_SECURITY 0x00200000
|
||||
#define WPA2_SECURITY 0x00400000
|
||||
@@ -66,7 +78,7 @@ typedef enum
|
||||
#define WSEC_SWFLAG 0x0008
|
||||
|
||||
#define KEY_ARRAY_SIZE 32
|
||||
|
||||
#define SSID_LENGTH_MAX_SIZE 32 + 1
|
||||
/**
|
||||
* Enumeration of Wi-Fi security modes
|
||||
*/
|
||||
@@ -88,8 +100,17 @@ typedef enum
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WIFI_EVT_INIT_DONE = 0,
|
||||
WIFI_EVT_LINK_DOWN,
|
||||
WIFI_EVT_LINK_UP,
|
||||
WIFI_EVT_CONNECT,
|
||||
WIFI_EVT_DISCONNECT,
|
||||
WIFI_EVT_AP_START,
|
||||
WIFI_EVT_AP_STOP,
|
||||
WIFI_EVENT_STA_ASSOC,
|
||||
WIFI_EVENT_STA_DISASSOC,
|
||||
WIFI_EVT_SCAN_DONE,
|
||||
WIFI_EVT_MAX,
|
||||
} rt_wlan_event_t;
|
||||
|
||||
/* wifi network information */
|
||||
@@ -117,9 +138,15 @@ struct rt_wlan_info_request
|
||||
struct rt_wlan_info *infos;/* the array of information to save response */
|
||||
};
|
||||
|
||||
typedef struct rt_wlan_scan_result
|
||||
{
|
||||
char ap_num;
|
||||
struct rt_wlan_info *ap_table;
|
||||
} rt_wlan_scan_result_t;
|
||||
|
||||
struct rt_wlan_device;
|
||||
typedef void (*rt_wlan_event_handler)(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data);
|
||||
|
||||
typedef void (*rt_wlan_monitor_callback_t)(uint8_t *data, int len, void *user_data);
|
||||
struct rt_wlan_device
|
||||
{
|
||||
struct eth_device parent;
|
||||
@@ -127,7 +154,7 @@ struct rt_wlan_device
|
||||
struct rt_wlan_info *info;
|
||||
char key[KEY_ARRAY_SIZE + 1];
|
||||
|
||||
rt_wlan_event_handler handler;
|
||||
rt_wlan_event_handler handler[WIFI_EVT_MAX];
|
||||
void *user_data;
|
||||
int interface;
|
||||
};
|
||||
@@ -157,7 +184,7 @@ int rt_wlan_set_info(struct rt_wlan_device* device, struct rt_wlan_info* info);
|
||||
struct rt_wlan_info *rt_wlan_get_info(struct rt_wlan_device *device);
|
||||
|
||||
/* get the AP result which were scaned in station */
|
||||
int rt_wlan_scan(struct rt_wlan_device* device, struct rt_wlan_info *infos, int item_sz);
|
||||
int rt_wlan_scan(struct rt_wlan_device *device, struct rt_wlan_scan_result **scan_result);
|
||||
|
||||
/* get rssi */
|
||||
int rt_wlan_get_rssi(struct rt_wlan_device *device);
|
||||
@@ -168,8 +195,26 @@ int rt_wlan_set_mac(struct rt_wlan_device* device,rt_uint8_t hwaddr[6]);
|
||||
/* enter power save level */
|
||||
int rt_wlan_enter_powersave(struct rt_wlan_device *device, int level);
|
||||
|
||||
void rt_wlan_set_event_callback(struct rt_wlan_device* device, rt_wlan_event_handler handler,
|
||||
/* register the event handler */
|
||||
int rt_wlan_register_event_handler(struct rt_wlan_device *device, rt_wlan_event_t event,
|
||||
rt_wlan_event_handler handler);
|
||||
|
||||
/* un-register the event handler */
|
||||
int rt_wlan_unregister_event_handler(struct rt_wlan_device *device, rt_wlan_event_t event);
|
||||
|
||||
/* wlan driver indicate event to upper layer through wifi_indication. */
|
||||
int rt_wlan_indicate_event_handle(struct rt_wlan_device *device, rt_wlan_event_t event,
|
||||
void *user_data);
|
||||
|
||||
#endif
|
||||
/* start or stop monitor */
|
||||
int rt_wlan_cfg_monitor(struct rt_wlan_device *device, rt_wlan_monitor_opition_t opition);
|
||||
|
||||
/* set callback function for monitor mode*/
|
||||
int rt_wlan_set_monitor_callback(struct rt_wlan_device *device, rt_wlan_monitor_callback_t callback);
|
||||
|
||||
/* Set the monitor channel */
|
||||
int rt_wlan_set_channel(struct rt_wlan_device *device, int channel);
|
||||
|
||||
void rt_wlan_release_scan_result(struct rt_wlan_scan_result **scan_result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* RT-Thread Wi-Fi Device
|
||||
*
|
||||
* COPYRIGHT (C) 2014 - 2018, Shanghai Real-Thread Technology Co., Ltd
|
||||
*
|
||||
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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:
|
||||
* Date Author Notes
|
||||
* 2018-02-27 EvalZero the first verion
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include <lwip/netifapi.h>
|
||||
|
||||
#include "wlan_dev.h"
|
||||
#include "wlan_cmd.h"
|
||||
|
||||
#define WLAN_MGNT_DEBUG 1
|
||||
|
||||
#if WLAN_MGNT_DEBUG
|
||||
#define WLAN_MGNT_DBG(...) rt_kprintf("[WLAN_MGNT]"),rt_kprintf(__VA_ARGS__)
|
||||
#else
|
||||
#define WLAN_MGNT_DBG(...)
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_DEVICE_STA_NAME
|
||||
#define WIFI_DEVICE_STA_NAME "w0"
|
||||
#endif
|
||||
#ifndef WIFI_DEVICE_AP_NAME
|
||||
#define WIFI_DEVICE_AP_NAME "ap"
|
||||
#endif
|
||||
|
||||
static void wlan_mgnt_init_done_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan init done event callback \n");
|
||||
}
|
||||
|
||||
static void wlan_mgnt_link_up_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan link up event callback \n");
|
||||
}
|
||||
|
||||
static void wlan_mgnt_link_down_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan link down event callback \n");
|
||||
}
|
||||
|
||||
static void wlan_mgnt_sta_connect_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan sta connect event callback \n");
|
||||
struct netif *netif = device->parent.netif;
|
||||
|
||||
netifapi_netif_set_up(netif);
|
||||
netifapi_netif_set_link_up(netif);
|
||||
#ifdef RT_LWIP_DHCP
|
||||
/* start DHCP */
|
||||
dhcp_start(netif);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void wlan_mgnt_sta_disconnect_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan sta disconnect event callback \n");
|
||||
netifapi_netif_set_down(device->parent.netif);
|
||||
netifapi_netif_set_link_down(device->parent.netif);
|
||||
rt_memset(&device->parent.netif->ip_addr, 0, sizeof(ip_addr_t));
|
||||
rt_memset(&device->parent.netif->netmask, 0, sizeof(ip_addr_t));
|
||||
rt_memset(&device->parent.netif->gw, 0, sizeof(ip_addr_t));
|
||||
#ifdef RT_LWIP_DHCP
|
||||
dhcp_stop(device->parent.netif);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void wlan_mgnt_ap_start_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan ap start event callback \n");
|
||||
netifapi_netif_set_up(device->parent.netif);
|
||||
netifapi_netif_set_link_up(device->parent.netif);
|
||||
|
||||
wifi_softap_setup_netif(device->parent.netif);
|
||||
}
|
||||
|
||||
|
||||
static void wlan_mgnt_ap_stop_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan ap stop event callback \n");
|
||||
|
||||
netifapi_netif_set_down(device->parent.netif);
|
||||
netifapi_netif_set_link_down(device->parent.netif);
|
||||
}
|
||||
|
||||
static void wlan_mgnt_ap_associate_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan ap associate event callback \n");
|
||||
}
|
||||
|
||||
static void wlan_mgnt_ap_disassociate_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan ap disassociate event callback \n");
|
||||
}
|
||||
|
||||
static void wlan_mgnt_scan_done_event(struct rt_wlan_device *device, rt_wlan_event_t event, void *user_data)
|
||||
{
|
||||
WLAN_MGNT_DBG("wlan scan done event callback \n");
|
||||
}
|
||||
|
||||
int rt_wlan_mgnt_attach(struct rt_wlan_device *device, void *user_data)
|
||||
{
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_INIT_DONE, wlan_mgnt_init_done_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_LINK_DOWN, wlan_mgnt_link_up_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_LINK_UP, wlan_mgnt_link_down_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_CONNECT, wlan_mgnt_sta_connect_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_DISCONNECT, wlan_mgnt_sta_disconnect_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_AP_START, wlan_mgnt_ap_start_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_AP_STOP, wlan_mgnt_ap_stop_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVENT_STA_ASSOC, wlan_mgnt_ap_associate_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVENT_STA_DISASSOC, wlan_mgnt_ap_disassociate_event);
|
||||
rt_wlan_register_event_handler(device, WIFI_EVT_SCAN_DONE, wlan_mgnt_scan_done_event);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
/*
|
||||
* File : rt_low_level_gcc.inc
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
* RT-Thread Wi-Fi Device
|
||||
*
|
||||
* COPYRIGHT (C) 2014 - 2018, Shanghai Real-Thread Technology Co., Ltd
|
||||
*
|
||||
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,13 +23,12 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-04-14 ArdaFu first version
|
||||
* 2018-02-27 EvalZero the first verion
|
||||
*/
|
||||
|
||||
/*--------- Stack size of CPU modes ------------------------------------------*/
|
||||
.equ UND_STK_SIZE, 2048
|
||||
.equ SVC_STK_SIZE, 4096
|
||||
.equ ABT_STK_SIZE, 2048
|
||||
.equ IRQ_STK_SIZE, 4096
|
||||
.equ FIQ_STK_SIZE, 4096
|
||||
.equ SYS_STK_SIZE, 2048
|
||||
#ifndef __WLAN_MGNT_H__
|
||||
#define __WLAN_MGNT_H__
|
||||
|
||||
int rt_wlan_mgnt_attach(struct rt_wlan_device *device, void *user_data);
|
||||
|
||||
#endif
|
||||
@@ -70,6 +70,10 @@ config FINSH_USING_MSH_DEFAULT
|
||||
config FINSH_USING_MSH_ONLY
|
||||
bool "Only using module shell"
|
||||
default n
|
||||
|
||||
config FINSH_ARG_MAX
|
||||
int "The command arg num for shell"
|
||||
default 10
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
@@ -37,7 +37,10 @@
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
|
||||
#define RT_FINSH_ARG_MAX 10
|
||||
#ifndef FINSH_ARG_MAX
|
||||
#define FINSH_ARG_MAX 10
|
||||
#endif
|
||||
|
||||
typedef int (*cmd_function_t)(int argc, char **argv);
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
@@ -99,7 +102,7 @@ int msh_help(int argc, char **argv)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(msh_help, __cmd_help, RT-Thread shell help.);
|
||||
|
||||
static int msh_split(char *cmd, rt_size_t length, char *argv[RT_FINSH_ARG_MAX])
|
||||
static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
{
|
||||
char *ptr;
|
||||
rt_size_t position;
|
||||
@@ -118,7 +121,7 @@ static int msh_split(char *cmd, rt_size_t length, char *argv[RT_FINSH_ARG_MAX])
|
||||
ptr ++; position ++;
|
||||
}
|
||||
|
||||
if(argc >= RT_FINSH_ARG_MAX)
|
||||
if(argc >= FINSH_ARG_MAX)
|
||||
{
|
||||
rt_kprintf("Too many args ! We only Use:\n");
|
||||
for(i = 0; i < argc; i++)
|
||||
@@ -284,7 +287,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
|
||||
int argc;
|
||||
rt_size_t cmd0_size = 0;
|
||||
cmd_function_t cmd_func;
|
||||
char *argv[RT_FINSH_ARG_MAX];
|
||||
char *argv[FINSH_ARG_MAX];
|
||||
|
||||
RT_ASSERT(cmd);
|
||||
RT_ASSERT(retp);
|
||||
|
||||
+5
-1
@@ -4,6 +4,7 @@ from building import *
|
||||
|
||||
comm = rtconfig.ARCH + '/common'
|
||||
path = rtconfig.ARCH + '/' + rtconfig.CPU
|
||||
ASFLAGS = ''
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
if rtconfig.PLATFORM == 'armcc':
|
||||
@@ -21,7 +22,10 @@ if rtconfig.PLATFORM == 'cl':
|
||||
if rtconfig.PLATFORM == 'mingw':
|
||||
src = Glob(path + '/*.c')
|
||||
|
||||
if rtconfig.PLATFORM == 'armcc' and rtconfig.ARCH == 'arm' and rtconfig.CPU == 'arm926':
|
||||
ASFLAGS = ' --cpreproc'
|
||||
|
||||
CPPPATH = [RTT_ROOT + '/libcpu/' + rtconfig.ARCH + '/' + rtconfig.CPU, RTT_ROOT + '/libcpu/' + rtconfig.ARCH + '/common']
|
||||
group = DefineGroup(rtconfig.CPU.upper(), src, depend = [''], CPPPATH = CPPPATH)
|
||||
group = DefineGroup(rtconfig.CPU.upper(), src, depend = [''], CPPPATH = CPPPATH, ASFLAGS = ASFLAGS)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
* 2015-06-04 aozima Align stack address to 8 byte.
|
||||
*/
|
||||
|
||||
#include "rt_low_level_init.h"
|
||||
|
||||
#define S_FRAME_SIZE (18*4) //72
|
||||
|
||||
@#define S_SPSR (17*4) //SPSR
|
||||
@@ -54,9 +56,8 @@
|
||||
#define MODE_ABT 0x17
|
||||
#define MODE_UND 0x1B
|
||||
#define MODEMASK 0x1F
|
||||
#define NOINT 0xC0
|
||||
|
||||
.include "rt_low_level_gcc.inc"
|
||||
#define NOINT 0xC0
|
||||
|
||||
@;----------------------- Stack and Heap Definitions ---------------------------
|
||||
.section .nobss, "w"
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
; * 2015-06-04 aozima Align stack address to 8 byte.
|
||||
; */
|
||||
|
||||
#include "rt_low_level_init.h"
|
||||
|
||||
#define S_FRAME_SIZE (18*4) ;72
|
||||
|
||||
;#define S_SPSR (17*4) ;SPSR
|
||||
@@ -54,9 +56,8 @@
|
||||
#define MODE_ABT 0x17
|
||||
#define MODE_UND 0x1B
|
||||
#define MODEMASK 0x1F
|
||||
#define NOINT 0xC0
|
||||
|
||||
#include "rt_low_level_iar.inc"
|
||||
#define NOINT 0xC0
|
||||
|
||||
;----------------------- Stack and Heap Definitions ----------------------------
|
||||
MODULE ?cstartup
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
; * 2015-06-04 aozima Align stack address to 8 byte.
|
||||
; */
|
||||
|
||||
#include "rt_low_level_init.h"
|
||||
|
||||
S_FRAME_SIZE EQU (18*4) ;72
|
||||
;S_SPSR EQU (17*4) ;SPSR
|
||||
;S_CPSR EQU (16*4) ;CPSR
|
||||
@@ -46,7 +48,6 @@ S_PC EQU (15*4) ;R15
|
||||
;S_R1 EQU (1*4)
|
||||
;S_R0 EQU (0*4)
|
||||
|
||||
|
||||
MODE_USR EQU 0X10
|
||||
MODE_FIQ EQU 0X11
|
||||
MODE_IRQ EQU 0X12
|
||||
@@ -58,8 +59,6 @@ MODEMASK EQU 0X1F
|
||||
|
||||
NOINT EQU 0xC0
|
||||
|
||||
GET rt_low_level_keil.inc
|
||||
|
||||
;----------------------- Stack and Heap Definitions ----------------------------
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem
|
||||
|
||||
+20
-2
@@ -487,6 +487,11 @@ def MergeGroup(src_group, group):
|
||||
src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
|
||||
else:
|
||||
src_group['CPPDEFINES'] = group['CPPDEFINES']
|
||||
if group.has_key('ASFLAGS'):
|
||||
if src_group.has_key('ASFLAGS'):
|
||||
src_group['ASFLAGS'] = src_group['ASFLAGS'] + group['ASFLAGS']
|
||||
else:
|
||||
src_group['ASFLAGS'] = group['ASFLAGS']
|
||||
|
||||
# for local CCFLAGS/CPPPATH/CPPDEFINES
|
||||
if group.has_key('LOCAL_CCFLAGS'):
|
||||
@@ -520,6 +525,11 @@ def MergeGroup(src_group, group):
|
||||
src_group['LIBPATH'] = src_group['LIBPATH'] + group['LIBPATH']
|
||||
else:
|
||||
src_group['LIBPATH'] = group['LIBPATH']
|
||||
if group.has_key('LOCAL_ASFLAGS'):
|
||||
if src_group.has_key('LOCAL_ASFLAGS'):
|
||||
src_group['LOCAL_ASFLAGS'] = src_group['LOCAL_ASFLAGS'] + group['LOCAL_ASFLAGS']
|
||||
else:
|
||||
src_group['LOCAL_ASFLAGS'] = group['LOCAL_ASFLAGS']
|
||||
|
||||
def DefineGroup(name, src, depend, **parameters):
|
||||
global Env
|
||||
@@ -550,6 +560,8 @@ def DefineGroup(name, src, depend, **parameters):
|
||||
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES'])
|
||||
if group.has_key('LINKFLAGS'):
|
||||
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS'])
|
||||
if group.has_key('ASFLAGS'):
|
||||
Env.AppendUnique(ASFLAGS = group['ASFLAGS'])
|
||||
|
||||
# check whether to clean up library
|
||||
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
|
||||
@@ -645,13 +657,14 @@ def DoBuilding(target, objects):
|
||||
|
||||
# handle local group
|
||||
def local_group(group, objects):
|
||||
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
|
||||
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES') or group.has_key('LOCAL_ASFLAGS'):
|
||||
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
|
||||
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
|
||||
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
|
||||
ASFLAGS = Env.get('ASFLAGS', '') + group.get('LOCAL_ASFLAGS', '')
|
||||
|
||||
for source in group['src']:
|
||||
objects.append(Env.Object(source, CCFLAGS = CCFLAGS,
|
||||
objects.append(Env.Object(source, CCFLAGS = CCFLAGS, ASFLAGS = ASFLAGS,
|
||||
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES))
|
||||
|
||||
return True
|
||||
@@ -775,6 +788,11 @@ def EndBuilding(target, program = None):
|
||||
from cscope import CscopeDatabase
|
||||
CscopeDatabase(Projects)
|
||||
|
||||
if not GetOption('help') and not GetOption('target'):
|
||||
if not os.path.exists(rtconfig.EXEC_PATH):
|
||||
print "Error: Toolchain path (%s) is not exist, please check 'EXEC_PATH' in path or rtconfig.py." % rtconfig.EXEC_PATH
|
||||
sys.exit(1)
|
||||
|
||||
def SrcRemove(src, remove):
|
||||
if not src:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user