From 3fb0a00c356d39f7ea2b4a330868941711eee987 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 22 Mar 2017 17:32:52 -0600 Subject: [PATCH 01/22] Small changes from review of last PR. Plus spacing and typo fix. --- arch/arm/src/stm32/Kconfig | 6 +++--- arch/arm/src/stm32/chip/stm32_flash.h | 24 ++++++++++++------------ configs/Makefile | 2 +- include/semaphore.h | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 9e3ce56127f..557f8434f01 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -2629,9 +2629,9 @@ config STM32_FLASH_PREFETCH default y if STM32_STM32F427 || STM32_STM32F429 || STM32_STM32F446 default n ---help--- - Enable FLASH prefetch and F2 and F4 parts (FLASH pre-fetch is always enabled - on F1 parts). Some early revisions of F4 parts do not support FLASH pre-fetch - properly and enabling this option may interfere with ADC accuracy. + Enable FLASH prefetch and F2 and F4 parts (FLASH pre-fetch is always enabled + on F1 parts). Some early revisions of F4 parts do not support FLASH pre-fetch + properly and enabling this option may interfere with ADC accuracy. config STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW bool "Workaround for FLASH data cache corruption" diff --git a/arch/arm/src/stm32/chip/stm32_flash.h b/arch/arm/src/stm32/chip/stm32_flash.h index 32eeaf90dd8..6bc1085bd18 100644 --- a/arch/arm/src/stm32/chip/stm32_flash.h +++ b/arch/arm/src/stm32/chip/stm32_flash.h @@ -324,10 +324,10 @@ # define FLASH_CR_OBL_LAUNCH (1 << 13) /* Bit 13: Force option byte loading */ # endif #elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) -# define FLASH_CR_PG (1 << 0) /* Bit 0: Programming */ -# define FLASH_CR_SER (1 << 1) /* Bit 1: Sector Erase */ -# define FLASH_CR_MER (1 << 2) /* Bit 2: Mass Erase sectors 0..11 */ -# define FLASH_CR_SNB_SHIFT (3) /* Bits 3-6: Sector number */ +# define FLASH_CR_PG (1 << 0) /* Bit 0: Programming */ +# define FLASH_CR_SER (1 << 1) /* Bit 1: Sector Erase */ +# define FLASH_CR_MER (1 << 2) /* Bit 2: Mass Erase sectors 0..11 */ +# define FLASH_CR_SNB_SHIFT (3) /* Bits 3-6: Sector number */ #if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) # define FLASH_CR_SNB_MASK (31 << FLASH_CR_SNB_SHIFT) # define FLASH_CR_SNB(n) (((n % 12) << FLASH_CR_SNB_SHIFT) | ((n / 12) << 7)) /* Sector n, n=0..23 */ @@ -335,19 +335,19 @@ # define FLASH_CR_SNB_MASK (15 << FLASH_CR_SNB_SHIFT) # define FLASH_CR_SNB(n) ((n) << FLASH_CR_SNB_SHIFT) /* Sector n, n=0..11 */ #endif -# define FLASH_CR_PSIZE_SHIFT (8) /* Bits 8-9: Program size */ +# define FLASH_CR_PSIZE_SHIFT (8) /* Bits 8-9: Program size */ # define FLASH_CR_PSIZE_MASK (3 << FLASH_CR_PSIZE_SHIFT) # define FLASH_CR_PSIZE_X8 (0 << FLASH_CR_PSIZE_SHIFT) /* 00 program x8 */ # define FLASH_CR_PSIZE_X16 (1 << FLASH_CR_PSIZE_SHIFT) /* 01 program x16 */ # define FLASH_CR_PSIZE_X32 (2 << FLASH_CR_PSIZE_SHIFT) /* 10 program x32 */ # define FLASH_CR_PSIZE_X64 (3 << FLASH_CR_PSIZE_SHIFT) /* 11 program x64 */ -# define FLASH_CR_STRT (1 << 16) /* Bit 16: Start Erase */ -# define FLASH_CR_EOPIE (1 << 24) /* Bit 24: End of operation interrupt enable */ -# define FLASH_CR_ERRIE (1 << 25) /* Bit 25: Error interrupt enable */ -# define FLASH_CR_LOCK (1 << 31) /* Bit 31: Lock */ +# define FLASH_CR_STRT (1 << 16) /* Bit 16: Start Erase */ +# define FLASH_CR_EOPIE (1 << 24) /* Bit 24: End of operation interrupt enable */ +# define FLASH_CR_ERRIE (1 << 25) /* Bit 25: Error interrupt enable */ +# define FLASH_CR_LOCK (1 << 31) /* Bit 31: Lock */ #endif #if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) -# define FLASH_CR_MER1 (1 << 15) /* Bit 15: Mass Erase sectors 12..23 */ +# define FLASH_CR_MER1 (1 << 15) /* Bit 15: Mass Erase sectors 12..23 */ #endif /* Flash Option Control Register (OPTCR) */ @@ -375,7 +375,7 @@ /* Flash Option Control Register (OPTCR1) */ #if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) -# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-27: Not write protect (high bank) */ +# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-27: Not write protect (high bank) */ # define FLASH_OPTCR1_NWRP_MASK (0xfff << FLASH_OPTCR_NWRP_SHIFT) # define FLASH_OPTCR1_BFB2_SHIFT (4) /* Bits 4: Dual-bank Boot option byte */ @@ -384,7 +384,7 @@ #endif #if defined(CONFIG_STM32_STM32F446) -# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-23: Not write protect (high bank) */ +# define FLASH_OPTCR1_NWRP_SHIFT (16) /* Bits 16-23: Not write protect (high bank) */ # define FLASH_OPTCR1_NWRP_MASK (0xff << FLASH_OPTCR_NWRP_SHIFT) #endif diff --git a/configs/Makefile b/configs/Makefile index f430e137e88..31de5604e08 100644 --- a/configs/Makefile +++ b/configs/Makefile @@ -89,7 +89,7 @@ OBJS = $(AOBJS) $(COBJS) BIN = libconfigs$(LIBEXT) all: $(BIN) -.PHONY: depend ccontext clean_context clean distclean +.PHONY: depend context clean_context clean distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) diff --git a/include/semaphore.h b/include/semaphore.h index 0056909db6a..e14b1aa409e 100644 --- a/include/semaphore.h +++ b/include/semaphore.h @@ -105,14 +105,14 @@ typedef struct sem_s sem_t; #ifdef CONFIG_PRIORITY_INHERITANCE # if CONFIG_SEM_PREALLOCHOLDERS > 0 # define SEM_INITIALIZER(c) \ - {(c), 0, NULL} /* semcount, flags, hhead */ + {(c), 0, NULL} /* semcount, flags, hhead */ # else # define SEM_INITIALIZER(c) \ {(c), 0, {SEMHOLDER_INITIALIZER, SEMHOLDER_INITIALIZER}} /* semcount, flags, holder[2] */ # endif #else # define SEM_INITIALIZER(c) \ - {(c)} /* semcount */ + {(c)} /* semcount */ #endif /**************************************************************************** From c73b65c9b9ad777b122cf99eecb2c559a1420b79 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 22 Mar 2017 23:56:54 +0000 Subject: [PATCH 02/22] stm32f7:stm32_allocateheap.c There are 5 configurations --- arch/arm/src/stm32f7/stm32_allocateheap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/stm32f7/stm32_allocateheap.c b/arch/arm/src/stm32f7/stm32_allocateheap.c index ffa6d27455b..4714b53f3d5 100644 --- a/arch/arm/src/stm32f7/stm32_allocateheap.c +++ b/arch/arm/src/stm32f7/stm32_allocateheap.c @@ -126,7 +126,7 @@ # endif #endif -/* There are 4 possible heap configurations: +/* There are 5 possible heap configurations: * * Configuration 1. System SRAM1 (only) * CONFIG_MM_REGIONS == 1 From 45f5d30e2eccd1da4f7e5253d1ac637d4cecd02d Mon Sep 17 00:00:00 2001 From: no1wudi <757509347@qq.com> Date: Thu, 23 Mar 2017 13:38:26 +0800 Subject: [PATCH 03/22] fix compile error when disabled the flash data cache corruption for stm32 f1xx --- arch/arm/src/stm32/stm32_flash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c index 8ba48a82623..f955085a27b 100644 --- a/arch/arm/src/stm32/stm32_flash.c +++ b/arch/arm/src/stm32/stm32_flash.c @@ -127,6 +127,7 @@ static void flash_lock(void) { modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_LOCK); } +#if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW) static void data_cache_disable(void) { @@ -144,6 +145,7 @@ static void data_cache_enable(void) modifyreg32(STM32_FLASH_ACR, 0, FLASH_ACR_DCEN); } +#endif /************************************************************************************ * Public Functions ************************************************************************************/ From 06af125e45c721a9191348466fb692bf8daaefa3 Mon Sep 17 00:00:00 2001 From: Aleksandr Vyhovanec Date: Thu, 23 Mar 2017 17:34:45 +0300 Subject: [PATCH 04/22] The interrupt occurs over the counter overflow --- arch/arm/src/stm32/stm32_qencoder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c index e2245075b91..126ef24987c 100644 --- a/arch/arm/src/stm32/stm32_qencoder.c +++ b/arch/arm/src/stm32/stm32_qencoder.c @@ -693,17 +693,17 @@ static int stm32_interrupt(int irq, FAR void *context, FAR void *arg) stm32_putreg16(priv, STM32_GTIM_SR_OFFSET, regval & ~GTIM_SR_UIF); /* Check the direction bit in the CR1 register and add or subtract the - * maximum value, as appropriate. + * maximum value + 1, as appropriate. */ regval = stm32_getreg16(priv, STM32_GTIM_CR1_OFFSET); if ((regval & ATIM_CR1_DIR) != 0) { - priv->position -= (int32_t)0x0000ffff; + priv->position -= (int32_t)0x00010000; } else { - priv->position += (int32_t)0x0000ffff; + priv->position += (int32_t)0x00010000; } return OK; From 2ec72c8f9421c17682ff4229bbeb5ea6275a8bf0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 23 Mar 2017 11:17:17 -0600 Subject: [PATCH 05/22] Clicker2-STM32: Add a README file --- Documentation/README.html | 4 +- README.txt | 2 + configs/clicker2-stm32/README.txt | 160 ++++++++++++++++++++++++ configs/clicker2-stm32/nsh/defconfig | 4 +- configs/clicker2-stm32/scripts/flash.ld | 3 +- 5 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 configs/clicker2-stm32/README.txt diff --git a/Documentation/README.html b/Documentation/README.html index 4430ef211f7..01a27ce6446 100644 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -8,7 +8,7 @@

NuttX README Files

-

Last Updated: March 21, 2017

+

Last Updated: March 23, 2017

@@ -68,6 +68,8 @@ nuttx/ | | `- README.txt | |- cc3200-launchpad/ | | `- README.txt + | |- clicker2-stm32/ + | | `- README.txt | |- cloudctrl/ | | `- README.txt | |- demo9s12ne64/ diff --git a/README.txt b/README.txt index 4bab1306ff7..3db07e882ac 100644 --- a/README.txt +++ b/README.txt @@ -1453,6 +1453,8 @@ nuttx/ | | `- README.txt | |- cc3200-launchpad/ | | `- README.txt + | |- clicker2-stm32 + | | `- README.txt | |- cloudctrl | | `- README.txt | |- demo0s12ne64/ diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt new file mode 100644 index 00000000000..935ea412015 --- /dev/null +++ b/configs/clicker2-stm32/README.txt @@ -0,0 +1,160 @@ +README +====== + + This is the README file for the port of NuttX to the Mikroe Clicker2 STM32 + board based on the STMicro STM32F407VGT6 MCU. + + Reference: https://shop.mikroe.com/development-boards/starter/clicker-2/stm32f4 + +Serial Console +============== + + The are no RS-232 drivers on-board. An RS-232 Click board is available: + https://shop.mikroe.com/click/interface/rs232 or you can cannot an off- + board TTL-to-RS-232 converter as follows: + + USART2: mikroBUS1 PD6/RX and PD5/TX + USART3: mikroBUS2 PD9/RX and PD8TX + + GND, 3.3V, and 5V. Are also available + + By default, USART3 on mikroBUS2 is used as the serial console in each + configuration unless stated otherwise in the description of the + configuration. + +LEDs +==== + + The Mikroe Clicker2 STM32 has two user controllable LEDs: + + LD1/PE12, Active high output illuminates + LD2/PE15, Active high output illuminates + + If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any + way. If CONFIG_ARCH_LEDs is defined, then NuttX will control the 2 LEDs on + board the Clicker2 for STM32. The following definitions describe how NuttX + controls the LEDs: + + SYMBOL Meaning LED state + LD1 LD2 + ------------------- ----------------------- -------- -------- + LED_STARTED NuttX has been started OFF OFF + LED_HEAPALLOCATE Heap has been allocated OFF OFF + LED_IRQSENABLED Interrupts enabled OFF OFF + LED_STACKCREATED Idle stack created ON OFF + LED_INIRQ In an interrupt N/C ON + LED_SIGNAL In a signal handler No change + LED_ASSERTION An assertion failed No change + LED_PANIC The system has crashed OFF Blinking + LED_IDLE STM32 is is sleep mode Not used + + Thus is LD1 is illuminated, the Clicker2 has completed boot-up. IF LD2 + is glowly softly, then interrupts are being taken; the level of illumination + depends amount of time processing interupts. If LD1 is off and LD2 is + blinking at about 2Hz, then the system has crashed. + +Buttons +======= + + The Mikroe Clicker2 STM32 has two buttons available to software: + + T2/E0, Low sensed when pressed + T3/PA10, Low sensed when pressed + +onfigurations +============== + + Information Common to All Configurations + ---------------------------------------- + Each Clicker2 configuration is maintained in a sub-directory and can be + selected as follow: + + cd tools + ./configure.sh clicker2-stm32/ + cd - + . ./setenv.sh + + Before sourcing the setenv.sh file above, you should examine it and + perform edits as necessary so that TOOLCHAIN_BIN is the correct path + to the directory than holds your toolchain binaries. + + And then build NuttX by simply typing the following. At the conclusion of + the make, the nuttx binary will reside in an ELF file called, simply, nuttx. + + make oldconfig + make + + The that is provided above as an argument to the tools/configure.sh + must be is one of the following. + + NOTES: + + 1. These configurations use the mconf-based configuration tool. To + change any of these configurations using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + see additional README.txt files in the NuttX tools repository. + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. Unless stated otherwise, all configurations generate console + output on USART3, channel 0) as described above under "Serial + Console". The relevant configuration settings are listed below: + + CONFIG_STM32_USART3=y + CONFIG_STM32_USART3_SERIALDRIVER=y + CONFIG_STM32_USART=y + + CONFIG_USART3_SERIALDRIVER=y + CONFIG_USART3_SERIAL_CONSOLE=y + + CONFIG_USART3_RXBUFSIZE=256 + CONFIG_USART3_TXBUFSIZE=256 + CONFIG_USART3_BAUD=115200 + CONFIG_USART3_BITS=8 + CONFIG_USART3_PARITY=0 + CONFIG_USART3_2STOP=0 + + + 3. All of these configurations are set up to build under Linux using the + "GNU Tools for ARM Embedded Processors" that is maintained by ARM + (unless stated otherwise in the description of the configuration). + + https://launchpad.net/gcc-arm-embedded + + That toolchain selection can easily be reconfigured using + 'make menuconfig'. Here are the relevant current settings: + + Build Setup: + CONFIG_HOST_LINUX =y : Linux environment + + System Type -> Toolchain: + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + + Configuration sub-directories + ----------------------------- + + nsh: + + Configures the NuttShell (nsh) located at examples/nsh. This + configuration is focused on low level, command-line driver testing. It + has no network. + + NOTES: + + 1. Support for NSH built-in applications is provided: + + Binary Formats: + CONFIG_BUILTIN=y : Enable support for built-in programs + + Application Configuration: + CONFIG_NSH_BUILTIN_APPS=y : Enable starting apps from NSH command line + + No built applications are enabled in the base configuration, however. + + 2. C++ support for applications is enabled: + + CONFIG_HAVE_CXX=y + CONFIG_HAVE_CXXINITIALIZE=y + CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y diff --git a/configs/clicker2-stm32/nsh/defconfig b/configs/clicker2-stm32/nsh/defconfig index 7ae63061f9c..764b16372c6 100644 --- a/configs/clicker2-stm32/nsh/defconfig +++ b/configs/clicker2-stm32/nsh/defconfig @@ -144,10 +144,10 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y # CONFIG_ARMV7M_HAVE_ITCM is not set # CONFIG_ARMV7M_HAVE_DTCM is not set # CONFIG_ARMV7M_TOOLCHAIN_IARL is not set -CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set # CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set -# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y # CONFIG_ARMV7M_OABI_TOOLCHAIN is not set CONFIG_ARMV7M_HAVE_STACKCHECK=y # CONFIG_ARMV7M_STACKCHECK is not set diff --git a/configs/clicker2-stm32/scripts/flash.ld b/configs/clicker2-stm32/scripts/flash.ld index ca2e7eefcfc..6bb3aabaddf 100644 --- a/configs/clicker2-stm32/scripts/flash.ld +++ b/configs/clicker2-stm32/scripts/flash.ld @@ -42,8 +42,7 @@ * * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 * where the code expects to begin execution by jumping to the entry point in - * the 0x0800:0000 address - * range. + * the 0x0800:0000 address range. */ MEMORY From 9353ca6039930d4b497f963e1912fb416b06b0a9 Mon Sep 17 00:00:00 2001 From: rg Date: Thu, 23 Mar 2017 11:24:18 -0600 Subject: [PATCH 06/22] STM32 I2C: Do not allow CONFIG_I2C_POLLED and CONFIG_I2C_DMA --- arch/arm/src/stm32/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 557f8434f01..eba911dfc56 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -6201,12 +6201,11 @@ config STM32_I2C_DUTY16_9 config STM32_I2C_DMA bool "I2C DMA Support" default n - depends on STM32_I2C && STM32_STM32F40XX && STM32_DMA1 + depends on STM32_I2C && STM32_STM32F40XX && STM32_DMA1 && !I2C_POLLED ---help--- This option enables the DMA for I2C transfers. Note: The user can define CONFIG_I2C_DMAPRIO: a custom priority value for the I2C dma streams, else the default priority level is set to medium. - Note: This option is compatible with CONFIG_I2C_POLLED. endmenu From 123a057be9c78147394a3f9463af875249c36c3a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 23 Mar 2017 11:43:32 -0600 Subject: [PATCH 07/22] Update README --- configs/clicker2-stm32/README.txt | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index 935ea412015..f97be665d43 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -6,6 +6,15 @@ README Reference: https://shop.mikroe.com/development-boards/starter/clicker-2/stm32f4 +Contents +======== + + o Serial Console + o LEDs + o Buttons + o Using JTAG + o Configurations + Serial Console ============== @@ -61,7 +70,30 @@ Buttons T2/E0, Low sensed when pressed T3/PA10, Low sensed when pressed -onfigurations +Using JTAG +========== + + The Clicker2 comes with the mikroBootloader installed. But it also offers + a 2x5 JTAG connector. You may use Dupont jumpers to connect this port to + JTAG as described here: + + https://www.mikroe.com/how-to-use-st-link-v2-with-clicker-2-for-stm32-a-detailed-walkthrough/ + http://www.playembedded.org/blog/en/2016/02/06/mikroe-clicker-2-for-stm32-and-stlink-v2/ + + NOTE that the FLASH is locked. You may need to follow the instructions at + the second link to unlock it (although I think you can do this with the ST-Micro + ST-Link Utility as well). + + You can avoid the mess of jumpers using the mikroProg to ST-Link v2 adapte + along with a 2x5, 10-wire ribbon cable connector: + + https://shop.mikroe.com/add-on-boards/adapter/mikroprog-st-link-v2-adapter + + OpenOCD can be used with the ST-Link to provide a debug environment. I suspect, + however, that adapter can be used with other JTAG debuggers such as J-Link, + but that remains to be verified. + +Configurations ============== Information Common to All Configurations From 20b8ccd9d451ee28c8aa87b3a067f445b9bd2692 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 23 Mar 2017 13:43:48 -0600 Subject: [PATCH 08/22] More updates to README.txt --- configs/clicker2-stm32/README.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index f97be665d43..14046a208b0 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -73,18 +73,25 @@ Buttons Using JTAG ========== - The Clicker2 comes with the mikroBootloader installed. But it also offers - a 2x5 JTAG connector. You may use Dupont jumpers to connect this port to - JTAG as described here: + The Clicker2 comes with the mikroBootloader installed. That bootloader + has not been used and is possibly incompatible with the Clicker2-STM32 + linker script at configs/clicker2-stm32/scripts/flash.ld. Often code must + be built to execute at an offset in to FLASH when a bootloader is used. + Certainly that is the case for the ST-Micro DFU bootloader but I am not + aware of the requirements for use with the mikroBootloader. + + JTAG has been used in the development of this board support. The + Clicker2-STM32 board offers a 2x5 JTAG connector. You may use Dupont + jumpers to connect this port to JTAG as described here: https://www.mikroe.com/how-to-use-st-link-v2-with-clicker-2-for-stm32-a-detailed-walkthrough/ http://www.playembedded.org/blog/en/2016/02/06/mikroe-clicker-2-for-stm32-and-stlink-v2/ NOTE that the FLASH is locked. You may need to follow the instructions at - the second link to unlock it (although I think you can do this with the ST-Micro - ST-Link Utility as well). + the second link to unlock it (although I think you may be able to do this + with the ST-Micro ST-Link Utility as well). - You can avoid the mess of jumpers using the mikroProg to ST-Link v2 adapte + You can avoid the mess of jumpers using the mikroProg to ST-Link v2 adapter along with a 2x5, 10-wire ribbon cable connector: https://shop.mikroe.com/add-on-boards/adapter/mikroprog-st-link-v2-adapter From c2a1b719be908673377454d5634a8d2e19bdbabf Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 23 Mar 2017 11:33:32 -1000 Subject: [PATCH 09/22] stm32_flash:Need conditinal on non F4 targets --- arch/arm/src/stm32/stm32_flash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c index 8ba48a82623..3b4ebd8a100 100644 --- a/arch/arm/src/stm32/stm32_flash.c +++ b/arch/arm/src/stm32/stm32_flash.c @@ -128,6 +128,7 @@ static void flash_lock(void) modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_LOCK); } +#if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW) static void data_cache_disable(void) { modifyreg32(STM32_FLASH_ACR, FLASH_ACR_DCEN, 0); @@ -143,6 +144,7 @@ static void data_cache_enable(void) modifyreg32(STM32_FLASH_ACR, 0, FLASH_ACR_DCEN); } +#endif /************************************************************************************ * Public Functions From f5cf22d871c04891a79f7e1059f739649b07b528 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 23 Mar 2017 11:36:44 -1000 Subject: [PATCH 10/22] stm32_i2c_alt:Duplicate non CS dev of regval --- arch/arm/src/stm32/stm32_i2c_alt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index 9112b084076..ca64656d8c7 100644 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -1867,7 +1867,6 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) #else /* Clear all interrupts */ - uint32_t regval; regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET); regval &= ~I2C_CR2_ALLINTS; stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval); From d25f8710d2085fb05a348634fe44ef7c6f68a01e Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 23 Mar 2017 11:37:12 -1000 Subject: [PATCH 11/22] stm32f40xxx_i2c:Duplicate non CS dev of regval --- arch/arm/src/stm32/stm32f40xxx_i2c.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c index 3d7d5567f89..8d3a9fa84de 100644 --- a/arch/arm/src/stm32/stm32f40xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c @@ -2015,7 +2015,6 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) #else /* Clear all interrupts */ - uint32_t regval; regval = stm32_i2c_getreg(priv, STM32_I2C_CR2_OFFSET); regval &= ~I2C_CR2_ALLINTS; stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval); From 7e3bec635b3e9591569be75a933bc8139a03b443 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 23 Mar 2017 11:50:37 -1000 Subject: [PATCH 12/22] stm32_i2c_alt:Move def of regval to top func def per CS --- arch/arm/src/stm32/stm32_i2c_alt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index ca64656d8c7..b115ce2795c 100644 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -1204,6 +1204,9 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr) static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) { +#ifndef CONFIG_I2C_POLLED + uint32_t regval; +#endif uint32_t status; i2cinfo("I2C ISR called\n"); From 66910577beb4735b0e19ba72dd28be9c5594d91f Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 23 Mar 2017 14:22:45 -1000 Subject: [PATCH 13/22] stm322_flash:missing unlock on F1 HSI off path --- arch/arm/src/stm32/stm32_flash.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c index 3b4ebd8a100..3f079442d85 100644 --- a/arch/arm/src/stm32/stm32_flash.c +++ b/arch/arm/src/stm32/stm32_flash.c @@ -290,6 +290,7 @@ ssize_t up_progmem_erasepage(size_t page) #if !defined(CONFIG_STM32_STM32F40XX) if (!(getreg32(STM32_RCC_CR) & RCC_CR_HSION)) { + sem_unlock(); return -EPERM; } #endif From fd76a3db05d18989f1c49fb539b62ef3e22d8ae7 Mon Sep 17 00:00:00 2001 From: no1wudi <757509347@qq.com> Date: Fri, 24 Mar 2017 08:52:46 +0800 Subject: [PATCH 14/22] fix spacing --- arch/arm/src/stm32/stm32_flash.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c index 0267d58eb25..85a3fb18040 100644 --- a/arch/arm/src/stm32/stm32_flash.c +++ b/arch/arm/src/stm32/stm32_flash.c @@ -127,7 +127,6 @@ static void flash_lock(void) { modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_LOCK); } -#if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW) #if defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW) static void data_cache_disable(void) @@ -145,9 +144,8 @@ static void data_cache_enable(void) modifyreg32(STM32_FLASH_ACR, 0, FLASH_ACR_DCEN); } -#endif +#endif /* defined(CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW) */ -#endif /************************************************************************************ * Public Functions ************************************************************************************/ From 61ff3c6b8424b24eade7bbd522ad3b96ea0b7797 Mon Sep 17 00:00:00 2001 From: Alexander Oryshchenko Date: Fri, 24 Mar 2017 06:43:40 -0600 Subject: [PATCH 15/22] =?UTF-8?q?I=20needed=20to=20use=20DS3231,=C2=A0I=20?= =?UTF-8?q?remember=C2=A0that=C2=A0in=20past=20it=20worked=20ok,=20but=20n?= =?UTF-8?q?ow=20for=20stm32f4xx=20is=20used=20another=20driver=20(chip=20s?= =?UTF-8?q?pecific,=C2=A0stm32f40xxx=5Fi2c.c)=20and=20DS3231=20driver=20do?= =?UTF-8?q?esn't=20work.=20After=20investigating=20a=20problem=20I=20found?= =?UTF-8?q?=20that=20I2C=20driver=20(isr=20routine)=20has=20a=20few=20plac?= =?UTF-8?q?es=20there=20it=20sends=20stop=20bit=20even=20if=20not=20all=20?= =?UTF-8?q?messages=20are=20managed.=20So,=20e.g.,=20removing=20stm32=5Fi2?= =?UTF-8?q?c=5Fsendstop=20(#1744)=20and=20adding=20stm32=5Fi2c=5Fsendstart?= =?UTF-8?q?=20after=20data=20reading=20helps=20to=20make=20DS3231=20workin?= =?UTF-8?q?g.=20=20Verified=20by=20David=20Sidrane.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm/src/stm32/stm32f40xxx_i2c.c | 56 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c index 8d3a9fa84de..12080928c20 100644 --- a/arch/arm/src/stm32/stm32f40xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c @@ -1261,6 +1261,15 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) priv->status = status; + /* Any new message should begin with "Start" condition + * Situation priv->msgc == 0 came from DMA RX handler and should be managed + */ + + if (priv->dcnt == -1 && priv->msgc != 0 && (status & I2C_SR1_SB) == 0) + { + return OK; + } + /* Check if this is a new transmission so to set up the * trace table accordingly. */ @@ -1516,9 +1525,16 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) status |= (stm32_i2c_getreg(priv, STM32_I2C_SR2_OFFSET) << 16); - /* Send Stop */ + /* Send Stop/Restart */ - stm32_i2c_sendstop(priv); + if (priv->msgc > 0) + { + stm32_i2c_sendstart(priv); + } + else + { + stm32_i2c_sendstop(priv); + } i2cinfo("Address ACKed beginning data reception\n"); i2cinfo("short read N=1: programming stop bit\n"); @@ -1828,7 +1844,17 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) { i2cinfo("short read N=2: DR and SR full setting stop bit and reading twice\n"); - stm32_i2c_sendstop(priv); + /* Send Stop/Restart */ + + if (priv->msgc > 0) + { + stm32_i2c_sendstart(priv); + } + else + { + stm32_i2c_sendstop(priv); + } + *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); priv->dcnt--; *priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET); @@ -1905,9 +1931,16 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv) stm32_i2c_traceevent(priv, I2CEVENT_READ_3, priv->dcnt); - /* Program stop */ + /* Program Stop/Restart */ - stm32_i2c_sendstop(priv); + if (priv->msgc > 0) + { + stm32_i2c_sendstart(priv); + } + else + { + stm32_i2c_sendstop(priv); + } /* read dcnt = 2 */ @@ -2061,7 +2094,14 @@ static void stm32_i2c_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *arg * interrupt routine if enabled. */ - stm32_i2c_sendstop(priv); + if (priv->msgc > 0) + { + stm32_i2c_sendstart(priv); + } + else + { + stm32_i2c_sendstop(priv); + } /* Let the I2C periph know to stop DMA transfers, also is used by ISR to check * if DMA is done. @@ -2115,10 +2155,6 @@ static void stm32_i2c_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *arg regval |= (I2C_CR2_ITERREN | I2C_CR2_ITEVFEN); stm32_i2c_putreg(priv, STM32_I2C_CR2_OFFSET, regval); #endif - - /* let the ISR routine take care of shutting down or switching to next msg */ - - stm32_i2c_isr(priv); } #endif /* ifdef CONFIG_STM32_I2C_DMA */ From 77b9f72083f83bb88208f553bfd40b5a469d4e56 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Fri, 24 Mar 2017 11:33:46 -0400 Subject: [PATCH 16/22] configs/clicker2-stm32: Cleans up minor issues --- configs/clicker2-stm32/src/clicker2-stm32.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configs/clicker2-stm32/src/clicker2-stm32.h b/configs/clicker2-stm32/src/clicker2-stm32.h index 544366c8dd2..24dd9e54dc6 100644 --- a/configs/clicker2-stm32/src/clicker2-stm32.h +++ b/configs/clicker2-stm32/src/clicker2-stm32.h @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __CONFIGS_OLIMEX_STM32_P407_SRC_H -#define __CONFIGS_OLIMEX_STM32_P407_SRC_H +#ifndef __CONFIGS_CLICKER2_STM32_SRC_CLICKER2_H +#define __CONFIGS_CLICKER2_STM32_SRC_CLICKER2_H /**************************************************************************** * Included Files @@ -212,7 +212,7 @@ #define GPIO_MB1_RST (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN7) -#define GPIO_MB1_RST (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ +#define GPIO_MB2_RST (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN13) /* Interrupts @@ -287,4 +287,4 @@ int stm32_can_setup(void); #endif #endif /* __ASSEMBLY__ */ -#endif /* __CONFIGS_OLIMEX_STM32_P407_SRC_H */ +#endif /* __CONFIGS_CLICKER2_STM32_SRC_CLICKER2_H */ From d0c54039dcafd360bbb7ecaf2d406778b7a2547c Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Fri, 24 Mar 2017 09:41:31 -0600 Subject: [PATCH 17/22] Add ffsl(), ffsll(), fls(), flsl(), flsll() and use GCC's __builtin_ctz/__builtin_clz for faster implementation of these --- include/nuttx/compiler.h | 12 +++++ include/strings.h | 11 +++++ libc/string/Make.defs | 3 +- libc/string/lib_ffs.c | 12 +++-- libc/string/lib_ffsl.c | 93 ++++++++++++++++++++++++++++++++++++++ libc/string/lib_ffsll.c | 97 +++++++++++++++++++++++++++++++++++++++ libc/string/lib_fls.c | 93 ++++++++++++++++++++++++++++++++++++++ libc/string/lib_flsl.c | 93 ++++++++++++++++++++++++++++++++++++++ libc/string/lib_flsll.c | 98 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 508 insertions(+), 4 deletions(-) create mode 100644 libc/string/lib_ffsl.c create mode 100644 libc/string/lib_ffsll.c create mode 100644 libc/string/lib_fls.c create mode 100644 libc/string/lib_flsl.c create mode 100644 libc/string/lib_flsll.c diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 5c5c25be295..15a0f059a9a 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -64,6 +64,18 @@ # define UNUSED(a) ((void)(a)) +/* Built-in functions */ + +/* GCC 4.x have __builtin_ctz(|l|ll) and __builtin_clz(|l|ll). These count + * trailing/leading zeros of input number and typically will generate few + * fast bit-counting instructions. Inputting zero to these functions is + * undefined and needs to be taken care of by the caller. */ + +#if __GNUC__ >= 4 +# define CONFIG_HAVE_BUILTIN_CTZ 1 +# define CONFIG_HAVE_BUILTIN_CLZ 1 +#endif + /* Attributes * * GCC supports weak symbols which can be used to reduce code size because diff --git a/include/strings.h b/include/strings.h index 4b7fc439da4..54be5dd380e 100644 --- a/include/strings.h +++ b/include/strings.h @@ -114,6 +114,17 @@ static inline FAR char *rindex(FAR const char *s, int c) ****************************************************************************/ int ffs(int j); +int ffsl(long j); +#ifdef CONFIG_HAVE_LONG_LONG +int ffsll(long long j); +#endif + +int fls(int j); +int flsl(long j); +#ifdef CONFIG_HAVE_LONG_LONG +int flsll(long long j); +#endif + int strcasecmp(FAR const char *, FAR const char *); int strncasecmp(FAR const char *, FAR const char *, size_t); diff --git a/libc/string/Make.defs b/libc/string/Make.defs index defedcfb60a..72cb8354d53 100644 --- a/libc/string/Make.defs +++ b/libc/string/Make.defs @@ -35,7 +35,8 @@ # Add the string C files to the build -CSRCS += lib_ffs.c lib_isbasedigit.c lib_memset.c lib_memchr.c +CSRCS += lib_ffs.c lib_ffsl.c lib_ffsll.c lib_fls.c lib_flsl.c +CSRCS += lib_flsll.c lib_isbasedigit.c lib_memset.c lib_memchr.c CSRCS += lib_memccpy.c lib_memcmp.c lib_memmove.c lib_skipspace.c CSRCS += lib_stpcpy.c lib_strcasecmp.c lib_strcat.c lib_strchr.c CSRCS += lib_strcpy.c lib_strcmp.c lib_strcspn.c lib_strdup.c diff --git a/libc/string/lib_ffs.c b/libc/string/lib_ffs.c index c52a9c43b23..885718ba49e 100644 --- a/libc/string/lib_ffs.c +++ b/libc/string/lib_ffs.c @@ -33,11 +33,11 @@ * ****************************************************************************/ - /**************************************************************************** * Included Files ****************************************************************************/ +#include #include /**************************************************************************** @@ -55,11 +55,11 @@ * * Description: * The ffs() function will find the first bit set (beginning with the least - * significant bit) in i, and return the index of that bit. Bits are + * significant bit) in j, and return the index of that bit. Bits are * numbered starting at one (the least significant bit). * * Returned Value: - * The ffs() function will return the index of the first bit set. If i is + * The ffs() function will return the index of the first bit set. If j is * 0, then ffs() will return 0. * ****************************************************************************/ @@ -70,6 +70,11 @@ int ffs(int j) if (j != 0) { +#ifdef CONFIG_HAVE_BUILTIN_CTZ + /* Count trailing zeros function can be used to implement ffs. */ + + ret = __builtin_ctz(j) + 1; +#else unsigned int value = (unsigned int)j; int bitno; @@ -81,6 +86,7 @@ int ffs(int j) break; } } +#endif } return ret; diff --git a/libc/string/lib_ffsl.c b/libc/string/lib_ffsl.c new file mode 100644 index 00000000000..4d5739cc03b --- /dev/null +++ b/libc/string/lib_ffsl.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * libc/string/lib_ffsl.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NBITS (8 * sizeof(unsigned long)) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ffsl + * + * Description: + * The ffsl() function will find the first bit set (beginning with the least + * significant bit) in j, and return the index of that bit. Bits are + * numbered starting at one (the least significant bit). + * + * Returned Value: + * The ffsl() function will return the index of the first bit set. If j is + * 0, then ffsl() will return 0. + * + ****************************************************************************/ + +int ffsl(long j) +{ + int ret = 0; + + if (j != 0) + { +#ifdef CONFIG_HAVE_BUILTIN_CTZ + /* Count trailing zeros function can be used to implement ffs. */ + + ret = __builtin_ctzl(j) + 1; +#else + unsigned long value = (unsigned long)j; + int bitno; + + for (bitno = 1; bitno <= NBITS; bitno++, value >>= 1) + { + if ((value & 1) != 0) + { + ret = bitno; + break; + } + } +#endif + } + + return ret; +} diff --git a/libc/string/lib_ffsll.c b/libc/string/lib_ffsll.c new file mode 100644 index 00000000000..111e664d422 --- /dev/null +++ b/libc/string/lib_ffsll.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * libc/string/lib_ffsll.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NBITS (8 * sizeof(unsigned long long)) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_HAVE_LONG_LONG + +/**************************************************************************** + * Name: ffsll + * + * Description: + * The ffsll() function will find the first bit set (beginning with the least + * significant bit) in i, and return the index of that bit. Bits are + * numbered starting at one (the least significant bit). + * + * Returned Value: + * The ffsll() function will return the index of the first bit set. If j is + * 0, then ffsll() will return 0. + * + ****************************************************************************/ + +int ffsll(long long j) +{ + int ret = 0; + + if (j != 0) + { +#ifdef CONFIG_HAVE_BUILTIN_CTZ + /* Count trailing zeros function can be used to implement ffs. */ + + ret = __builtin_ctzll(j) + 1; +#else + unsigned long long value = (unsigned long long)j; + int bitno; + + for (bitno = 1; bitno <= NBITS; bitno++, value >>= 1) + { + if ((value & 1) != 0) + { + ret = bitno; + break; + } + } +#endif + } + + return ret; +} + +#endif diff --git a/libc/string/lib_fls.c b/libc/string/lib_fls.c new file mode 100644 index 00000000000..5894fb1953a --- /dev/null +++ b/libc/string/lib_fls.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * libc/string/lib_fls.c + * + * Copyright (C) 2017 Haltian Ltd. All rights reserved. + * Author: Jussi Kivilinna + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NBITS (8 * sizeof(unsigned int)) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: fls + * + * Description: + * The fls() function will find the last bit set in value and return + * the index of that bit. Bits are numbered starting at one (the least + * significant bit). + * + * Returned Value: + * The fls() function will return the index of the last bit set. If j is + * 0, then fls() will return 0. + * + ****************************************************************************/ + +int fls(int j) +{ + int ret = 0; + + if (j != 0) + { +#ifdef CONFIG_HAVE_BUILTIN_CLZ + /* Count leading zeros function can be used to implement fls. */ + + ret = NBITS - __builtin_clz(j); +#else + unsigned int value = (unsigned int)j; + int bitno; + + for (bitno = 1; bitno <= NBITS; bitno++, value >>= 1) + { + if (value == 1) + { + ret = bitno; + break; + } + } +#endif + } + + return ret; +} diff --git a/libc/string/lib_flsl.c b/libc/string/lib_flsl.c new file mode 100644 index 00000000000..2a3837ddc7e --- /dev/null +++ b/libc/string/lib_flsl.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * libc/string/lib_fls.c + * + * Copyright (C) 2017 Haltian Ltd. All rights reserved. + * Author: Jussi Kivilinna + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NBITS (8 * sizeof(unsigned long)) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: flsl + * + * Description: + * The flsl() function will find the last bit set in value and return + * the index of that bit. Bits are numbered starting at one (the least + * significant bit). + * + * Returned Value: + * The flsl() function will return the index of the last bit set. If j is + * 0, then flsl() will return 0. + * + ****************************************************************************/ + +int flsl(long j) +{ + int ret = 0; + + if (j != 0) + { +#ifdef CONFIG_HAVE_BUILTIN_CLZ + /* Count leading zeros function can be used to implement fls. */ + + ret = NBITS - __builtin_clzl(j); +#else + unsigned long value = (unsigned long)j; + int bitno; + + for (bitno = 1; bitno <= NBITS; bitno++, value >>= 1) + { + if (value == 1) + { + ret = bitno; + break; + } + } +#endif + } + + return ret; +} diff --git a/libc/string/lib_flsll.c b/libc/string/lib_flsll.c new file mode 100644 index 00000000000..2f30f8142e1 --- /dev/null +++ b/libc/string/lib_flsll.c @@ -0,0 +1,98 @@ +/**************************************************************************** + * libc/string/lib_fls.c + * + * Copyright (C) 2017 Haltian Ltd. All rights reserved. + * Author: Jussi Kivilinna + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NBITS (8 * sizeof(unsigned long long)) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_HAVE_LONG_LONG + +/**************************************************************************** + * Name: flsll + * + * Description: + * The flsll() function will find the last bit set in value and return + * the index of that bit. Bits are numbered starting at one (the least + * significant bit). + * + * Returned Value: + * The flsll() function will return the index of the last bit set. If j is + * 0, then flsll() will return 0. + * + ****************************************************************************/ + +int flsll(long long j) +{ + int ret = 0; + + if (j != 0) + { +#ifdef CONFIG_HAVE_BUILTIN_CLZ + /* Count leading zeros function can be used to implement fls. */ + + ret = NBITS - __builtin_clzll(j); +#else + unsigned long long value = (unsigned long long)j; + int bitno; + + for (bitno = 1; bitno <= NBITS; bitno++, value >>= 1) + { + if (value == 1) + { + ret = bitno; + break; + } + } +#endif + } + + return ret; +} + +#endif + From c12b066f14797658bc5096385744e230481cd2c6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 24 Mar 2017 12:11:31 -0600 Subject: [PATCH 18/22] Update README file --- configs/clicker2-stm32/README.txt | 62 ++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index 14046a208b0..3a8b7db14ca 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -87,18 +87,68 @@ Using JTAG https://www.mikroe.com/how-to-use-st-link-v2-with-clicker-2-for-stm32-a-detailed-walkthrough/ http://www.playembedded.org/blog/en/2016/02/06/mikroe-clicker-2-for-stm32-and-stlink-v2/ - NOTE that the FLASH is locked. You may need to follow the instructions at - the second link to unlock it (although I think you may be able to do this - with the ST-Micro ST-Link Utility as well). + NOTE that the FLASH probably has read protection enabled locked. You may + need to follow the instructions at the second link to unlock it. You can + also use the STM32 ST-Link CLI tool to remove the read protection using + the -OB command: + + $ ./ST-LINK_CLI.exe -c SN=53FF6F064966545035320387 SWD LPM + STM32 ST-LINK CLI v2.3.0 + STM32 ST-LINK Command Line Interface + + ST-LINK SN : 53FF6F064966545035320387 + ST-LINK Firmware version : V2J24S4 + Connected via SWD. + SWD Frequency = 4000K. + Target voltage = 3.2 V. + Connection mode : Normal. + Debug in Low Power mode enabled. + Device ID:0x413 + Device family :STM32F40xx/F41xx + + $ ./ST-LINK_CLI.exe -OB RDP=0 + STM32 ST-LINK CLI v2.3.0 + STM32 ST-LINK Command Line Interface + + ST-LINK SN : 53FF6F064966545035320387 + ST-LINK Firmware version : V2J24S4 + Connected via SWD. + SWD Frequency = 4000K. + Target voltage = 3.2 V. + Connection mode : Normal. + Device ID:0x413 + Device family :STM32F40xx/F41xx + Updating option bytes... + Option bytes updated successfully. + + NOTE: + 1. The ST-LINK Utility command line interface is located at: + [Install_Directory]\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe + 2. You can get a summary of all of the command options by running + ST-LINK_CLI.exe with no arguments. + 3. You can get the serial number of the ST-Link when from the information + window if you connect via the ST-Link Utility: + + 11:04:28 : ST-LINK SN : 53FF6F064966545035320387 + 11:04:28 : ST-LINK Firmware version : V2J24S4 + 11:04:28 : Connected via SWD. + 11:04:28 : SWD Frequency = 100 KHz. + 11:04:28 : Connection mode : Normal. + 11:04:28 : Debug in Low Power mode enabled. + 11:04:30 : Device ID:0x413 + 11:04:30 : Device family :STM32F40xx/F41xx + 11:04:30 : Can not read memory! + Disable Read Out Protection and retry. You can avoid the mess of jumpers using the mikroProg to ST-Link v2 adapter along with a 2x5, 10-wire ribbon cable connector: https://shop.mikroe.com/add-on-boards/adapter/mikroprog-st-link-v2-adapter - OpenOCD can be used with the ST-Link to provide a debug environment. I suspect, - however, that adapter can be used with other JTAG debuggers such as J-Link, - but that remains to be verified. + Then you can use the ST-Link Utility or other debugger software to write + the NuttX binary to FLASH. OpenOCD can be used with the ST-Link to provide + a debug environment. The debug adaptor is NOT compatible with other JTAG + debuggers such as the Segger J-Link. Configurations ============== From c3990e1b7f441039a87e67bb20e4f3238011e327 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 24 Mar 2017 12:46:01 -0600 Subject: [PATCH 19/22] Update README and some comments --- configs/clicker2-stm32/README.txt | 12 +++++++----- configs/clicker2-stm32/include/board.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index 3a8b7db14ca..c412c114350 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -89,8 +89,8 @@ Using JTAG NOTE that the FLASH probably has read protection enabled locked. You may need to follow the instructions at the second link to unlock it. You can - also use the STM32 ST-Link CLI tool to remove the read protection using - the -OB command: + also use the STM32 ST-Link CLI tool on Windows to remove the read protection + using the -OB command: $ ./ST-LINK_CLI.exe -c SN=53FF6F064966545035320387 SWD LPM STM32 ST-LINK CLI v2.3.0 @@ -122,11 +122,13 @@ Using JTAG Option bytes updated successfully. NOTE: - 1. The ST-LINK Utility command line interface is located at: + 1. You can get the ST-Link Utilies here: + http://www.st.com/en/embedded-software/stsw-link004.html + 2. The ST-LINK Utility command line interface is located at: [Install_Directory]\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe - 2. You can get a summary of all of the command options by running + 3. You can get a summary of all of the command options by running ST-LINK_CLI.exe with no arguments. - 3. You can get the serial number of the ST-Link when from the information + 4. You can get the serial number of the ST-Link when from the information window if you connect via the ST-Link Utility: 11:04:28 : ST-LINK SN : 53FF6F064966545035320387 diff --git a/configs/clicker2-stm32/include/board.h b/configs/clicker2-stm32/include/board.h index fa271666cb2..7f757d49516 100644 --- a/configs/clicker2-stm32/include/board.h +++ b/configs/clicker2-stm32/include/board.h @@ -269,8 +269,8 @@ * Assuming RS-232 connverted connected on mikroMB1/12 */ -#define GPIO_USART2_RX GPIO_USART2_RX_2 /* PD6 */ -#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */ +#define GPIO_USART2_RX GPIO_USART2_RX_2 /* PD6 */ +#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */ #define GPIO_USART3_RX GPIO_USART3_RX_3 /* PD9 */ #define GPIO_USART3_TX GPIO_USART3_TX_3 /* PD8 / From 3949ab38fd740bc57423f7c9aef0b223e983a661 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 24 Mar 2017 17:21:28 -0600 Subject: [PATCH 20/22] configs/: Rename all stm32_wireless.c files to stm32_cc3000.c. --- configs/nucleo-l476rg/src/Makefile | 2 +- configs/nucleo-l476rg/src/{stm32_wireless.c => stm32_cc3000.c} | 2 +- configs/spark/src/Makefile | 2 +- configs/spark/src/{stm32_wireless.c => stm32_cc3000.c} | 2 +- configs/stm32_tiny/src/Makefile | 2 +- configs/stm32_tiny/src/{stm32_wireless.c => stm32_cc3000.c} | 2 +- configs/stm32f103-minimum/src/Makefile | 2 +- .../stm32f103-minimum/src/{stm32_wireless.c => stm32_cc3000.c} | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename configs/nucleo-l476rg/src/{stm32_wireless.c => stm32_cc3000.c} (99%) rename configs/spark/src/{stm32_wireless.c => stm32_cc3000.c} (99%) rename configs/stm32_tiny/src/{stm32_wireless.c => stm32_cc3000.c} (99%) rename configs/stm32f103-minimum/src/{stm32_wireless.c => stm32_cc3000.c} (98%) diff --git a/configs/nucleo-l476rg/src/Makefile b/configs/nucleo-l476rg/src/Makefile index a27b0f3b84f..7c908435278 100644 --- a/configs/nucleo-l476rg/src/Makefile +++ b/configs/nucleo-l476rg/src/Makefile @@ -49,7 +49,7 @@ CSRCS += stm32_buttons.c endif ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += stm32_wireless.c +CSRCS += stm32_cc3000.c ifeq ($(CONFIG_CC3000_PROBES),) CSRCS += stm32_io.c endif diff --git a/configs/nucleo-l476rg/src/stm32_wireless.c b/configs/nucleo-l476rg/src/stm32_cc3000.c similarity index 99% rename from configs/nucleo-l476rg/src/stm32_wireless.c rename to configs/nucleo-l476rg/src/stm32_cc3000.c index b65a5eaae5f..d1c94b338e9 100644 --- a/configs/nucleo-l476rg/src/stm32_wireless.c +++ b/configs/nucleo-l476rg/src/stm32_cc3000.c @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/nucleo-l476rg/src/stm32_wireless.c + * configs/nucleo-l476rg/src/stm32_cc3000.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Laurent Latil diff --git a/configs/spark/src/Makefile b/configs/spark/src/Makefile index 51ee3a02805..70a7879f15b 100644 --- a/configs/spark/src/Makefile +++ b/configs/spark/src/Makefile @@ -66,7 +66,7 @@ CSRCS += stm32_composite.c endif ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += stm32_wireless.c +CSRCS += stm32_cc3000.c endif ifeq ($(CONFIG_CC3000_PROBES),) diff --git a/configs/spark/src/stm32_wireless.c b/configs/spark/src/stm32_cc3000.c similarity index 99% rename from configs/spark/src/stm32_wireless.c rename to configs/spark/src/stm32_cc3000.c index afd0f9a819d..7f384213e41 100644 --- a/configs/spark/src/stm32_wireless.c +++ b/configs/spark/src/stm32_cc3000.c @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/spark/src/stm32_wireless.c + * configs/spark/src/stm32_cc3000.c * * Copyright (C) 2009, 2013 Gregory Nutt. All rights reserved. * Author: Laurent Latil diff --git a/configs/stm32_tiny/src/Makefile b/configs/stm32_tiny/src/Makefile index 14ee306846f..02062684c6c 100644 --- a/configs/stm32_tiny/src/Makefile +++ b/configs/stm32_tiny/src/Makefile @@ -44,7 +44,7 @@ CSRCS += stm32_pwm.c endif ifeq ($(CONFIG_WL_NRF24L01),y) -CSRCS += stm32_wireless.c +CSRCS += stm32_cc3000.c endif ifeq ($(CONFIG_LIB_BOARDCTL),y) diff --git a/configs/stm32_tiny/src/stm32_wireless.c b/configs/stm32_tiny/src/stm32_cc3000.c similarity index 99% rename from configs/stm32_tiny/src/stm32_wireless.c rename to configs/stm32_tiny/src/stm32_cc3000.c index a08e48a65ab..9a8a0d3619b 100644 --- a/configs/stm32_tiny/src/stm32_wireless.c +++ b/configs/stm32_tiny/src/stm32_cc3000.c @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/stm32_tiny/src/stm32_wireless.c + * configs/stm32_tiny/src/stm32_cc3000.c * * Copyright (C) 2009, 2013, 2017 Gregory Nutt. All rights reserved. * Author: Laurent Latil diff --git a/configs/stm32f103-minimum/src/Makefile b/configs/stm32f103-minimum/src/Makefile index 7eaf2d9c277..75b6cb29532 100644 --- a/configs/stm32f103-minimum/src/Makefile +++ b/configs/stm32f103-minimum/src/Makefile @@ -86,7 +86,7 @@ CSRCS += stm32_veml6070.c endif ifeq ($(CONFIG_WL_NRF24L01),y) -CSRCS += stm32_wireless.c +CSRCS += stm32_cc3000.c endif ifeq ($(CONFIG_USBDEV),y) diff --git a/configs/stm32f103-minimum/src/stm32_wireless.c b/configs/stm32f103-minimum/src/stm32_cc3000.c similarity index 98% rename from configs/stm32f103-minimum/src/stm32_wireless.c rename to configs/stm32f103-minimum/src/stm32_cc3000.c index c3ddcff7848..23b1144ef51 100644 --- a/configs/stm32f103-minimum/src/stm32_wireless.c +++ b/configs/stm32f103-minimum/src/stm32_cc3000.c @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/stm32f103-minimum//src/stm32_wireless.c + * configs/stm32f103-minimum//src/stm32_cc3000.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Laurent Latil From 210ac0f77d96b4f9fe460c0f406ae316dbe42663 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 24 Mar 2017 17:30:58 -0600 Subject: [PATCH 21/22] configs/: Rename all xyz_wifi.c files to stm32_cc3000.c. --- .../include/{kl_wifi.h => kl_cc3000.h} | 35 ++++++++++--------- configs/freedom-kl25z/src/Makefile | 2 +- .../src/{kl_wifi.c => kl_cc3000.c} | 4 +-- 3 files changed, 22 insertions(+), 19 deletions(-) rename configs/freedom-kl25z/include/{kl_wifi.h => kl_cc3000.h} (82%) rename configs/freedom-kl25z/src/{kl_wifi.c => kl_cc3000.c} (99%) diff --git a/configs/freedom-kl25z/include/kl_wifi.h b/configs/freedom-kl25z/include/kl_cc3000.h similarity index 82% rename from configs/freedom-kl25z/include/kl_wifi.h rename to configs/freedom-kl25z/include/kl_cc3000.h index ab9ac43564a..117fc57eefc 100644 --- a/configs/freedom-kl25z/include/kl_wifi.h +++ b/configs/freedom-kl25z/include/kl_cc3000.h @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/freedom-kl25z/include/kl_wifi.h + * configs/freedom-kl25z/include/kl_cc300.h * * Copyright (C) 2013 Alan Carvalho de Assis * Author: Alan Carvalho de Assis @@ -38,34 +38,36 @@ * ****************************************************************************/ +#ifndef __CONFIGS_FREEDOM_KL25Z_INCLUDE_KL_CC3000_H +#define __CONFIGS_FREEDOM_KL25Z_INCLUDE_KL_CC3000_H 1 + /**************************************************************************** * Included Files ****************************************************************************/ + #include #include +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ long ReadWlanInterruptPin(void); -/* - * Enable WiFi Interrupt - */ +/* Enable WiFi Interrupt */ void WlanInterruptEnable(void); -/* - * Disable WiFi Interrupt - */ +/* Disable WiFi Interrupt */ + void WlanInterruptDisable(void); -/* - * Enable/Disable WiFi - */ +/* Enable/Disable WiFi */ + void WriteWlanEnablePin(uint8_t val); -/* - * Assert CC3000 CS - */ +/* Assert CC3000 CS */ + void AssertWlanCS(void); /* @@ -73,8 +75,9 @@ void AssertWlanCS(void); */ void DeassertWlanCS(void); -/* - * Setup needed pins - */ +/* Setup needed pins */ + void Wlan_Setup(void); +#endif /* __CONFIGS_FREEDOM_KL25Z_INCLUDE_KL_CC3000_H */ + diff --git a/configs/freedom-kl25z/src/Makefile b/configs/freedom-kl25z/src/Makefile index 2105da11019..37f83bc1ffb 100644 --- a/configs/freedom-kl25z/src/Makefile +++ b/configs/freedom-kl25z/src/Makefile @@ -43,7 +43,7 @@ CSRCS += kl_appinit.c endif ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += kl_wifi.c +CSRCS += kl_cc3000.c endif ifeq ($(CONFIG_KL_TSI),y) diff --git a/configs/freedom-kl25z/src/kl_wifi.c b/configs/freedom-kl25z/src/kl_cc3000.c similarity index 99% rename from configs/freedom-kl25z/src/kl_wifi.c rename to configs/freedom-kl25z/src/kl_cc3000.c index 0f1810da37b..55e96721f3a 100644 --- a/configs/freedom-kl25z/src/kl_wifi.c +++ b/configs/freedom-kl25z/src/kl_cc3000.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/freedom-kl25z/src/kl_tsi.c + * configs/freedom-kl25z/src/kl_cc3000.c * * Copyright (C) 2014 Alan Carvalho de Assis * Author: Alan Carvalho de Assis @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#include +#include #include #include From af85aca1aa0da7bbd329d3541b71272be31d9a35 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 24 Mar 2017 12:46:01 -0600 Subject: [PATCH 22/22] Remove some whitespace at the end of some lines --- configs/freedom-kl25z/src/kl_cc3000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/freedom-kl25z/src/kl_cc3000.c b/configs/freedom-kl25z/src/kl_cc3000.c index 55e96721f3a..e233a64d062 100644 --- a/configs/freedom-kl25z/src/kl_cc3000.c +++ b/configs/freedom-kl25z/src/kl_cc3000.c @@ -212,12 +212,12 @@ static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable) if (enable) { (void)kl_gpioirqattach(GPIO_WIFI_INT, priv->handler, priv->arg); - kl_gpioirqenable(GPIO_WIFI_INT); + kl_gpioirqenable(GPIO_WIFI_INT); } else { (void)kl_gpioirqattach(GPIO_WIFI_INT, NULL, NULL); - kl_gpioirqdisable(GPIO_WIFI_INT); + kl_gpioirqdisable(GPIO_WIFI_INT); } }