Add support for Fire STM32v3; sscanf fixes from Kate
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5168 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
d4513b1e64
commit
626be6d914
@ -3377,3 +3377,12 @@
|
|||||||
commands used in the build (Contributed by Richard Cochran).
|
commands used in the build (Contributed by Richard Cochran).
|
||||||
* drivers/net/enc28j60.c: The ENC28J60 Ethernet driver is
|
* drivers/net/enc28j60.c: The ENC28J60 Ethernet driver is
|
||||||
now functional.
|
now functional.
|
||||||
|
* configs/fire-stm32v2: Add support or the fire-stm32v3 board as
|
||||||
|
well (untested because I do not have a v3 board).
|
||||||
|
* lib/stdio/lib_sscanf.c: Add %n psuedo-format (from Kate).
|
||||||
|
* lib/stdio/lib_sscanf.c: There is an issue of handling input
|
||||||
|
when (1) no fieldwidth is provided and (2) there is no space
|
||||||
|
seperating the input values. No solutions is in place for this
|
||||||
|
case now (either space or a fieldwidth must be provided). But
|
||||||
|
at least some of the bad logic that attempted to handle this
|
||||||
|
case has been removed (noted by Kate).
|
||||||
|
@ -1753,7 +1753,7 @@
|
|||||||
STM32F103VCT chip. Contributed by Laurent Latil.
|
STM32F103VCT chip. Contributed by Laurent Latil.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
This M3 Wildfire development board (STM32F103VET6), version 2.
|
The M3 Wildfire development board (STM32F103VET6), version 2.
|
||||||
See <a href="http://firestm32.taobao.com">http://firestm32.taobao.com</a> (the current board is version 3).
|
See <a href="http://firestm32.taobao.com">http://firestm32.taobao.com</a> (the current board is version 3).
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
@ -1787,7 +1787,9 @@
|
|||||||
Support for the Wildfire board was included in version 6.22 of NuttX.
|
Support for the Wildfire board was included in version 6.22 of NuttX.
|
||||||
The board port is basically functional.
|
The board port is basically functional.
|
||||||
Not all features have been verified.
|
Not all features have been verified.
|
||||||
The ENC28J60 network is not yet functional.
|
Support for FAT file system on an an SD card had been verified.
|
||||||
|
The ENC28J60 network is functional (but required lifting the chip select pin on the W25x16 part).
|
||||||
|
Customizations for the v3 version of the Wildfire board a selectable (but untested).
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
|
@ -130,8 +130,8 @@ config ARCH_BOARD_EZ80F910200ZCO
|
|||||||
development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line
|
development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line
|
||||||
tools. The development environment is Cygwin under WinXP.
|
tools. The development environment is Cygwin under WinXP.
|
||||||
|
|
||||||
config ARCH_BOARD_FIRE_STM32V2
|
config ARCH_BOARD_FIRE_STM32
|
||||||
bool "M3 Wildfire STM32v2 board"
|
bool "M3 Wildfire STM3 board (v2 or v3)"
|
||||||
depends on ARCH_CHIP_STM32F103VET6
|
depends on ARCH_CHIP_STM32F103VET6
|
||||||
select ARCH_HAVE_LEDS
|
select ARCH_HAVE_LEDS
|
||||||
select ARCH_HAVE_BUTTONS
|
select ARCH_HAVE_BUTTONS
|
||||||
@ -607,7 +607,7 @@ config ARCH_BOARD
|
|||||||
default "ekk-lm3s9b96" if ARCH_BOARD_EKK_LM3S9B96
|
default "ekk-lm3s9b96" if ARCH_BOARD_EKK_LM3S9B96
|
||||||
default "ez80f0910200kitg" if ARCH_BOARD_EZ80F910200KITG
|
default "ez80f0910200kitg" if ARCH_BOARD_EZ80F910200KITG
|
||||||
default "ez80f0910200zco" if ARCH_BOARD_EZ80F910200ZCO
|
default "ez80f0910200zco" if ARCH_BOARD_EZ80F910200ZCO
|
||||||
default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32V2
|
default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32
|
||||||
default "hymini-stm32v" if ARCH_BOARD_HYMINI_STM32V
|
default "hymini-stm32v" if ARCH_BOARD_HYMINI_STM32V
|
||||||
default "kwikstik-k40" if ARCH_BOARD_KWIKSTIK_K40
|
default "kwikstik-k40" if ARCH_BOARD_KWIKSTIK_K40
|
||||||
default "lincoln60" if ARCH_BOARD_LINCOLN60
|
default "lincoln60" if ARCH_BOARD_LINCOLN60
|
||||||
@ -747,7 +747,7 @@ endif
|
|||||||
if ARCH_BOARD_EZ80F910200ZCO
|
if ARCH_BOARD_EZ80F910200ZCO
|
||||||
source "configs/ez80f910200zco/Kconfig"
|
source "configs/ez80f910200zco/Kconfig"
|
||||||
endif
|
endif
|
||||||
if ARCH_BOARD_FIRE_STM32V2
|
if ARCH_BOARD_FIRE_STM32
|
||||||
source "configs/fire-stm32v2/Kconfig"
|
source "configs/fire-stm32v2/Kconfig"
|
||||||
endif
|
endif
|
||||||
if ARCH_BOARD_HYMINI_STM32V
|
if ARCH_BOARD_HYMINI_STM32V
|
||||||
|
@ -1570,7 +1570,8 @@ configs/ez80f0910200zco
|
|||||||
|
|
||||||
configs/fire-stm32v2
|
configs/fire-stm32v2
|
||||||
A configuration for the M3 Wildfire STM32 board. This board is based on the
|
A configuration for the M3 Wildfire STM32 board. This board is based on the
|
||||||
STM32F103VET6 chip. See http://firestm32.taobao.com
|
STM32F103VET6 chip. See http://firestm32.taobao.com . Version 2 and 3 of
|
||||||
|
the boards are supported but only version 2 has been tested.
|
||||||
|
|
||||||
configs/hymini-stm32v
|
configs/hymini-stm32v
|
||||||
A configuration for the HY-Mini STM32v board. This board is based on the
|
A configuration for the HY-Mini STM32v board. This board is based on the
|
||||||
|
@ -4,3 +4,25 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
comment "M3 Wildfire Configuration"
|
comment "M3 Wildfire Configuration"
|
||||||
|
|
||||||
|
if ARCH_BOARD_FIRE_STM32
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Select Wildfire STM32 version"
|
||||||
|
default ARCH_BOARD_FIRE_STM32V2
|
||||||
|
---help---
|
||||||
|
This port has logic differences to support either the Version 2 or
|
||||||
|
Version 3 of the Wildfire board.
|
||||||
|
|
||||||
|
config ARCH_BOARD_FIRE_STM32V2
|
||||||
|
bool "Wildfire STM32v2"
|
||||||
|
---help---
|
||||||
|
Selects the M3 Wildfire version 2.
|
||||||
|
|
||||||
|
config ARCH_BOARD_FIRE_STM32V3
|
||||||
|
bool "Wildfire STM32v3"
|
||||||
|
---help---
|
||||||
|
Selects the M3 Wildfire version 3.
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
endif
|
||||||
|
@ -4,6 +4,10 @@ README
|
|||||||
This README discusses issues unique to NuttX configurations for the M3
|
This README discusses issues unique to NuttX configurations for the M3
|
||||||
Wildfire development board (STM32F103VET6). See http://firestm32.taobao.com
|
Wildfire development board (STM32F103VET6). See http://firestm32.taobao.com
|
||||||
|
|
||||||
|
This configuration should support both the version 2 and version 3 of the
|
||||||
|
Wildfire board (using NuttX configuration options). However, only version 2
|
||||||
|
has been verified.
|
||||||
|
|
||||||
Contents
|
Contents
|
||||||
========
|
========
|
||||||
|
|
||||||
@ -27,8 +31,10 @@ PIN NAME SIGNAL NOTES
|
|||||||
|
|
||||||
1 PE2 PE2-C-RCLK Camera (P9)
|
1 PE2 PE2-C-RCLK Camera (P9)
|
||||||
2 PE3 PE3-USB-M USB2.0
|
2 PE3 PE3-USB-M USB2.0
|
||||||
3 PE4 PE4-BEEP LS1 Bell
|
3 PE4 PE4-BEEP LS1 Bell (v2)
|
||||||
4 PE5 (no name) 10Mbps ENC28J60 Interrupt
|
PE4 10Mbps ENC28J60 Interrupt (v3)
|
||||||
|
4 PE5 (no name) 10Mbps ENC28J60 Interrupt (v2)
|
||||||
|
PE5 KEY1, Low when closed (pulled high if open) (v3)
|
||||||
5 PE6
|
5 PE6
|
||||||
6 VBAT BT1 Battery (BT1)
|
6 VBAT BT1 Battery (BT1)
|
||||||
7 PC13 Header 7X2
|
7 PC13 Header 7X2
|
||||||
@ -64,7 +70,8 @@ PIN NAME SIGNAL NOTES
|
|||||||
32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||||
33 PC4 PC4-LED2 LED2, Active low (pulled high)
|
33 PC4 PC4-LED2 LED2, Active low (pulled high)
|
||||||
34 PC5 PC5-LED3 LED3, Active low (pulled high)
|
34 PC5 PC5-LED3 LED3, Active low (pulled high)
|
||||||
35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open)
|
35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open) (v2)
|
||||||
|
PB0 Header P5 (v3)
|
||||||
36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
|
36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
|
||||||
37 PB2 BOOT1/DGND
|
37 PB2 BOOT1/DGND
|
||||||
38 PE7 PE7-FSMC_D4 2.4" TFT + Touchscreen
|
38 PE7 PE7-FSMC_D4 2.4" TFT + Touchscreen
|
||||||
@ -525,7 +532,8 @@ M3 Wildfire-specific Configuration Options
|
|||||||
|
|
||||||
CONFIG_ARCH_BOARD_name - For use in C code
|
CONFIG_ARCH_BOARD_name - For use in C code
|
||||||
|
|
||||||
CONFIG_ARCH_BOARD_FIRE_STM32V2=y
|
CONFIG_ARCH_BOARD_FIRE_STM32V2=y (Version 2)
|
||||||
|
CONFIG_ARCH_BOARD_FIRE_STM32V3=y (Version 3)
|
||||||
|
|
||||||
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
|
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
|
||||||
of delay loops
|
of delay loops
|
||||||
|
@ -150,6 +150,7 @@ CONFIG_STM32_USART2=y
|
|||||||
CONFIG_STM32_USB=y
|
CONFIG_STM32_USB=y
|
||||||
# CONFIG_STM32_WWDG is not set
|
# CONFIG_STM32_WWDG is not set
|
||||||
CONFIG_STM32_SPI=y
|
CONFIG_STM32_SPI=y
|
||||||
|
CONFIG_STM32_I2C=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Alternate Pin Mapping
|
# Alternate Pin Mapping
|
||||||
@ -171,6 +172,15 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
|
|||||||
# CONFIG_STM32_SPI_INTERRUPTS is not set
|
# CONFIG_STM32_SPI_INTERRUPTS is not set
|
||||||
# CONFIG_STM32_SPI_DMA is not set
|
# CONFIG_STM32_SPI_DMA is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# I2C Configuration
|
||||||
|
#
|
||||||
|
# CONFIG_STM32_I2C_DYNTIMEO is not set
|
||||||
|
CONFIG_STM32_I2CTIMEOSEC=0
|
||||||
|
CONFIG_STM32_I2CTIMEOMS=500
|
||||||
|
CONFIG_STM32_I2CTIMEOTICKS=500
|
||||||
|
# CONFIG_STM32_I2C_DUTY16_9 is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# SDIO Configuration
|
# SDIO Configuration
|
||||||
#
|
#
|
||||||
@ -215,7 +225,7 @@ CONFIG_BOOT_RUNFROMFLASH=y
|
|||||||
#
|
#
|
||||||
# Board Selection
|
# Board Selection
|
||||||
#
|
#
|
||||||
CONFIG_ARCH_BOARD_FIRE_STM32V2=y
|
CONFIG_ARCH_BOARD_FIRE_STM32=y
|
||||||
# CONFIG_ARCH_BOARD_CUSTOM is not set
|
# CONFIG_ARCH_BOARD_CUSTOM is not set
|
||||||
CONFIG_ARCH_BOARD="fire-stm32v2"
|
CONFIG_ARCH_BOARD="fire-stm32v2"
|
||||||
|
|
||||||
@ -238,6 +248,8 @@ CONFIG_NSH_MMCSDSPIPORTNO=0
|
|||||||
#
|
#
|
||||||
# M3 Wildfire Configuration
|
# M3 Wildfire Configuration
|
||||||
#
|
#
|
||||||
|
CONFIG_ARCH_BOARD_FIRE_STM32V2=y
|
||||||
|
# CONFIG_ARCH_BOARD_FIRE_STM32V3 is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# RTOS Features
|
# RTOS Features
|
||||||
@ -316,6 +328,8 @@ CONFIG_I2C_TRANSFER=y
|
|||||||
# CONFIG_I2C_WRITEREAD is not set
|
# CONFIG_I2C_WRITEREAD is not set
|
||||||
CONFIG_I2C_POLLED=y
|
CONFIG_I2C_POLLED=y
|
||||||
# CONFIG_I2C_TRACE is not set
|
# CONFIG_I2C_TRACE is not set
|
||||||
|
CONFIG_ARCH_HAVE_I2CRESET=y
|
||||||
|
# CONFIG_I2C_RESET is not set
|
||||||
CONFIG_SPI=y
|
CONFIG_SPI=y
|
||||||
# CONFIG_SPI_OWNBUS is not set
|
# CONFIG_SPI_OWNBUS is not set
|
||||||
CONFIG_SPI_EXCHANGE=y
|
CONFIG_SPI_EXCHANGE=y
|
||||||
@ -348,6 +362,7 @@ CONFIG_ENC28J60_SPIMODE=0
|
|||||||
CONFIG_ENC28J60_FREQUENCY=20000000
|
CONFIG_ENC28J60_FREQUENCY=20000000
|
||||||
# CONFIG_ENC28J60_STATS is not set
|
# CONFIG_ENC28J60_STATS is not set
|
||||||
# CONFIG_ENC28J60_HALFDUPPLEX is not set
|
# CONFIG_ENC28J60_HALFDUPPLEX is not set
|
||||||
|
# CONFIG_ENC28J60_DUMPPACKET is not set
|
||||||
# CONFIG_NET_E1000 is not set
|
# CONFIG_NET_E1000 is not set
|
||||||
# CONFIG_NET_SLIP is not set
|
# CONFIG_NET_SLIP is not set
|
||||||
# CONFIG_NET_VNET is not set
|
# CONFIG_NET_VNET is not set
|
||||||
|
@ -166,7 +166,8 @@
|
|||||||
* PIN NAME SIGNAL NOTES
|
* PIN NAME SIGNAL NOTES
|
||||||
* --- ------ -------------- -------------------------------------------------------------------
|
* --- ------ -------------- -------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* 35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open)
|
* 35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open) (v2)
|
||||||
|
* 35 PE5 PB0 KEY1, Low when closed (pulled high if open) (v3)
|
||||||
* 36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
|
* 36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -174,8 +175,13 @@
|
|||||||
#define MAX_IRQBUTTON BUTTON_KEY2
|
#define MAX_IRQBUTTON BUTTON_KEY2
|
||||||
#define NUM_IRQBUTTONS (MAX_IRQBUTTON - MIN_IRQBUTTON + 1)
|
#define NUM_IRQBUTTONS (MAX_IRQBUTTON - MIN_IRQBUTTON + 1)
|
||||||
|
|
||||||
#define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
#ifdef CONFIG_ARCH_BOARD_FIRE_STM32V3
|
||||||
|
# define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||||
|
GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
|
||||||
|
#else
|
||||||
|
# define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||||
GPIO_EXTI|GPIO_PORTB|GPIO_PIN0)
|
GPIO_EXTI|GPIO_PORTB|GPIO_PIN0)
|
||||||
|
#endif
|
||||||
#define GPIO_BTN_KEY2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
#define GPIO_BTN_KEY2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||||
GPIO_EXTI|GPIO_PORTB|GPIO_PIN1)
|
GPIO_EXTI|GPIO_PORTB|GPIO_PIN1)
|
||||||
|
|
||||||
@ -207,7 +213,8 @@
|
|||||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
|
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
|
||||||
* 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
|
* 4 PE5 (no name) 10Mbps ENC28J60 Interrupt (v2)
|
||||||
|
* 4 PE4 PE4 10Mbps ENC28J60 Interrupt (v3)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_ENC28J60)
|
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_ENC28J60)
|
||||||
@ -224,9 +231,14 @@
|
|||||||
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
|
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
|
||||||
# define GPIO_ENC28J60_RESET (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
# define GPIO_ENC28J60_RESET (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN1)
|
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN1)
|
||||||
|
#ifdef CONFIG_ARCH_BOARD_FIRE_STM32V3
|
||||||
|
# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||||
|
GPIO_EXTI|GPIO_PORTE|GPIO_PIN4)
|
||||||
|
#else /* CONFIG_ARCH_BOARD_FIRE_STM32V2 */
|
||||||
# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||||
GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
|
GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* MP3
|
/* MP3
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* lib/stdio/lib_sscanf.c
|
* lib/stdio/lib_sscanf.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -63,7 +63,7 @@
|
|||||||
* Global Function Prototypes
|
* Global Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int vsscanf(char *buf, const char *s, va_list ap);
|
int vsscanf(char *buf, const char *fmt, va_list ap);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Global Constant Data
|
* Global Constant Data
|
||||||
@ -109,67 +109,81 @@ int sscanf(FAR const char *buf, FAR const char *fmt, ...)
|
|||||||
* ANSI standard vsscanf implementation.
|
* ANSI standard vsscanf implementation.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|
||||||
|
int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
FAR char *bufstart;
|
||||||
|
FAR char *tv;
|
||||||
|
FAR const char *tc;
|
||||||
int count;
|
int count;
|
||||||
int noassign;
|
int noassign;
|
||||||
int width;
|
int width;
|
||||||
int base = 10;
|
int base = 10;
|
||||||
int lflag;
|
int lflag;
|
||||||
FAR char *tv;
|
|
||||||
FAR const char *tc;
|
|
||||||
char tmp[MAXLN];
|
char tmp[MAXLN];
|
||||||
|
|
||||||
lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, s);
|
lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, fmt);
|
||||||
|
|
||||||
count = noassign = width = lflag = 0;
|
/* Remember the start of the input buffer. We will need this for %n
|
||||||
while (*s && *buf)
|
* calculations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
bufstart = buf;
|
||||||
|
|
||||||
|
/* Parse the format, extracting values from the input buffer as needed */
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
noassign = 0;
|
||||||
|
width = 0;
|
||||||
|
lflag = 0;
|
||||||
|
|
||||||
|
while (*fmt && *buf)
|
||||||
{
|
{
|
||||||
/* Skip over white space */
|
/* Skip over white space */
|
||||||
|
|
||||||
while (isspace(*s))
|
while (isspace(*fmt))
|
||||||
{
|
{
|
||||||
s++;
|
fmt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a conversion specifier */
|
/* Check for a conversion specifier */
|
||||||
|
|
||||||
if (*s == '%')
|
if (*fmt == '%')
|
||||||
{
|
{
|
||||||
lvdbg("vsscanf: Specifier found\n");
|
lvdbg("vsscanf: Specifier found\n");
|
||||||
|
|
||||||
/* Check for qualifiers on the conversion specifier */
|
/* Check for qualifiers on the conversion specifier */
|
||||||
s++;
|
fmt++;
|
||||||
for (; *s; s++)
|
for (; *fmt; fmt++)
|
||||||
{
|
{
|
||||||
lvdbg("vsscanf: Processing %c\n", *s);
|
lvdbg("vsscanf: Processing %c\n", *fmt);
|
||||||
|
|
||||||
if (strchr("dibouxcsefg%", *s))
|
if (strchr("dibouxcsefgn%", *fmt))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*s == '*')
|
if (*fmt == '*')
|
||||||
{
|
{
|
||||||
noassign = 1;
|
noassign = 1;
|
||||||
}
|
}
|
||||||
else if (*s == 'l' || *s == 'L')
|
else if (*fmt == 'l' || *fmt == 'L')
|
||||||
{
|
{
|
||||||
lflag = 1;
|
lflag = 1;
|
||||||
}
|
}
|
||||||
else if (*s >= '1' && *s <= '9')
|
else if (*fmt >= '1' && *fmt <= '9')
|
||||||
{
|
{
|
||||||
for (tc = s; isdigit(*s); s++);
|
for (tc = fmt; isdigit(*fmt); fmt++);
|
||||||
strncpy(tmp, tc, s - tc);
|
strncpy(tmp, tc, fmt - tc);
|
||||||
tmp[s - tc] = '\0';
|
tmp[fmt - tc] = '\0';
|
||||||
width = atoi(tmp);
|
width = atoi(tmp);
|
||||||
s--;
|
fmt--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process %s: String conversion */
|
/* Process %s: String conversion */
|
||||||
|
|
||||||
if (*s == 's')
|
if (*fmt == 's')
|
||||||
{
|
{
|
||||||
lvdbg("vsscanf: Performing string conversion\n");
|
lvdbg("vsscanf: Performing string conversion\n");
|
||||||
|
|
||||||
@ -178,9 +192,26 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Was a fieldwidth specified? */
|
||||||
|
|
||||||
if (!width)
|
if (!width)
|
||||||
{
|
{
|
||||||
width = strcspn(buf, spaces);
|
/* No... is there a space after the format? */
|
||||||
|
|
||||||
|
#if 0 /* Needs more thought */
|
||||||
|
if (isspace(*(s + 1)) || *(s + 1) == 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Use the input up until the first white space is
|
||||||
|
* encountered. NOTE: This means that values on the
|
||||||
|
* input line must be separated by whitespace or they
|
||||||
|
* will get combined! This is a bug. We have no good
|
||||||
|
* way of determining the width of the data if there
|
||||||
|
* is no field with and no space separating the input.
|
||||||
|
*/
|
||||||
|
|
||||||
|
width = strcspn(buf, spaces);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noassign)
|
if (!noassign)
|
||||||
@ -189,17 +220,22 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
strncpy(tv, buf, width);
|
strncpy(tv, buf, width);
|
||||||
tv[width] = '\0';
|
tv[width] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
buf += width;
|
buf += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process %c: Character conversion */
|
/* Process %c: Character conversion */
|
||||||
|
|
||||||
else if (*s == 'c')
|
else if (*fmt == 'c')
|
||||||
{
|
{
|
||||||
lvdbg("vsscanf: Performing character conversion\n");
|
lvdbg("vsscanf: Performing character conversion\n");
|
||||||
|
|
||||||
|
/* Was a fieldwidth specified? */
|
||||||
|
|
||||||
if (!width)
|
if (!width)
|
||||||
{
|
{
|
||||||
|
/* No, then width is this one single character */
|
||||||
|
|
||||||
width = 1;
|
width = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,12 +245,13 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
strncpy(tv, buf, width);
|
strncpy(tv, buf, width);
|
||||||
tv[width] = '\0';
|
tv[width] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
buf += width;
|
buf += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process %d, %o, %b, %x, %u: Various integer conversions */
|
/* Process %d, %o, %b, %x, %u: Various integer conversions */
|
||||||
|
|
||||||
else if (strchr("dobxu", *s))
|
else if (strchr("dobxu", *fmt))
|
||||||
{
|
{
|
||||||
lvdbg("vsscanf: Performing integer conversion\n");
|
lvdbg("vsscanf: Performing integer conversion\n");
|
||||||
|
|
||||||
@ -229,37 +266,47 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
* conversion specification.
|
* conversion specification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (*s == 'd' || *s == 'u')
|
if (*fmt == 'd' || *fmt == 'u')
|
||||||
{
|
{
|
||||||
base = 10;
|
base = 10;
|
||||||
}
|
}
|
||||||
else if (*s == 'x')
|
else if (*fmt == 'x')
|
||||||
{
|
{
|
||||||
base = 16;
|
base = 16;
|
||||||
}
|
}
|
||||||
else if (*s == 'o')
|
else if (*fmt == 'o')
|
||||||
{
|
{
|
||||||
base = 8;
|
base = 8;
|
||||||
}
|
}
|
||||||
else if (*s == 'b')
|
else if (*fmt == 'b')
|
||||||
{
|
{
|
||||||
base = 2;
|
base = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the integer string into a temporary working buffer. */
|
/* Was a fieldwidth specified? */
|
||||||
|
|
||||||
if (!width)
|
if (!width)
|
||||||
{
|
{
|
||||||
|
/* No... is there a space after the format? */
|
||||||
|
|
||||||
|
#if 0 /* Needs more thought */
|
||||||
if (isspace(*(s + 1)) || *(s + 1) == 0)
|
if (isspace(*(s + 1)) || *(s + 1) == 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
/* Use the input up until the first white space is
|
||||||
|
* encountered. NOTE: This means that values on the
|
||||||
|
* input line must be separated by whitespace or they
|
||||||
|
* will get combined! This is a bug. We have no good
|
||||||
|
* way of determining the width of the data if there
|
||||||
|
* is no field with and no space separating the input.
|
||||||
|
*/
|
||||||
|
|
||||||
width = strcspn(buf, spaces);
|
width = strcspn(buf, spaces);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
width = strchr(buf, *(s + 1)) - buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy the numeric string into a temporary working buffer. */
|
||||||
|
|
||||||
strncpy(tmp, buf, width);
|
strncpy(tmp, buf, width);
|
||||||
tmp[width] = '\0';
|
tmp[width] = '\0';
|
||||||
|
|
||||||
@ -284,7 +331,7 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
|
|
||||||
/* Process %f: Floating point conversion */
|
/* Process %f: Floating point conversion */
|
||||||
|
|
||||||
else if (*s == 'f')
|
else if (*fmt == 'f')
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_LIBC_FLOATINGPOINT
|
#ifndef CONFIG_LIBC_FLOATINGPOINT
|
||||||
/* No floating point conversions */
|
/* No floating point conversions */
|
||||||
@ -303,20 +350,30 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the real string into a temporary working buffer. */
|
/* Was a fieldwidth specified? */
|
||||||
|
|
||||||
if (!width)
|
if (!width)
|
||||||
{
|
{
|
||||||
|
/* No... is there a space after the format? */
|
||||||
|
|
||||||
|
#if 0 /* Needs more thought */
|
||||||
if (isspace(*(s + 1)) || *(s + 1) == 0)
|
if (isspace(*(s + 1)) || *(s + 1) == 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
width = strcspn(buf, spaces);
|
/* Use the input up until the first white space is
|
||||||
}
|
* encountered. NOTE: This means that values on the
|
||||||
else
|
* input line must be separated by whitespace or they
|
||||||
{
|
* will get combined! This is a bug. We have no good
|
||||||
width = strchr(buf, *(s + 1)) - buf;
|
* way of determining the width of the data if there
|
||||||
|
* is no field with and no space separating the input.
|
||||||
|
*/
|
||||||
|
|
||||||
|
width = strcspn(buf, spaces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy the real string into a temporary working buffer. */
|
||||||
|
|
||||||
strncpy(tmp, buf, width);
|
strncpy(tmp, buf, width);
|
||||||
tmp[width] = '\0';
|
tmp[width] = '\0';
|
||||||
buf += width;
|
buf += width;
|
||||||
@ -356,13 +413,28 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noassign)
|
/* Process %n: Character count */
|
||||||
|
|
||||||
|
else if (*fmt == 'n')
|
||||||
|
{
|
||||||
|
lvdbg("vsscanf: Performing character count\n");
|
||||||
|
|
||||||
|
if (!noassign)
|
||||||
|
{
|
||||||
|
int *pint = va_arg(ap, int*);
|
||||||
|
*pint = (int)(buf - bufstart) - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Note %n does not count as a conversion */
|
||||||
|
|
||||||
|
if (!noassign && *fmt != 'n')
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = noassign = lflag = 0;
|
width = noassign = lflag = 0;
|
||||||
s++;
|
fmt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Its is not a conversion specifier */
|
/* Its is not a conversion specifier */
|
||||||
@ -374,13 +446,13 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
|
|||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*s != *buf)
|
if (*fmt != *buf)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s++;
|
fmt++;
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user