summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--README.md1
-rw-r--r--bsp/beaglebone/drivers/serial.c244
-rw-r--r--bsp/beaglebone/rtconfig.h14
-rw-r--r--bsp/simulator/drivers/nanddrv_file.c12
-rwxr-xr-xbsp/simulator/drivers/sdl_fb.c14
-rw-r--r--components/CMSIS/Include/arm_common_tables.h97
-rw-r--r--components/CMSIS/Include/arm_math.h1421
-rw-r--r--components/CMSIS/Include/core_cm0.h55
-rw-r--r--components/CMSIS/Include/core_cm0plus.h59
-rw-r--r--components/CMSIS/Include/core_cm3.h57
-rw-r--r--components/CMSIS/Include/core_cm4.h57
-rw-r--r--components/CMSIS/Include/core_cm4_simd.h54
-rw-r--r--components/CMSIS/Include/core_cmFunc.h72
-rw-r--r--components/CMSIS/Include/core_cmInstr.h134
-rw-r--r--components/CMSIS/Include/core_sc000.h55
-rw-r--r--components/CMSIS/Include/core_sc300.h57
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c17
-rw-r--r--components/dfs/filesystems/nfs/dfs_nfs.c9
-rw-r--r--components/dfs/filesystems/nfs/mount.h4
-rw-r--r--components/dfs/filesystems/nfs/mount_xdr.c89
-rw-r--r--components/dfs/filesystems/nfs/nfs.h6
-rw-r--r--components/dfs/filesystems/nfs/nfs_xdr.c16
-rw-r--r--components/dfs/filesystems/nfs/rpc/auth_none.c5
-rw-r--r--components/dfs/filesystems/nfs/rpc/clnt_udp.c23
-rw-r--r--components/dfs/filesystems/nfs/rpc/pmap.c10
-rw-r--r--components/dfs/filesystems/nfs/rpc/rpc_prot.c40
-rw-r--r--components/dfs/filesystems/nfs/rpc/xdr.c64
-rw-r--r--components/dfs/filesystems/nfs/rpc/xdr_mem.c4
-rw-r--r--components/dfs/filesystems/ramfs/dfs_ramfs.c1
-rw-r--r--components/dfs/filesystems/romfs/mkromfs.py13
-rw-r--r--components/dfs/src/dfs_file.c168
-rw-r--r--components/drivers/serial/serial.c29
-rw-r--r--components/finsh/cmd.c30
-rw-r--r--components/finsh/msh.c154
-rw-r--r--components/finsh/msh_cmd.c12
-rw-r--r--components/finsh/shell.c15
-rw-r--r--components/init/components.c4
-rw-r--r--components/net/lwip-1.4.1/src/arch/sys_arch.c8
-rw-r--r--components/pthreads/posix_types.h121
-rw-r--r--components/pthreads/pthread.c4
-rw-r--r--components/pthreads/pthread_attr.c10
-rw-r--r--components/pthreads/sched.c2
-rw-r--r--include/rtdebug.h2
-rw-r--r--include/rtdef.h16
-rw-r--r--include/rtthread.h7
-rw-r--r--libcpu/arm/am335x/am33xx.h10
-rw-r--r--src/module.c263
-rw-r--r--src/thread.c3
-rw-r--r--tools/building.py122
-rw-r--r--tools/ua.py70
-rwxr-xr-x[-rw-r--r--]tools/wizard.py0
52 files changed, 2227 insertions, 1533 deletions
diff --git a/.gitignore b/.gitignore
index 9e2a6e8fc5..0f50154a67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,9 @@
*.ilk
build
*~
+*.o
+*.bak
+*.dep
+*.lib
+*.a
+
diff --git a/README.md b/README.md
index 4b232a9048..228ad1cae5 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,6 @@ RT-Thread RTOS can support many architectures:
* ARM Cortex-R4
* ARM Cortex-A8/A9
* ARM920T/ARM926 etc
-
* MIPS
* x86
* PowerPC
diff --git a/bsp/beaglebone/drivers/serial.c b/bsp/beaglebone/drivers/serial.c
index b29ffc9963..d07621080b 100644
--- a/bsp/beaglebone/drivers/serial.c
+++ b/bsp/beaglebone/drivers/serial.c
@@ -10,6 +10,7 @@
* Change Logs:
* Date Author Notes
* 2013-07-06 Bernard the first version
+ * 2014-01-11 RTsien support UART0 to UART5 straightly
*/
#include <rthw.h>
@@ -38,7 +39,7 @@ static void am33xx_uart_isr(int irqno, void* param)
iir = UART_IIR_REG(uart->base);
- if ((iir & (0x02 << 1)) || (iir & (0x6 << 1)))
+ if ((iir & (0x02 << 1)) || (iir & (0x6 << 1)))
{
rt_hw_serial_isr(serial);
}
@@ -162,14 +163,66 @@ static const struct rt_uart_ops am33xx_uart_ops =
am33xx_getc,
};
-/* UART1 device driver structure */
-struct serial_ringbuffer uart1_int_rx;
-struct am33xx_uart uart1 =
+/* UART device driver structure */
+#ifdef RT_USING_UART0
+struct serial_ringbuffer uart0_int_rx;
+struct am33xx_uart uart0 =
{
UART0_BASE,
UART0_INT,
};
+struct rt_serial_device serial0;
+#endif
+
+#ifdef RT_USING_UART1
+struct serial_ringbuffer uart1_int_rx;
+struct am33xx_uart uart1 =
+{
+ UART1_BASE,
+ UART1_INT,
+};
struct rt_serial_device serial1;
+#endif
+
+#ifdef RT_USING_UART2
+struct serial_ringbuffer uart2_int_rx;
+struct am33xx_uart uart2 =
+{
+ UART2_BASE,
+ UART2_INT,
+};
+struct rt_serial_device serial2;
+#endif
+
+#ifdef RT_USING_UART3
+struct serial_ringbuffer uart3_int_rx;
+struct am33xx_uart uart3 =
+{
+ UART3_BASE,
+ UART3_INT,
+};
+struct rt_serial_device serial3;
+#endif
+
+#ifdef RT_USING_UART4
+struct serial_ringbuffer uart4_int_rx;
+struct am33xx_uart uart4 =
+{
+ UART4_BASE,
+ UART4_INT,
+};
+struct rt_serial_device serial4;
+#endif
+
+#ifdef RT_USING_UART5
+struct serial_ringbuffer uart5_int_rx;
+struct am33xx_uart uart5 =
+{
+ UART5_BASE,
+ UART5_INT,
+};
+struct rt_serial_device serial5;
+#endif
#define write_reg(base, value) *(int*)(base) = value
#define read_reg(base) *(int*)(base)
@@ -219,11 +272,41 @@ static void start_uart_clk(void)
;
/* enable uart1 */
+#ifdef RT_USING_UART1
CM_PER_UART1_CLKCTRL_REG(prcm_base) |= 0x2;
-
/* wait for uart1 clk */
while ((CM_PER_UART1_CLKCTRL_REG(prcm_base) & (0x3<<16)) != 0)
;
+#endif
+
+#ifdef RT_USING_UART2
+ CM_PER_UART2_CLKCTRL_REG(prcm_base) |= 0x2;
+ /* wait for uart2 clk */
+ while ((CM_PER_UART2_CLKCTRL_REG(prcm_base) & (0x3<<16)) != 0)
+ ;
+#endif
+
+#ifdef RT_USING_UART3
+ CM_PER_UART3_CLKCTRL_REG(prcm_base) |= 0x2;
+ /* wait for uart3 clk */
+ while ((CM_PER_UART3_CLKCTRL_REG(prcm_base) & (0x3<<16)) != 0)
+ ;
+#endif
+
+#ifdef RT_USING_UART4
+ CM_PER_UART4_CLKCTRL_REG(prcm_base) |= 0x2;
+ /* wait for uart4 clk */
+ while ((CM_PER_UART4_CLKCTRL_REG(prcm_base) & (0x3<<16)) != 0)
+ ;
+#endif
+
+#ifdef RT_USING_UART5
+ CM_PER_UART5_CLKCTRL_REG(prcm_base) |= 0x2;
+ /* wait for uart5 clk */
+ while ((CM_PER_UART5_CLKCTRL_REG(prcm_base) & (0x3<<16)) != 0)
+ ;
+#endif
+
/* Waiting for the L4LS UART clock */
while (!(CM_PER_L4LS_CLKSTCTRL_REG(prcm_base) & (1<<10)))
;
@@ -236,46 +319,173 @@ static void config_pinmux(void)
ctlm_base = AM33XX_CTLM_REGS;
/* make sure the pin mux is OK for uart */
+#ifdef RT_USING_UART1
REG32(ctlm_base + 0x800 + 0x180) = 0x20;
REG32(ctlm_base + 0x800 + 0x184) = 0x00;
+#endif
+
+#ifdef RT_USING_UART2
+ REG32(ctlm_base + 0x800 + 0x150) = 0x20;
+ REG32(ctlm_base + 0x800 + 0x154) = 0x00;
+#endif
+
+#ifdef RT_USING_UART3
+ REG32(ctlm_base + 0x800 + 0x164) = 0x01;
+#endif
+
+#ifdef RT_USING_UART4
+ REG32(ctlm_base + 0x800 + 0x070) = 0x26;
+ REG32(ctlm_base + 0x800 + 0x074) = 0x06;
+#endif
+
+#ifdef RT_USING_UART5
+ REG32(ctlm_base + 0x800 + 0x0C4) = 0x24;
+ REG32(ctlm_base + 0x800 + 0x0C0) = 0x04;
+#endif
}
int rt_hw_serial_init(void)
{
- struct am33xx_uart* uart;
struct serial_configure config;
- uart = &uart1;
- uart->base = UART1_BASE;
-
poweron_per_domain();
start_uart_clk();
config_pinmux();
+#ifdef RT_USING_UART0
config.baud_rate = BAUD_RATE_115200;
config.bit_order = BIT_ORDER_LSB;
config.data_bits = DATA_BITS_8;
config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL;
+ serial0.ops = &am33xx_uart_ops;
+ serial0.int_rx = &uart0_int_rx;
+ serial0.config = config;
+ /* enable RX interrupt */
+ UART_IER_REG(uart0.base) = 0x01;
+ /* install ISR */
+ rt_hw_interrupt_install(uart0.irq, am33xx_uart_isr, &serial0, "uart0");
+ rt_hw_interrupt_control(uart0.irq, 0, 0);
+ rt_hw_interrupt_mask(uart0.irq);
+ /* register UART0 device */
+ rt_hw_serial_register(&serial0, "uart0",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart0);
+#endif
+#ifdef RT_USING_UART1
+ config.baud_rate = BAUD_RATE_115200;
+ config.bit_order = BIT_ORDER_LSB;
+ config.data_bits = DATA_BITS_8;
+ config.parity = PARITY_NONE;
+ config.stop_bits = STOP_BITS_1;
+ config.invert = NRZ_NORMAL;
serial1.ops = &am33xx_uart_ops;
serial1.int_rx = &uart1_int_rx;
serial1.config = config;
+ /* enable RX interrupt */
+ UART_IER_REG(uart1.base) = 0x01;
+ /* install ISR */
+ rt_hw_interrupt_install(uart1.irq, am33xx_uart_isr, &serial1, "uart1");
+ rt_hw_interrupt_control(uart1.irq, 0, 0);
+ rt_hw_interrupt_mask(uart1.irq);
+ /* register UART0 device */
+ rt_hw_serial_register(&serial1, "uart1",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart1);
+#endif
+#ifdef RT_USING_UART2
+ config.baud_rate = BAUD_RATE_115200;
+ config.bit_order = BIT_ORDER_LSB;
+ config.data_bits = DATA_BITS_8;
+ config.parity = PARITY_NONE;
+ config.stop_bits = STOP_BITS_1;
+ config.invert = NRZ_NORMAL;
+ serial2.ops = &am33xx_uart_ops;
+ serial2.int_rx = &uart2_int_rx;
+ serial2.config = config;
/* enable RX interrupt */
- UART_IER_REG(uart->base) = 0x01;
+ UART_IER_REG(uart2.base) = 0x01;
/* install ISR */
- rt_hw_interrupt_install(uart->irq, am33xx_uart_isr, &serial1, "uart1");
- rt_hw_interrupt_control(uart->irq, 0, 0);
- rt_hw_interrupt_mask(uart->irq);
+ rt_hw_interrupt_install(uart2.irq, am33xx_uart_isr, &serial2, "uart2");
+ rt_hw_interrupt_control(uart2.irq, 0, 0);
+ rt_hw_interrupt_mask(uart2.irq);
+ /* register UART2 device */
+ rt_hw_serial_register(&serial2, "uart2",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart2);
+#endif
- /* register UART1 device */
- rt_hw_serial_register(&serial1, "uart1",
+#ifdef RT_USING_UART3
+ config.baud_rate = BAUD_RATE_115200;
+ config.bit_order = BIT_ORDER_LSB;
+ config.data_bits = DATA_BITS_8;
+ config.parity = PARITY_NONE;
+ config.stop_bits = STOP_BITS_1;
+ config.invert = NRZ_NORMAL;
+ serial3.ops = &am33xx_uart_ops;
+ serial3.int_rx = &uart_3_int_rx;
+ serial3.config = config;
+ /* enable RX interrupt */
+ UART_IER_REG(uart3.base) = 0x01;
+ /* install ISR */
+ rt_hw_interrupt_install(uart3.irq, am33xx_uart_isr, &serial3, "uart3");
+ rt_hw_interrupt_control(uart3.irq, 0, 0);
+ rt_hw_interrupt_mask(uart3.irq);
+ /* register UART3 device */
+ rt_hw_serial_register(&serial3, "uart3",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
- uart);
+ &uart3);
+#endif
+
+#ifdef RT_USING_UART4
+ config.baud_rate = BAUD_RATE_115200;
+ config.bit_order = BIT_ORDER_LSB;
+ config.data_bits = DATA_BITS_8;
+ config.parity = PARITY_NONE;
+ config.stop_bits = STOP_BITS_1;
+ config.invert = NRZ_NORMAL;
+
+ serial4.ops = &am33xx_uart_ops;
+ serial4.int_rx = &uart4_int_rx;
+ serial4.config = config;
+ /* enable RX interrupt */
+ UART_IER_REG(uart4.base) = 0x01;
+ /* install ISR */
+ rt_hw_interrupt_install(uart4.irq, am33xx_uart_isr, &serial4, "uart4");
+ rt_hw_interrupt_control(uart4.irq, 0, 0);
+ rt_hw_interrupt_mask(uart4.irq);
+ /* register UART4 device */
+ rt_hw_serial_register(&serial4, "uart4",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart4);
+#endif
+
+#ifdef RT_USING_UART5
+ config.baud_rate = BAUD_RATE_115200;
+ config.bit_order = BIT_ORDER_LSB;
+ config.data_bits = DATA_BITS_8;
+ config.parity = PARITY_NONE;
+ config.stop_bits = STOP_BITS_1;
+ config.invert = NRZ_NORMAL;
+
+ serial5.ops = &am33xx_uart_ops;
+ serial5.int_rx = &uart5_int_rx;
+ serial5.config = config;
+ /* enable RX interrupt */
+ UART_IER_REG(uart5.base) = 0x01;
+ /* install ISR */
+ rt_hw_interrupt_install(uart5.irq, am33xx_uart_isr, &serial5, "uart5");
+ rt_hw_interrupt_control(uart5.irq, 0, 0);
+ rt_hw_interrupt_mask(uart5.irq);
+ /* register UART4 device */
+ rt_hw_serial_register(&serial5, "uart5",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
+ &uart5);
+#endif
return 0;
}
INIT_BOARD_EXPORT(rt_hw_serial_init);
-
diff --git a/bsp/beaglebone/rtconfig.h b/bsp/beaglebone/rtconfig.h
index 27992c84cd..15326d74cf 100644
--- a/bsp/beaglebone/rtconfig.h
+++ b/bsp/beaglebone/rtconfig.h
@@ -73,6 +73,18 @@
#define RT_USING_DEVICE_IPC
// <bool name="RT_USING_SERIAL" description="Using Serial Device Driver Framework" default="true" />
#define RT_USING_SERIAL
+// <bool name="RT_USING_UART0" description="Using uart0" default="true" >
+#define RT_USING_UART0
+// <bool name="RT_USING_UART1" description="Using uart1" default="true" >
+#define RT_USING_UART1
+// <bool name="RT_USING_UART2" description="Using uart2" default="true" >
+#define RT_USING_UART2
+// <bool name="RT_USING_UART3" description="Using uart3" default="true" >
+//#define RT_USING_UART3
+// <bool name="RT_USING_UART4" description="Using uart4" default="true" >
+#define RT_USING_UART4
+// <bool name="RT_USING_UART5" description="Using uart5" default="true" >
+#define RT_USING_UART5
// <integer name="RT_UART_RX_BUFFER_SIZE" description="The buffer size for UART reception" default="64" />
#define RT_UART_RX_BUFFER_SIZE 64
// <bool name=RT_USING_INTERRUPT_INFO description="Using interrupt information description" default="true" />
@@ -84,7 +96,7 @@
// <integer name="RT_CONSOLEBUF_SIZE" description="The buffer size for console output" default="128" />
#define RT_CONSOLEBUF_SIZE 128
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" />
-#define RT_CONSOLE_DEVICE_NAME "uart1"
+#define RT_CONSOLE_DEVICE_NAME "uart0"
// </section>
// <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" />
diff --git a/bsp/simulator/drivers/nanddrv_file.c b/bsp/simulator/drivers/nanddrv_file.c
index 770751ac79..075ed7f5d8 100644
--- a/bsp/simulator/drivers/nanddrv_file.c
+++ b/bsp/simulator/drivers/nanddrv_file.c
@@ -4,23 +4,23 @@
#include <string.h>
#define NAND_SIM "nand.bin"
+
#if 1
#define OOB_SIZE 64
#define PAGE_DATA_SIZE 2048
-#define PAGE_SIZE (2048 + 64)
#define PAGE_PER_BLOCK 64
-#define BLOCK_SIZE (PAGE_SIZE * PAGE_PER_BLOCK)
+#define ECC_SIZE ((PAGE_DATA_SIZE) * 3 / 256)
#define BLOCK_NUM 512
-// #define BLOCK_NUM 2048
#else
#define OOB_SIZE 16
-#define PAGE_SIZE (512 + OOB_SIZE)
+#define PAGE_DATA_SIZE 512
#define PAGE_PER_BLOCK 32
-#define BLOCK_SIZE (PAGE_SIZE * PAGE_PER_BLOCK)
+#define ECC_SIZE ((PAGE_DATA_SIZE) * 3 / 256)
#define BLOCK_NUM 512
#endif
-#define ECC_SIZE ((PAGE_DATA_SIZE) * 3 / 256)
+#define BLOCK_SIZE (PAGE_SIZE * PAGE_PER_BLOCK)
+#define PAGE_SIZE (PAGE_DATA_SIZE + OOB_SIZE)
static unsigned char block_data[BLOCK_SIZE];
static struct rt_mtd_nand_device _nanddrv_file_device;
diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c
index 78bca6f07f..198b85d0d9 100755
--- a/bsp/simulator/drivers/sdl_fb.c
+++ b/bsp/simulator/drivers/sdl_fb.c
@@ -11,6 +11,8 @@
#define SDL_SCREEN_WIDTH 800
#define SDL_SCREEN_HEIGHT 480
+extern void rt_hw_exit(void);
+
struct sdlfb_device
{
struct rt_device parent;
@@ -54,7 +56,7 @@ static rt_err_t sdlfb_control(rt_device_t dev, rt_uint8_t cmd, void *args)
info = (struct rt_device_graphic_info *) args;
info->bits_per_pixel = 16;
- info->pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565P;
+ info->pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
info->framebuffer = device->screen->pixels;
info->width = device->screen->w;
info->height = device->screen->h;
@@ -304,10 +306,14 @@ static void *sdl_loop(void *lpParam)
break;
}
- if (quit)
- break;
+ if (quit)
+ {
+ exit(1);
+ break;
+ }
+
}
- //exit(0);
+ rt_hw_exit();
return 0;
}
diff --git a/components/CMSIS/Include/arm_common_tables.h b/components/CMSIS/Include/arm_common_tables.h
index 8c35ef2bd5..7a59b5923e 100644
--- a/components/CMSIS/Include/arm_common_tables.h
+++ b/components/CMSIS/Include/arm_common_tables.h
@@ -1,24 +1,41 @@
-/* ----------------------------------------------------------------------
-* Copyright (C) 2010 ARM Limited. All rights reserved.
-*
-* $Date: 11. November 2010
-* $Revision: V1.0.2
-*
-* Project: CMSIS DSP Library
-* Title: arm_common_tables.h
-*
-* Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
-*
+/* ----------------------------------------------------------------------
+* Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+*
+* $Date: 17. January 2013
+* $Revision: V1.4.1
+*
+* Project: CMSIS DSP Library
+* Title: arm_common_tables.h
+*
+* Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
+*
* Target Processor: Cortex-M4/Cortex-M3
-*
-* Version 1.0.2 2010/11/11
-* Documentation updated.
-*
-* Version 1.0.1 2010/10/05
-* Production release and review comments incorporated.
-*
-* Version 1.0.0 2010/09/20
-* Production release and review comments incorporated.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - 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.
+* - Neither the name of ARM LIMITED 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 OWNER 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.
* -------------------------------------------------------------------- */
#ifndef _ARM_COMMON_TABLES_H
@@ -31,8 +48,46 @@ extern const q15_t armRecipTableQ15[64];
extern const q31_t armRecipTableQ31[64];
extern const q31_t realCoefAQ31[1024];
extern const q31_t realCoefBQ31[1024];
-extern const float32_t twiddleCoef[6144];
+extern const float32_t twiddleCoef_16[32];
+extern const float32_t twiddleCoef_32[64];
+extern const float32_t twiddleCoef_64[128];
+extern const float32_t twiddleCoef_128[256];
+extern const float32_t twiddleCoef_256[512];
+extern const float32_t twiddleCoef_512[1024];
+extern const float32_t twiddleCoef_1024[2048];
+extern const float32_t twiddleCoef_2048[4096];
+extern const float32_t twiddleCoef_4096[8192];
+#define twiddleCoef twiddleCoef_4096
extern const q31_t twiddleCoefQ31[6144];
extern const q15_t twiddleCoefQ15[6144];
+extern const float32_t twiddleCoef_rfft_32[32];
+extern const float32_t twiddleCoef_rfft_64[64];
+extern const float32_t twiddleCoef_rfft_128[128];
+extern const float32_t twiddleCoef_rfft_256[256];
+extern const float32_t twiddleCoef_rfft_512[512];
+extern const float32_t twiddleCoef_rfft_1024[1024];
+extern const float32_t twiddleCoef_rfft_2048[2048];
+extern const float32_t twiddleCoef_rfft_4096[4096];
+
+
+#define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 )
+#define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 )
+#define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 )
+#define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 )
+#define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 )
+#define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 )
+#define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800)
+#define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808)
+#define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032)
+
+extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH];
+extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH];
#endif /* ARM_COMMON_TABLES_H */
diff --git a/components/CMSIS/Include/arm_math.h b/components/CMSIS/Include/arm_math.h
index 7266c3efb3..65304c127d 100644
--- a/components/CMSIS/Include/arm_math.h
+++ b/components/CMSIS/Include/arm_math.h
@@ -1,33 +1,41 @@
-/* ----------------------------------------------------------------------
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
- *
- * $Date: 15. February 2012
- * $Revision: V1.1.0
- *
- * Project: CMSIS DSP Library
- * Title: arm_math.h
- *
- * Description: Public header file for CMSIS DSP Library
- *
- * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
- *
- * Version 1.1.0 2012/02/15
- * Updated with more optimizations, bug fixes and minor API changes.
- *
- * Version 1.0.10 2011/7/15
- * Big Endian support added and Merged M0 and M3/M4 Source code.
- *
- * Version 1.0.3 2010/11/29
- * Re-organized the CMSIS folders and updated documentation.
- *
- * Version 1.0.2 2010/11/11
- * Documentation updated.
- *
- * Version 1.0.1 2010/10/05
- * Production release and review comments incorporated.
- *
- * Version 1.0.0 2010/09/20
- * Production release and review comments incorporated.
+/* ----------------------------------------------------------------------
+* Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+*
+* $Date: 17. January 2013
+* $Revision: V1.4.1
+*
+* Project: CMSIS DSP Library
+* Title: arm_math.h
+*
+* Description: Public header file for CMSIS DSP Library
+*
+* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* - Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* - 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.
+* - Neither the name of ARM LIMITED 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 OWNER 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.
* -------------------------------------------------------------------- */
/**
@@ -35,10 +43,10 @@
*
* <b>Introduction</b>
*
- * This user manual describes the CMSIS DSP software library,
+ * This user manual describes the CMSIS DSP software library,
* a suite of common signal processing functions for use on Cortex-M processor based devices.
*
- * The library is divided into a number of functions each covering a specific category:
+ * The library is divided into a number of functions each covering a specific category:
* - Basic math functions
* - Fast math functions
* - Complex math functions
@@ -51,41 +59,7 @@
* - Interpolation functions
*
* The library has separate functions for operating on 8-bit integers, 16-bit integers,
- * 32-bit integer and 32-bit floating-point values.
- *
- * <b>Pre-processor Macros</b>
- *
- * Each library project have differant pre-processor macros.
- *
- * - UNALIGNED_SUPPORT_DISABLE:
- *
- * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
- *
- * - ARM_MATH_BIG_ENDIAN:
- *
- * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
- *
- * - ARM_MATH_MATRIX_CHECK:
- *
- * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
- *
- * - ARM_MATH_ROUNDING:
- *
- * Define macro ARM_MATH_ROUNDING for rounding on support functions
- *
- * - ARM_MATH_CMx:
- *
- * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
- * and ARM_MATH_CM0 for building library on cortex-M0 target.
- *
- * - __FPU_PRESENT:
- *
- * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries
- *
- * <b>Toolchain Support</b>
- *
- * The library has been developed and tested with MDK-ARM version 4.23.
- * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
+ * 32-bit integer and 32-bit floating-point values.
*
* <b>Using the Library</b>
*
@@ -100,33 +74,67 @@
* - arm_cortexM0b_math.lib (Big endian on Cortex-M3)
*
* The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
- * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
- * public header file <code> arm_math.h</code> for Cortex-M4/M3/M0 with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
- * Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or
- * ARM_MATH_CM0 depending on the target processor in the application.
+ * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
+ * public header file <code> arm_math.h</code> for Cortex-M4/M3/M0 with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
+ * Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or
+ * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
*
* <b>Examples</b>
*
* The library ships with a number of examples which demonstrate how to use the library functions.
*
+ * <b>Toolchain Support</b>
+ *
+ * The library has been developed and tested with MDK-ARM version 4.60.
+ * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
+ *
* <b>Building the Library</b>
*
* The library installer contains project files to re build libraries on MDK Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
* - arm_cortexM0b_math.uvproj
* - arm_cortexM0l_math.uvproj
* - arm_cortexM3b_math.uvproj
- * - arm_cortexM3l_math.uvproj
+ * - arm_cortexM3l_math.uvproj
* - arm_cortexM4b_math.uvproj
* - arm_cortexM4l_math.uvproj
* - arm_cortexM4bf_math.uvproj
* - arm_cortexM4lf_math.uvproj
*
*
- * The project can be built by opening the appropriate project in MDK-ARM 4.23 chain and defining the optional pre processor MACROs detailed above.
+ * The project can be built by opening the appropriate project in MDK-ARM 4.60 chain and defining the optional pre processor MACROs detailed above.
+ *
+ * <b>Pre-processor Macros</b>
+ *
+ * Each library project have differant pre-processor macros.
+ *
+ * - UNALIGNED_SUPPORT_DISABLE:
+ *
+ * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
+ *
+ * - ARM_MATH_BIG_ENDIAN:
+ *
+ * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
+ *
+ * - ARM_MATH_MATRIX_CHECK:
+ *
+ * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
+ *
+ * - ARM_MATH_ROUNDING:
+ *
+ * Define macro ARM_MATH_ROUNDING for rounding on support functions
+ *
+ * - ARM_MATH_CMx:
+ *
+ * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
+ * and ARM_MATH_CM0 for building library on cortex-M0 target, ARM_MATH_CM0PLUS for building library on cortex-M0+ target.
+ *
+ * - __FPU_PRESENT:
+ *
+ * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries
*
* <b>Copyright Notice</b>
*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
*/
@@ -264,6 +272,10 @@
#include "core_cm3.h"
#elif defined (ARM_MATH_CM0)
#include "core_cm0.h"
+#define ARM_MATH_CM0_FAMILY
+#elif defined (ARM_MATH_CM0PLUS)
+#include "core_cm0plus.h"
+#define ARM_MATH_CM0_FAMILY
#else
#include "ARMCM4.h"
#warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on ARM_MATH_CM4....."
@@ -365,17 +377,27 @@ extern "C"
/**
* @brief definition to read/write two 16 bit values.
*/
-#if defined (__GNUC__)
- #define __SIMD32(addr) (*( int32_t **) & (addr))
- #define _SIMD32_OFFSET(addr) (*( int32_t * ) (addr))
+#if defined __CC_ARM
+#define __SIMD32_TYPE int32_t __packed
+#define CMSIS_UNUSED __attribute__((unused))
+#elif defined __ICCARM__
+#define CMSIS_UNUSED
+#define __SIMD32_TYPE int32_t __packed
+#elif defined __GNUC__
+#define __SIMD32_TYPE int32_t
+#define CMSIS_UNUSED __attribute__((unused))
#else
- #define __SIMD32(addr) (*(__packed int32_t **) & (addr))
- #define _SIMD32_OFFSET(addr) (*(__packed int32_t * ) (addr))
-#endif
+#error Unknown compiler
+#endif
+
+#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
+#define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
- #define __SIMD64(addr) (*(int64_t **) & (addr))
+#define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
-#if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0)
+#define __SIMD64(addr) (*(int64_t **) & (addr))
+
+#if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
/**
* @brief definition to pack two 16 bit values.
*/
@@ -409,7 +431,7 @@ extern "C"
/**
* @brief Clips Q63 to Q31 values.
*/
- __STATIC_INLINE q31_t clip_q63_to_q31(
+ static __INLINE q31_t clip_q63_to_q31(
q63_t x)
{
return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
@@ -419,7 +441,7 @@ extern "C"
/**
* @brief Clips Q63 to Q15 values.
*/
- __STATIC_INLINE q15_t clip_q63_to_q15(
+ static __INLINE q15_t clip_q63_to_q15(
q63_t x)
{
return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
@@ -429,7 +451,7 @@ extern "C"
/**
* @brief Clips Q31 to Q7 values.
*/
- __STATIC_INLINE q7_t clip_q31_to_q7(
+ static __INLINE q7_t clip_q31_to_q7(
q31_t x)
{
return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
@@ -439,7 +461,7 @@ extern "C"
/**
* @brief Clips Q31 to Q15 values.
*/
- __STATIC_INLINE q15_t clip_q31_to_q15(
+ static __INLINE q15_t clip_q31_to_q15(
q31_t x)
{
return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
@@ -450,7 +472,7 @@ extern "C"
* @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
*/
- __STATIC_INLINE q63_t mult32x64(
+ static __INLINE q63_t mult32x64(
q63_t x,
q31_t y)
{
@@ -459,20 +481,18 @@ extern "C"
}
-#if defined (ARM_MATH_CM0) && defined ( __CC_ARM )
+#if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
#define __CLZ __clz
#endif
-#if defined (ARM_MATH_CM0) && defined ( __TASKING__ )
-/* No need to redefine __CLZ */
-#endif
-
-#if defined (ARM_MATH_CM0) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) )
+#if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) || defined (__TASKING__) )
- __STATIC_INLINE uint32_t __CLZ(q31_t data);
+ static __INLINE uint32_t __CLZ(
+ q31_t data);
- __STATIC_INLINE uint32_t __CLZ(q31_t data)
+ static __INLINE uint32_t __CLZ(
+ q31_t data)
{
uint32_t count = 0;
uint32_t mask = 0x80000000;
@@ -490,10 +510,10 @@ extern "C"
#endif
/**
- * @brief Function to Calculates 1/in(reciprocal) value of Q31 Data type.
+ * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
*/
- __STATIC_INLINE uint32_t arm_recip_q31(
+ static __INLINE uint32_t arm_recip_q31(
q31_t in,
q31_t * dst,
q31_t * pRecipTable)
@@ -542,9 +562,9 @@ extern "C"
}
/**
- * @brief Function to Calculates 1/in(reciprocal) value of Q15 Data type.
+ * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
*/
- __STATIC_INLINE uint32_t arm_recip_q15(
+ static __INLINE uint32_t arm_recip_q15(
q15_t in,
q15_t * dst,
q15_t * pRecipTable)
@@ -595,9 +615,9 @@ extern "C"
/*
* @brief C custom defined intrinisic function for only M0 processors
*/
-#if defined(ARM_MATH_CM0)
+#if defined(ARM_MATH_CM0_FAMILY)
- __STATIC_INLINE q31_t __SSAT(
+ static __INLINE q31_t __SSAT(
q31_t x,
uint32_t y)
{
@@ -633,19 +653,19 @@ extern "C"
}
-#endif /* end of ARM_MATH_CM0 */
+#endif /* end of ARM_MATH_CM0_FAMILY */
/*
* @brief C custom defined intrinsic function for M3 and M0 processors
*/
-#if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0)
+#if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
/*
* @brief C custom defined QADD8 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QADD8(
+ static __INLINE q31_t __QADD8(
q31_t x,
q31_t y)
{
@@ -672,7 +692,7 @@ extern "C"
/*
* @brief C custom defined QSUB8 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QSUB8(
+ static __INLINE q31_t __QSUB8(
q31_t x,
q31_t y)
{
@@ -702,7 +722,7 @@ extern "C"
/*
* @brief C custom defined QADD16 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QADD16(
+ static __INLINE q31_t __QADD16(
q31_t x,
q31_t y)
{
@@ -725,7 +745,7 @@ extern "C"
/*
* @brief C custom defined SHADD16 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SHADD16(
+ static __INLINE q31_t __SHADD16(
q31_t x,
q31_t y)
{
@@ -748,7 +768,7 @@ extern "C"
/*
* @brief C custom defined QSUB16 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QSUB16(
+ static __INLINE q31_t __QSUB16(
q31_t x,
q31_t y)
{
@@ -770,7 +790,7 @@ extern "C"
/*
* @brief C custom defined SHSUB16 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SHSUB16(
+ static __INLINE q31_t __SHSUB16(
q31_t x,
q31_t y)
{
@@ -792,7 +812,7 @@ extern "C"
/*
* @brief C custom defined QASX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QASX(
+ static __INLINE q31_t __QASX(
q31_t x,
q31_t y)
{
@@ -810,7 +830,7 @@ extern "C"
/*
* @brief C custom defined SHASX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SHASX(
+ static __INLINE q31_t __SHASX(
q31_t x,
q31_t y)
{
@@ -833,7 +853,7 @@ extern "C"
/*
* @brief C custom defined QSAX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QSAX(
+ static __INLINE q31_t __QSAX(
q31_t x,
q31_t y)
{
@@ -851,7 +871,7 @@ extern "C"
/*
* @brief C custom defined SHSAX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SHSAX(
+ static __INLINE q31_t __SHSAX(
q31_t x,
q31_t y)
{
@@ -873,7 +893,7 @@ extern "C"
/*
* @brief C custom defined SMUSDX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMUSDX(
+ static __INLINE q31_t __SMUSDX(
q31_t x,
q31_t y)
{
@@ -885,7 +905,7 @@ extern "C"
/*
* @brief C custom defined SMUADX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMUADX(
+ static __INLINE q31_t __SMUADX(
q31_t x,
q31_t y)
{
@@ -897,7 +917,7 @@ extern "C"
/*
* @brief C custom defined QADD for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QADD(
+ static __INLINE q31_t __QADD(
q31_t x,
q31_t y)
{
@@ -907,7 +927,7 @@ extern "C"
/*
* @brief C custom defined QSUB for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __QSUB(
+ static __INLINE q31_t __QSUB(
q31_t x,
q31_t y)
{
@@ -917,7 +937,7 @@ extern "C"
/*
* @brief C custom defined SMLAD for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMLAD(
+ static __INLINE q31_t __SMLAD(
q31_t x,
q31_t y,
q31_t sum)
@@ -930,7 +950,7 @@ extern "C"
/*
* @brief C custom defined SMLADX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMLADX(
+ static __INLINE q31_t __SMLADX(
q31_t x,
q31_t y,
q31_t sum)
@@ -943,7 +963,7 @@ extern "C"
/*
* @brief C custom defined SMLSDX for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMLSDX(
+ static __INLINE q31_t __SMLSDX(
q31_t x,
q31_t y,
q31_t sum)
@@ -956,7 +976,7 @@ extern "C"
/*
* @brief C custom defined SMLALD for M3 and M0 processors
*/
- __STATIC_INLINE q63_t __SMLALD(
+ static __INLINE q63_t __SMLALD(
q31_t x,
q31_t y,
q63_t sum)
@@ -969,7 +989,7 @@ extern "C"
/*
* @brief C custom defined SMLALDX for M3 and M0 processors
*/
- __STATIC_INLINE q63_t __SMLALDX(
+ static __INLINE q63_t __SMLALDX(
q31_t x,
q31_t y,
q63_t sum)
@@ -982,7 +1002,7 @@ extern "C"
/*
* @brief C custom defined SMUAD for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMUAD(
+ static __INLINE q31_t __SMUAD(
q31_t x,
q31_t y)
{
@@ -994,7 +1014,7 @@ extern "C"
/*
* @brief C custom defined SMUSD for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SMUSD(
+ static __INLINE q31_t __SMUSD(
q31_t x,
q31_t y)
{
@@ -1007,7 +1027,7 @@ extern "C"
/*
* @brief C custom defined SXTB16 for M3 and M0 processors
*/
- __STATIC_INLINE q31_t __SXTB16(
+ static __INLINE q31_t __SXTB16(
q31_t x)
{
@@ -1016,7 +1036,7 @@ extern "C"
}
-#endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0) */
+#endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
/**
@@ -1516,6 +1536,7 @@ extern "C"
* @param[in] *pSrcA points to the first input matrix structure
* @param[in] *pSrcB points to the second input matrix structure
* @param[out] *pDst points to output matrix structure
+ * @param[in] *pState points to the array for storing intermediate results
* @return The function returns either
* <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
*/
@@ -1531,7 +1552,7 @@ extern "C"
* @param[in] *pSrcA points to the first input matrix structure
* @param[in] *pSrcB points to the second input matrix structure
* @param[out] *pDst points to output matrix structure
- * @param[in] *pState points to the array for storing intermediate results
+ * @param[in] *pState points to the array for storing intermediate results
* @return The function returns either
* <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
*/
@@ -1713,7 +1734,7 @@ extern "C"
typedef struct
{
q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
-#ifdef ARM_MATH_CM0
+#ifdef ARM_MATH_CM0_FAMILY
q15_t A1;
q15_t A2;
#else
@@ -1931,23 +1952,12 @@ extern "C"
uint32_t blockSize);
- /**
- * @brief Instance structure for the Q15 CFFT/CIFFT function.
- */
- typedef struct
- {
- uint16_t fftLen; /**< length of the FFT. */
- uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
- uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
- q15_t *pTwiddle; /**< points to the twiddle factor table. */
- uint16_t *pBitRevTable; /**< points to the bit reversal table. */
- uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
- uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
- } arm_cfft_radix4_instance_q15;
+
+
/**
- * @brief Instance structure for the Q31 CFFT/CIFFT function.
+ * @brief Instance structure for the Q15 CFFT/CIFFT function.
*/
typedef struct
@@ -1955,28 +1965,22 @@ extern "C"
uint16_t fftLen; /**< length of the FFT. */
uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
- q31_t *pTwiddle; /**< points to the twiddle factor table. */
+ q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
uint16_t *pBitRevTable; /**< points to the bit reversal table. */
uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
- } arm_cfft_radix4_instance_q31;
+ } arm_cfft_radix2_instance_q15;
+ arm_status arm_cfft_radix2_init_q15(
+ arm_cfft_radix2_instance_q15 * S,
+ uint16_t fftLen,
+ uint8_t ifftFlag,
+ uint8_t bitReverseFlag);
- /**
- * @brief Instance structure for the floating-point CFFT/CIFFT function.
- */
+ void arm_cfft_radix2_q15(
+ const arm_cfft_radix2_instance_q15 * S,
+ q15_t * pSrc);
- typedef struct
- {
- uint16_t fftLen; /**< length of the FFT. */
- uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
- uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
- float32_t *pTwiddle; /**< points to the twiddle factor table. */
- uint16_t *pBitRevTable; /**< points to the bit reversal table. */
- uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
- uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
- float32_t onebyfftLen; /**< value of 1/fftLen. */
- } arm_cfft_radix4_instance_f32;
/**
@@ -1988,11 +1992,21 @@ extern "C"
uint16_t fftLen; /**< length of the FFT. */
uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
- q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
+ q15_t *pTwiddle; /**< points to the twiddle factor table. */
uint16_t *pBitRevTable; /**< points to the bit reversal table. */
uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
- } arm_cfft_radix2_instance_q15;
+ } arm_cfft_radix4_instance_q15;
+
+ arm_status arm_cfft_radix4_init_q15(
+ arm_cfft_radix4_instance_q15 * S,
+ uint16_t fftLen,
+ uint8_t ifftFlag,
+ uint8_t bitReverseFlag);
+
+ void arm_cfft_radix4_q15(
+ const arm_cfft_radix4_instance_q15 * S,
+ q15_t * pSrc);
/**
* @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
@@ -2009,95 +2023,36 @@ extern "C"
uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
} arm_cfft_radix2_instance_q31;
- /**
- * @brief Instance structure for the floating-point CFFT/CIFFT function.
- */
-
- typedef struct
- {
- uint16_t fftLen; /**< length of the FFT. */
- uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
- uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
- float32_t *pTwiddle; /**< points to the Twiddle factor table. */
- uint16_t *pBitRevTable; /**< points to the bit reversal table. */
- uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
- uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
- float32_t onebyfftLen; /**< value of 1/fftLen. */
- } arm_cfft_radix2_instance_f32;
-
-
- /**
- * @brief Processing function for the Q15 CFFT/CIFFT.
- * @param[in] *S points to an instance of the Q15 CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
- */
-
- void arm_cfft_radix4_q15(
- const arm_cfft_radix4_instance_q15 * S,
- q15_t * pSrc);
-
- /**
- * @brief Processing function for the Q15 CFFT/CIFFT.
- * @param[in] *S points to an instance of the Q15 CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
- */
-
- void arm_cfft_radix2_q15(
- const arm_cfft_radix2_instance_q15 * S,
- q15_t * pSrc);
-
- /**
- * @brief Initialization function for the Q15 CFFT/CIFFT.
- * @param[in,out] *S points to an instance of the Q15 CFFT/CIFFT structure.
- * @param[in] fftLen length of the FFT.
- * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
- */
-
- arm_status arm_cfft_radix4_init_q15(
- arm_cfft_radix4_instance_q15 * S,
+ arm_status arm_cfft_radix2_init_q31(
+ arm_cfft_radix2_instance_q31 * S,
uint16_t fftLen,
uint8_t ifftFlag,
uint8_t bitReverseFlag);
+ void arm_cfft_radix2_q31(
+ const arm_cfft_radix2_instance_q31 * S,
+ q31_t * pSrc);
+
/**
- * @brief Initialization function for the Q15 CFFT/CIFFT.
- * @param[in,out] *S points to an instance of the Q15 CFFT/CIFFT structure.
- * @param[in] fftLen length of the FFT.
- * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
+ * @brief Instance structure for the Q31 CFFT/CIFFT function.
*/
- arm_status arm_cfft_radix2_init_q15(
- arm_cfft_radix2_instance_q15 * S,
- uint16_t fftLen,
- uint8_t ifftFlag,
- uint8_t bitReverseFlag);
+ typedef struct
+ {
+ uint16_t fftLen; /**< length of the FFT. */
+ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
+ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
+ q31_t *pTwiddle; /**< points to the twiddle factor table. */
+ uint16_t *pBitRevTable; /**< points to the bit reversal table. */
+ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
+ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
+ } arm_cfft_radix4_instance_q31;
- /**
- * @brief Processing function for the Q31 CFFT/CIFFT.
- * @param[in] *S points to an instance of the Q31 CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
- */
void arm_cfft_radix4_q31(
const arm_cfft_radix4_instance_q31 * S,
q31_t * pSrc);
- /**
- * @brief Initialization function for the Q31 CFFT/CIFFT.
- * @param[in,out] *S points to an instance of the Q31 CFFT/CIFFT structure.
- * @param[in] fftLen length of the FFT.
- * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
- */
-
arm_status arm_cfft_radix4_init_q31(
arm_cfft_radix4_instance_q31 * S,
uint16_t fftLen,
@@ -2105,322 +2060,79 @@ extern "C"
uint8_t bitReverseFlag);
/**
- * @brief Processing function for the Radix-2 Q31 CFFT/CIFFT.
- * @param[in] *S points to an instance of the Radix-2 Q31 CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
+ * @brief Instance structure for the floating-point CFFT/CIFFT function.
*/
- void arm_cfft_radix2_q31(
- const arm_cfft_radix2_instance_q31 * S,
- q31_t * pSrc);
-
- /**
- * @brief Initialization function for the Radix-2 Q31 CFFT/CIFFT.
- * @param[in,out] *S points to an instance of the Radix-2 Q31 CFFT/CIFFT structure.
- * @param[in] fftLen length of the FFT.
- * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
- */
+ typedef struct
+ {
+ uint16_t fftLen; /**< length of the FFT. */
+ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
+ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
+ float32_t *pTwiddle; /**< points to the Twiddle factor table. */
+ uint16_t *pBitRevTable; /**< points to the bit reversal table. */
+ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
+ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
+ float32_t onebyfftLen; /**< value of 1/fftLen. */
+ } arm_cfft_radix2_instance_f32;
- arm_status arm_cfft_radix2_init_q31(
- arm_cfft_radix2_instance_q31 * S,
+/* Deprecated */
+ arm_status arm_cfft_radix2_init_f32(
+ arm_cfft_radix2_instance_f32 * S,
uint16_t fftLen,
uint8_t ifftFlag,
uint8_t bitReverseFlag);
-
-
- /**
- * @brief Processing function for the floating-point CFFT/CIFFT.
- * @param[in] *S points to an instance of the floating-point CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
- */
-
+/* Deprecated */
void arm_cfft_radix2_f32(
const arm_cfft_radix2_instance_f32 * S,
float32_t * pSrc);
/**
- * @brief Initialization function for the floating-point CFFT/CIFFT.
- * @param[in,out] *S points to an instance of the floating-point CFFT/CIFFT structure.
- * @param[in] fftLen length of the FFT.
- * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
+ * @brief Instance structure for the floating-point CFFT/CIFFT function.
*/
- arm_status arm_cfft_radix2_init_f32(
- arm_cfft_radix2_instance_f32 * S,
+ typedef struct
+ {
+ uint16_t fftLen; /**< length of the FFT. */
+ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
+ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
+ float32_t *pTwiddle; /**< points to the Twiddle factor table. */
+ uint16_t *pBitRevTable; /**< points to the bit reversal table. */
+ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
+ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
+ float32_t onebyfftLen; /**< value of 1/fftLen. */
+ } arm_cfft_radix4_instance_f32;
+
+/* Deprecated */
+ arm_status arm_cfft_radix4_init_f32(
+ arm_cfft_radix4_instance_f32 * S,
uint16_t fftLen,
uint8_t ifftFlag,
uint8_t bitReverseFlag);
- /**
- * @brief Processing function for the floating-point CFFT/CIFFT.
- * @param[in] *S points to an instance of the floating-point CFFT/CIFFT structure.
- * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place.
- * @return none.
- */
-
+/* Deprecated */
void arm_cfft_radix4_f32(
const arm_cfft_radix4_instance_f32 * S,
float32_t * pSrc);
/**
- * @brief Initialization function for the floating-point CFFT/CIFFT.
- * @param[in,out] *S points to an instance of the floating-point CFFT/CIFFT structure.
- * @param[in] fftLen length of the FFT.
- * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
+ * @brief Instance structure for the floating-point CFFT/CIFFT function.
*/
- arm_status arm_cfft_radix4_init_f32(
- arm_cfft_radix4_instance_f32 * S,
- uint16_t fftLen,
+ typedef struct
+ {
+ uint16_t fftLen; /**< length of the FFT. */
+ const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
+ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
+ uint16_t bitRevLength; /**< bit reversal table length. */
+ } arm_cfft_instance_f32;
+
+ void arm_cfft_f32(
+ const arm_cfft_instance_f32 * S,
+ float32_t * p1,
uint8_t ifftFlag,
uint8_t bitReverseFlag);
-
-
- /*----------------------------------------------------------------------
- * Internal functions prototypes FFT function
- ----------------------------------------------------------------------*/
-
- /**
- * @brief Core function for the floating-point CFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to the twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix4_butterfly_f32(
- float32_t * pSrc,
- uint16_t fftLen,
- float32_t * pCoef,
- uint16_t twidCoefModifier);
-
- /**
- * @brief Core function for the floating-point CIFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @param[in] onebyfftLen value of 1/fftLen.
- * @return none.
- */
-
- void arm_radix4_butterfly_inverse_f32(
- float32_t * pSrc,
- uint16_t fftLen,
- float32_t * pCoef,
- uint16_t twidCoefModifier,
- float32_t onebyfftLen);
-
- /**
- * @brief In-place bit reversal function.
- * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
- * @param[in] fftSize length of the FFT.
- * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table.
- * @param[in] *pBitRevTab points to the bit reversal table.
- * @return none.
- */
-
- void arm_bitreversal_f32(
- float32_t * pSrc,
- uint16_t fftSize,
- uint16_t bitRevFactor,
- uint16_t * pBitRevTab);
-
- /**
- * @brief Core function for the Q31 CFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix4_butterfly_q31(
- q31_t * pSrc,
- uint32_t fftLen,
- q31_t * pCoef,
- uint32_t twidCoefModifier);
-
- /**
- * @brief Core function for the f32 FFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of f32 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix2_butterfly_f32(
- float32_t * pSrc,
- uint32_t fftLen,
- float32_t * pCoef,
- uint16_t twidCoefModifier);
-
- /**
- * @brief Core function for the Radix-2 Q31 CFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix2_butterfly_q31(
- q31_t * pSrc,
- uint32_t fftLen,
- q31_t * pCoef,
- uint16_t twidCoefModifier);
-
- /**
- * @brief Core function for the Radix-2 Q15 CFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix2_butterfly_q15(
- q15_t * pSrc,
- uint32_t fftLen,
- q15_t * pCoef,
- uint16_t twidCoefModifier);
-
- /**
- * @brief Core function for the Radix-2 Q15 CFFT Inverse butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix2_butterfly_inverse_q15(
- q15_t * pSrc,
- uint32_t fftLen,
- q15_t * pCoef,
- uint16_t twidCoefModifier);
-
- /**
- * @brief Core function for the Radix-2 Q31 CFFT Inverse butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix2_butterfly_inverse_q31(
- q31_t * pSrc,
- uint32_t fftLen,
- q31_t * pCoef,
- uint16_t twidCoefModifier);
-
- /**
- * @brief Core function for the f32 IFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of f32 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to Twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @param[in] onebyfftLen 1/fftLenfth
- * @return none.
- */
-
- void arm_radix2_butterfly_inverse_f32(
- float32_t * pSrc,
- uint32_t fftLen,
- float32_t * pCoef,
- uint16_t twidCoefModifier,
- float32_t onebyfftLen);
-
- /**
- * @brief Core function for the Q31 CIFFT butterfly process.
- * @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef points to twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix4_butterfly_inverse_q31(
- q31_t * pSrc,
- uint32_t fftLen,
- q31_t * pCoef,
- uint32_t twidCoefModifier);
-
- /**
- * @brief In-place bit reversal function.
- * @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
- * @param[in] *pBitRevTab points to bit reversal table.
- * @return none.
- */
-
- void arm_bitreversal_q31(
- q31_t * pSrc,
- uint32_t fftLen,
- uint16_t bitRevFactor,
- uint16_t * pBitRevTab);
-
- /**
- * @brief Core function for the Q15 CFFT butterfly process.
- * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef16 points to twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix4_butterfly_q15(
- q15_t * pSrc16,
- uint32_t fftLen,
- q15_t * pCoef16,
- uint32_t twidCoefModifier);
-
-
- /**
- * @brief Core function for the Q15 CIFFT butterfly process.
- * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] *pCoef16 points to twiddle coefficient buffer.
- * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
- * @return none.
- */
-
- void arm_radix4_butterfly_inverse_q15(
- q15_t * pSrc16,
- uint32_t fftLen,
- q15_t * pCoef16,
- uint32_t twidCoefModifier);
-
- /**
- * @brief In-place bit reversal function.
- * @param[in, out] *pSrc points to the in-place buffer of Q15 data type.
- * @param[in] fftLen length of the FFT.
- * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
- * @param[in] *pBitRevTab points to bit reversal table.
- * @return none.
- */
-
- void arm_bitreversal_q15(
- q15_t * pSrc,
- uint32_t fftLen,
- uint16_t bitRevFactor,
- uint16_t * pBitRevTab);
-
-
/**
* @brief Instance structure for the Q15 RFFT/RIFFT function.
*/
@@ -2437,6 +2149,18 @@ extern "C"
arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
} arm_rfft_instance_q15;
+ arm_status arm_rfft_init_q15(
+ arm_rfft_instance_q15 * S,
+ arm_cfft_radix4_instance_q15 * S_CFFT,
+ uint32_t fftLenReal,
+ uint32_t ifftFlagR,
+ uint32_t bitReverseFlag);
+
+ void arm_rfft_q15(
+ const arm_rfft_instance_q15 * S,
+ q15_t * pSrc,
+ q15_t * pDst);
+
/**
* @brief Instance structure for the Q31 RFFT/RIFFT function.
*/
@@ -2453,6 +2177,18 @@ extern "C"
arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
} arm_rfft_instance_q31;
+ arm_status arm_rfft_init_q31(
+ arm_rfft_instance_q31 * S,
+ arm_cfft_radix4_instance_q31 * S_CFFT,
+ uint32_t fftLenReal,
+ uint32_t ifftFlagR,
+ uint32_t bitReverseFlag);
+
+ void arm_rfft_q31(
+ const arm_rfft_instance_q31 * S,
+ q31_t * pSrc,
+ q31_t * pDst);
+
/**
* @brief Instance structure for the floating-point RFFT/RIFFT function.
*/
@@ -2469,76 +2205,6 @@ extern "C"
arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
} arm_rfft_instance_f32;
- /**
- * @brief Processing function for the Q15 RFFT/RIFFT.
- * @param[in] *S points to an instance of the Q15 RFFT/RIFFT structure.
- * @param[in] *pSrc points to the input buffer.
- * @param[out] *pDst points to the output buffer.
- * @return none.
- */
-
- void arm_rfft_q15(
- const arm_rfft_instance_q15 * S,
- q15_t * pSrc,
- q15_t * pDst);
-
- /**
- * @brief Initialization function for the Q15 RFFT/RIFFT.
- * @param[in, out] *S points to an instance of the Q15 RFFT/RIFFT structure.
- * @param[in] *S_CFFT points to an instance of the Q15 CFFT/CIFFT structure.
- * @param[in] fftLenReal length of the FFT.
- * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value.
- */
-
- arm_status arm_rfft_init_q15(
- arm_rfft_instance_q15 * S,
- arm_cfft_radix4_instance_q15 * S_CFFT,
- uint32_t fftLenReal,
- uint32_t ifftFlagR,
- uint32_t bitReverseFlag);
-
- /**
- * @brief Processing function for the Q31 RFFT/RIFFT.
- * @param[in] *S points to an instance of the Q31 RFFT/RIFFT structure.
- * @param[in] *pSrc points to the input buffer.
- * @param[out] *pDst points to the output buffer.
- * @return none.
- */
-
- void arm_rfft_q31(
- const arm_rfft_instance_q31 * S,
- q31_t * pSrc,
- q31_t * pDst);
-
- /**
- * @brief Initialization function for the Q31 RFFT/RIFFT.
- * @param[in, out] *S points to an instance of the Q31 RFFT/RIFFT structure.
- * @param[in, out] *S_CFFT points to an instance of the Q31 CFFT/CIFFT structure.
- * @param[in] fftLenReal length of the FFT.
- * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value.
- */
-
- arm_status arm_rfft_init_q31(
- arm_rfft_instance_q31 * S,
- arm_cfft_radix4_instance_q31 * S_CFFT,
- uint32_t fftLenReal,
- uint32_t ifftFlagR,
- uint32_t bitReverseFlag);
-
- /**
- * @brief Initialization function for the floating-point RFFT/RIFFT.
- * @param[in,out] *S points to an instance of the floating-point RFFT/RIFFT structure.
- * @param[in,out] *S_CFFT points to an instance of the floating-point CFFT/CIFFT structure.
- * @param[in] fftLenReal length of the FFT.
- * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform.
- * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
- * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value.
- */
-
arm_status arm_rfft_init_f32(
arm_rfft_instance_f32 * S,
arm_cfft_radix4_instance_f32 * S_CFFT,
@@ -2546,20 +2212,32 @@ extern "C"
uint32_t ifftFlagR,
uint32_t bitReverseFlag);
- /**
- * @brief Processing function for the floating-point RFFT/RIFFT.
- * @param[in] *S points to an instance of the floating-point RFFT/RIFFT structure.
- * @param[in] *pSrc points to the input buffer.
- * @param[out] *pDst points to the output buffer.
- * @return none.
- */
-
void arm_rfft_f32(
const arm_rfft_instance_f32 * S,
float32_t * pSrc,
float32_t * pDst);
/**
+ * @brief Instance structure for the floating-point RFFT/RIFFT function.
+ */
+
+typedef struct
+ {
+ arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
+ uint16_t fftLenRFFT; /**< length of the real sequence */
+ float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
+ } arm_rfft_fast_instance_f32 ;
+
+arm_status arm_rfft_fast_init_f32 (
+ arm_rfft_fast_instance_f32 * S,
+ uint16_t fftLen);
+
+void arm_rfft_fast_f32(
+ arm_rfft_fast_instance_f32 * S,
+ float32_t * p, float32_t * pOut,
+ uint8_t ifftFlag);
+
+ /**
* @brief Instance structure for the floating-point DCT4/IDCT4 function.
*/
@@ -3155,7 +2833,7 @@ extern "C"
q31_t * pDst,
uint32_t blockSize);
/**
- * @brief Copies the elements of a floating-point vector.
+ * @brief Copies the elements of a floating-point vector.
* @param[in] *pSrc input pointer
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3167,7 +2845,7 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Copies the elements of a Q7 vector.
+ * @brief Copies the elements of a Q7 vector.
* @param[in] *pSrc input pointer
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3179,7 +2857,7 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Copies the elements of a Q15 vector.
+ * @brief Copies the elements of a Q15 vector.
* @param[in] *pSrc input pointer
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3191,7 +2869,7 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Copies the elements of a Q31 vector.
+ * @brief Copies the elements of a Q31 vector.
* @param[in] *pSrc input pointer
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3202,7 +2880,7 @@ extern "C"
q31_t * pDst,
uint32_t blockSize);
/**
- * @brief Fills a constant value into a floating-point vector.
+ * @brief Fills a constant value into a floating-point vector.
* @param[in] value input value to be filled
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3214,7 +2892,7 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Fills a constant value into a Q7 vector.
+ * @brief Fills a constant value into a Q7 vector.
* @param[in] value input value to be filled
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3226,7 +2904,7 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Fills a constant value into a Q15 vector.
+ * @brief Fills a constant value into a Q15 vector.
* @param[in] value input value to be filled
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3238,7 +2916,7 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Fills a constant value into a Q31 vector.
+ * @brief Fills a constant value into a Q31 vector.
* @param[in] value input value to be filled
* @param[out] *pDst output pointer
* @param[in] blockSize number of samples to process
@@ -3249,14 +2927,14 @@ extern "C"
q31_t * pDst,
uint32_t blockSize);
-/**
- * @brief Convolution of floating-point sequences.
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
- * @return none.
+/**
+ * @brief Convolution of floating-point sequences.
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
+ * @return none.
*/
void arm_conv_f32(
@@ -3266,17 +2944,17 @@ extern "C"
uint32_t srcBLen,
float32_t * pDst);
-
- /**
- * @brief Convolution of Q15 sequences.
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
- * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
- * @return none.
+
+ /**
+ * @brief Convolution of Q15 sequences.
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
+ * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
+ * @return none.
*/
@@ -3290,14 +2968,14 @@ extern "C"
q15_t * pScratch2);
-/**
- * @brief Convolution of Q15 sequences.
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
- * @return none.
+/**
+ * @brief Convolution of Q15 sequences.
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
+ * @return none.
*/
void arm_conv_q15(
@@ -3331,9 +3009,9 @@ extern "C"
* @param[in] *pSrcB points to the second input sequence.
* @param[in] srcBLen length of the second input sequence.
* @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
- * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
- * @return none.
+ * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
+ * @return none.
*/
void arm_conv_fast_opt_q15(
@@ -3382,16 +3060,16 @@ extern "C"
q31_t * pDst);
- /**
- * @brief Convolution of Q7 sequences.
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
- * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
- * @return none.
+ /**
+ * @brief Convolution of Q7 sequences.
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
+ * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
+ * @return none.
*/
void arm_conv_opt_q7(
@@ -3444,18 +3122,18 @@ extern "C"
uint32_t firstIndex,
uint32_t numPoints);
- /**
- * @brief Partial convolution of Q15 sequences.
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the block of output data
- * @param[in] firstIndex is the first output sample to start with.
- * @param[in] numPoints is the number of output points to be computed.
- * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
- * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
+ /**
+ * @brief Partial convolution of Q15 sequences.
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the block of output data
+ * @param[in] firstIndex is the first output sample to start with.
+ * @param[in] numPoints is the number of output points to be computed.
+ * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
+ * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
*/
arm_status arm_conv_partial_opt_q15(
@@ -3522,9 +3200,9 @@ extern "C"
* @param[out] *pDst points to the block of output data
* @param[in] firstIndex is the first output sample to start with.
* @param[in] numPoints is the number of output points to be computed.
- * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
- * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
+ * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
+ * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
*/
arm_status arm_conv_partial_fast_opt_q15(
@@ -3583,18 +3261,18 @@ extern "C"
uint32_t numPoints);
- /**
- * @brief Partial convolution of Q7 sequences
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the block of output data
- * @param[in] firstIndex is the first output sample to start with.
- * @param[in] numPoints is the number of output points to be computed.
- * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
- * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
+ /**
+ * @brief Partial convolution of Q7 sequences
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the block of output data
+ * @param[in] firstIndex is the first output sample to start with.
+ * @param[in] numPoints is the number of output points to be computed.
+ * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
+ * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
*/
arm_status arm_conv_partial_opt_q7(
@@ -4086,8 +3764,8 @@ extern "C"
* @brief Initialization function for the Q15 FIR lattice filter.
* @param[in] *S points to an instance of the Q15 FIR lattice structure.
* @param[in] numStages number of filter stages.
- * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
- * @param[in] *pState points to the state buffer. The array is of length numStages.
+ * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
+ * @param[in] *pState points to the state buffer. The array is of length numStages.
* @return none.
*/
@@ -4654,15 +4332,15 @@ extern "C"
float32_t * pDst);
- /**
- * @brief Correlation of Q15 sequences
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
- * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @return none.
+ /**
+ * @brief Correlation of Q15 sequences
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
+ * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @return none.
*/
void arm_correlate_opt_q15(
q15_t * pSrcA,
@@ -4716,7 +4394,7 @@ extern "C"
* @param[in] *pSrcB points to the second input sequence.
* @param[in] srcBLen length of the second input sequence.
* @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
- * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
* @return none.
*/
@@ -4764,16 +4442,16 @@ extern "C"
- /**
- * @brief Correlation of Q7 sequences.
- * @param[in] *pSrcA points to the first input sequence.
- * @param[in] srcALen length of the first input sequence.
- * @param[in] *pSrcB points to the second input sequence.
- * @param[in] srcBLen length of the second input sequence.
- * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
- * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
- * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
- * @return none.
+ /**
+ * @brief Correlation of Q7 sequences.
+ * @param[in] *pSrcA points to the first input sequence.
+ * @param[in] srcALen length of the first input sequence.
+ * @param[in] *pSrcB points to the second input sequence.
+ * @param[in] srcBLen length of the second input sequence.
+ * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
+ * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+ * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
+ * @return none.
*/
void arm_correlate_opt_q7(
@@ -5019,9 +4697,9 @@ extern "C"
/*
* @brief Floating-point sin_cos function.
- * @param[in] theta input value in degrees
- * @param[out] *pSinVal points to the processed sine output.
- * @param[out] *pCosVal points to the processed cos output.
+ * @param[in] theta input value in degrees
+ * @param[out] *pSinVal points to the processed sine output.
+ * @param[out] *pCosVal points to the processed cos output.
* @return none.
*/
@@ -5032,9 +4710,9 @@ extern "C"
/*
* @brief Q31 sin_cos function.
- * @param[in] theta scaled input value in degrees
- * @param[out] *pSinVal points to the processed sine output.
- * @param[out] *pCosVal points to the processed cosine output.
+ * @param[in] theta scaled input value in degrees
+ * @param[out] *pSinVal points to the processed sine output.
+ * @param[out] *pCosVal points to the processed cosine output.
* @return none.
*/
@@ -5132,7 +4810,7 @@ extern "C"
/**
* @defgroup PID PID Motor Control
*
- * A Proportional Integral Derivative (PID) controller is a generic feedback control
+ * A Proportional Integral Derivative (PID) controller is a generic feedback control
* loop mechanism widely used in industrial control systems.
* A PID controller is the most commonly used type of feedback controller.
*
@@ -5151,39 +4829,39 @@ extern "C"
*
* \par
* where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
- *
- * \par
- * \image html PID.gif "Proportional Integral Derivative Controller"
+ *
+ * \par
+ * \image html PID.gif "Proportional Integral Derivative Controller"
*
* \par
* The PID controller calculates an "error" value as the difference between
* the measured output and the reference input.
- * The controller attempts to minimize the error by adjusting the process control inputs.
- * The proportional value determines the reaction to the current error,
- * the integral value determines the reaction based on the sum of recent errors,
+ * The controller attempts to minimize the error by adjusting the process control inputs.
+ * The proportional value determines the reaction to the current error,
+ * the integral value determines the reaction based on the sum of recent errors,
* and the derivative value determines the reaction based on the rate at which the error has been changing.
*
- * \par Instance Structure
- * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
- * A separate instance structure must be defined for each PID Controller.
- * There are separate instance structure declarations for each of the 3 supported data types.
- *
- * \par Reset Functions
- * There is also an associated reset function for each data type which clears the state array.
+ * \par Instance Structure
+ * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
+ * A separate instance structure must be defined for each PID Controller.
+ * There are separate instance structure declarations for each of the 3 supported data types.
+ *
+ * \par Reset Functions
+ * There is also an associated reset function for each data type which clears the state array.
*
- * \par Initialization Functions
- * There is also an associated initialization function for each data type.
- * The initialization function performs the following operations:
+ * \par Initialization Functions
+ * There is also an associated initialization function for each data type.
+ * The initialization function performs the following operations:
* - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
- * - Zeros out the values in the state buffer.
- *
- * \par
- * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
+ * - Zeros out the values in the state buffer.
*
- * \par Fixed-Point Behavior
- * Care must be taken when using the fixed-point versions of the PID Controller functions.
- * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
- * Refer to the function specific documentation below for usage guidelines.
+ * \par
+ * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
+ *
+ * \par Fixed-Point Behavior
+ * Care must be taken when using the fixed-point versions of the PID Controller functions.
+ * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
+ * Refer to the function specific documentation below for usage guidelines.
*/
/**
@@ -5199,7 +4877,7 @@ extern "C"
*/
- __STATIC_INLINE float32_t arm_pid_f32(
+ static __INLINE float32_t arm_pid_f32(
arm_pid_instance_f32 * S,
float32_t in)
{
@@ -5225,16 +4903,16 @@ extern "C"
* @param[in] in input sample to process
* @return out processed output sample.
*
- * <b>Scaling and Overflow Behavior:</b>
- * \par
- * The function is implemented using an internal 64-bit accumulator.
- * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
- * Thus, if the accumulator result overflows it wraps around rather than clip.
- * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
- * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
+ * <b>Scaling and Overflow Behavior:</b>
+ * \par
+ * The function is implemented using an internal 64-bit accumulator.
+ * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
+ * Thus, if the accumulator result overflows it wraps around rather than clip.
+ * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
+ * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
*/
- __STATIC_INLINE q31_t arm_pid_q31(
+ static __INLINE q31_t arm_pid_q31(
arm_pid_instance_q31 * S,
q31_t in)
{
@@ -5272,47 +4950,42 @@ extern "C"
* @param[in] in input sample to process
* @return out processed output sample.
*
- * <b>Scaling and Overflow Behavior:</b>
- * \par
- * The function is implemented using a 64-bit internal accumulator.
- * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
- * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
- * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
- * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
+ * <b>Scaling and Overflow Behavior:</b>
+ * \par
+ * The function is implemented using a 64-bit internal accumulator.
+ * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
+ * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
+ * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
+ * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
* Lastly, the accumulator is saturated to yield a result in 1.15 format.
*/
- __STATIC_INLINE q15_t arm_pid_q15(
+ static __INLINE q15_t arm_pid_q15(
arm_pid_instance_q15 * S,
q15_t in)
{
q63_t acc;
q15_t out;
- /* Implementation of PID controller */
-
-#ifdef ARM_MATH_CM0
-
- /* acc = A0 * x[n] */
- acc = ((q31_t) S->A0) * in;
+#ifndef ARM_MATH_CM0_FAMILY
+ __SIMD32_TYPE *vstate;
-#else
+ /* Implementation of PID controller */
/* acc = A0 * x[n] */
acc = (q31_t) __SMUAD(S->A0, in);
-#endif
-
-#ifdef ARM_MATH_CM0
-
/* acc += A1 * x[n-1] + A2 * x[n-2] */
- acc += (q31_t) S->A1 * S->state[0];
- acc += (q31_t) S->A2 * S->state[1];
+ vstate = __SIMD32_CONST(S->state);
+ acc = __SMLALD(S->A1, (q31_t) *vstate, acc);
#else
+ /* acc = A0 * x[n] */
+ acc = ((q31_t) S->A0) * in;
/* acc += A1 * x[n-1] + A2 * x[n-2] */
- acc = __SMLALD(S->A1, (q31_t) __SIMD32(S->state), acc);
+ acc += (q31_t) S->A1 * S->state[0];
+ acc += (q31_t) S->A2 * S->state[1];
#endif
@@ -5366,7 +5039,7 @@ extern "C"
* and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
* can be calculated using only <code>Ia</code> and <code>Ib</code>.
*
- * The function operates on a single sample of data and each call to the function returns the processed output.
+ * The function operates on a single sample of data and each call to the function returns the processed output.
* The library provides separate functions for Q31 and floating-point data types.
* \par Algorithm
* \image html clarkeFormula.gif
@@ -5393,7 +5066,7 @@ extern "C"
* @return none.
*/
- __STATIC_INLINE void arm_clarke_f32(
+ static __INLINE void arm_clarke_f32(
float32_t Ia,
float32_t Ib,
float32_t * pIalpha,
@@ -5423,7 +5096,7 @@ extern "C"
* There is saturation on the addition, hence there is no risk of overflow.
*/
- __STATIC_INLINE void arm_clarke_q31(
+ static __INLINE void arm_clarke_q31(
q31_t Ia,
q31_t Ib,
q31_t * pIalpha,
@@ -5470,8 +5143,8 @@ extern "C"
/**
* @defgroup inv_clarke Vector Inverse Clarke Transform
* Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
- *
- * The function operates on a single sample of data and each call to the function returns the processed output.
+ *
+ * The function operates on a single sample of data and each call to the function returns the processed output.
* The library provides separate functions for Q31 and floating-point data types.
* \par Algorithm
* \image html clarkeInvFormula.gif
@@ -5498,7 +5171,7 @@ extern "C"
*/
- __STATIC_INLINE void arm_inv_clarke_f32(
+ static __INLINE void arm_inv_clarke_f32(
float32_t Ialpha,
float32_t Ibeta,
float32_t * pIa,
@@ -5513,7 +5186,7 @@ extern "C"
}
/**
- * @brief Inverse Clarke transform for Q31 version
+ * @brief Inverse Clarke transform for Q31 version
* @param[in] Ialpha input two-phase orthogonal vector axis alpha
* @param[in] Ibeta input two-phase orthogonal vector axis beta
* @param[out] *pIa points to output three-phase coordinate <code>a</code>
@@ -5527,7 +5200,7 @@ extern "C"
* There is saturation on the subtraction, hence there is no risk of overflow.
*/
- __STATIC_INLINE void arm_inv_clarke_q31(
+ static __INLINE void arm_inv_clarke_q31(
q31_t Ialpha,
q31_t Ibeta,
q31_t * pIa,
@@ -5575,19 +5248,19 @@ extern "C"
* @defgroup park Vector Park Transform
*
* Forward Park transform converts the input two-coordinate vector to flux and torque components.
- * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
- * from the stationary to the moving reference frame and control the spatial relationship between
+ * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
+ * from the stationary to the moving reference frame and control the spatial relationship between
* the stator vector current and rotor flux vector.
- * If we consider the d axis aligned with the rotor flux, the diagram below shows the
+ * If we consider the d axis aligned with the rotor flux, the diagram below shows the
* current vector and the relationship from the two reference frames:
* \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
*
- * The function operates on a single sample of data and each call to the function returns the processed output.
+ * The function operates on a single sample of data and each call to the function returns the processed output.
* The library provides separate functions for Q31 and floating-point data types.
* \par Algorithm
* \image html parkFormula.gif
- * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
- * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
+ * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
+ * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
* cosine and sine values of theta (rotor flux position).
* \par Fixed-Point Behavior
* Care must be taken when using the Q31 version of the Park transform.
@@ -5614,7 +5287,7 @@ extern "C"
*
*/
- __STATIC_INLINE void arm_park_f32(
+ static __INLINE void arm_park_f32(
float32_t Ialpha,
float32_t Ibeta,
float32_t * pId,
@@ -5631,7 +5304,7 @@ extern "C"
}
/**
- * @brief Park transform for Q31 version
+ * @brief Park transform for Q31 version
* @param[in] Ialpha input two-phase vector coordinate alpha
* @param[in] Ibeta input two-phase vector coordinate beta
* @param[out] *pId points to output rotor reference frame d
@@ -5648,7 +5321,7 @@ extern "C"
*/
- __STATIC_INLINE void arm_park_q31(
+ static __INLINE void arm_park_q31(
q31_t Ialpha,
q31_t Ibeta,
q31_t * pId,
@@ -5704,12 +5377,12 @@ extern "C"
* @defgroup inv_park Vector Inverse Park transform
* Inverse Park transform converts the input flux and torque components to two-coordinate vector.
*
- * The function operates on a single sample of data and each call to the function returns the processed output.
+ * The function operates on a single sample of data and each call to the function returns the processed output.
* The library provides separate functions for Q31 and floating-point data types.
* \par Algorithm
* \image html parkInvFormula.gif
- * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
- * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
+ * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
+ * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
* cosine and sine values of theta (rotor flux position).
* \par Fixed-Point Behavior
* Care must be taken when using the Q31 version of the Park transform.
@@ -5733,7 +5406,7 @@ extern "C"
* @return none.
*/
- __STATIC_INLINE void arm_inv_park_f32(
+ static __INLINE void arm_inv_park_f32(
float32_t Id,
float32_t Iq,
float32_t * pIalpha,
@@ -5751,7 +5424,7 @@ extern "C"
/**
- * @brief Inverse Park transform for Q31 version
+ * @brief Inverse Park transform for Q31 version
* @param[in] Id input coordinate of rotor reference frame d
* @param[in] Iq input coordinate of rotor reference frame q
* @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
@@ -5768,7 +5441,7 @@ extern "C"
*/
- __STATIC_INLINE void arm_inv_park_q31(
+ static __INLINE void arm_inv_park_q31(
q31_t Id,
q31_t Iq,
q31_t * pIalpha,
@@ -5827,7 +5500,7 @@ extern "C"
* Linear interpolation is a method of curve fitting using linear polynomials.
* Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
*
- * \par
+ * \par
* \image html LinearInterp.gif "Linear interpolation"
*
* \par
@@ -5847,10 +5520,10 @@ extern "C"
* sample of data and each call to the function returns a single processed value.
* <code>S</code> points to an instance of the Linear Interpolate function data structure.
* <code>x</code> is the input sample value. The functions returns the output value.
- *
+ *
* \par
- * if x is outside of the table boundary, Linear interpolation returns first value of the table
- * if x is below input range and returns last value of table if x is above range.
+ * if x is outside of the table boundary, Linear interpolation returns first value of the table
+ * if x is below input range and returns last value of table if x is above range.
*/
/**
@@ -5866,7 +5539,7 @@ extern "C"
*
*/
- __STATIC_INLINE float32_t arm_linear_interp_f32(
+ static __INLINE float32_t arm_linear_interp_f32(
arm_linear_interp_instance_f32 * S,
float32_t x)
{
@@ -5879,14 +5552,14 @@ extern "C"
float32_t *pYData = S->pYData; /* pointer to output table */
/* Calculation of index */
- i = (x - S->x1) / xSpacing;
+ i = (int32_t) ((x - S->x1) / xSpacing);
if(i < 0)
{
/* Iniatilize output for below specified range as least output value of table */
y = pYData[0];
}
- else if(i >= S->nValues)
+ else if((uint32_t)i >= S->nValues)
{
/* Iniatilize output for above specified range as last output value of table */
y = pYData[S->nValues - 1];
@@ -5925,7 +5598,7 @@ extern "C"
*/
- __STATIC_INLINE q31_t arm_linear_interp_q31(
+ static __INLINE q31_t arm_linear_interp_q31(
q31_t * pYData,
q31_t x,
uint32_t nValues)
@@ -5940,7 +5613,7 @@ extern "C"
/* Index value calculation */
index = ((x & 0xFFF00000) >> 20);
- if(index >= (nValues - 1))
+ if(index >= (int32_t)(nValues - 1))
{
return (pYData[nValues - 1]);
}
@@ -5982,12 +5655,12 @@ extern "C"
*
* \par
* Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
- * This function can support maximum of table size 2^12.
+ * This function can support maximum of table size 2^12.
*
*/
- __STATIC_INLINE q15_t arm_linear_interp_q15(
+ static __INLINE q15_t arm_linear_interp_q15(
q15_t * pYData,
q31_t x,
uint32_t nValues)
@@ -6002,7 +5675,7 @@ extern "C"
/* Index value calculation */
index = ((x & 0xFFF00000) >> 20u);
- if(index >= (nValues - 1))
+ if(index >= (int32_t)(nValues - 1))
{
return (pYData[nValues - 1]);
}
@@ -6047,7 +5720,7 @@ extern "C"
*/
- __STATIC_INLINE q7_t arm_linear_interp_q7(
+ static __INLINE q7_t arm_linear_interp_q7(
q7_t * pYData,
q31_t x,
uint32_t nValues)
@@ -6055,22 +5728,22 @@ extern "C"
q31_t y; /* output */
q7_t y0, y1; /* Nearest output values */
q31_t fract; /* fractional part */
- int32_t index; /* Index to read nearest output values */
+ uint32_t index; /* Index to read nearest output values */
/* Input is in 12.20 format */
/* 12 bits for the table index */
/* Index value calculation */
- index = ((x & 0xFFF00000) >> 20u);
+ if (x < 0)
+ {
+ return (pYData[0]);
+ }
+ index = (x >> 20) & 0xfff;
if(index >= (nValues - 1))
{
return (pYData[nValues - 1]);
}
- else if(index < 0)
- {
- return (pYData[0]);
- }
else
{
@@ -6162,14 +5835,14 @@ extern "C"
* @defgroup SQRT Square Root
*
* Computes the square root of a number.
- * There are separate functions for Q15, Q31, and floating-point data types.
+ * There are separate functions for Q15, Q31, and floating-point data types.
* The square root function is computed using the Newton-Raphson algorithm.
* This is an iterative algorithm of the form:
* <pre>
* x1 = x0 - f(x0)/f'(x0)
* </pre>
* where <code>x1</code> is the current estimate,
- * <code>x0</code> is the previous estimate and
+ * <code>x0</code> is the previous estimate, and
* <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
* For the square root function, the algorithm reduces to:
* <pre>
@@ -6192,21 +5865,19 @@ extern "C"
* <code>in</code> is negative value and returns zero output for negative values.
*/
- __STATIC_INLINE arm_status arm_sqrt_f32(
+ static __INLINE arm_status arm_sqrt_f32(
float32_t in,
float32_t * pOut)
{
if(in > 0)
{
-// #if __FPU_USED
- #if (__FPU_USED == 1) && defined ( __CC_ARM )
- *pOut = __sqrtf(in);
- #elif (__FPU_USED == 1) && defined ( __TMS_740 )
- *pOut = __builtin_sqrtf(in);
- #else
- *pOut = sqrtf(in);
- #endif
+// #if __FPU_USED
+#if (__FPU_USED == 1) && defined ( __CC_ARM )
+ *pOut = __sqrtf(in);
+#else
+ *pOut = sqrtf(in);
+#endif
return (ARM_MATH_SUCCESS);
}
@@ -6254,7 +5925,7 @@ extern "C"
* @brief floating-point Circular write function.
*/
- __STATIC_INLINE void arm_circularWrite_f32(
+ static __INLINE void arm_circularWrite_f32(
int32_t * circBuffer,
int32_t L,
uint16_t * writeOffset,
@@ -6299,7 +5970,7 @@ extern "C"
/**
* @brief floating-point Circular Read function.
*/
- __STATIC_INLINE void arm_circularRead_f32(
+ static __INLINE void arm_circularRead_f32(
int32_t * circBuffer,
int32_t L,
int32_t * readOffset,
@@ -6354,7 +6025,7 @@ extern "C"
* @brief Q15 Circular write function.
*/
- __STATIC_INLINE void arm_circularWrite_q15(
+ static __INLINE void arm_circularWrite_q15(
q15_t * circBuffer,
int32_t L,
uint16_t * writeOffset,
@@ -6399,7 +6070,7 @@ extern "C"
/**
* @brief Q15 Circular Read function.
*/
- __STATIC_INLINE void arm_circularRead_q15(
+ static __INLINE void arm_circularRead_q15(
q15_t * circBuffer,
int32_t L,
int32_t * readOffset,
@@ -6456,7 +6127,7 @@ extern "C"
* @brief Q7 Circular write function.
*/
- __STATIC_INLINE void arm_circularWrite_q7(
+ static __INLINE void arm_circularWrite_q7(
q7_t * circBuffer,
int32_t L,
uint16_t * writeOffset,
@@ -6501,7 +6172,7 @@ extern "C"
/**
* @brief Q7 Circular Read function.
*/
- __STATIC_INLINE void arm_circularRead_q7(
+ static __INLINE void arm_circularRead_q7(
q7_t * circBuffer,
int32_t L,
int32_t * readOffset,
@@ -7072,11 +6743,11 @@ extern "C"
uint32_t numSamples);
/**
- * @brief Converts the elements of the floating-point vector to Q31 vector.
- * @param[in] *pSrc points to the floating-point input vector
+ * @brief Converts the elements of the floating-point vector to Q31 vector.
+ * @param[in] *pSrc points to the floating-point input vector
* @param[out] *pDst points to the Q31 output vector
- * @param[in] blockSize length of the input vector
- * @return none.
+ * @param[in] blockSize length of the input vector
+ * @return none.
*/
void arm_float_to_q31(
float32_t * pSrc,
@@ -7084,10 +6755,10 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Converts the elements of the floating-point vector to Q15 vector.
- * @param[in] *pSrc points to the floating-point input vector
+ * @brief Converts the elements of the floating-point vector to Q15 vector.
+ * @param[in] *pSrc points to the floating-point input vector
* @param[out] *pDst points to the Q15 output vector
- * @param[in] blockSize length of the input vector
+ * @param[in] blockSize length of the input vector
* @return none
*/
void arm_float_to_q15(
@@ -7096,10 +6767,10 @@ extern "C"
uint32_t blockSize);
/**
- * @brief Converts the elements of the floating-point vector to Q7 vector.
- * @param[in] *pSrc points to the floating-point input vector
+ * @brief Converts the elements of the floating-point vector to Q7 vector.
+ * @param[in] *pSrc points to the floating-point input vector
* @param[out] *pDst points to the Q7 output vector
- * @param[in] blockSize length of the input vector
+ * @param[in] blockSize length of the input vector
* @return none
*/
void arm_float_to_q7(
@@ -7219,12 +6890,12 @@ extern "C"
* + f(XF, YF+1) * (1-(x-XF))*(y-YF)
* + f(XF+1, YF+1) * (x-XF)*(y-YF)
* </pre>
- * Note that the coordinates (x, y) contain integer and fractional components.
+ * Note that the coordinates (x, y) contain integer and fractional components.
* The integer components specify which portion of the table to use while the
* fractional components control the interpolation processor.
*
* \par
- * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
+ * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
*/
/**
@@ -7242,7 +6913,7 @@ extern "C"
*/
- __STATIC_INLINE float32_t arm_bilinear_interp_f32(
+ static __INLINE float32_t arm_bilinear_interp_f32(
const arm_bilinear_interp_instance_f32 * S,
float32_t X,
float32_t Y)
@@ -7310,7 +6981,7 @@ extern "C"
* @return out interpolated value.
*/
- __STATIC_INLINE q31_t arm_bilinear_interp_q31(
+ static __INLINE q31_t arm_bilinear_interp_q31(
arm_bilinear_interp_instance_q31 * S,
q31_t X,
q31_t Y)
@@ -7386,7 +7057,7 @@ extern "C"
* @return out interpolated value.
*/
- __STATIC_INLINE q15_t arm_bilinear_interp_q15(
+ static __INLINE q15_t arm_bilinear_interp_q15(
arm_bilinear_interp_instance_q15 * S,
q31_t X,
q31_t Y)
@@ -7466,7 +7137,7 @@ extern "C"
* @return out interpolated value.
*/
- __STATIC_INLINE q7_t arm_bilinear_interp_q7(
+ static __INLINE q7_t arm_bilinear_interp_q7(
arm_bilinear_interp_instance_q7 * S,
q31_t X,
q31_t Y)
@@ -7539,6 +7210,84 @@ extern "C"
*/
+#if defined ( __CC_ARM ) //Keil
+//SMMLAR
+ #define multAcc_32x32_keep32_R(a, x, y) \
+ a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
+
+//SMMLSR
+ #define multSub_32x32_keep32_R(a, x, y) \
+ a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
+
+//SMMULR
+ #define mult_32x32_keep32_R(a, x, y) \
+ a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
+
+//Enter low optimization region - place directly above function definition
+ #define LOW_OPTIMIZATION_ENTER \
+ _Pragma ("push") \
+ _Pragma ("O1")
+
+//Exit low optimization region - place directly after end of function definition
+ #define LOW_OPTIMIZATION_EXIT \
+ _Pragma ("pop")
+
+//Enter low optimization region - place directly above function definition
+ #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
+
+//Exit low optimization region - place directly after end of function definition
+ #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
+
+#elif defined(__ICCARM__) //IAR
+ //SMMLA
+ #define multAcc_32x32_keep32_R(a, x, y) \
+ a += (q31_t) (((q63_t) x * y) >> 32)
+
+ //SMMLS
+ #define multSub_32x32_keep32_R(a, x, y) \
+ a -= (q31_t) (((q63_t) x * y) >> 32)
+
+//SMMUL
+ #define mult_32x32_keep32_R(a, x, y) \
+ a = (q31_t) (((q63_t) x * y ) >> 32)
+
+//Enter low optimization region - place directly above function definition
+ #define LOW_OPTIMIZATION_ENTER \
+ _Pragma ("optimize=low")
+
+//Exit low optimization region - place directly after end of function definition
+ #define LOW_OPTIMIZATION_EXIT
+
+//Enter low optimization region - place directly above function definition
+ #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
+ _Pragma ("optimize=low")
+
+//Exit low optimization region - place directly after end of function definition
+ #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
+
+#elif defined(__GNUC__)
+ //SMMLA
+ #define multAcc_32x32_keep32_R(a, x, y) \
+ a += (q31_t) (((q63_t) x * y) >> 32)
+
+ //SMMLS
+ #define multSub_32x32_keep32_R(a, x, y) \
+ a -= (q31_t) (((q63_t) x * y) >> 32)
+
+//SMMUL
+ #define mult_32x32_keep32_R(a, x, y) \
+ a = (q31_t) (((q63_t) x * y ) >> 32)
+
+ #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") ))
+
+ #define LOW_OPTIMIZATION_EXIT
+
+ #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
+
+ #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
+
+#endif
+
diff --git a/components/CMSIS/Include/core_cm0.h b/components/CMSIS/Include/core_cm0.h
index 19bad5ebeb..ab31de0ee8 100644
--- a/components/CMSIS/Include/core_cm0.h
+++ b/components/CMSIS/Include/core_cm0.h
@@ -1,25 +1,40 @@
/**************************************************************************//**
* @file core_cm0.h
* @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
- * @version V3.01
- * @date 13. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
+
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
@@ -54,7 +69,7 @@
/* CMSIS CM0 definitions */
#define __CM0_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
-#define __CM0_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
+#define __CM0_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16) | \
__CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
@@ -590,9 +605,9 @@ __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
{
if(IRQn < 0) {
- return((uint32_t)((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
+ return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
else {
- return((uint32_t)((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
+ return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
}
@@ -640,9 +655,9 @@ __STATIC_INLINE void NVIC_SystemReset(void)
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
- if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+ if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
- SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ SysTick->LOAD = ticks - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
diff --git a/components/CMSIS/Include/core_cm0plus.h b/components/CMSIS/Include/core_cm0plus.h
index aa20e6879f..5cea74e9af 100644
--- a/components/CMSIS/Include/core_cm0plus.h
+++ b/components/CMSIS/Include/core_cm0plus.h
@@ -1,25 +1,40 @@
/**************************************************************************//**
* @file core_cm0plus.h
* @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File
- * @version V3.01
- * @date 22. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
+
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
@@ -54,7 +69,7 @@
/* CMSIS CM0P definitions */
#define __CM0PLUS_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
-#define __CM0PLUS_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
+#define __CM0PLUS_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16) | \
__CM0PLUS_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
@@ -361,8 +376,8 @@ typedef struct
#if (__VTOR_PRESENT == 1)
/* SCB Interrupt Control State Register Definitions */
-#define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */
-#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
+#define SCB_VTOR_TBLOFF_Pos 8 /*!< SCB VTOR: TBLOFF Position */
+#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
#endif
/* SCB Application Interrupt and Reset Control Register Definitions */
@@ -701,9 +716,9 @@ __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
{
if(IRQn < 0) {
- return((uint32_t)((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0+ system interrupts */
+ return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
else {
- return((uint32_t)((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
+ return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
}
@@ -751,9 +766,9 @@ __STATIC_INLINE void NVIC_SystemReset(void)
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
- if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+ if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
- SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ SysTick->LOAD = ticks - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
diff --git a/components/CMSIS/Include/core_cm3.h b/components/CMSIS/Include/core_cm3.h
index 0173893fbd..122c9aa4a8 100644
--- a/components/CMSIS/Include/core_cm3.h
+++ b/components/CMSIS/Include/core_cm3.h
@@ -1,25 +1,40 @@
/**************************************************************************//**
* @file core_cm3.h
* @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File
- * @version V3.01
- * @date 22. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
+
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
@@ -54,7 +69,7 @@
/* CMSIS CM3 definitions */
#define __CM3_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
-#define __CM3_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
+#define __CM3_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | \
__CM3_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
@@ -636,14 +651,14 @@ typedef struct
__IO uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */
uint32_t RESERVED2[15];
__IO uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */
- uint32_t RESERVED3[29];
+ uint32_t RESERVED3[29];
__O uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */
__I uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */
__IO uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */
- uint32_t RESERVED4[43];
+ uint32_t RESERVED4[43];
__O uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */
__I uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */
- uint32_t RESERVED5[6];
+ uint32_t RESERVED5[6];
__I uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */
__I uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */
__I uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */
@@ -1516,9 +1531,9 @@ __STATIC_INLINE void NVIC_SystemReset(void)
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
- if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+ if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
- SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ SysTick->LOAD = ticks - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
diff --git a/components/CMSIS/Include/core_cm4.h b/components/CMSIS/Include/core_cm4.h
index a965537402..d65016c714 100644
--- a/components/CMSIS/Include/core_cm4.h
+++ b/components/CMSIS/Include/core_cm4.h
@@ -1,25 +1,40 @@
/**************************************************************************//**
* @file core_cm4.h
* @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File
- * @version V3.01
- * @date 22. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
+
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
@@ -54,7 +69,7 @@
/* CMSIS CM4 definitions */
#define __CM4_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
-#define __CM4_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
+#define __CM4_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16) | \
__CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
@@ -669,14 +684,14 @@ typedef struct
__IO uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */
uint32_t RESERVED2[15];
__IO uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */
- uint32_t RESERVED3[29];
+ uint32_t RESERVED3[29];
__O uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */
__I uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */
__IO uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */
- uint32_t RESERVED4[43];
+ uint32_t RESERVED4[43];
__O uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */
__I uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */
- uint32_t RESERVED5[6];
+ uint32_t RESERVED5[6];
__I uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */
__I uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */
__I uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */
@@ -1661,9 +1676,9 @@ __STATIC_INLINE void NVIC_SystemReset(void)
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
- if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+ if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
- SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ SysTick->LOAD = ticks - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
diff --git a/components/CMSIS/Include/core_cm4_simd.h b/components/CMSIS/Include/core_cm4_simd.h
index 3bc7906152..83db95b5f1 100644
--- a/components/CMSIS/Include/core_cm4_simd.h
+++ b/components/CMSIS/Include/core_cm4_simd.h
@@ -1,25 +1,39 @@
/**************************************************************************//**
* @file core_cm4_simd.h
* @brief CMSIS Cortex-M4 SIMD Header File
- * @version V3.01
- * @date 06. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
#ifdef __cplusplus
extern "C" {
@@ -110,6 +124,8 @@
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
+#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
+ ((int64_t)(ARG3) << 32) ) >> 32))
/*-- End CM4 SIMD Intrinsics -----------------------------------------------------*/
@@ -624,6 +640,14 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB(uint32_t op1,
__RES; \
})
+__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
+{
+ int32_t result;
+
+ __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
+ return(result);
+}
+
/*-- End CM4 SIMD Intrinsics -----------------------------------------------------*/
diff --git a/components/CMSIS/Include/core_cmFunc.h b/components/CMSIS/Include/core_cmFunc.h
index 3c932e0d6e..0a18fafc30 100644
--- a/components/CMSIS/Include/core_cmFunc.h
+++ b/components/CMSIS/Include/core_cmFunc.h
@@ -1,25 +1,39 @@
/**************************************************************************//**
* @file core_cmFunc.h
* @brief CMSIS Cortex-M Core Function Access Header File
- * @version V3.01
- * @date 06. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
#ifndef __CORE_CMFUNC_H
#define __CORE_CMFUNC_H
@@ -314,7 +328,7 @@ __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
{
- __ASM volatile ("cpsie i");
+ __ASM volatile ("cpsie i" : : : "memory");
}
@@ -325,7 +339,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
{
- __ASM volatile ("cpsid i");
+ __ASM volatile ("cpsid i" : : : "memory");
}
@@ -352,7 +366,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
{
- __ASM volatile ("MSR control, %0" : : "r" (control) );
+ __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
}
@@ -424,7 +438,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
{
- __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) );
+ __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
}
@@ -451,7 +465,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
- __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) );
+ __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
}
@@ -478,7 +492,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
{
- __ASM volatile ("MSR primask, %0" : : "r" (priMask) );
+ __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
}
@@ -491,7 +505,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t p
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
{
- __ASM volatile ("cpsie f");
+ __ASM volatile ("cpsie f" : : : "memory");
}
@@ -502,7 +516,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
{
- __ASM volatile ("cpsid f");
+ __ASM volatile ("cpsid f" : : : "memory");
}
@@ -529,7 +543,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
{
- __ASM volatile ("MSR basepri, %0" : : "r" (value) );
+ __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
}
@@ -556,7 +570,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
{
- __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
+ __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
}
#endif /* (__CORTEX_M >= 0x03) */
@@ -575,7 +589,10 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
uint32_t result;
+ /* Empty asm statement works as a scheduling barrier */
+ __ASM volatile ("");
__ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
+ __ASM volatile ("");
return(result);
#else
return(0);
@@ -592,7 +609,10 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
{
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
- __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) );
+ /* Empty asm statement works as a scheduling barrier */
+ __ASM volatile ("");
+ __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
+ __ASM volatile ("");
#endif
}
diff --git a/components/CMSIS/Include/core_cmInstr.h b/components/CMSIS/Include/core_cmInstr.h
index 597e64df04..d213f0eed7 100644
--- a/components/CMSIS/Include/core_cmInstr.h
+++ b/components/CMSIS/Include/core_cmInstr.h
@@ -1,25 +1,39 @@
/**************************************************************************//**
* @file core_cmInstr.h
* @brief CMSIS Cortex-M Core Instruction Access Header File
- * @version V3.01
- * @date 06. March 2012
+ * @version V3.20
+ * @date 05. March 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
#ifndef __CORE_CMINSTR_H
#define __CORE_CMINSTR_H
@@ -111,12 +125,13 @@
\param [in] value Value to reverse
\return Reversed value
*/
+#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
{
rev16 r0, r0
bx lr
}
-
+#endif
/** \brief Reverse byte order in signed short value
@@ -125,11 +140,13 @@ __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(u
\param [in] value Value to reverse
\return Reversed value
*/
+#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
{
revsh r0, r0
bx lr
}
+#endif
/** \brief Rotate Right in unsigned value (32 bit)
@@ -143,6 +160,17 @@ __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(in
#define __ROR __ror
+/** \brief Breakpoint
+
+ This function causes the processor to enter Debug state.
+ Debug tools can use this to investigate system state when the instruction at a particular address is reached.
+
+ \param [in] value is ignored by the processor.
+ If required, a debugger can use it to store additional information about the breakpoint.
+ */
+#define __BKPT(value) __breakpoint(value)
+
+
#if (__CORTEX_M >= 0x03)
/** \brief Reverse bit order of value
@@ -279,6 +307,17 @@ __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(in
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
/* GNU gcc specific functions */
+/* Define macros for porting to both thumb1 and thumb2.
+ * For thumb1, use low register (r0-r7), specified by constrant "l"
+ * Otherwise, use general registers, specified by constrant "r" */
+#if defined (__thumb__) && !defined (__thumb2__)
+#define __CMSIS_GCC_OUT_REG(r) "=l" (r)
+#define __CMSIS_GCC_USE_REG(r) "l" (r)
+#else
+#define __CMSIS_GCC_OUT_REG(r) "=r" (r)
+#define __CMSIS_GCC_USE_REG(r) "r" (r)
+#endif
+
/** \brief No Operation
No Operation does nothing. This instruction can be used for code alignment purposes.
@@ -364,10 +403,14 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
{
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+ return __builtin_bswap32(value);
+#else
uint32_t result;
- __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
+ __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
return(result);
+#endif
}
@@ -382,7 +425,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t val
{
uint32_t result;
- __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
+ __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
return(result);
}
@@ -396,10 +439,14 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t val
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
{
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+ return (short)__builtin_bswap16(value);
+#else
uint32_t result;
- __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
+ __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
return(result);
+#endif
}
@@ -413,12 +460,21 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
{
-
- __ASM volatile ("ror %0, %0, %1" : "+r" (op1) : "r" (op2) );
- return(op1);
+ return (op1 >> op2) | (op1 << (32 - op2));
}
+/** \brief Breakpoint
+
+ This function causes the processor to enter Debug state.
+ Debug tools can use this to investigate system state when the instruction at a particular address is reached.
+
+ \param [in] value is ignored by the processor.
+ If required, a debugger can use it to store additional information about the breakpoint.
+ */
+#define __BKPT(value) __ASM volatile ("bkpt "#value)
+
+
#if (__CORTEX_M >= 0x03)
/** \brief Reverse bit order of value
@@ -446,9 +502,16 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t valu
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
{
- uint8_t result;
+ uint32_t result;
- __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+ __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
+#else
+ /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
+ accepted by assembler. So has to use following less efficient pattern.
+ */
+ __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
+#endif
return(result);
}
@@ -462,9 +525,16 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uin
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
{
- uint16_t result;
+ uint32_t result;
- __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+ __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
+#else
+ /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
+ accepted by assembler. So has to use following less efficient pattern.
+ */
+ __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
+#endif
return(result);
}
@@ -480,7 +550,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile ui
{
uint32_t result;
- __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
+ __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
return(result);
}
@@ -498,7 +568,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t val
{
uint32_t result;
- __ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
+ __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
return(result);
}
@@ -516,7 +586,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t va
{
uint32_t result;
- __ASM volatile ("strexh %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
+ __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
return(result);
}
@@ -534,7 +604,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t va
{
uint32_t result;
- __ASM volatile ("strex %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
+ __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
return(result);
}
@@ -546,7 +616,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t va
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
{
- __ASM volatile ("clrex");
+ __ASM volatile ("clrex" ::: "memory");
}
@@ -591,7 +661,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
{
- uint8_t result;
+ uint32_t result;
__ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
return(result);
diff --git a/components/CMSIS/Include/core_sc000.h b/components/CMSIS/Include/core_sc000.h
index 39ee60c5e5..1a2a0f2e30 100644
--- a/components/CMSIS/Include/core_sc000.h
+++ b/components/CMSIS/Include/core_sc000.h
@@ -1,25 +1,40 @@
/**************************************************************************//**
* @file core_sc000.h
* @brief CMSIS SC000 Core Peripheral Access Layer Header File
- * @version V3.01
- * @date 22. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
+
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
@@ -54,7 +69,7 @@
/* CMSIS SC000 definitions */
#define __SC000_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
-#define __SC000_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
+#define __SC000_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16) | \
__SC000_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
@@ -721,9 +736,9 @@ __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
{
if(IRQn < 0) {
- return((uint32_t)((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for SC000 system interrupts */
+ return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
else {
- return((uint32_t)((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
+ return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
}
@@ -771,9 +786,9 @@ __STATIC_INLINE void NVIC_SystemReset(void)
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
- if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+ if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
- SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ SysTick->LOAD = ticks - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
diff --git a/components/CMSIS/Include/core_sc300.h b/components/CMSIS/Include/core_sc300.h
index 7e56b0f332..cc34d6fc0e 100644
--- a/components/CMSIS/Include/core_sc300.h
+++ b/components/CMSIS/Include/core_sc300.h
@@ -1,25 +1,40 @@
/**************************************************************************//**
* @file core_sc300.h
* @brief CMSIS SC300 Core Peripheral Access Layer Header File
- * @version V3.01
- * @date 22. March 2012
+ * @version V3.20
+ * @date 25. February 2013
*
* @note
- * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
- *
- * @par
- * ARM Limited (ARM) is supplying this software for use with Cortex-M
- * processor based microcontrollers. This file can be freely distributed
- * within development tools that are supporting such ARM based processors.
- *
- * @par
- * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
- * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
- * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
+/* Copyright (c) 2009 - 2013 ARM LIMITED
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ - 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.
+ - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
+ ---------------------------------------------------------------------------*/
+
+
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
@@ -54,7 +69,7 @@
/* CMSIS SC300 definitions */
#define __SC300_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
-#define __SC300_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
+#define __SC300_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16) | \
__SC300_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
@@ -607,14 +622,14 @@ typedef struct
__IO uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */
uint32_t RESERVED2[15];
__IO uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */
- uint32_t RESERVED3[29];
+ uint32_t RESERVED3[29];
__O uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */
__I uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */
__IO uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */
- uint32_t RESERVED4[43];
+ uint32_t RESERVED4[43];
__O uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */
__I uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */
- uint32_t RESERVED5[6];
+ uint32_t RESERVED5[6];
__I uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */
__I uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */
__I uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */
@@ -1487,9 +1502,9 @@ __STATIC_INLINE void NVIC_SystemReset(void)
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
- if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+ if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
- SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ SysTick->LOAD = ticks - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index 0d7f9b781c..3658a5dc80 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -25,6 +25,7 @@
* 2012-07-26 aozima implement ff_memalloc and ff_memfree.
* 2012-12-19 Bernard fixed the O_APPEND and lseek issue.
* 2013-03-01 aozima fixed the stat(st_mtime) issue.
+ * 2014-01-26 Bernard Check the sector size before mount.
*/
#include <rtthread.h>
@@ -110,20 +111,30 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
FATFS *fat;
FRESULT result;
int index;
+ struct rt_device_blk_geometry geometry;
/* get an empty position */
index = get_disk(RT_NULL);
if (index == -1)
- return -DFS_STATUS_ENOSPC;
+ return -DFS_STATUS_ENOENT;
/* save device */
disk[index] = fs->dev_id;
-
+ /* check sector size */
+ if (rt_device_control(fs->dev_id, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry) == RT_EOK)
+ {
+ if (geometry.bytes_per_sector > _MAX_SS)
+ {
+ rt_kprintf("The sector size of device is greater than the sector size of FAT.\n");
+ return -DFS_STATUS_EINVAL;
+ }
+ }
+
fat = (FATFS *)rt_malloc(sizeof(FATFS));
if (fat == RT_NULL)
{
disk[index] = RT_NULL;
- return -1;
+ return -DFS_STATUS_ENOMEM;
}
/* mount fatfs, always 0 logic driver */
diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c
index 3709cc33fe..5f03314309 100644
--- a/components/dfs/filesystems/nfs/dfs_nfs.c
+++ b/components/dfs/filesystems/nfs/dfs_nfs.c
@@ -233,7 +233,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
copy_handle(handle, &nfs->current_handle);
}
- while ((file = strtok_r(RT_NULL, "/", &path)) != RT_NULL && path != RT_NULL)
+ while ((file = strtok_r(RT_NULL, "/", &path)) != RT_NULL && path[0] != 0)
{
LOOKUP3args args;
LOOKUP3res res;
@@ -678,7 +678,9 @@ int nfs_write(struct dfs_fd *file, const void *buf, rt_size_t count)
total += bytes;
/* update current position */
file->pos = fd->offset;
- /* todo: update file size */
+ /* update file size */
+ if (fd->size < fd->offset) fd->size = fd->offset;
+ file->size = fd->size;
}
xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
} while (count > 0);
@@ -796,6 +798,7 @@ int nfs_open(struct dfs_fd *file)
/* set private file */
file->data = fp;
+ file->size = fp->size;
}
return 0;
@@ -1092,8 +1095,6 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
index = 0;
while (1)
{
- char *fn;
-
d = dirp + index;
name = nfs_readdir(nfs, dir);
diff --git a/components/dfs/filesystems/nfs/mount.h b/components/dfs/filesystems/nfs/mount.h
index 852cf2dc2b..4ce3714f98 100644
--- a/components/dfs/filesystems/nfs/mount.h
+++ b/components/dfs/filesystems/nfs/mount.h
@@ -20,7 +20,7 @@ extern "C" {
#define FHSIZE3 64
typedef struct {
- u_int fhandle3_len;
+ unsigned int fhandle3_len;
char *fhandle3_val;
} fhandle3;
@@ -51,7 +51,7 @@ typedef enum mountstat3 mountstat3;
struct mountres3_ok {
fhandle3 fhandle;
struct {
- u_int auth_flavors_len;
+ unsigned int auth_flavors_len;
int *auth_flavors_val;
} auth_flavors;
};
diff --git a/components/dfs/filesystems/nfs/mount_xdr.c b/components/dfs/filesystems/nfs/mount_xdr.c
index 1f30e0e18a..e4d2b86f47 100644
--- a/components/dfs/filesystems/nfs/mount_xdr.c
+++ b/components/dfs/filesystems/nfs/mount_xdr.c
@@ -11,14 +11,7 @@
bool_t
xdr_fhandle3(register XDR *xdrs, fhandle3 *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
- if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
+ if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3))
return (FALSE);
return (TRUE);
}
@@ -26,13 +19,6 @@ xdr_fhandle3(register XDR *xdrs, fhandle3 *objp)
bool_t
xdr_dirpath(register XDR *xdrs, dirpath *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_string(xdrs, objp, MNTPATHLEN))
return (FALSE);
return (TRUE);
@@ -41,13 +27,6 @@ xdr_dirpath(register XDR *xdrs, dirpath *objp)
bool_t
xdr_name(register XDR *xdrs, name *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_string(xdrs, objp, MNTNAMLEN))
return (FALSE);
return (TRUE);
@@ -56,13 +35,6 @@ xdr_name(register XDR *xdrs, name *objp)
bool_t
xdr_exports(register XDR *xdrs, exports *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode))
return (FALSE);
return (TRUE);
@@ -71,13 +43,6 @@ xdr_exports(register XDR *xdrs, exports *objp)
bool_t
xdr_groups(register XDR *xdrs, groups *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode))
return (FALSE);
return (TRUE);
@@ -86,13 +51,6 @@ xdr_groups(register XDR *xdrs, groups *objp)
bool_t
xdr_mountlist(register XDR *xdrs, mountlist *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody))
return (FALSE);
return (TRUE);
@@ -103,17 +61,11 @@ xdr_mountstat3(register XDR *xdrs, mountstat3 *objp)
{
int enum_objp;
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)&enum_objp))
{
- *objp = enum_objp;
+ *objp = (mountstat3)enum_objp;
return (FALSE);
}
@@ -123,16 +75,9 @@ xdr_mountstat3(register XDR *xdrs, mountstat3 *objp)
bool_t
xdr_mountres3_ok(register XDR *xdrs, mountres3_ok *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_fhandle3(xdrs, &objp->fhandle))
return (FALSE);
- if (!xdr_array(xdrs, (char **)&objp->auth_flavors.auth_flavors_val, (u_int *) &objp->auth_flavors.auth_flavors_len, ~0,
+ if (!xdr_array(xdrs, (char **)&objp->auth_flavors.auth_flavors_val, (unsigned int *) &objp->auth_flavors.auth_flavors_len, ~0,
sizeof (int), (xdrproc_t) xdr_int))
return (FALSE);
return (TRUE);
@@ -141,13 +86,6 @@ xdr_mountres3_ok(register XDR *xdrs, mountres3_ok *objp)
bool_t
xdr_mountres3(register XDR *xdrs, mountres3 *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_mountstat3(xdrs, &objp->fhs_status))
return (FALSE);
switch (objp->fhs_status) {
@@ -162,13 +100,6 @@ xdr_mountres3(register XDR *xdrs, mountres3 *objp)
bool_t
xdr_mountbody(register XDR *xdrs, mountbody *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_name(xdrs, &objp->ml_hostname))
return (FALSE);
if (!xdr_dirpath(xdrs, &objp->ml_directory))
@@ -181,13 +112,6 @@ xdr_mountbody(register XDR *xdrs, mountbody *objp)
bool_t
xdr_groupnode(register XDR *xdrs, groupnode *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_name(xdrs, &objp->gr_name))
return (FALSE);
if (!xdr_groups(xdrs, &objp->gr_next))
@@ -198,13 +122,6 @@ xdr_groupnode(register XDR *xdrs, groupnode *objp)
bool_t
xdr_exportnode(register XDR *xdrs, exportnode *objp)
{
-
-#if defined(_LP64) || defined(_KERNEL)
- register int *buf;
-#else
- register long *buf;
-#endif
-
if (!xdr_dirpath(xdrs, &objp->ex_dir))
return (FALSE);
if (!xdr_groups(xdrs, &objp->ex_groups))
diff --git a/components/dfs/filesystems/nfs/nfs.h b/components/dfs/filesystems/nfs/nfs.h
index e668ac01b6..7e3e3671af 100644
--- a/components/dfs/filesystems/nfs/nfs.h
+++ b/components/dfs/filesystems/nfs/nfs.h
@@ -130,7 +130,7 @@ typedef struct specdata3 specdata3;
struct nfs_fh3 {
struct {
- u_int data_len;
+ unsigned int data_len;
char *data_val;
} data;
};
@@ -408,7 +408,7 @@ struct READ3resok {
count3 count;
bool_t eof;
struct {
- u_int data_len;
+ unsigned int data_len;
char *data_val;
} data;
};
@@ -434,7 +434,7 @@ struct WRITE3args {
count3 count;
stable_how stable;
struct {
- u_int data_len;
+ unsigned int data_len;
char *data_val;
} data;
};
diff --git a/components/dfs/filesystems/nfs/nfs_xdr.c b/components/dfs/filesystems/nfs/nfs_xdr.c
index f47acd2f4c..72d6edc42a 100644
--- a/components/dfs/filesystems/nfs/nfs_xdr.c
+++ b/components/dfs/filesystems/nfs/nfs_xdr.c
@@ -151,7 +151,7 @@ xdr_nfsstat3(register XDR *xdrs, nfsstat3 *objp)
enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)objp))
{
- *objp = enum_objp;
+ *objp = (nfsstat3)enum_objp;
return (FALSE);
}
@@ -165,7 +165,7 @@ xdr_ftype3(register XDR *xdrs, ftype3 *objp)
enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)objp))
{
- *objp = enum_objp;
+ *objp = (ftype3)enum_objp;
return (FALSE);
}
@@ -179,7 +179,7 @@ xdr_stable_how(register XDR *xdrs, stable_how *objp)
enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)objp))
{
- *objp = enum_objp;
+ *objp = (stable_how)enum_objp;
return (FALSE);
}
@@ -193,7 +193,7 @@ xdr_createmode3(register XDR *xdrs, createmode3 *objp)
enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)objp))
{
- *objp = enum_objp;
+ *objp = (createmode3)enum_objp;
return (FALSE);
}
@@ -213,7 +213,7 @@ xdr_specdata3(register XDR *xdrs, specdata3 *objp)
bool_t
xdr_nfs_fh3(register XDR *xdrs, nfs_fh3 *objp)
{
- if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS3_FHSIZE))
+ if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, NFS3_FHSIZE))
return (FALSE);
return (TRUE);
}
@@ -343,7 +343,7 @@ xdr_time_how(register XDR *xdrs, time_how *objp)
enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)objp))
{
- *objp = enum_objp;
+ *objp = (time_how)enum_objp;
return (FALSE);
}
@@ -713,7 +713,7 @@ xdr_READ3resok(register XDR *xdrs, READ3resok *objp)
return (FALSE);
if (!xdr_bool(xdrs, &objp->eof))
return (FALSE);
- if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))
+ if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, ~0))
return (FALSE);
return (TRUE);
}
@@ -755,7 +755,7 @@ xdr_WRITE3args(register XDR *xdrs, WRITE3args *objp)
return (FALSE);
if (!xdr_stable_how(xdrs, &objp->stable))
return (FALSE);
- if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))
+ if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, ~0))
return (FALSE);
return (TRUE);
}
diff --git a/components/dfs/filesystems/nfs/rpc/auth_none.c b/components/dfs/filesystems/nfs/rpc/auth_none.c
index 2edcd28159..92947581d2 100644
--- a/components/dfs/filesystems/nfs/rpc/auth_none.c
+++ b/components/dfs/filesystems/nfs/rpc/auth_none.c
@@ -73,6 +73,7 @@ AUTH *authnone_create()
register struct authnone_private *ap = authnone_private;
XDR xdr_stream;
register XDR *xdrs;
+ extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap);
if (ap == 0) {
ap = (struct authnone_private *) rt_malloc (sizeof(*ap));
@@ -95,9 +96,7 @@ AUTH *authnone_create()
}
/*ARGSUSED*/
-static bool_t authnone_marshal(client, xdrs)
-AUTH *client;
-XDR *xdrs;
+static bool_t authnone_marshal(AUTH *client, XDR *xdrs)
{
register struct authnone_private *ap = authnone_private;
diff --git a/components/dfs/filesystems/nfs/rpc/clnt_udp.c b/components/dfs/filesystems/nfs/rpc/clnt_udp.c
index e161c1c07b..a69bc0621a 100644
--- a/components/dfs/filesystems/nfs/rpc/clnt_udp.c
+++ b/components/dfs/filesystems/nfs/rpc/clnt_udp.c
@@ -135,6 +135,10 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
if (raddr->sin_port == 0) {
unsigned short port;
+ extern unsigned short pmap_getport(struct sockaddr_in *address,
+ unsigned long program,
+ unsigned long version,
+ unsigned int protocol);
if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
@@ -165,8 +169,6 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
if (*sockp < 0)
{
- int dontblock = 1;
-
*sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (*sockp < 0)
{
@@ -229,7 +231,10 @@ call_again:
if ((!XDR_PUTLONG(xdrs, (long *) &proc)) ||
(!AUTH_MARSHALL(cl->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp)))
- return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
+ {
+ cu->cu_error.re_status = RPC_CANTENCODEARGS;
+ return RPC_CANTENCODEARGS;
+ }
outlen = (int) XDR_GETPOS(xdrs);
send_again:
@@ -238,7 +243,9 @@ send_again:
!= outlen)
{
cu->cu_error.re_errno = errno;
- return (cu->cu_error.re_status = RPC_CANTSEND);
+ cu->cu_error.re_status = RPC_CANTSEND;
+
+ return RPC_CANTSEND;
}
/*
@@ -264,7 +271,9 @@ send_again:
{
rt_kprintf("recv error, len %d\n", inlen);
cu->cu_error.re_errno = errno;
- return (cu->cu_error.re_status = RPC_CANTRECV);
+ cu->cu_error.re_status = RPC_CANTRECV;
+
+ return RPC_CANTRECV;
}
/* see if reply transaction id matches sent id */
@@ -292,6 +301,8 @@ send_again:
}
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
{
+ extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap);
+
xdrs->x_op = XDR_FREE;
(void) xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
}
@@ -311,7 +322,7 @@ send_again:
cu->cu_error.re_status = RPC_CANTDECODERES;
}
- return (cu->cu_error.re_status);
+ return (enum clnt_stat)(cu->cu_error.re_status);
}
static void clntudp_geterr(CLIENT *cl, struct rpc_err *errp)
diff --git a/components/dfs/filesystems/nfs/rpc/pmap.c b/components/dfs/filesystems/nfs/rpc/pmap.c
index cbf5add2ab..fcf8e9d948 100644
--- a/components/dfs/filesystems/nfs/rpc/pmap.c
+++ b/components/dfs/filesystems/nfs/rpc/pmap.c
@@ -6,9 +6,7 @@ static struct timeval timeout = { 5, 0 };
static struct timeval tottimeout = { 60, 0 };
-bool_t xdr_pmap(xdrs, regs)
-XDR *xdrs;
-struct pmap *regs;
+bool_t xdr_pmap(XDR *xdrs, struct pmap *regs)
{
if (xdr_u_long(xdrs, &regs->pm_prog) &&
xdr_u_long(xdrs, &regs->pm_vers) &&
@@ -22,11 +20,7 @@ struct pmap *regs;
* Calls the pmap service remotely to do the lookup.
* Returns 0 if no map exists.
*/
-unsigned short pmap_getport(address, program, version, protocol)
-struct sockaddr_in *address;
-unsigned long program;
-unsigned long version;
-unsigned int protocol;
+unsigned short pmap_getport(struct sockaddr_in *address, unsigned long program, unsigned long version, unsigned int protocol)
{
unsigned short port = 0;
int socket = -1;
diff --git a/components/dfs/filesystems/nfs/rpc/rpc_prot.c b/components/dfs/filesystems/nfs/rpc/rpc_prot.c
index 3cfb8dc3fa..21fc1f4ea4 100644
--- a/components/dfs/filesystems/nfs/rpc/rpc_prot.c
+++ b/components/dfs/filesystems/nfs/rpc/rpc_prot.c
@@ -52,9 +52,7 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
* XDR an opaque authentication struct
* (see auth.h)
*/
-bool_t xdr_opaque_auth(xdrs, ap)
-register XDR *xdrs;
-register struct opaque_auth *ap;
+bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
{
if (xdr_enum(xdrs, &(ap->oa_flavor)))
@@ -66,9 +64,7 @@ register struct opaque_auth *ap;
/*
* XDR a DES block
*/
-bool_t xdr_des_block(xdrs, blkp)
-register XDR *xdrs;
-register des_block *blkp;
+bool_t xdr_des_block(XDR *xdrs, des_block *blkp)
{
return (xdr_opaque(xdrs, (char*) blkp, sizeof(des_block)));
}
@@ -78,9 +74,7 @@ register des_block *blkp;
/*
* XDR the MSG_ACCEPTED part of a reply message union
*/
-static bool_t xdr_accepted_reply(xdrs, ar)
-register XDR *xdrs;
-register struct accepted_reply *ar;
+static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
{
/* personalized union, rather than calling xdr_union */
@@ -104,9 +98,7 @@ register struct accepted_reply *ar;
/*
* XDR the MSG_DENIED part of a reply message union
*/
-static bool_t xdr_rejected_reply(xdrs, rr)
-register XDR *xdrs;
-register struct rejected_reply *rr;
+static bool_t xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr)
{
/* personalized union, rather than calling xdr_union */
@@ -134,9 +126,7 @@ static struct xdr_discrim reply_dscrm[3] = {
/*
* XDR a reply message
*/
-bool_t xdr_replymsg(xdrs, rmsg)
-register XDR *xdrs;
-register struct rpc_msg *rmsg;
+bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
{
if (xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
xdr_enum(xdrs, (enum_t *) & (rmsg->rm_direction)) &&
@@ -153,9 +143,7 @@ register struct rpc_msg *rmsg;
* The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
* The rm_xid is not really static, but the user can easily munge on the fly.
*/
-bool_t xdr_callhdr(xdrs, cmsg)
-register XDR *xdrs;
-register struct rpc_msg *cmsg;
+bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
{
cmsg->rm_direction = CALL;
@@ -172,9 +160,7 @@ register struct rpc_msg *cmsg;
/* ************************** Client utility routine ************* */
-static void accepted(acpt_stat, error)
-register enum accept_stat acpt_stat;
-register struct rpc_err *error;
+static void accepted(enum accept_stat acpt_stat, struct rpc_err *error)
{
switch (acpt_stat) {
@@ -209,9 +195,7 @@ register struct rpc_err *error;
error->re_lb.s2 = (long) acpt_stat;
}
-static void rejected(rjct_stat, error)
-register enum reject_stat rjct_stat;
-register struct rpc_err *error;
+static void rejected(enum reject_stat rjct_stat, struct rpc_err *error)
{
switch (rjct_stat) {
@@ -233,9 +217,7 @@ register struct rpc_err *error;
/*
* given a reply message, fills in the error
*/
-void _seterr_reply(msg, error)
-register struct rpc_msg *msg;
-register struct rpc_err *error;
+void _seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
{
/* optimized for normal, SUCCESSful case */
@@ -246,11 +228,11 @@ register struct rpc_err *error;
error->re_status = RPC_SUCCESS;
return;
};
- accepted(msg->acpted_rply.ar_stat, error);
+ accepted((enum accept_stat)msg->acpted_rply.ar_stat, error);
break;
case MSG_DENIED:
- rejected(msg->rjcted_rply.rj_stat, error);
+ rejected((enum reject_stat)msg->rjcted_rply.rj_stat, error);
break;
default:
diff --git a/components/dfs/filesystems/nfs/rpc/xdr.c b/components/dfs/filesystems/nfs/rpc/xdr.c
index 0c6ee781e6..ec37d6beb9 100644
--- a/components/dfs/filesystems/nfs/rpc/xdr.c
+++ b/components/dfs/filesystems/nfs/rpc/xdr.c
@@ -50,8 +50,8 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
/*
* constants specific to the xdr "protocol"
*/
-#define XDR_FALSE ((long) 0)
-#define XDR_TRUE ((long) 1)
+#define XDR_FALSE ((long) 0)
+#define XDR_TRUE ((long) 1)
#define LASTUNSIGNED ((unsigned int) 0-1)
/*
@@ -327,9 +327,7 @@ bool_t xdr_u_char(XDR* xdrs, unsigned char* cp)
/*
* XDR booleans
*/
-bool_t xdr_bool(xdrs, bp)
-register XDR *xdrs;
-bool_t *bp;
+bool_t xdr_bool(XDR *xdrs, bool_t *bp)
{
long lb;
@@ -355,9 +353,7 @@ bool_t *bp;
/*
* XDR enumerations
*/
-bool_t xdr_enum(xdrs, ep)
-XDR *xdrs;
-enum_t *ep;
+bool_t xdr_enum(XDR *xdrs, enum_t *ep)
{
/*
* enums are treated as ints
@@ -370,10 +366,7 @@ enum_t *ep;
* Allows the specification of a fixed size sequence of opaque bytes.
* cp points to the opaque object and cnt gives the byte length.
*/
-bool_t xdr_opaque(xdrs, cp, cnt)
-register XDR *xdrs;
-char* cp;
-register unsigned int cnt;
+bool_t xdr_opaque(XDR *xdrs, char* cp, unsigned int cnt)
{
register unsigned int rndup;
static char crud[BYTES_PER_XDR_UNIT];
@@ -421,11 +414,7 @@ register unsigned int cnt;
* *cpp is a pointer to the bytes, *sizep is the count.
* If *cpp is NULL maxsize bytes are allocated
*/
-bool_t xdr_bytes(xdrs, cpp, sizep, maxsize)
-register XDR *xdrs;
-char **cpp;
-register unsigned int *sizep;
-unsigned int maxsize;
+bool_t xdr_bytes(XDR *xdrs, char** cpp, unsigned int *sizep, unsigned int maxsize)
{
register char *sp = *cpp; /* sp is the actual string pointer */
register unsigned int nodesize;
@@ -475,11 +464,8 @@ unsigned int maxsize;
/*
* Implemented here due to commonality of the object.
*/
-bool_t xdr_netobj(xdrs, np)
-XDR *xdrs;
-struct netobj *np;
+bool_t xdr_netobj(XDR *xdrs, struct netobj *np)
{
-
return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
}
@@ -537,10 +523,7 @@ bool_t xdr_union(XDR* xdrs, enum_t* dscmp, char* unp, const struct xdr_discrim*
* storage is allocated. The last parameter is the max allowed length
* of the string as specified by a protocol.
*/
-bool_t xdr_string(xdrs, cpp, maxsize)
-register XDR *xdrs;
-char **cpp;
-unsigned int maxsize;
+bool_t xdr_string(XDR *xdrs, char **cpp, unsigned int maxsize)
{
register char *sp = *cpp; /* sp is the actual string pointer */
unsigned int size;
@@ -600,9 +583,7 @@ unsigned int maxsize;
* Wrapper for xdr_string that can be called directly from
* routines like clnt_call
*/
-bool_t xdr_wrapstring(xdrs, cpp)
-XDR *xdrs;
-char **cpp;
+bool_t xdr_wrapstring(XDR *xdrs, char **cpp)
{
if (xdr_string(xdrs, cpp, LASTUNSIGNED)) {
return (TRUE);
@@ -617,13 +598,7 @@ char **cpp;
* elsize is the size (in bytes) of each element, and elproc is the
* xdr procedure to call to handle each element of the array.
*/
-bool_t xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
-register XDR *xdrs;
-char* *addrp; /* array pointer */
-unsigned int *sizep; /* number of elements */
-unsigned int maxsize; /* max numberof elements */
-unsigned int elsize; /* size in bytes of each element */
-xdrproc_t elproc; /* xdr routine to handle each element */
+bool_t xdr_array(XDR *xdrs, char **addrp, unsigned int *sizep, unsigned int maxsize, unsigned int elsize, xdrproc_t elproc)
{
register unsigned int i;
register char* target = *addrp;
@@ -700,12 +675,7 @@ xdrproc_t elproc; /* xdr routine to handle each element */
* > elemsize: size of each element
* > xdr_elem: routine to XDR each element
*/
-bool_t xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
-register XDR *xdrs;
-register char *basep;
-register unsigned int nelem;
-register unsigned int elemsize;
-register xdrproc_t xdr_elem;
+bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elemsize, xdrproc_t xdr_elem)
{
register unsigned int i;
register char *elptr;
@@ -730,11 +700,7 @@ register xdrproc_t xdr_elem;
* size is the sizeof the referneced structure.
* proc is the routine to handle the referenced structure.
*/
-bool_t xdr_reference(xdrs, pp, size, proc)
-register XDR *xdrs;
-char* *pp; /* the pointer to work on */
-unsigned int size; /* size of the object pointed to */
-xdrproc_t proc; /* xdr routine to handle the object */
+bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc)
{
register char* loc = *pp;
register bool_t stat;
@@ -783,11 +749,7 @@ xdrproc_t proc; /* xdr routine to handle the object */
* > xdr_obj: routine to XDR an object.
*
*/
-bool_t xdr_pointer(xdrs, objpp, obj_size, xdr_obj)
-register XDR *xdrs;
-char **objpp;
-unsigned int obj_size;
-xdrproc_t xdr_obj;
+bool_t xdr_pointer(XDR *xdrs, char **objpp, unsigned int obj_size, xdrproc_t xdr_obj)
{
bool_t more_data;
diff --git a/components/dfs/filesystems/nfs/rpc/xdr_mem.c b/components/dfs/filesystems/nfs/rpc/xdr_mem.c
index b4afabedb8..d6baf85837 100644
--- a/components/dfs/filesystems/nfs/rpc/xdr_mem.c
+++ b/components/dfs/filesystems/nfs/rpc/xdr_mem.c
@@ -135,9 +135,7 @@ static unsigned int xdrmem_getpos (const XDR *xdrs)
return ((unsigned long) xdrs->x_private - (unsigned long) xdrs->x_base);
}
-static bool_t xdrmem_setpos(xdrs, pos)
-register XDR *xdrs;
-unsigned int pos;
+static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos)
{
register char* newaddr = xdrs->x_base + pos;
register char* lastaddr = xdrs->x_private + xdrs->x_handy;
diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.c b/components/dfs/filesystems/ramfs/dfs_ramfs.c
index 117528c1e2..fecebe4688 100644
--- a/components/dfs/filesystems/ramfs/dfs_ramfs.c
+++ b/components/dfs/filesystems/ramfs/dfs_ramfs.c
@@ -414,6 +414,7 @@ int dfs_ramfs_init(void)
return 0;
}
+INIT_FS_EXPORT(dfs_ramfs_init);
struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
{
diff --git a/components/dfs/filesystems/romfs/mkromfs.py b/components/dfs/filesystems/romfs/mkromfs.py
index a84458e892..d1354eb259 100644
--- a/components/dfs/filesystems/romfs/mkromfs.py
+++ b/components/dfs/filesystems/romfs/mkromfs.py
@@ -4,6 +4,7 @@ import string
basename = ''
output = ''
+sep = os.sep
def mkromfs_output(out):
# print '%s' % out,
@@ -54,12 +55,12 @@ def mkromfs_dir(dirname, is_root = False):
fullpath = os.path.join(path, item)
if os.path.isfile(fullpath):
subpath = fullpath[len(basename):]
- array = subpath.split('\\')
+ array = subpath.split(sep)
arrayname = string.join(array, '_')
mkromfs_file(fullpath, arrayname)
subpath = path[len(basename):]
- dir = subpath.split('\\')
+ dir = subpath.split(sep)
direntname = string.join(dir, '_')
if is_root:
mkromfs_output('const struct romfs_dirent _root_dirent[] = {\n')
@@ -69,12 +70,12 @@ def mkromfs_dir(dirname, is_root = False):
for item in list:
fullpath = os.path.join(path, item)
fn = fullpath[len(dirname):]
- if fn[0] == '\\':
+ if fn[0] == sep:
fn = fn[1:]
fn = fn.replace('\\', '/')
subpath = fullpath[len(basename):]
- items = subpath.split('\\')
+ items = subpath.split(sep)
item_name = string.join(items, '_')
item_name = item_name.replace('.', '_')
item_name = item_name.replace('-', '_')
@@ -92,12 +93,12 @@ def mkromfs_dir(dirname, is_root = False):
for item in list:
fullpath = os.path.join(path, item)
fn = fullpath[len(dirname):]
- if fn[0] == '\\':
+ if fn[0] == sep:
fn = fn[1:]
fn = fn.replace('\\', '/')
subpath = fullpath[len(basename):]
- items = subpath.split('\\')
+ items = subpath.split(sep)
item_name = string.join(items, '_')
item_name = item_name.replace('.', '_')
item_name = item_name.replace('-', '_')
diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c
index 3ec9b5b5b0..32198371d7 100644
--- a/components/dfs/src/dfs_file.c
+++ b/components/dfs/src/dfs_file.c
@@ -593,7 +593,7 @@ void cat(const char* filename)
FINSH_FUNCTION_EXPORT(cat, print file)
#define BUF_SZ 4096
-void copy(const char *src, const char *dst)
+static void copyfile(const char *src, const char *dst)
{
struct dfs_fd src_fd;
rt_uint8_t *block_ptr;
@@ -637,7 +637,171 @@ void copy(const char *src, const char *dst)
dfs_file_close(&fd);
rt_free(block_ptr);
}
-FINSH_FUNCTION_EXPORT(copy, copy source file to destination file)
+
+extern int mkdir(const char *path, mode_t mode);
+static void copydir(const char * src, const char * dst)
+{
+ struct dfs_fd fd;
+ struct dirent dirent;
+ struct stat stat;
+ int length;
+
+ if (dfs_file_open(&fd, src, DFS_O_DIRECTORY) < 0)
+ {
+ rt_kprintf("open %s failed\n", src);
+ return ;
+ }
+
+ do
+ {
+ rt_memset(&dirent, 0, sizeof(struct dirent));
+ length = dfs_file_getdents(&fd, &dirent, sizeof(struct dirent));
+ if (length > 0)
+ {
+ char * src_entry_full = RT_NULL;
+ char * dst_entry_full = RT_NULL;
+
+ if (strcmp(dirent.d_name, "..") == 0 || strcmp(dirent.d_name, ".") == 0)
+ continue;
+
+ /* build full path for each file */
+ if ((src_entry_full = dfs_normalize_path(src, dirent.d_name)) == RT_NULL)
+ {
+ rt_kprintf("out of memory!\n");
+ break;
+ }
+ if ((dst_entry_full = dfs_normalize_path(dst, dirent.d_name)) == RT_NULL)
+ {
+ rt_kprintf("out of memory!\n");
+ rt_free(src_entry_full);
+ break;
+ }
+
+ rt_memset(&stat, 0, sizeof(struct stat));
+ if (dfs_file_stat(src_entry_full, &stat) != 0)
+ {
+ rt_kprintf("open file: %s failed\n", dirent.d_name);
+ continue;
+ }
+
+ if (DFS_S_ISDIR(stat.st_mode))
+ {
+ mkdir(dst_entry_full, 0);
+ copydir(src_entry_full, dst_entry_full);
+ }
+ else
+ {
+ copyfile(src_entry_full, dst_entry_full);
+ }
+ rt_free(src_entry_full);
+ rt_free(dst_entry_full);
+ }
+ }while(length > 0);
+
+ dfs_file_close(&fd);
+}
+
+static const char *_get_path_lastname(const char *path)
+{
+ char * ptr;
+ if ((ptr = strrchr(path, '/')) == RT_NULL)
+ return path;
+
+ /* skip the '/' then return */
+ return ++ptr;
+}
+void copy(const char *src, const char *dst)
+{
+#define FLAG_SRC_TYPE 0x03
+#define FLAG_SRC_IS_DIR 0x01
+#define FLAG_SRC_IS_FILE 0x02
+#define FLAG_SRC_NON_EXSIT 0x00
+
+#define FLAG_DST_TYPE 0x0C
+#define FLAG_DST_IS_DIR 0x04
+#define FLAG_DST_IS_FILE 0x08
+#define FLAG_DST_NON_EXSIT 0x00
+
+ struct stat stat;
+ rt_uint32_t flag = 0;
+
+ /* check the staus of src and dst */
+ if (dfs_file_stat(src, &stat) < 0)
+ {
+ rt_kprintf("copy failed, bad %s\n", src);
+ return;
+ }
+ if (DFS_S_ISDIR(stat.st_mode))
+ flag |= FLAG_SRC_IS_DIR;
+ else
+ flag |= FLAG_SRC_IS_FILE;
+
+ if (dfs_file_stat(dst, &stat) < 0)
+ {
+ flag |= FLAG_DST_NON_EXSIT;
+ }
+ else
+ {
+ if (DFS_S_ISDIR(stat.st_mode))
+ flag |= FLAG_DST_IS_DIR;
+ else
+ flag |= FLAG_DST_IS_FILE;
+ }
+
+ //2. check status
+ if ((flag & FLAG_SRC_IS_DIR) && (flag & FLAG_DST_IS_FILE))
+ {
+ rt_kprintf("cp faild, cp dir to file is not permitted!\n");
+ return ;
+ }
+
+ //3. do copy
+ if (flag & FLAG_SRC_IS_FILE)
+ {
+ if (flag & FLAG_DST_IS_DIR)
+ {
+ char * fdst;
+ fdst = dfs_normalize_path(dst, _get_path_lastname(src));
+ if (fdst == NULL)
+ {
+ rt_kprintf("out of memory\n");
+ return;
+ }
+ copyfile(src, fdst);
+ rt_free(fdst);
+ }
+ else
+ {
+ copyfile(src, dst);
+ }
+ }
+ else //flag & FLAG_SRC_IS_DIR
+ {
+ if (flag & FLAG_DST_IS_DIR)
+ {
+ char * fdst;
+ fdst = dfs_normalize_path(dst, _get_path_lastname(src));
+ if (fdst == NULL)
+ {
+ rt_kprintf("out of memory\n");
+ return;
+ }
+ mkdir(fdst, 0);
+ copydir(src, fdst);
+ rt_free(fdst);
+ }
+ else if ((flag & FLAG_DST_TYPE) == FLAG_DST_NON_EXSIT)
+ {
+ mkdir(dst, 0);
+ copydir(src, dst);
+ }
+ else
+ {
+ copydir(src, dst);
+ }
+ }
+}
+FINSH_FUNCTION_EXPORT(copy, copy file or dir)
#endif
/* @} */
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 5e7a8ec814..622d2cd68c 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -368,20 +368,25 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
switch (cmd)
{
- case RT_DEVICE_CTRL_SUSPEND:
- /* suspend device */
- dev->flag |= RT_DEVICE_FLAG_SUSPENDED;
- break;
+ case RT_DEVICE_CTRL_SUSPEND:
+ /* suspend device */
+ dev->flag |= RT_DEVICE_FLAG_SUSPENDED;
+ break;
- case RT_DEVICE_CTRL_RESUME:
- /* resume device */
- dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED;
- break;
+ case RT_DEVICE_CTRL_RESUME:
+ /* resume device */
+ dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED;
+ break;
- case RT_DEVICE_CTRL_CONFIG:
- /* configure device */
- serial->ops->configure(serial, (struct serial_configure *)args);
- break;
+ case RT_DEVICE_CTRL_CONFIG:
+ /* configure device */
+ serial->ops->configure(serial, (struct serial_configure *)args);
+ break;
+
+ default :
+ /* control device */
+ serial->ops->control(serial, cmd, args);
+ break;
}
return RT_EOK;
diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c
index 0613452279..9a79ba396b 100644
--- a/components/finsh/cmd.c
+++ b/components/finsh/cmd.c
@@ -516,8 +516,8 @@ int list_module(void)
return 0;
}
-
-FINSH_FUNCTION_EXPORT(list_module, list module in system)
+FINSH_FUNCTION_EXPORT(list_module, list module in system);
+MSH_CMD_EXPORT(list_module, list module in system);
int list_mod_detail(const char *name)
{
@@ -536,7 +536,7 @@ int list_mod_detail(const char *name)
/* list main thread in module */
if (module->module_thread != RT_NULL)
- {
+ {
rt_kprintf("main thread pri status sp stack size max used left tick error\n");
rt_kprintf("------------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
thread = module->module_thread;
@@ -555,7 +555,7 @@ int list_mod_detail(const char *name)
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
thread->remaining_tick,
thread->error);
- }
+ }
/* list sub thread in module */
tlist = &module->module_object[RT_Object_Class_Thread].object_list;
@@ -605,20 +605,24 @@ int list_mod_detail(const char *name)
if (!rt_list_isempty(tlist)) _list_timer(tlist);
}
- rt_kprintf("symbol address \n");
- rt_kprintf("-------- ----------\n");
-
- /* list module export symbols */
- for (i=0; i<module->nsym; i++)
- {
- rt_kprintf("%s 0x%x\n",
- module->symtab[i].name, module->symtab[i].addr);
- }
+ if (module->nsym > 0)
+ {
+ rt_kprintf("symbol address \n");
+ rt_kprintf("-------- ----------\n");
+
+ /* list module export symbols */
+ for (i=0; i<module->nsym; i++)
+ {
+ rt_kprintf("%s 0x%x\n",
+ module->symtab[i].name, module->symtab[i].addr);
+ }
+ }
}
return 0;
}
FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system)
+MSH_CMD_EXPORT(list_mod_detail, list module objects in system)
#endif
long list(void)
diff --git a/components/finsh/msh.c b/components/finsh/msh.c
index b6ebdf2ac9..1492e017e1 100644
--- a/components/finsh/msh.c
+++ b/components/finsh/msh.c
@@ -155,7 +155,7 @@ static int msh_split(char* cmd, rt_size_t length, char* argv[RT_FINSH_ARG_MAX])
return argc;
}
-static cmd_function_t msh_get_cmd(char *cmd)
+static cmd_function_t msh_get_cmd(char *cmd, int size)
{
struct finsh_syscall *index;
cmd_function_t cmd_func = RT_NULL;
@@ -166,7 +166,8 @@ static cmd_function_t msh_get_cmd(char *cmd)
{
if (strncmp(index->name, "__cmd_", 6) != 0) continue;
- if (strcmp(&index->name[6], cmd) == 0)
+ if (strncmp(&index->name[6], cmd, size) == 0 &&
+ index->name[6 + size] == '\0')
{
cmd_func = (cmd_function_t)index->func;
break;
@@ -177,33 +178,42 @@ static cmd_function_t msh_get_cmd(char *cmd)
}
#if defined(RT_USING_MODULE) && defined(RT_USING_DFS)
-int msh_exec_module(int argc, char** argv)
+/* Return 0 on module executed. Other value indicate error.
+ */
+int msh_exec_module(char* cmd_line, int size)
{
+ int ret;
int fd = -1;
char *pg_name;
- int length, cmd_length;
+ int length, cmd_length = 0;
- if (argc == 0) return -RT_ERROR; /* no command */
+ if (size == 0)
+ return -RT_ERROR;
+ /* get the length of command0 */
+ while ((cmd_line[cmd_length] != ' ' && cmd_line[cmd_length] != '\t') && cmd_length < size)
+ cmd_length ++;
/* get name length */
- cmd_length = rt_strlen(argv[0]); length = cmd_length + 32;
+ length = cmd_length + 32;
+ /* allocate program name memory */
pg_name = (char*) rt_malloc(length);
- if (pg_name == RT_NULL) return -RT_ENOMEM; /* no memory */
+ if (pg_name == RT_NULL)
+ return -RT_ENOMEM;
+
+ /* copy command0 */
+ memcpy(pg_name, cmd_line, cmd_length);
+ pg_name[cmd_length] = '\0';
- if (strstr(argv[0], ".mo") != RT_NULL || strstr(argv[0], ".MO") != RT_NULL)
+ if (strstr(pg_name, ".mo") != RT_NULL || strstr(pg_name, ".MO") != RT_NULL)
{
/* try to open program */
- if (fd < 0)
- {
- rt_snprintf(pg_name, length - 1, "%s", argv[0]);
- fd = open(pg_name, O_RDONLY, 0);
- }
+ fd = open(pg_name, O_RDONLY, 0);
/* search in /bin path */
if (fd < 0)
{
- rt_snprintf(pg_name, length - 1, "/bin/%s", argv[0]);
+ rt_snprintf(pg_name, length - 1, "/bin/%.*s", cmd_length, cmd_line);
fd = open(pg_name, O_RDONLY, 0);
}
}
@@ -212,61 +222,112 @@ int msh_exec_module(int argc, char** argv)
/* add .mo and open program */
/* try to open program */
- if (fd < 0)
- {
- rt_snprintf(pg_name, length - 1, "%s.mo", argv[0]);
- fd = open(pg_name, O_RDONLY, 0);
- }
+ strcat(pg_name, ".mo");
+ fd = open(pg_name, O_RDONLY, 0);
/* search in /bin path */
if (fd < 0)
{
- rt_snprintf(pg_name, length - 1, "/bin/%s.mo", argv[0]);
+ rt_snprintf(pg_name, length - 1, "/bin/%.*s.mo", cmd_length, cmd_line);
fd = open(pg_name, O_RDONLY, 0);
}
}
-
+
if (fd >= 0)
{
/* found program */
close(fd);
- rt_module_open(pg_name);
+ rt_module_exec_cmd(pg_name, cmd_line, size);
+ ret = 0;
}
else
{
- rt_kprintf("%s: program not found.\n", argv[0]);
+ ret = -1;
}
rt_free(pg_name);
- return 0;
+ return ret;
}
#endif
-int msh_exec(char* cmd, rt_size_t length)
+static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp)
{
int argc;
+ int cmd0_size = 0;
+ cmd_function_t cmd_func;
char *argv[RT_FINSH_ARG_MAX];
- cmd_function_t cmd_func;
+ RT_ASSERT(cmd);
+ RT_ASSERT(retp);
+
+ /* find the size of first command */
+ while ((cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t') && cmd0_size < length)
+ cmd0_size ++;
+ if (cmd0_size == 0)
+ return -RT_ERROR;
+ cmd_func = msh_get_cmd(cmd, cmd0_size);
+ if (cmd_func == RT_NULL)
+ return -RT_ERROR;
+
+ /* split arguments */
memset(argv, 0x00, sizeof(argv));
argc = msh_split(cmd, length, argv);
- if (argc == 0) return -1;
+ if (argc == 0)
+ return -RT_ERROR;
+
+ /* exec this command */
+ *retp = cmd_func(argc, argv);
+ return 0;
+}
+
+int msh_exec(char* cmd, rt_size_t length)
+{
+ int cmd_ret;
- /* get command in internal commands */
- cmd_func = msh_get_cmd(argv[0]);
- if (cmd_func == RT_NULL)
+ /* strim the beginning of command */
+ while(*cmd == ' ' || *cmd == '\t')
{
+ cmd++;
+ length--;
+ }
+
+ if (length == 0)
+ return 0;
+
+ /* Exec sequence:
+ * 1. built-in command
+ * 2. module(if enabled)
+ * 3. chdir to the directry(if possible)
+ */
+ if (_msh_exec_cmd(cmd, length, &cmd_ret) == 0)
+ {
+ return cmd_ret;
+ }
#ifdef RT_USING_MODULE
- msh_exec_module(argc, argv);
-#else
- rt_kprintf("%s: command not found.\n", argv[0]);
+ if (msh_exec_module(cmd, length) == 0)
+ {
+ return 0;
+ }
#endif
- return -1;
+#ifdef DFS_USING_WORKDIR
+ if (chdir(cmd) == 0)
+ {
+ return 0;
}
-
- /* exec this command */
- return cmd_func(argc, argv);
+#endif
+ /* truncate the cmd at the first space. */
+ {
+ char *tcmd;
+ tcmd = cmd;
+ while(*tcmd != ' ' && *tcmd != '\0')
+ {
+ tcmd++;
+ }
+ *tcmd = '\0';
+ }
+ rt_kprintf("%s: command not found.\n", cmd);
+ return -1;
}
static int str_common(const char *str1, const char *str2)
@@ -293,7 +354,7 @@ void msh_auto_complete_path(char *path)
if (full_path == RT_NULL) return; /* out of memory */
ptr = full_path;
- if (*path != '/')
+ if (*path != '/')
{
getcwd(full_path, 256);
if (full_path[rt_strlen(full_path) - 1] != '/')
@@ -313,7 +374,7 @@ void msh_auto_complete_path(char *path)
char *dest = index;
/* fill the parent path */
- ptr = full_path;
+ ptr = full_path;
while (*ptr) ptr ++;
for (index = path; index != dest;)
@@ -338,7 +399,7 @@ void msh_auto_complete_path(char *path)
{
dirent = readdir(dir);
if (dirent == RT_NULL) break;
-
+
rt_kprintf("%s\n", dirent->d_name);
}
}
@@ -427,12 +488,21 @@ void msh_auto_complete(char *prefix)
msh_auto_complete_path(ptr + 1);
break;
}
-
+
ptr --;
}
+#ifdef RT_USING_MODULE
+ /* There is a chance that the user want to run the module directly. So
+ * try to complete the file names. If the completed path is not a
+ * module, the system won't crash anyway. */
+ if (ptr == prefix)
+ {
+ msh_auto_complete_path(ptr);
+ }
+#endif
}
#endif
-
+
/* checks in internal command */
{
for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c
index a5a5b79f15..c11873dc91 100644
--- a/components/finsh/msh_cmd.c
+++ b/components/finsh/msh_cmd.c
@@ -179,6 +179,18 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_mkdir, __cmd_mkdir, Create the DIRECTORY.);
#endif
+#ifdef RT_USING_LWIP
+int cmd_ifconfig(int argc, char** argv)
+{
+ extern void list_if(void);
+
+ list_if();
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_ifconfig, __cmd_ifconfig, list the information of network interfaces);
+
+#endif
+
int cmd_ps(int argc, char** argv)
{
extern long list_thread(void);
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index 74b7ed7d95..4313fcf6b2 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -58,11 +58,18 @@ struct finsh_shell* shell;
#include <dfs_posix.h>
const char* finsh_get_prompt()
{
- #define _PROMPT "finsh "
- static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {_PROMPT};
-
+ #define _MSH_PROMPT "msh "
+ #define _PROMPT "finsh "
+ static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {0};
+
+#ifdef FINSH_USING_MSH
+ if (msh_is_used()) strcpy(finsh_prompt, _MSH_PROMPT);
+ else
+#endif
+ strcpy(finsh_prompt, _PROMPT);
+
/* get current working directory */
- getcwd(&finsh_prompt[6], RT_CONSOLEBUF_SIZE - 8);
+ getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
strcat(finsh_prompt, ">");
return finsh_prompt;
diff --git a/components/init/components.c b/components/init/components.c
index 44ff11361a..2c507e12f8 100644
--- a/components/init/components.c
+++ b/components/init/components.c
@@ -148,6 +148,10 @@ void rt_components_init(void)
dfs_romfs_init();
#endif
+#ifdef RT_USING_DFS_RAMFS
+ dfs_ramfs_init();
+#endif
+
#ifdef RT_USING_DFS_DEVFS
devfs_init();
#endif
diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c
index 958803f156..ee1d952410 100644
--- a/components/net/lwip-1.4.1/src/arch/sys_arch.c
+++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c
@@ -622,6 +622,14 @@ RTM_EXPORT(lwip_select);
RTM_EXPORT(lwip_ioctl);
RTM_EXPORT(lwip_fcntl);
+RTM_EXPORT(lwip_htons);
+RTM_EXPORT(lwip_ntohs);
+RTM_EXPORT(lwip_htonl);
+RTM_EXPORT(lwip_ntohl);
+
+RTM_EXPORT(ipaddr_aton);
+RTM_EXPORT(ipaddr_ntoa);
+
#if LWIP_DNS
#include <lwip/netdb.h>
RTM_EXPORT(lwip_gethostbyname);
diff --git a/components/pthreads/posix_types.h b/components/pthreads/posix_types.h
index 280867c4ca..6f02417512 100644
--- a/components/pthreads/posix_types.h
+++ b/components/pthreads/posix_types.h
@@ -68,139 +68,26 @@ struct timeval
long tv_usec; /* microseconds */
};
-/* errno definitions */
+#ifdef RT_USING_LWIP
+#include <lwip/arch.h>
+#else
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Arg list too long */
-#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math argument out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-#define ENOMSG 35 /* No message of desired type */
-#define EIDRM 36 /* Identifier removed */
-#define ECHRNG 37 /* Channel number out of range */
-#define EL2NSYNC 38 /* Level 2 not synchronized */
-#define EL3HLT 39 /* Level 3 halted */
-#define EL3RST 40 /* Level 3 reset */
-#define ELNRNG 41 /* Link number out of range */
-#define EUNATCH 42 /* Protocol driver not attached */
-#define ENOCSI 43 /* No CSI structure available */
-#define EL2HLT 44 /* Level 2 halted */
#define EDEADLK 45 /* Resource deadlock would occur */
-#define ENOLCK 46 /* No record locks available */
-#define EBADE 50 /* Invalid exchange */
-#define EBADR 51 /* Invalid request descriptor */
-#define EXFULL 52 /* Exchange full */
-#define ENOANO 53 /* No anode */
-#define EBADRQC 54 /* Invalid request code */
-#define EBADSLT 55 /* Invalid slot */
-#define EDEADLOCK 56 /* File locking deadlock error */
-#define EBFONT 59 /* Bad font file format */
-#define ENOSTR 60 /* Device not a stream */
-#define ENODATA 61 /* No data available */
-#define ETIME 62 /* Timer expired */
-#define ENOSR 63 /* Out of streams resources */
-#define ENONET 64 /* Machine is not on the network */
-#define ENOPKG 65 /* Package not installed */
-#define EREMOTE 66 /* Object is remote */
-#define ENOLINK 67 /* Link has been severed */
-#define EADV 68 /* Advertise error */
-#define ESRMNT 69 /* Srmount error */
-#define ECOMM 70 /* Communication error on send */
-#define EPROTO 71 /* Protocol error */
-#define EDOTDOT 73 /* RFS specific error */
-#define EMULTIHOP 74 /* Multihop attempted */
#define EBADMSG 77 /* Not a data message */
-#define ENAMETOOLONG 78 /* File name too long */
-#define EOVERFLOW 79 /* Value too large for defined data type */
-#define ENOTUNIQ 80 /* Name not unique on network */
-#define EBADFD 81 /* File descriptor in bad state */
-#define EREMCHG 82 /* Remote address changed */
-#define ELIBACC 83 /* Can not access a needed shared library */
-#define ELIBBAD 84 /* Accessing a corrupted shared library */
-#define ELIBSCN 85 /* .lib section in a.out corrupted */
-#define ELIBMAX 86 /* Attempting to link in too many shared libraries */
-#define ELIBEXEC 87 /* Cannot exec a shared library directly */
-#define EILSEQ 88 /* Illegal byte sequence */
#define ENOSYS 89 /* Function not implemented */
-#define ELOOP 90 /* Too many symbolic links encountered */
-#define ERESTART 91 /* Interrupted system call should be restarted */
-#define ESTRPIPE 92 /* Streams pipe error */
-#define ENOTEMPTY 93 /* Directory not empty */
-#define EUSERS 94 /* Too many users */
-#define ENOTSOCK 95 /* Socket operation on non-socket */
-#define EDESTADDRREQ 96 /* Destination address required */
-#define EMSGSIZE 97 /* Message too long */
-#define EPROTOTYPE 98 /* Protocol wrong type for socket */
-#define ENOPROTOOPT 99 /* Protocol not available */
-#define EPROTONOSUPPORT 120 /* Protocol not supported */
-#define ESOCKTNOSUPPORT 121 /* Socket type not supported */
#define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */
-#define ENOTSUP EOPNOTSUPP/* Operation not supported on transport endpoint */
-#define EPFNOSUPPORT 123 /* Protocol family not supported */
-#define EAFNOSUPPORT 124 /* Address family not supported by protocol */
-#define EADDRINUSE 125 /* Address already in use */
-#define EADDRNOTAVAIL 126 /* Cannot assign requested address */
-#define ENETDOWN 127 /* Network is down */
-#define ENETUNREACH 128 /* Network is unreachable */
-#define ENETRESET 129 /* Network dropped connection because of reset */
-#define ECONNABORTED 130 /* Software caused connection abort */
-#define ECONNRESET 131 /* Connection reset by peer */
-#define ENOBUFS 132 /* No buffer space available */
-#define EISCONN 133 /* Transport endpoint is already connected */
-#define ENOTCONN 134 /* Transport endpoint is not connected */
-#define EUCLEAN 135 /* Structure needs cleaning */
-#define ENOTNAM 137 /* Not a XENIX named type file */
-#define ENAVAIL 138 /* No XENIX semaphores available */
-#define EISNAM 139 /* Is a named type file */
-#define EREMOTEIO 140 /* Remote I/O error */
-#define EINIT 141 /* Reserved */
-#define EREMDEV 142 /* Error 142 */
-#define ESHUTDOWN 143 /* Cannot send after transport endpoint shutdown */
-#define ETOOMANYREFS 144 /* Too many references: cannot splice */
#define ETIMEDOUT 145 /* Connection timed out */
-#define ECONNREFUSED 146 /* Connection refused */
-#define EHOSTDOWN 147 /* Host is down */
-#define EHOSTUNREACH 148 /* No route to host */
-#define EWOULDBLOCK EAGAIN /* Operation would block */
-#define EALREADY 149 /* Operation already in progress */
-#define EINPROGRESS 150 /* Operation now in progress */
-#define ESTALE 151 /* Stale NFS file handle */
-#define ECANCELED 158 /* AIO operation canceled */
-#define ENOMEDIUM 159 /* No medium found */
-#define EMEDIUMTYPE 160 /* Wrong medium type */
-#define ENOKEY 161 /* Required key not available */
-#define EKEYEXPIRED 162 /* Key has expired */
-#define EKEYREVOKED 163 /* Key has been revoked */
-#define EKEYREJECTED 164 /* Key was rejected by service */
-#define EDQUOT 1133 /* Quota exceeded */
+#endif
#ifdef RT_USING_DFS
#include <dfs_posix.h>
diff --git a/components/pthreads/pthread.c b/components/pthreads/pthread.c
index a823253d48..41432f760f 100644
--- a/components/pthreads/pthread.c
+++ b/components/pthreads/pthread.c
@@ -347,13 +347,13 @@ RTM_EXPORT(pthread_once);
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
{
- return ENOTSUP;
+ return EOPNOTSUPP;
}
RTM_EXPORT(pthread_atfork);
int pthread_kill(pthread_t thread, int sig)
{
- return ENOTSUP;
+ return EOPNOTSUPP;
}
RTM_EXPORT(pthread_kill);
diff --git a/components/pthreads/pthread_attr.c b/components/pthreads/pthread_attr.c
index 9b84935a83..3e0f7b1e4c 100644
--- a/components/pthreads/pthread_attr.c
+++ b/components/pthreads/pthread_attr.c
@@ -151,7 +151,7 @@ int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack_addr)
{
RT_ASSERT(attr != RT_NULL);
- return ENOTSUP;
+ return EOPNOTSUPP;
}
RTM_EXPORT(pthread_attr_setstackaddr);
@@ -159,7 +159,7 @@ int pthread_attr_getstackaddr(pthread_attr_t const *attr, void **stack_addr)
{
RT_ASSERT(attr != RT_NULL);
- return ENOTSUP;
+ return EOPNOTSUPP;
}
RTM_EXPORT(pthread_attr_getstackaddr);
@@ -191,12 +191,12 @@ RTM_EXPORT(pthread_attr_getstack);
int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guard_size)
{
- return ENOTSUP;
+ return EOPNOTSUPP;
}
int pthread_attr_getguardsize(pthread_attr_t const *attr, size_t *guard_size)
{
- return ENOTSUP;
+ return EOPNOTSUPP;
}
RTM_EXPORT(pthread_attr_getguardsize);
@@ -205,7 +205,7 @@ int pthread_attr_setscope(pthread_attr_t *attr, int scope)
if (scope == PTHREAD_SCOPE_SYSTEM)
return 0;
if (scope == PTHREAD_SCOPE_PROCESS)
- return ENOTSUP;
+ return EOPNOTSUPP;
return EINVAL;
}
diff --git a/components/pthreads/sched.c b/components/pthreads/sched.c
index 83810cd8aa..6f75127bf2 100644
--- a/components/pthreads/sched.c
+++ b/components/pthreads/sched.c
@@ -51,6 +51,6 @@ RTM_EXPORT(sched_get_priority_max);
int sched_setscheduler(pid_t pid, int policy)
{
- return ENOTSUP;
+ return EOPNOTSUPP;
}
RTM_EXPORT(sched_setscheduler);
diff --git a/include/rtdebug.h b/include/rtdebug.h
index 6ef04f6bf9..8fd07b5b76 100644
--- a/include/rtdebug.h
+++ b/include/rtdebug.h
@@ -64,7 +64,7 @@
#endif
#ifndef RT_DEBUG_INIT
-#define RT_DEBUG_INIT 0
+#define RT_DEBUG_INIT 0
#endif
/* Turn on this to enable context check */
diff --git a/include/rtdef.h b/include/rtdef.h
index 2851dcee51..2d1ea4dfd2 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -34,6 +34,7 @@
#ifndef __RT_DEF_H__
#define __RT_DEF_H__
+/* include rtconfig header to import configuration */
#include <rtconfig.h>
#ifdef __cplusplus
@@ -952,10 +953,11 @@ struct rt_module
rt_uint8_t *module_space; /**< module memory space */
- void *module_entry; /**< entry address of module's thread */
- rt_thread_t module_thread; /**< stack size of module's thread */
- rt_uint32_t stack_size; /**< priority of module's thread */
- rt_uint32_t thread_priority;
+ void *module_entry; /**< the entry address of module */
+ rt_thread_t module_thread; /**< the main thread of module */
+
+ rt_uint8_t* module_cmd_line; /**< module command line */
+ rt_uint32_t module_cmd_size; /**< the size of module command line */
#ifdef RT_USING_SLAB
/* module memory allocator */
@@ -964,10 +966,10 @@ struct rt_module
rt_uint32_t page_cnt; /**< module's using pages count */
#endif
- rt_uint32_t nsym; /**< number of symbol in the module */
- struct rt_module_symtab *symtab; /**< module symbol table */
+ rt_uint16_t nref; /**< reference count */
- rt_uint32_t nref; /**< reference count */
+ rt_uint16_t nsym; /**< number of symbol in the module */
+ struct rt_module_symtab *symtab; /**< module symbol table */
/* object in this module, module object is the last basic object type */
struct rt_object_information module_object[RT_Object_Class_Unknown];
diff --git a/include/rtthread.h b/include/rtthread.h
index 0891ed9bcc..abe3a614ed 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -31,8 +31,9 @@
#ifndef __RT_THREAD_H__
#define __RT_THREAD_H__
-#include <rtdef.h>
+#include <rtconfig.h>
#include <rtdebug.h>
+#include <rtdef.h>
#include <rtservice.h>
#include <rtm.h>
@@ -420,6 +421,7 @@ rt_module_t rt_module_load(const char *name, void *module_ptr);
rt_err_t rt_module_unload(rt_module_t module);
#ifdef RT_USING_DFS
rt_module_t rt_module_open(const char *filename);
+rt_module_t rt_module_exec_cmd(const char *path, char* cmd_line, int size);
#endif
void *rt_module_malloc(rt_size_t size);
void *rt_module_realloc(void *ptr, rt_size_t size);
@@ -432,6 +434,9 @@ void rt_module_load_sethook(void (*hook)(rt_module_t module));
void rt_module_unload_sethook(void (*hook)(rt_module_t module));
#endif
+void rt_module_init_object_container(struct rt_module *module);
+rt_err_t rt_module_destroy(rt_module_t module);
+
/*@}*/
#endif
diff --git a/libcpu/arm/am335x/am33xx.h b/libcpu/arm/am335x/am33xx.h
index 86ed82750a..68ea4478d3 100644
--- a/libcpu/arm/am335x/am33xx.h
+++ b/libcpu/arm/am335x/am33xx.h
@@ -84,7 +84,11 @@
#define CM_PER(base) ((base) + 0)
#define CM_PER_L4LS_CLKSTCTRL(base) (CM_PER(base) + 0)
-#define CM_PER_UART1_CLKCTRL(base) (CM_PER(base) + 0x06C)
+#define CM_PER_UART1_CLKCTRL(base) (CM_PER(base) + 0x6C)
+#define CM_PER_UART2_CLKCTRL(base) (CM_PER(base) + 0x70)
+#define CM_PER_UART3_CLKCTRL(base) (CM_PER(base) + 0x74)
+#define CM_PER_UART4_CLKCTRL(base) (CM_PER(base) + 0x78)
+#define CM_PER_UART5_CLKCTRL(base) (CM_PER(base) + 0x38)
#define CM_WKUP(base) ((base) + 0x400)
#define CM_DPLL(base) ((base) + 0x500)
#define CM_MPU(base) ((base) + 0x600)
@@ -171,6 +175,10 @@
/* PRCM registers */
#define CM_PER_L4LS_CLKSTCTRL_REG(base) REG32((base) + 0x0)
#define CM_PER_UART1_CLKCTRL_REG(base) REG32(CM_PER_UART1_CLKCTRL(base))
+#define CM_PER_UART2_CLKCTRL_REG(base) REG32(CM_PER_UART2_CLKCTRL(base))
+#define CM_PER_UART3_CLKCTRL_REG(base) REG32(CM_PER_UART3_CLKCTRL(base))
+#define CM_PER_UART4_CLKCTRL_REG(base) REG32(CM_PER_UART4_CLKCTRL(base))
+#define CM_PER_UART5_CLKCTRL_REG(base) REG32(CM_PER_UART5_CLKCTRL(base))
#define CM_PER_TIMER7_CLKCTRL(base) REG32((base) + 0x7C)
#define CM_PER_TIMER2_CLKCTRL(base) REG32((base) + 0x80)
diff --git a/src/module.c b/src/module.c
index ac689dbade..428d42e961 100644
--- a/src/module.c
+++ b/src/module.c
@@ -242,7 +242,7 @@ static int rt_module_arm_relocate(struct rt_module *module,
return 0;
}
-static void rt_module_init_object_container(struct rt_module *module)
+void rt_module_init_object_container(struct rt_module *module)
{
RT_ASSERT(module != RT_NULL);
@@ -801,6 +801,10 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
/* init module object container */
rt_module_init_object_container(module);
+ /* initialize an empty command */
+ module->module_cmd_line = RT_NULL;
+ module->module_cmd_size = 0;
+
/* increase module reference count */
module->nref ++;
@@ -816,18 +820,10 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
module->page_cnt = 0;
#endif
- /* get the main thread stack size */
- module->stack_size = 2048;
- module->thread_priority = RT_THREAD_PRIORITY_MAX - 2;
-
/* create module thread */
- module->module_thread =
- rt_thread_create(name,
- (void(*)(void *))module->module_entry,
- RT_NULL,
- module->stack_size,
- module->thread_priority,
- 10);
+ module->module_thread = rt_thread_create(name,
+ (void(*)(void *))module->module_entry, RT_NULL,
+ 2048, RT_THREAD_PRIORITY_MAX - 2, 10);
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("thread entry 0x%x\n",
module->module_entry));
@@ -855,6 +851,168 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
return module;
}
+#define RT_MODULE_ARG_MAX 8
+static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[])
+{
+ int argc = 0;
+ char *ptr = cmd;
+
+ while ((ptr - cmd) < length)
+ {
+ /* strip bank and tab */
+ while ((*ptr == ' ' || *ptr == '\t') && (ptr -cmd)< length)
+ *ptr++ = '\0';
+ /* check whether it's the end of line */
+ if ((ptr - cmd)>= length) break;
+
+ /* handle string with quote */
+ if (*ptr == '"')
+ {
+ argv[argc++] = ++ptr;
+
+ /* skip this string */
+ while (*ptr != '"' && (ptr-cmd) < length)
+ if (*ptr ++ == '\\') ptr ++;
+ if ((ptr - cmd) >= length) break;
+
+ /* skip '"' */
+ *ptr ++ = '\0';
+ }
+ else
+ {
+ argv[argc++] = ptr;
+ while ((*ptr != ' ' && *ptr != '\t') && (ptr - cmd) < length)
+ ptr ++;
+ }
+
+ if (argc >= RT_MODULE_ARG_MAX) break;
+ }
+
+ return argc;
+}
+/* module main thread entry */
+static void module_main_entry(void* parameter)
+{
+ int argc;
+ char *argv[RT_MODULE_ARG_MAX];
+ typedef int (*main_func_t)(int argc, char** argv);
+
+ rt_module_t module = (rt_module_t) parameter;
+ if (module == RT_NULL || module->module_cmd_line == RT_NULL) return;
+
+ rt_memset(argv, 0x00, sizeof(argv));
+ argc = _rt_module_split_arg((char*)module->module_cmd_line, module->module_cmd_size, argv);
+ if (argc == 0) return ;
+
+ /* do the main function */
+ ((main_func_t)module->module_entry)(argc, argv);
+ return;
+}
+
+/**
+ * This function will load a module with a main function from memory and create a
+ * main thread for it
+ *
+ * @param name the name of module, which shall be unique
+ * @param module_ptr the memory address of module image
+ * @argc the count of argument
+ * @argd the argument data, which should be a
+ *
+ * @return the module object
+ */
+rt_module_t rt_module_do_main(const char *name, void *module_ptr, char* cmd_line, int line_size)
+{
+ rt_module_t module;
+
+ RT_DEBUG_NOT_IN_INTERRUPT;
+
+ RT_DEBUG_LOG(RT_DEBUG_MODULE, ("rt_module_load: %s ,", name));
+
+ /* check ELF header */
+ if (rt_memcmp(elf_module->e_ident, RTMMAG, SELFMAG) != 0 &&
+ rt_memcmp(elf_module->e_ident, ELFMAG, SELFMAG) != 0)
+ {
+ rt_kprintf("Module: magic error\n");
+
+ return RT_NULL;
+ }
+
+ /* check ELF class */
+ if (elf_module->e_ident[EI_CLASS] != ELFCLASS32)
+ {
+ rt_kprintf("Module: ELF class error\n");
+ return RT_NULL;
+ }
+
+ if (elf_module->e_type == ET_REL)
+ {
+ module = _load_relocated_object(name, module_ptr);
+ }
+ else if (elf_module->e_type == ET_DYN)
+ {
+ module = _load_shared_object(name, module_ptr);
+ }
+ else
+ {
+ rt_kprintf("Module: unsupported excutable program\n");
+ return RT_NULL;
+ }
+
+ if (module == RT_NULL)
+ return RT_NULL;
+
+ /* init module object container */
+ rt_module_init_object_container(module);
+
+ /* increase module reference count */
+ module->nref ++;
+
+ if (elf_module->e_entry != 0)
+ {
+#ifdef RT_USING_SLAB
+ /* init module memory allocator */
+ module->mem_list = RT_NULL;
+
+ /* create page array */
+ module->page_array =
+ (void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info));
+ module->page_cnt = 0;
+#endif
+
+ /* set module argument */
+ module->module_cmd_line = (rt_uint8_t*)rt_malloc(line_size + 1);
+ rt_memcpy(module->module_cmd_line, cmd_line, line_size);
+ module->module_cmd_line[line_size] = '\0';
+ module->module_cmd_size = line_size;
+
+ /* create module thread */
+ module->module_thread = rt_thread_create(name,
+ module_main_entry, module,
+ 2048, RT_THREAD_PRIORITY_MAX - 2, 10);
+
+ /* set module id */
+ module->module_thread->module_id = (void *)module;
+ module->parent.flag = RT_MODULE_FLAG_WITHENTRY;
+
+ /* startup main thread */
+ rt_thread_startup(module->module_thread);
+ }
+ else
+ {
+ /* without entry point */
+ module->parent.flag |= RT_MODULE_FLAG_WITHOUTENTRY;
+ }
+
+#ifdef RT_USING_HOOK
+ if (rt_module_load_hook != RT_NULL)
+ {
+ rt_module_load_hook(module);
+ }
+#endif
+
+ return module;
+}
+
#ifdef RT_USING_DFS
#include <dfs_posix.h>
@@ -958,9 +1116,82 @@ rt_module_t rt_module_open(const char *path)
return module;
}
+/**
+ * This function will do a excutable program with main function and parameters.
+ *
+ * @param path the full path of application module
+ * @cmd_line the command line of program
+ * @size the size of command line of program
+ *
+ * @return the module object
+ */
+rt_module_t rt_module_exec_cmd(const char *path, char* cmd_line, int size)
+{
+ struct stat s;
+ int fd, length;
+ char *name, *buffer, *offset_ptr;
+ struct rt_module *module = RT_NULL;
+
+ name = buffer = RT_NULL;
+
+ RT_DEBUG_NOT_IN_INTERRUPT;
+
+ /* check parameters */
+ RT_ASSERT(path != RT_NULL);
+
+ /* get file size */
+ if (stat(path, &s) !=0)
+ {
+ rt_kprintf("Module: access %s failed\n", path);
+ goto __exit;
+ }
+
+ /* allocate buffer to save program */
+ offset_ptr = buffer = (char *)rt_malloc(s.st_size);
+ if (buffer == RT_NULL)
+ {
+ rt_kprintf("Module: out of memory\n");
+ goto __exit;
+ }
+
+ fd = open(path, O_RDONLY, 0);
+ if (fd < 0)
+ {
+ rt_kprintf("Module: open %s failed\n", path);
+ goto __exit;
+ }
+
+ do
+ {
+ length = read(fd, offset_ptr, 4096);
+ if (length > 0)
+ {
+ offset_ptr += length;
+ }
+ }while (length > 0);
+ /* close fd */
+ close(fd);
+
+ if ((rt_uint32_t)offset_ptr - (rt_uint32_t)buffer != s.st_size)
+ {
+ rt_kprintf("Module: read file failed\n");
+ goto __exit;
+ }
+
+ /* get module */
+ name = _module_name(path);
+ /* execute module */
+ module = rt_module_do_main(name, (void *)buffer, cmd_line, size);
+
+__exit:
+ rt_free(buffer);
+ rt_free(name);
+
+ return module;
+}
+
#if defined(RT_USING_FINSH)
#include <finsh.h>
-
FINSH_FUNCTION_EXPORT_ALIAS(rt_module_open, exec, exec module from a file);
#endif
@@ -1131,6 +1362,12 @@ rt_err_t rt_module_destroy(rt_module_t module)
rt_timer_delete((rt_timer_t)object);
}
}
+
+ /* delete command line */
+ if (module->module_cmd_line != RT_NULL)
+ {
+ rt_free(module->module_cmd_line);
+ }
}
#ifdef RT_USING_SLAB
diff --git a/src/thread.c b/src/thread.c
index c2282f6ee6..6c0490a6a3 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -575,6 +575,9 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
thread->stat = RT_THREAD_SUSPEND;
rt_schedule_remove_thread(thread);
+ /* stop thread timer anyway */
+ rt_timer_stop(&(thread->thread_timer));
+
/* enable interrupt */
rt_hw_interrupt_enable(temp);
diff --git a/tools/building.py b/tools/building.py
index acc3a8a213..54193fcf2f 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -53,7 +53,10 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
# reset AR command flags
env['ARCOM'] = '$AR --create $TARGET $SOURCES'
env['LIBPREFIX'] = ''
- env['LIBSUFFIX'] = '_rvds.lib'
+ env['LIBSUFFIX'] = '.lib'
+ env['LIBLINKPREFIX'] = ''
+ env['LIBLINKSUFFIX'] = '.lib'
+ env['LIBDIRPREFIX'] = '--userlibpath '
# patch for win32 spawn
if env['PLATFORM'] == 'win32' and rtconfig.PLATFORM == 'gcc':
@@ -69,6 +72,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
# add program path
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
+ # add library build action
+ act = SCons.Action.Action(BuildLibInstallAction, 'Install compiled library... $TARGET')
+ bld = Builder(action = act)
+ Env.Append(BUILDERS = {'BuildLib': bld})
+
# parse rtconfig.h to get used component
PreProcessor = SCons.cpp.PreProcessor()
f = file('rtconfig.h', 'r')
@@ -127,12 +135,17 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
dest='buildlib',
type='string',
help='building library of a component')
+ AddOption('--cleanlib',
+ dest='cleanlib',
+ action='store_true',
+ default=False,
+ help='clean up the library by --buildlib')
# add target option
AddOption('--target',
dest='target',
type='string',
- help='set target project: mdk')
+ help='set target project: mdk/iar/vs/ua')
#{target_name:(CROSS_TOOL, PLATFORM)}
tgt_dict = {'mdk':('keil', 'armcc'),
@@ -140,7 +153,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
'iar':('iar', 'iar'),
'vs':('msvc', 'cl'),
'vs2012':('msvc', 'cl'),
- 'cb':('keil', 'armcc')}
+ 'cb':('keil', 'armcc'),
+ 'ua':('keil', 'armcc')}
tgt_name = GetOption('target')
if tgt_name:
# --target will change the toolchain settings which clang-analyzer is
@@ -196,17 +210,25 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
return objs
def PrepareModuleBuilding(env, root_directory):
- import SCons.cpp
import rtconfig
- global BuildOptions
- global Projects
global Env
global Rtt_Root
Env = env
Rtt_Root = root_directory
+ # add build/clean library option for library checking
+ AddOption('--buildlib',
+ dest='buildlib',
+ type='string',
+ help='building library of a component')
+ AddOption('--cleanlib',
+ dest='cleanlib',
+ action='store_true',
+ default=False,
+ help='clean up the library by --buildlib')
+
# add program path
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
@@ -276,10 +298,18 @@ def DefineGroup(name, src, depend, **parameters):
if not GetDepend(depend):
return []
+ # find exist group and get path of group
+ group_path = ''
+ for g in Projects:
+ if g['name'] == name:
+ group_path = g['path']
+ if group_path == '':
+ group_path = GetCurrentDir()
+
group = parameters
group['name'] = name
- group['path'] = GetCurrentDir()
- if type(src) == type(['src1', 'str2']):
+ group['path'] = group_path
+ if type(src) == type(['src1']):
group['src'] = File(src)
else:
group['src'] = src
@@ -292,13 +322,27 @@ def DefineGroup(name, src, depend, **parameters):
Env.Append(CPPDEFINES = group['CPPDEFINES'])
if group.has_key('LINKFLAGS'):
Env.Append(LINKFLAGS = group['LINKFLAGS'])
+
+ # check whether to clean up library
+ if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
+ if group['src'] != []:
+ print 'Remove library:', GroupLibFullName(name, Env)
+ do_rm_file(os.path.join(group['path'], GroupLibFullName(name, Env)))
+
+ # check whether exist group library
+ if not GetOption('buildlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
+ group['src'] = []
+ if group.has_key('LIBS'): group['LIBS'] = group['LIBS'] + [GroupLibName(name, Env)]
+ else : group['LIBS'] = [GroupLibName(name, Env)]
+ if group.has_key('LIBPATH'): group['LIBPATH'] = group['LIBPATH'] + [GetCurrentDir()]
+ else : group['LIBPATH'] = [GetCurrentDir()]
+
if group.has_key('LIBS'):
Env.Append(LIBS = group['LIBS'])
if group.has_key('LIBPATH'):
Env.Append(LIBPATH = group['LIBPATH'])
objs = Env.Object(group['src'])
-
if group.has_key('LIBRARY'):
objs = Env.Library(name, objs)
@@ -332,6 +376,28 @@ def PreBuilding():
for a in PREBUILDING:
a()
+def GroupLibName(name, env):
+ import rtconfig
+ if rtconfig.PLATFORM == 'armcc':
+ return name + '_rvds'
+ elif rtconfig.PLATFORM == 'gcc':
+ return name + '_gcc'
+
+ return name
+
+def GroupLibFullName(name, env):
+ return env['LIBPREFIX'] + GroupLibName(name, env) + env['LIBSUFFIX']
+
+def BuildLibInstallAction(target, source, env):
+ lib_name = GetOption('buildlib')
+ for Group in Projects:
+ if Group['name'] == lib_name:
+ lib_name = GroupLibFullName(Group['name'], env)
+ dst_name = os.path.join(Group['path'], lib_name)
+ print 'Copy %s => %s' % (lib_name, dst_name)
+ do_copy_file(lib_name, dst_name)
+ break
+
def DoBuilding(target, objects):
program = None
# check whether special buildlib option
@@ -340,27 +406,34 @@ def DoBuilding(target, objects):
# build library with special component
for Group in Projects:
if Group['name'] == lib_name:
+ lib_name = GroupLibName(Group['name'], Env)
objects = Env.Object(Group['src'])
program = Env.Library(lib_name, objects)
+
+ # add library copy action
+ Env.BuildLib(lib_name, program)
+
break
else:
+ # merge the repeated items in the Env
+ if Env.has_key('CPPPATH') : Env['CPPPATH'] = list(set(Env['CPPPATH']))
+ if Env.has_key('CPPDEFINES'): Env['CPPDEFINES'] = list(set(Env['CPPDEFINES']))
+ if Env.has_key('LIBPATH') : Env['LIBPATH'] = list(set(Env['LIBPATH']))
+ if Env.has_key('LIBS') : Env['LIBS'] = list(set(Env['LIBS']))
+
program = Env.Program(target, objects)
EndBuilding(target, program)
-
def EndBuilding(target, program = None):
import rtconfig
- from keil import MDKProject
- from keil import MDK4Project
- from iar import IARProject
- from vs import VSProject
- from vs2012 import VS2012Project
- from codeblocks import CBProject
Env.AddPostAction(target, rtconfig.POST_ACTION)
if GetOption('target') == 'mdk':
+ from keil import MDKProject
+ from keil import MDK4Project
+
template = os.path.isfile('template.Uv2')
if template:
MDKProject('project.Uv2', Projects)
@@ -372,20 +445,30 @@ def EndBuilding(target, program = None):
print 'No template project file found.'
if GetOption('target') == 'mdk4':
+ from keil import MDKProject
+ from keil import MDK4Project
MDK4Project('project.uvproj', Projects)
if GetOption('target') == 'iar':
+ from iar import IARProject
IARProject('project.ewp', Projects)
if GetOption('target') == 'vs':
+ from vs import VSProject
VSProject('project.vcproj', Projects, program)
if GetOption('target') == 'vs2012':
+ from vs2012 import VS2012Project
VS2012Project('project.vcxproj', Projects, program)
if GetOption('target') == 'cb':
+ from codeblocks import CBProject
CBProject('project.cbp', Projects, program)
+ if GetOption('target') == 'ua':
+ from ua import PrepareUA
+ PrepareUA(Projects, Rtt_Root, str(Dir('#')))
+
if GetOption('copy') and program != None:
MakeCopy(program)
if GetOption('copy-header') and program != None:
@@ -449,6 +532,13 @@ def GlobSubDir(sub_dir, ext_name):
dst.append(os.path.relpath(item, sub_dir))
return dst
+def file_path_exist(path, *args):
+ return os.path.exists(os.path.join(path, *args))
+
+def do_rm_file(src):
+ if os.path.exists(src):
+ os.unlink(src)
+
def do_copy_file(src, dst):
import shutil
# check source file
diff --git a/tools/ua.py b/tools/ua.py
new file mode 100644
index 0000000000..ac3ea9061c
--- /dev/null
+++ b/tools/ua.py
@@ -0,0 +1,70 @@
+import os
+import sys
+from utils import _make_path_relative
+
+def PrefixPath(prefix, path):
+ path = os.path.abspath(path)
+ prefix = os.path.abspath(prefix)
+
+ if sys.platform == 'win32':
+ prefix = prefix.lower()
+ path = path.lower()
+
+ if path.startswith(prefix):
+ return True
+
+ return False
+
+def PrepareUA(project, RTT_ROOT, BSP_ROOT):
+ with open('rtua.py', 'w') as ua:
+ # ua.write('import os\n')
+ # ua.write('import sys\n')
+ ua.write('\n')
+
+ print RTT_ROOT
+
+ CPPPATH = []
+ CPPDEFINES = []
+
+ for group in project:
+ # get each include path
+ if group.has_key('CPPPATH') and group['CPPPATH']:
+ CPPPATH += group['CPPPATH']
+
+ # get each group's definitions
+ if group.has_key('CPPDEFINES') and group['CPPDEFINES']:
+ CPPDEFINES += group['CPPDEFINES']
+
+ if len(CPPPATH):
+ # use absolute path
+ for i in range(len(CPPPATH)):
+ CPPPATH[i] = os.path.abspath(CPPPATH[i])
+
+ # remove repeat path
+ paths = [i for i in set(CPPPATH)]
+ CPPPATH = []
+ for path in paths:
+ if PrefixPath(RTT_ROOT, path):
+ CPPPATH += ['RTT_ROOT + "/%s",' % _make_path_relative(RTT_ROOT, path).replace('\\', '/')]
+
+ elif PrefixPath(BSP_ROOT, path):
+ CPPPATH += ['BSP_ROOT + "/%s",' % _make_path_relative(BSP_ROOT, path).replace('\\', '/')]
+ else:
+ CPPPATH += ['"%s",' % path.replace('\\', '/')]
+
+ CPPPATH.sort()
+ ua.write('def GetCPPPATH(BSP_ROOT, RTT_ROOT):\n')
+ ua.write('\tCPPPATH=[\n')
+ for path in CPPPATH:
+ ua.write('\t\t%s\n' % path)
+ ua.write('\t]\n\n')
+ ua.write('\treturn CPPPATH\n\n')
+
+ if len(CPPDEFINES):
+ CPPDEFINES = [i for i in set(CPPDEFINES)]
+
+ ua.write('def GetCPPDEFINES():\n')
+ ua.write('\tCPPDEFINES=%s\n' % str(CPPDEFINES))
+ ua.write('\treturn CPPDEFINES\n\n')
+
+ print CPPDEFINES
diff --git a/tools/wizard.py b/tools/wizard.py
index 4b2186fadb..4b2186fadb 100644..100755
--- a/tools/wizard.py
+++ b/tools/wizard.py