diff --git a/Documentation/NuttXCCodingStandard.html b/Documentation/NuttXCCodingStandard.html
index f867fb3782..7d65a766a2 100644
--- a/Documentation/NuttXCCodingStandard.html
+++ b/Documentation/NuttXCCodingStandard.html
@@ -12,7 +12,7 @@
NuttX C Coding Standard
- Last Updated: April 18, 2017
+ Last Updated: May 6, 2017
@@ -405,8 +405,11 @@
Line Spacing
A single blank line should precede and follow each comment.
- The only exception is for the file header block comment that begins on line one;
+ The only exceptions are (1) for the file header block comment that begins on line one;
there is no preceding blank line in that case.
+ And (2) for conditional compilation.
+ Conditional compilation should include the conditional logic and all comments associated with the conditional logic.
+ In this case, the blank line appears before the conditional, not after it.
@@ -416,6 +419,12 @@
a = b;
/* set b equal to c */
b = c;
+
+ /* Do the impossible */
+
+#ifdef CONFIG_THE_IMPOSSIBLE
+ the_impossible();
+#endif
|
@@ -430,6 +439,11 @@
b = c;
+#ifdef CONFIG_THE_IMPOSSIBLE
+ /* Do the impossible */
+
+ the_impossible();
+#endif
|
@@ -1611,7 +1625,7 @@ enum xyz_state_e
Lowercase Exceptions.
- There are3 a few lower case values in NuttX macro names. Such as a lower-case p
for a period or decimal point (such as VOLTAGE_3p3V
).
+ There are a few lower case values in NuttX macro names. Such as a lower-case p
for a period or decimal point (such as VOLTAGE_3p3V
).
I have also used lower-case v
for a version number (such as CONFIG_NET_IPv6
).
However, these are exceptions to the rule rather than illustrating a rule.
diff --git a/Documentation/README.html b/Documentation/README.html
index 727b2f3684..726f4aa3cf 100644
--- a/Documentation/README.html
+++ b/Documentation/README.html
@@ -208,6 +208,8 @@ nuttx/
| | `- README.txt
| |- pic32mz-starterkit/
| | `- README.txt
+ | |- photon/
+ | | `- README.txt
| |- qemu-i486/
| | `- README.txt
| |- sabre-6quad/
diff --git a/README.txt b/README.txt
index f06800339f..334b501e51 100644
--- a/README.txt
+++ b/README.txt
@@ -1580,6 +1580,8 @@ nuttx/
| | `- README.txt
| |- pic32mz-starterkit/
| | `- README.txt
+ | |- photon/
+ | | `- README.txt
| |- qemu-i486/
| | `- README.txt
| |- sabre-6quad/
diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig
index e36b54673e..a74bfafc59 100644
--- a/arch/arm/src/stm32/Kconfig
+++ b/arch/arm/src/stm32/Kconfig
@@ -6165,6 +6165,19 @@ if STM32_SERIALDRIVER
comment "Serial Driver Configuration"
+config STM32_SERIAL_RXDMA_BUFFER_SIZE
+ int "Rx DMA buffer size"
+ default 32
+ range 32 4096
+ depends on USART1_RXDMA || USART2_RXDMA || USART3_RXDMA || UART4_RXDMA || UART5_RXDMA || USART6_RXDMA || UART7_RXDMA || UART8_RXDMA
+ ---help---
+ The DMA buffer size when using RX DMA to emulate a FIFO.
+
+ When streaming data, the generic serial layer will be called
+ every time the FIFO receives half or this number of bytes.
+
+ Value given here will be rounded up to next multiple of 4 bytes.
+
config SERIAL_DISABLE_REORDERING
bool "Disable reordering of ttySx devices."
depends on STM32_USART1 || STM32_USART2 || STM32_USART3 || STM32_UART4 || STM32_UART5 || STM32_USART6 || STM32_UART7 || STM32_UART8
diff --git a/arch/arm/src/stm32/stm32_freerun.c b/arch/arm/src/stm32/stm32_freerun.c
index 673b0412d7..f631aa0aa5 100644
--- a/arch/arm/src/stm32/stm32_freerun.c
+++ b/arch/arm/src/stm32/stm32_freerun.c
@@ -137,6 +137,7 @@ int stm32_freerun_initialize(struct stm32_freerun_s *freerun, int chan,
*/
freerun->chan = chan;
+ freerun->width = STM32_TIM_GETWIDTH(freerun->tch);
freerun->running = false;
#ifdef CONFIG_CLOCK_TIMEKEEPING
@@ -153,7 +154,7 @@ int stm32_freerun_initialize(struct stm32_freerun_s *freerun, int chan,
/* Set timer period */
- STM32_TIM_SETPERIOD(freerun->tch, UINT32_MAX);
+ STM32_TIM_SETPERIOD(freerun->tch, (uint32_t)((1ull << freerun->width) - 1));
/* Start the counter */
@@ -248,7 +249,8 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun,
* usecs = (ticks * USEC_PER_SEC) / frequency;
*/
- usec = ((((uint64_t)overflow << 32) + (uint64_t)counter) * USEC_PER_SEC) /
+ usec = ((((uint64_t)overflow << freerun->width) +
+ (uint64_t)counter) * USEC_PER_SEC) /
freerun->frequency;
/* And return the value of the timer */
diff --git a/arch/arm/src/stm32/stm32_freerun.h b/arch/arm/src/stm32/stm32_freerun.h
index bc7609666c..b263367d16 100644
--- a/arch/arm/src/stm32/stm32_freerun.h
+++ b/arch/arm/src/stm32/stm32_freerun.h
@@ -63,6 +63,7 @@
struct stm32_freerun_s
{
uint8_t chan; /* The timer/counter in use */
+ uint8_t width; /* Width of timer (16- or 32-bits) */
bool running; /* True: the timer is running */
FAR struct stm32_tim_dev_s *tch; /* Handle returned by stm32_tim_init() */
uint32_t frequency;
diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c
index 6b6161f0ce..6425cd2d91 100644
--- a/arch/arm/src/stm32/stm32_serial.c
+++ b/arch/arm/src/stm32/stm32_serial.c
@@ -182,8 +182,14 @@
* When streaming data, the generic serial layer will be called
* every time the FIFO receives half this number of bytes.
*/
-
-# define RXDMA_BUFFER_SIZE 32
+# if !defined(CONFIG_STM32_SERIAL_RXDMA_BUFFER_SIZE)
+# define CONFIG_STM32_SERIAL_RXDMA_BUFFER_SIZE 32
+# endif
+# define RXDMA_MUTIPLE 4
+# define RXDMA_MUTIPLE_MASK (RXDMA_MUTIPLE -1)
+# define RXDMA_BUFFER_SIZE ((CONFIG_STM32_SERIAL_RXDMA_BUFFER_SIZE \
+ + RXDMA_MUTIPLE_MASK) \
+ & ~RXDMA_MUTIPLE_MASK))
/* DMA priority */
diff --git a/arch/arm/src/stm32/stm32_tim.c b/arch/arm/src/stm32/stm32_tim.c
index 5590992827..d4a4ed2559 100644
--- a/arch/arm/src/stm32/stm32_tim.c
+++ b/arch/arm/src/stm32/stm32_tim.c
@@ -334,22 +334,23 @@ static void stm32_tim_gpioconfig(uint32_t cfg, stm32_tim_channel_t mode);
/* Timer methods */
-static int stm32_tim_setmode(FAR struct stm32_tim_dev_s *dev, stm32_tim_mode_t mode);
-static int stm32_tim_setclock(FAR struct stm32_tim_dev_s *dev, uint32_t freq);
+static int stm32_tim_setmode(FAR struct stm32_tim_dev_s *dev, stm32_tim_mode_t mode);
+static int stm32_tim_setclock(FAR struct stm32_tim_dev_s *dev, uint32_t freq);
static void stm32_tim_setperiod(FAR struct stm32_tim_dev_s *dev,
uint32_t period);
static uint32_t stm32_tim_getcounter(FAR struct stm32_tim_dev_s *dev);
-static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
- stm32_tim_channel_t mode);
-static int stm32_tim_setcompare(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
- uint32_t compare);
-static int stm32_tim_getcapture(FAR struct stm32_tim_dev_s *dev, uint8_t channel);
-static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev, xcpt_t handler,
- void *arg, int source);
+static int stm32_tim_getwidth(FAR struct stm32_tim_dev_s *dev);
+static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
+ stm32_tim_channel_t mode);
+static int stm32_tim_setcompare(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
+ uint32_t compare);
+static int stm32_tim_getcapture(FAR struct stm32_tim_dev_s *dev, uint8_t channel);
+static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev, xcpt_t handler,
+ void *arg, int source);
static void stm32_tim_enableint(FAR struct stm32_tim_dev_s *dev, int source);
static void stm32_tim_disableint(FAR struct stm32_tim_dev_s *dev, int source);
static void stm32_tim_ackint(FAR struct stm32_tim_dev_s *dev, int source);
-static int stm32_tim_checkint(FAR struct stm32_tim_dev_s *dev, int source);
+static int stm32_tim_checkint(FAR struct stm32_tim_dev_s *dev, int source);
/************************************************************************************
* Private Data
@@ -361,6 +362,7 @@ static const struct stm32_tim_ops_s stm32_tim_ops =
.setclock = stm32_tim_setclock,
.setperiod = stm32_tim_setperiod,
.getcounter = stm32_tim_getcounter,
+ .getwidth = stm32_tim_getwidth,
.setchannel = stm32_tim_setchannel,
.setcompare = stm32_tim_setcompare,
.getcapture = stm32_tim_getcapture,
@@ -904,6 +906,41 @@ static uint32_t stm32_tim_getcounter(FAR struct stm32_tim_dev_s *dev)
return stm32_getreg32(dev, STM32_BTIM_CNT_OFFSET);
}
+/************************************************************************************
+ * Name: stm32_tim_getwidth
+ ************************************************************************************/
+
+static int stm32_tim_getwidth(FAR struct stm32_tim_dev_s *dev)
+{
+ /* Only TIM2 and TIM5 timers may be 32-bits in width
+ *
+ * Reference Table 2 of en.DM00042534.pdf
+ */
+
+ switch (((struct stm32_tim_priv_s *)dev)->base)
+ {
+ /* TIM2 is 32-bits on all except F10x, L0x, and L1x lines */
+
+#if defined(CONFIG_STM32_TIM2) && !defined(STM32_STM32F10XX) && \
+ !defined(STM32_STM32L15XX)
+ case STM32_TIM2_BASE:
+ return 32;
+#endif
+
+ /* TIM5 is 32-bits on all except F10x lines */
+
+#if defined(CONFIG_STM32_TIM5) && !defined(STM32_STM32F10XX)
+ case STM32_TIM5_BASE:
+ return 32;
+#endif
+
+ /* All others are 16-bit times */
+
+ default:
+ return 16;
+ }
+}
+
/************************************************************************************
* Name: stm32_tim_setchannel
************************************************************************************/
diff --git a/arch/arm/src/stm32/stm32_tim.h b/arch/arm/src/stm32/stm32_tim.h
index 921baebc6c..5b9422f3ee 100644
--- a/arch/arm/src/stm32/stm32_tim.h
+++ b/arch/arm/src/stm32/stm32_tim.h
@@ -61,6 +61,7 @@
#define STM32_TIM_SETCLOCK(d,freq) ((d)->ops->setclock(d,freq))
#define STM32_TIM_SETPERIOD(d,period) ((d)->ops->setperiod(d,period))
#define STM32_TIM_GETCOUNTER(d) ((d)->ops->getcounter(d))
+#define STM32_TIM_GETWIDTH(d) ((d)->ops->getwidth(d))
#define STM32_TIM_SETCHANNEL(d,ch,mode) ((d)->ops->setchannel(d,ch,mode))
#define STM32_TIM_SETCOMPARE(d,ch,comp) ((d)->ops->setcompare(d,ch,comp))
#define STM32_TIM_GETCAPTURE(d,ch) ((d)->ops->getcapture(d,ch))
@@ -166,6 +167,7 @@ struct stm32_tim_ops_s
/* General and Advanced Timers Adds */
+ int (*getwidth)(FAR struct stm32_tim_dev_s *dev);
int (*setchannel)(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
stm32_tim_channel_t mode);
int (*setcompare)(FAR struct stm32_tim_dev_s *dev, uint8_t channel,
diff --git a/configs/photon/README.txt b/configs/photon/README.txt
new file mode 100644
index 0000000000..779226e632
--- /dev/null
+++ b/configs/photon/README.txt
@@ -0,0 +1,125 @@
+README
+======
+
+ This README discusses issues unique to NuttX configurations for the
+ Particle.io Photon board featuring the STM32F205RG MCU.
+ The STM32F205RG is a 120 MHz Cortex-M3 operation with 1Mbit Flash
+ memory and 128kbytes. The board includes a Broadcom BCM43362 WiFi.
+
+Contents
+========
+
+ - Selecting the Photon board on NuttX
+ - Configuring NuttX to use your Wireless Router (aka Access Point)
+ - Flashing NuttX in the Photon board
+ - Serial console configuration
+
+Selecting the Photon board on NuttX
+===================================
+
+ NOTICE: We will not discuss about toolchains and environment configuration
+ here, please take a look at STM32F4Discory board README or other STM32 board
+ because it should work for Photon board as well.
+
+ Let us to consider that you cloned the nuttx and apps repositories, then
+ follow these steps:
+
+ 1) Clear your build system before to start:
+
+ $ make apps_distclean
+ $ make distclean
+
+ 2) Enter inside nuttx/tools and configure to use the Photon board:
+
+ $ cd nuttx
+ $ cd tools
+ $ ./configure.sh photon/wlan
+
+ Now please return to root of nuttx/ directory:
+
+ $ cd ..
+
+Configuring NuttX to use your Wireless Router (aka Access Point)
+================================================================
+
+ Since you are already in the root of nuttx/ repository, execute
+ make menuconfig to define your Wireless Router and your password:
+
+ $ make menuconfig
+
+ Browser the menus this way:
+
+ Application Configuration --->
+ NSH Library --->
+ Networking Configuration --->
+ WAPI Configuration --->
+ (myApSSID) SSID
+ (mySSIDpassphrase) Passprhase
+
+ Replace the SSID from myApSSID with your wireless router name and
+ the Passprhase with your WiFi password.
+
+ Exit and save your configuration.
+
+ Finally just compile NuttX:
+
+ $ make
+
+Flashing NuttX in the Photon board
+==================================
+
+ Connect the Photon board in your computer using a MicroUSB cable. Press and
+ hold both board's buttons (SETUP and RESET), then release the RESET button,
+ the board will start blinking in the Purple color, waiting until it starts
+ blinking in Yellow color. Now you can release the SETUP button as well.
+
+ 1) You can verify if DFU mode in your board is working, using this command:
+
+ $ sudo dfu-util -l
+ dfu-util 0.8
+
+ Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
+ Copyright 2010-2014 Tormod Volden and Stefan Schmidt
+ This program is Free Software and has ABSOLUTELY NO WARRANTY
+ Please report bugs to dfu-util@lists.gnumonks.org
+
+ Found DFU: [2b04:d006] ver=0200, devnum=15, cfg=1, intf=0, alt=1, name="@DCT Flash /0x00000000/01*016Kg", serial="00000000010C"
+ Found DFU: [2b04:d006] ver=0200, devnum=15, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg", serial="00000000010C"
+
+ 2) Flash the nuttx.bin inside the Internal Flash:
+
+ $ sudo dfu-util -d 2b04:d006 -a 0 -s 0x08020000 -D nuttx.bin
+
+ dfu-util 0.8
+
+ Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
+ Copyright 2010-2014 Tormod Volden and Stefan Schmidt
+ This program is Free Software and has ABSOLUTELY NO WARRANTY
+ Please report bugs to dfu-util@lists.gnumonks.org
+
+ dfu-util: Invalid DFU suffix signature
+ dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
+ Opening DFU capable USB device...
+ ID 2b04:d006
+ Run-time device DFU version 011a
+ Claiming USB DFU Interface...
+ Setting Alternate Setting #0 ...
+ Determining device status: state = dfuIDLE, status = 0
+ dfuIDLE, continuing
+ DFU mode device DFU version 011a
+ Device returned transfer size 4096
+ DfuSe interface name: "Internal Flash "
+ Downloading to address = 0x08020000, size = 331348
+ Download [=========================] 100% 331348 bytes
+ Download done.
+ File downloaded successfully
+
+
+Serial console configuration
+============================
+
+ Connect a USB/Serial 3.3V dongle to GND, TX and RX pins of Photon board.
+ Then use some serial console client (minicom, picocom, teraterm, etc) confi-
+ gured to 115200 8n1 without software or hardware flow control.
+
+ Reset the board and you should see NuttX starting in the serial.