mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Merge remote-tracking branch 'origin/master' into ieee802154
This commit is contained in:
@@ -9,6 +9,8 @@ Make.dep
|
||||
.*.swp
|
||||
core
|
||||
.gdbinit
|
||||
.project
|
||||
.cproject
|
||||
cscope.out
|
||||
/Make.dep
|
||||
/.depend
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
README
|
||||
======
|
||||
|
||||
This README discusses the port of NuttX to the STMicro B-L475E-IOT01A
|
||||
Discovery kit powered by STM32L475VG Cortex-M4. This board targets IoT
|
||||
nodes with a choice of connectivity options including WiFi, Bluetooth LE,
|
||||
NFC, and sub-GHZ RF at 868 or 915 MHz, as well as a long list of various
|
||||
environmental sensors.
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
o STATUS
|
||||
o Board Features
|
||||
o LEDs and Buttons
|
||||
o Serial Console
|
||||
o Configurations
|
||||
|
||||
STATUS
|
||||
======
|
||||
|
||||
o 2017-06-10: I have no hardware in hand and I am not sure that I will
|
||||
even pursue this port. This README is really no more than a thought
|
||||
experiment at the present time.
|
||||
|
||||
A few days ago, I did add support for the STM32L4x5 MCU family to
|
||||
NuttX. But no work has yet been done for this board port other
|
||||
than writing this README file.
|
||||
|
||||
o 2017-06-13: I just learned that development boards will not be
|
||||
available for another month.
|
||||
|
||||
Board Features
|
||||
==============
|
||||
|
||||
B-L475E-IOT01A Discovery kit key features and specifications:
|
||||
|
||||
o MCU: STM32L475 Series MCU based on ARM Cortex-M4 core with 1 MB
|
||||
Flash memory, 128 KB SRAM
|
||||
o Storage: 64 Mbit (8MB) Quad-SPI Flash memory (Macronix)
|
||||
o Connectivity:
|
||||
- Bluetooth 4.1 LE module (SPBTLE-RF)
|
||||
- Sub-GHz (868 or 915 MHz) low-power-programmable RF module (SPSGRF-868
|
||||
or SPSGRF-915)
|
||||
- Wi-Fi module based on Inventek ISM43362-M3G-L44 (802.11 b/g/n
|
||||
compliant)
|
||||
- Dynamic NFC tag based on M24SR with its printed NFC antenna
|
||||
o Sensors:
|
||||
- 2x digital omni-directional microphones (MP34DT01)
|
||||
- Capacitive digital sensor for relative humidity and temperature
|
||||
(HTS221)
|
||||
- 3-axis magnetometer (LIS3MDL)
|
||||
- 3D accelerometer and 3D gyroscope (LSM6DSL)
|
||||
- 260-1260 hPa absolute digital output barometer (LPS22HB)
|
||||
- Time-of-Flight and gesture-detection sensor (VL53L0X
|
||||
o USB – 1x micro USB OTG port (Full speed)
|
||||
o Expansion – Arduino UNO V3 headers, PMOD header
|
||||
o Debugging – On-board ST-LINK/V2-1 debugger/programmer with USB
|
||||
re-enumeration capability: mass storage, virtual COM port and debug
|
||||
port
|
||||
o Misc – 2 push-buttons (user and reset)
|
||||
o Power Supply – 5V via ST LINK USB VBUS or external sources
|
||||
|
||||
The board supports ARM mbed online compiler, but can also be programmed
|
||||
using IDEs such as IAR, Keil, and GCC-based IDEs. STMicro also provides
|
||||
HAL libraries and code samples as part of the STM32Cube Package, as well
|
||||
as X-CUBE-AWS expansion software to connect to the Amazon Web Services
|
||||
(AWS) IoT platform.
|
||||
|
||||
NOTES:
|
||||
|
||||
1. The board usese Wi-Fi® module Inventek ISM43362-M3G-L44 (802.11 b/g/n
|
||||
compliant), which consists of BCM43362 and STM32F205 host processor
|
||||
that has a standard SPI or UART interface capability. It means you
|
||||
will only use AT command to talk with Wi-Fi® module by SPI. All the
|
||||
tcp/ip stack is built-in STM32F205 in Wi-Fi® module.
|
||||
|
||||
This cannot integrate cleanly with the NuttX network stack. A
|
||||
USERSOCK option was recently added that would permit implementation
|
||||
of the Inventek support in an applications. But that would then
|
||||
preclude the 6loWPAN integration into IPv6.
|
||||
|
||||
2. The board uses Bluetooth® V4.1 module (SPBTLE-RF), which has built-in
|
||||
BLE stack. Similar with wifi, you only use simple AT command to talk
|
||||
with this BLE module.
|
||||
|
||||
3. STMicro provides contiki 6lowpan for mesh.
|
||||
http://www.st.com/en/embedded-software/osxcontiki6lp.html but mesh
|
||||
network is not popular in the market, star network is the mainstream
|
||||
for its simplicity and robustness.
|
||||
|
||||
LEDs and Buttons
|
||||
================
|
||||
|
||||
The black button B1 located on top side is the reset of the STM32L475VGT6.
|
||||
|
||||
The blue button B1 located top side is available to be used as a digital
|
||||
input or as alternate function Wake-up. When the button is depressed the logic state is "0", otherwise the logic state is "1".
|
||||
|
||||
Two green LEDs (LD1 and LD2), located on the top side are available for the user. To light a LED a high logic state "1" should be written in the corresponding GPIO.
|
||||
|
||||
Reference Color Name Comment
|
||||
B2 blue Wake-up Alternate function Wake-up
|
||||
LD1 green LED1 PA5 (alternate with ARD.D13)
|
||||
LD2 green LED2 PB14
|
||||
|
||||
These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
||||
selected. In that case, the usage by the board port is defined in
|
||||
include/board.h and src/lpc31_leds.c. The LEDs are used to encode
|
||||
OS-related events as follows:
|
||||
|
||||
SYMBOL Meaning LED state
|
||||
LED2 LED1
|
||||
------------------- ----------------------- -------- --------
|
||||
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 N/C
|
||||
LED_SIGNAL In a signal handler N/C N/C
|
||||
LED_ASSERTION An assertion failed N/C N/C
|
||||
LED_PANIC The system has crashed N/C Blinking
|
||||
LED_IDLE MCU is is sleep mode Not used
|
||||
|
||||
Thus if LED2 is statically on, NuttX has successfully booted and is,
|
||||
apparently, running normmally. If LED1 is flashing at approximately
|
||||
2Hz, then a fatal error has been detected and the system has halted.
|
||||
|
||||
NOTE: That LED2 is not used after completion of booting and may
|
||||
be used by other board-specific logic.
|
||||
|
||||
Of course, if CONFIG_ARCH_LEDS is not selected, then both LEDs are
|
||||
available for use by other logic.
|
||||
|
||||
Serial Console
|
||||
==============
|
||||
|
||||
Arduino Serial Shield
|
||||
---------------------
|
||||
An TLL-to-RS232 Converter shield may be used with UART4:
|
||||
|
||||
UART4:
|
||||
-------------- ---------------- ------------------
|
||||
STM32L475VGTx Board Signal Arduino Connector
|
||||
-------------- ---------------- ------------------
|
||||
UART4_RX PA1 ARD.D0-UART4_RX CN3 pin1 RX/D0
|
||||
UART4_TX PA0 ARD.D1-UART4_TX CN3 pin2 TX/D1
|
||||
-------------- ---------------- ------------------
|
||||
|
||||
Virtual COM Port
|
||||
----------------
|
||||
The serial interface USART1 is directly available as a virtual COM port
|
||||
of the PC connected to the ST-LINK/V2-1 USB connector CN7.
|
||||
|
||||
USART1:
|
||||
-------------- ---------------- --------------
|
||||
STM32L475VGTx Board Signal STM32F103CBT6
|
||||
-------------- ---------------- --------------
|
||||
USART1_TX PB6 ST-LINK-UART1_TX USART2_RX PA3
|
||||
UAART1_RX PB7 ST-LINK-UART1_RX USART2_TX PA2
|
||||
-------------- ---------------- --------------
|
||||
|
||||
The virtual COM port settings are configured as: 115200 b/s, 8 bits data,
|
||||
no parity, 1 stop bit, no flow control.
|
||||
|
||||
Other Options
|
||||
-------------
|
||||
|
||||
USART2 - Available on CN10 if solder bridges closed.
|
||||
-------------- ---------------- ---------------------------
|
||||
STM32L475VGTx Board Signal PMOD / Solder Bridges
|
||||
-------------- ---------------- ---------------------------
|
||||
USART2_RX PD4 PMOD-UART2_RX CN10 pin1 or 2 (SB12, SB14)
|
||||
USART2_TX PD5 PMOD-UART2_TX CN10 pin2 TX/D1 (SB20)
|
||||
-------------- ---------------- ---------------------------
|
||||
|
||||
USART3 - Dedicated to ISM43362-M3G-L44 Serial-to-Wifi Module.
|
||||
-------------- ---------------- ------------------
|
||||
STM32L475VGTx Board Signal Arduino Connector
|
||||
-------------- ---------------- ------------------
|
||||
USART3_RX PD9 INTERNAL-UART3_RX CN3 pin1 RX/D0
|
||||
USART3_TX PD8 INTERNAL-UART3_TX CN3 pin2 TX/D1
|
||||
-------------- ---------------- ------------------
|
||||
|
||||
Configurations
|
||||
==============
|
||||
|
||||
Information Common to All Configurations
|
||||
----------------------------------------
|
||||
Each B-L475E-IOT01A configuration is maintained in a sub-directory and
|
||||
can be selected as follow:
|
||||
|
||||
cd tools
|
||||
./configure.sh b-l475e-iot01a/<subdir>
|
||||
cd -
|
||||
|
||||
Before building, make sure that:
|
||||
|
||||
1. The PATH environment variable include the correct path to the
|
||||
directory than holds your toolchain binaries.
|
||||
2. Check the .config file. Make sure that the configuration is set for
|
||||
your build platform (e.g., Linux vs. Windows) and that the toolchain
|
||||
is set for the toolchain type you are using.
|
||||
|
||||
The <subdir> that is provided above as an argument to the
|
||||
tools/configure.sh must be is one of those listed below.
|
||||
|
||||
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
|
||||
|
||||
Where 'make oldconfig' brings the configuration up to data with the current configuration data and 'make' will compile all of the source
|
||||
files and generate the final binary.
|
||||
|
||||
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 USART1 (i.e., for ST-Link Virtual COM port).
|
||||
|
||||
3. All of these configurations are set up to build under Windows 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_WINDOWS=y : Window environment
|
||||
CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows
|
||||
|
||||
System Type -> Toolchain:
|
||||
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain
|
||||
|
||||
Configuration sub-directories
|
||||
-----------------------------
|
||||
@@ -348,6 +348,24 @@
|
||||
#define PIN_I2C0_SCL PIN_I2C0_SCL_3
|
||||
#define PIN_I2C0_SDA PIN_I2C0_SDA_3
|
||||
|
||||
/* RF/WIFI
|
||||
*
|
||||
* J6 Pin Name K66 Name
|
||||
* ------ ----- ------ ---------
|
||||
* 1 GND
|
||||
* 2 P3V3
|
||||
* 3 CE PTB20 PTB20
|
||||
* 4 CS PTD4 SPI1_PCS0 (use as GPIO)
|
||||
* 5 SCK PTD5 SPI1_SCK
|
||||
* 6 MOSI PTD6 SPI1_MOSI
|
||||
* 7 MISO PTD7 SPI1_MISO
|
||||
* 8 IRQ PTC18 PTC18
|
||||
*/
|
||||
|
||||
#define PIN_SPI1_SCK PIN_SPI1_SCK_3
|
||||
#define PIN_SPI1_OUT PIN_SPI1_SOUT_3
|
||||
#define PIN_SPI1_SIN PIN_SPI1_SIN_3
|
||||
|
||||
/*
|
||||
* Ethernet MAC/KSZ8081 PHY
|
||||
* ------------------------
|
||||
|
||||
@@ -223,7 +223,7 @@ CONFIG_KINETIS_UART4=y
|
||||
# CONFIG_KINETIS_FLEXCAN0 is not set
|
||||
# CONFIG_KINETIS_FLEXCAN1 is not set
|
||||
# CONFIG_KINETIS_SPI0 is not set
|
||||
# CONFIG_KINETIS_SPI1 is not set
|
||||
CONFIG_KINETIS_SPI1=y
|
||||
# CONFIG_KINETIS_SPI2 is not set
|
||||
CONFIG_KINETIS_I2C0=y
|
||||
# CONFIG_KINETIS_I2C1 is not set
|
||||
@@ -546,7 +546,15 @@ CONFIG_I2C_DRIVER=y
|
||||
# CONFIG_ARCH_HAVE_SPI_CRCGENERATION is not set
|
||||
# CONFIG_ARCH_HAVE_SPI_CS_CONTROL is not set
|
||||
# CONFIG_ARCH_HAVE_SPI_BITORDER is not set
|
||||
# CONFIG_SPI is not set
|
||||
CONFIG_SPI=y
|
||||
# CONFIG_SPI_SLAVE is not set
|
||||
CONFIG_SPI_EXCHANGE=y
|
||||
# CONFIG_SPI_CMDDATA is not set
|
||||
# CONFIG_SPI_CALLBACK is not set
|
||||
# CONFIG_SPI_HWFEATURES is not set
|
||||
CONFIG_SPI_CS_DELAY_CONTROL=y
|
||||
# CONFIG_SPI_DRIVER is not set
|
||||
# CONFIG_SPI_BITBANG is not set
|
||||
# CONFIG_I2S is not set
|
||||
|
||||
#
|
||||
@@ -576,6 +584,7 @@ CONFIG_INPUT=y
|
||||
# CONFIG_INPUT_ADS7843E is not set
|
||||
# CONFIG_INPUT_MXT is not set
|
||||
# CONFIG_INPUT_STMPE811 is not set
|
||||
# CONFIG_INPUT_CYPRESS_MBR3108 is not set
|
||||
CONFIG_BUTTONS=y
|
||||
CONFIG_BUTTONS_LOWER=y
|
||||
CONFIG_BUTTONS_NPOLLWAITERS=2
|
||||
@@ -607,6 +616,7 @@ CONFIG_MMCSD_NSLOTS=1
|
||||
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||
CONFIG_MMCSD_MMCSUPPORT=y
|
||||
CONFIG_MMCSD_HAVECARDDETECT=y
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
CONFIG_ARCH_HAVE_SDIO=y
|
||||
# CONFIG_SDIO_DMA is not set
|
||||
# CONFIG_ARCH_HAVE_SDIOWAIT_WRCOMPLETE is not set
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#define HAVE_PROC 1
|
||||
#define HAVE_MMCSD 1
|
||||
#define HAVE_AUTOMOUNTER 1
|
||||
#define HAVE_SPI 1
|
||||
#define HAVE_USBDEV 1
|
||||
|
||||
#if defined(CONFIG_KINETIS_RTC)
|
||||
@@ -173,6 +174,11 @@
|
||||
# undef CONFIG_KINETIS_SPI2
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_KINETIS_SPI0) && !defined(CONFIG_KINETIS_SPI1) && \
|
||||
!defined(CONFIG_KINETIS_SPI3)
|
||||
# undef HAVE_SPI
|
||||
#endif
|
||||
|
||||
/* FREEDOM-K66F GPIOs ****************************************************************/
|
||||
/* A micro Secure Digital (SD) card slot is available on the FRDM-K66F connected to
|
||||
* the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro
|
||||
@@ -223,6 +229,11 @@
|
||||
#define GPIO_LED_G (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTE | PIN6)
|
||||
#define GPIO_LED_B (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTA | PIN11)
|
||||
|
||||
/* SPI1 on J6 */
|
||||
|
||||
#define PIN_CE (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTB | PIN20)
|
||||
#define PIN_SPI1_PCS0 (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTD | PIN4)
|
||||
|
||||
/************************************************************************************
|
||||
* Public data
|
||||
************************************************************************************/
|
||||
|
||||
@@ -47,8 +47,10 @@
|
||||
#include <debug.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/input/buttons.h>
|
||||
|
||||
#include "kinetis_spi.h"
|
||||
#include "freedom-k66f.h"
|
||||
|
||||
#if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE)
|
||||
@@ -67,6 +69,9 @@
|
||||
|
||||
int k66_bringup(void)
|
||||
{
|
||||
#ifdef HAVE_SPI
|
||||
FAR struct spi_dev_s *spi1;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_PROC
|
||||
@@ -151,8 +156,20 @@ int k66_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SPI
|
||||
|
||||
/* Verify we can initialize SPI bus 1 */
|
||||
|
||||
spi1 = kinetis_spibus_initialize(1);
|
||||
|
||||
if (!spi1)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR:FAILED to initialize SPI port 1\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_LIB_BOARDCTL CONFIG_BOARD_INITIALIZE */
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#include "freedom-k66f.h"
|
||||
|
||||
#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI1) || \
|
||||
defined(CONFIG_KINETIS_SPI2)
|
||||
defined(CONFIG_KINETIS_SPI2)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
@@ -69,7 +69,10 @@
|
||||
|
||||
void weak_function k66_spidev_initialize(void)
|
||||
{
|
||||
# warning "Missing logic"
|
||||
/* Initialize the CE CS pins on J6 RF/WIFI connector */
|
||||
|
||||
kinetis_pinconfig(PIN_CE);
|
||||
kinetis_pinconfig(PIN_SPI1_PCS0);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
@@ -118,7 +121,7 @@ uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
void kinetis_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
# warning "Missing logic"
|
||||
kinetis_gpiowrite(PIN_SPI1_PCS0, !selected);
|
||||
}
|
||||
|
||||
uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
* configs/nucleo-f334r8/src/stm32_hrtim.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Mateusz Szafoni <raiden00@railab.me>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "stm32.h"
|
||||
|
||||
#if defined(CONFIG_HRTIM) && defined(CONFIG_STM32_HRTIM1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_hrtim_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize HRTIM driver
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success, a negated errno value on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_hrtim_setup(void)
|
||||
{
|
||||
static bool initialized = false;
|
||||
struct hrtim_dev_s* hrtim = NULL;
|
||||
int ret;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* Get the HRTIM interface */
|
||||
|
||||
hrtim = stm32_hrtiminitialize();
|
||||
if (hrtim == NULL)
|
||||
{
|
||||
tmrerr("ERROR: Failed to get HRTIM1 interface\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the HRTIM character driver at /dev/hrtim0 */
|
||||
|
||||
ret = hrtim_register("/dev/hrtim0", hrtim);
|
||||
if (ret < 0)
|
||||
{
|
||||
tmrerr("ERROR: hrtim_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HRTIM && CONFIG_STM32_HRTIM1 */
|
||||
@@ -731,7 +731,9 @@ CONFIG_ARCH_HAVE_CAN_ERRORS=y
|
||||
# CONFIG_CAN_FD is not set
|
||||
CONFIG_CAN_FIFOSIZE=8
|
||||
CONFIG_CAN_NPENDINGRTR=4
|
||||
# CONFIG_CAN_TXREADY is not set
|
||||
CONFIG_CAN_TXREADY=y
|
||||
# CONFIG_CAN_TXREADY_LOPRI is not set
|
||||
CONFIG_CAN_TXREADY_HIPRI=y
|
||||
|
||||
#
|
||||
# CAN Bus Controllers:
|
||||
|
||||
@@ -53,6 +53,10 @@ else
|
||||
CSRCS += stm32_userleds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEV_GPIO),y)
|
||||
CSRCS += stm32_gpio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PWM),y)
|
||||
CSRCS += stm32_pwm.c
|
||||
endif
|
||||
|
||||
@@ -112,6 +112,15 @@ int stm32_bringup(void)
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_DEV_GPIO
|
||||
ret = stm32_gpio_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MMCSD
|
||||
ret = stm32_mmcsd_initialize(MMCSD_MINOR);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
/****************************************************************************
|
||||
* configs/stm32f103-minimum/src/stm32_gpio.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017 Alan Carvalho de Assis. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Based on: configs/sim/src/sim_gpio.c
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/ioexpander/gpio.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "stm32.h"
|
||||
#include "stm32f103_minimum.h"
|
||||
|
||||
#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct stm32gpio_dev_s
|
||||
{
|
||||
struct gpio_dev_s gpio;
|
||||
uint8_t id;
|
||||
};
|
||||
|
||||
struct stm32gpint_dev_s
|
||||
{
|
||||
struct stm32gpio_dev_s stm32gpio;
|
||||
pin_interrupt_t callback;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value);
|
||||
static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value);
|
||||
static int gpout_write(FAR struct gpio_dev_s *dev, bool value);
|
||||
static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value);
|
||||
static int gpint_attach(FAR struct gpio_dev_s *dev,
|
||||
pin_interrupt_t callback);
|
||||
static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct gpio_operations_s gpin_ops =
|
||||
{
|
||||
.go_read = gpin_read,
|
||||
.go_write = NULL,
|
||||
.go_attach = NULL,
|
||||
.go_enable = NULL,
|
||||
};
|
||||
|
||||
static const struct gpio_operations_s gpout_ops =
|
||||
{
|
||||
.go_read = gpout_read,
|
||||
.go_write = gpout_write,
|
||||
.go_attach = NULL,
|
||||
.go_enable = NULL,
|
||||
};
|
||||
|
||||
static const struct gpio_operations_s gpint_ops =
|
||||
{
|
||||
.go_read = gpint_read,
|
||||
.go_write = NULL,
|
||||
.go_attach = gpint_attach,
|
||||
.go_enable = gpint_enable,
|
||||
};
|
||||
|
||||
#if BOARD_NGPIOIN > 0
|
||||
/* This array maps the GPIO pins used as INPUT */
|
||||
|
||||
static const uint32_t g_gpioinputs[BOARD_NGPIOIN] =
|
||||
{
|
||||
GPIO_IN1,
|
||||
};
|
||||
|
||||
static struct stm32gpio_dev_s g_gpin[BOARD_NGPIOIN];
|
||||
#endif
|
||||
|
||||
#if BOARD_NGPIOOUT
|
||||
/* This array maps the GPIO pins used as OUTPUT */
|
||||
|
||||
static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] =
|
||||
{
|
||||
GPIO_OUT1,
|
||||
};
|
||||
|
||||
static struct stm32gpio_dev_s g_gpout[BOARD_NGPIOOUT];
|
||||
#endif
|
||||
|
||||
#if BOARD_NGPIOINT > 0
|
||||
/* This array maps the GPIO pins used as INTERRUPT INPUTS */
|
||||
|
||||
static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] =
|
||||
{
|
||||
GPIO_INT1,
|
||||
};
|
||||
|
||||
static struct stm32gpint_dev_s g_gpint[BOARD_NGPIOINT];
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32gpio_interrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
FAR struct stm32gpint_dev_s *stm32gpint = (FAR struct stm32gpint_dev_s *)arg;
|
||||
|
||||
DEBUGASSERT(stm32gpint != NULL && stm32gpint->callback != NULL);
|
||||
gpioinfo("Interrupt! callback=%p\n", stm32gpint->callback);
|
||||
|
||||
stm32gpint->callback(&stm32gpint->stm32gpio.gpio);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value)
|
||||
{
|
||||
FAR struct stm32gpio_dev_s *stm32gpio = (FAR struct stm32gpio_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(stm32gpio != NULL && value != NULL);
|
||||
DEBUGASSERT(stm32gpio->id < BOARD_NGPIOIN);
|
||||
gpioinfo("Reading...\n");
|
||||
|
||||
*value = stm32_gpioread(g_gpioinputs[stm32gpio->id]);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value)
|
||||
{
|
||||
FAR struct stm32gpio_dev_s *stm32gpio = (FAR struct stm32gpio_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(stm32gpio != NULL && value != NULL);
|
||||
DEBUGASSERT(stm32gpio->id < BOARD_NGPIOOUT);
|
||||
gpioinfo("Reading...\n");
|
||||
|
||||
*value = stm32_gpioread(g_gpiooutputs[stm32gpio->id]);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int gpout_write(FAR struct gpio_dev_s *dev, bool value)
|
||||
{
|
||||
FAR struct stm32gpio_dev_s *stm32gpio = (FAR struct stm32gpio_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(stm32gpio != NULL);
|
||||
DEBUGASSERT(stm32gpio->id < BOARD_NGPIOOUT);
|
||||
gpioinfo("Writing %d\n", (int)value);
|
||||
|
||||
stm32_gpiowrite(g_gpiooutputs[stm32gpio->id], value);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value)
|
||||
{
|
||||
FAR struct stm32gpint_dev_s *stm32gpint = (FAR struct stm32gpint_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(stm32gpint != NULL && value != NULL);
|
||||
DEBUGASSERT(stm32gpint->stm32gpio && stm32gpint->stm32gpio.id < BOARD_NGPIOINT);
|
||||
gpioinfo("Reading int pin...\n");
|
||||
|
||||
*value = stm32_gpioread(g_gpiointinputs[stm32gpint->stm32gpio.id]);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int gpint_attach(FAR struct gpio_dev_s *dev,
|
||||
pin_interrupt_t callback)
|
||||
{
|
||||
FAR struct stm32gpint_dev_s *stm32gpint = (FAR struct stm32gpint_dev_s *)dev;
|
||||
|
||||
gpioinfo("Attaching the callback\n");
|
||||
|
||||
/* Make sure the interrupt is disabled */
|
||||
|
||||
(void)stm32_gpiosetevent(g_gpiointinputs[stm32gpint->stm32gpio.id], false,
|
||||
false, false, NULL, NULL);
|
||||
|
||||
gpioinfo("Attach %p\n", callback);
|
||||
stm32gpint->callback = callback;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable)
|
||||
{
|
||||
FAR struct stm32gpint_dev_s *stm32gpint = (FAR struct stm32gpint_dev_s *)dev;
|
||||
|
||||
if (enable)
|
||||
{
|
||||
if (stm32gpint->callback != NULL)
|
||||
{
|
||||
gpioinfo("Enabling the interrupt\n");
|
||||
|
||||
/* Configure the interrupt for rising edge */
|
||||
|
||||
(void)stm32_gpiosetevent(g_gpiointinputs[stm32gpint->stm32gpio.id],
|
||||
true, false, false, stm32gpio_interrupt,
|
||||
&g_gpint[stm32gpint->stm32gpio.id]);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gpioinfo("Disable the interrupt\n");
|
||||
(void)stm32_gpiosetevent(g_gpiointinputs[stm32gpint->stm32gpio.id],
|
||||
false, false, false, NULL, NULL);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_gpio_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize GPIO drivers for use with /apps/examples/gpio
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_gpio_initialize(void)
|
||||
{
|
||||
int i;
|
||||
int pincount = 0;
|
||||
|
||||
#if BOARD_NGPIOIN > 0
|
||||
for (i = 0; i < BOARD_NGPIOIN; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
||||
g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN;
|
||||
g_gpin[i].gpio.gp_ops = &gpin_ops;
|
||||
g_gpin[i].id = i;
|
||||
(void)gpio_pin_register(&g_gpin[i].gpio, pincount);
|
||||
|
||||
/* Configure the pin that will be used as input */
|
||||
|
||||
stm32_configgpio(g_gpioinputs[i]);
|
||||
|
||||
pincount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOARD_NGPIOOUT > 0
|
||||
for (i = 0; i < BOARD_NGPIOOUT; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
||||
g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN;
|
||||
g_gpout[i].gpio.gp_ops = &gpout_ops;
|
||||
g_gpout[i].id = i;
|
||||
(void)gpio_pin_register(&g_gpout[i].gpio, pincount);
|
||||
|
||||
/* Configure the pin that will be used as output */
|
||||
stm32_gpiowrite(g_gpiooutputs[i], 0);
|
||||
stm32_configgpio(g_gpiooutputs[i]);
|
||||
|
||||
pincount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOARD_NGPIOINT > 0
|
||||
for (i = 0; i < BOARD_NGPIOINT; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
||||
g_gpint[i].stm32gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
|
||||
g_gpint[i].stm32gpio.gpio.gp_ops = &gpint_ops;
|
||||
g_gpint[i].stm32gpio.id = i;
|
||||
(void)gpio_pin_register(&g_gpint[i].stm32gpio.gpio, pincount);
|
||||
|
||||
/* Configure the pin that will be used as interrupt input */
|
||||
|
||||
stm32_configgpio(g_gpiointinputs[i]);
|
||||
|
||||
pincount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */
|
||||
@@ -70,9 +70,9 @@ struct stm32_mcp2515config_s
|
||||
|
||||
/* Additional private definitions only known to this driver */
|
||||
|
||||
MCP2515_HANDLE handle; /* The MCP2515 driver handle */
|
||||
mcp2515_handler_t handler; /* The MCP2515 interrupt handler */
|
||||
FAR void *arg; /* Argument to pass to the interrupt handler */
|
||||
FAR struct mcp2515_can_s *handle; /* The MCP2515 driver handle */
|
||||
mcp2515_handler_t handler; /* The MCP2515 interrupt handler */
|
||||
FAR void *arg; /* Argument to pass to the interrupt handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -146,7 +146,7 @@ static int mcp2515_attach(FAR struct mcp2515_config_s *state,
|
||||
(FAR struct stm32_mcp2515config_s *)state;
|
||||
irqstate_t flags;
|
||||
|
||||
caninfo("Saving handle %p\n", handler);
|
||||
caninfo("Saving handler %p\n", handler);
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
@@ -220,7 +220,7 @@ int stm32_mcp2515initialize(FAR const char *devpath)
|
||||
|
||||
/* Save the opaque structure */
|
||||
|
||||
g_mcp2515config.handle = (MCP2515_HANDLE) mcp2515;
|
||||
g_mcp2515config.handle = mcp2515;
|
||||
|
||||
/* Initialize the CAN Device with the MCP2515 operations */
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ int stm32_mfrc522initialize(FAR const char *devpath)
|
||||
}
|
||||
|
||||
/* Then register the MFRC522 */
|
||||
|
||||
|
||||
ret = mfrc522_register(devpath, spi);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
@@ -136,7 +136,7 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CL_MFRC522)
|
||||
if (devid == SPIDEV_WIRELESS(0))
|
||||
if (devid == SPIDEV_CONTACTLESS(0))
|
||||
{
|
||||
stm32_gpiowrite(GPIO_CS_MFRC522, !selected);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* configs/stm32f103minimum/src/stm32_tone.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -129,6 +129,18 @@
|
||||
#define GPIO_USB_PULLUP (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN13)
|
||||
|
||||
/* GPIO pins used by the GPIO Subsystem */
|
||||
|
||||
#define BOARD_NGPIOIN 1 /* Amount of GPIO Input pins */
|
||||
#define BOARD_NGPIOOUT 1 /* Amount of GPIO Output pins */
|
||||
#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */
|
||||
|
||||
#define GPIO_IN1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_OUT1 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN1)
|
||||
|
||||
#define GPIO_INT1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_PORTA|GPIO_PIN2)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
@@ -155,6 +167,18 @@
|
||||
|
||||
int stm32_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_gpio_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize GPIO drivers for use with /apps/examples/gpio
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEV_GPIO
|
||||
int stm32_gpio_initialize(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_spidev_initialize
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user