You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2019/12/20 21:55:37 UTC

[incubator-nuttx] branch stage updated (49a666e -> f231296)

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a change to branch stage
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 49a666e  arch/arm/src/stm32f0l0g0: Added i2c pinmap and Kconfig select I2C2 for this board
     new dfaafc3  boards/arm/stm32f0l0g0/nucleo-g070rb: Enable i2C
     new f231296  boards/arm/stm32f0l0g0/nucleo-g070rb: Fix issues appointed by nxstyle

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 boards/arm/stm32f0l0g0/nucleo-g070rb/README.txt    |  1 +
 .../nucleo-g070rb/configs/nsh/defconfig            |  5 ++
 .../arm/stm32f0l0g0/nucleo-g070rb/include/board.h  |  1 +
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c  | 75 ++++++++++++++++++++--
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_buttons.c  | 28 ++++----
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_timer.c    |  3 +-
 6 files changed, 94 insertions(+), 19 deletions(-)


[incubator-nuttx] 02/02: boards/arm/stm32f0l0g0/nucleo-g070rb: Fix issues appointed by nxstyle

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch stage
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit f231296ce396914a3d9bda6affed694f6a6b04e3
Author: Daniel Pereira Volpato <dp...@certi.org.br>
AuthorDate: Fri Dec 20 13:15:12 2019 -0300

    boards/arm/stm32f0l0g0/nucleo-g070rb: Fix issues appointed by nxstyle
---
 .../arm/stm32f0l0g0/nucleo-g070rb/include/board.h  |  1 +
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c  | 10 ++++----
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_buttons.c  | 28 +++++++++++-----------
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_timer.c    |  3 ++-
 4 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/include/board.h b/boards/arm/stm32f0l0g0/nucleo-g070rb/include/board.h
index b865061..9b4d2a5 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/include/board.h
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/include/board.h
@@ -215,6 +215,7 @@
 /* Alternate function pin selections ****************************************/
 
 /* I2C */
+
 #define GPIO_I2C1_SCL       GPIO_I2C1_SCL_3      /* PB8  */
 #define GPIO_I2C1_SDA       GPIO_I2C1_SDA_3      /* PB9  */
 
diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c
index e3a4263..eaccd51 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c
@@ -143,7 +143,8 @@ static void stm32_i2ctool(void)
  *   CONFIG_BOARD_LATE_INITIALIZE=y :
  *     Called from board_late_initialize().
  *
- *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y && CONFIG_NSH_ARCHINIT:
+ *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y
+ *     && CONFIG_NSH_ARCHINIT:
  *     Called from the NSH library
  *
  ****************************************************************************/
@@ -184,7 +185,6 @@ int stm32_bringup(void)
   if (ret < 0)
     {
       syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
-      return ret;
     }
 #endif
 
@@ -206,7 +206,8 @@ int stm32_bringup(void)
   ret = stm32_timer_driver_setup("/dev/timer0", 6);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: stm32_timer_driver_setup failed. TIM6: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: stm32_timer_driver_setup failed. TIM6: %d\n",
+             ret);
     }
 #endif
 
@@ -214,7 +215,8 @@ int stm32_bringup(void)
   ret = stm32_timer_driver_setup("/dev/timer1", 7);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: stm32_timer_driver_setup failed. TIM7: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: stm32_timer_driver_setup failed. TIM7: %d\n",
+             ret);
     }
 
 #endif
diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_buttons.c b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_buttons.c
index 15496b3..9b0ed65 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_buttons.c
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_buttons.c
@@ -98,21 +98,20 @@ uint32_t board_buttons(void)
  * Button support.
  *
  * Description:
- *   board_button_initialize() must be called to initialize button resources.  After
- *   that, board_buttons() may be called to collect the current state of all
- *   buttons or board_button_irq() may be called to register button interrupt
- *   handlers.
+ *   board_button_initialize() must be called to initialize button resources.
+ *   After that, board_buttons() may be called to collect the current state of
+ *   all buttons or board_button_irq() may be called to register button
+ *   interrupt handlers.
  *
- *   After board_button_initialize() has been called, board_buttons() may be called to
- *   collect the state of all buttons.  board_buttons() returns an 32-bit bit set
- *   with each bit associated with a button.  See the BUTTON_*_BIT
- *   definitions in board.h for the meaning of each bit.
+ *   After board_button_initialize() has been called, board_buttons() may be
+ *   called to collect the state of all buttons.  board_buttons() returns an
+ *   32-bit bit set with each bit associated with a button.  See the
+ *   BUTTON_*_BIT definitions in board.h for the meaning of each bit.
  *
- *   board_button_irq() may be called to register an interrupt handler that will
- *   be called when a button is depressed or released.  The ID value is a
- *   button enumeration value that uniquely identifies a button resource. See the
- *   BUTTON_* definitions in board.h for the meaning of enumeration
- *   value.
+ *   board_button_irq() may be called to register an interrupt handler that
+ *   will be called when a button is depressed or released.  The ID value is a
+ *   button enumeration value that uniquely identifies a button resource. See
+ *   the BUTTON_* definitions in board.h for the meaning of enumeration value.
  *
  ****************************************************************************/
 
@@ -123,7 +122,8 @@ int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
 
   if (id == BUTTON_USER)
     {
-      ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler, arg);
+      ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler,
+        arg);
     }
 
   return ret;
diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_timer.c b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_timer.c
index 2d16d7c..7ef4569 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_timer.c
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_timer.c
@@ -62,7 +62,8 @@
  *   Configure the timer driver.
  *
  * Input Parameters:
- *   devpath - The full path to the timer device.  This should be of the form /dev/timer0
+ *   devpath - The full path to the timer device.  This should be of the form
+ *             /dev/timer0
  *   timer   - The timer's number.
  *
  * Returned Value:


[incubator-nuttx] 01/02: boards/arm/stm32f0l0g0/nucleo-g070rb: Enable i2C

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch stage
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit dfaafc31d0a4e74fcb7b1987e9754f4e4394ef2d
Author: Guillherme Amaral <gv...@certi.org.br>
AuthorDate: Mon Dec 16 16:36:26 2019 -0300

    boards/arm/stm32f0l0g0/nucleo-g070rb: Enable i2C
---
 boards/arm/stm32f0l0g0/nucleo-g070rb/README.txt    |  1 +
 .../nucleo-g070rb/configs/nsh/defconfig            |  5 ++
 .../stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c  | 65 ++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/README.txt b/boards/arm/stm32f0l0g0/nucleo-g070rb/README.txt
index 73c0433..932a270 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/README.txt
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/README.txt
@@ -12,3 +12,4 @@ STATUS
   2019-10-04: Enable basic timer TIM6. Timer example working.
   2019-10-17: Add PWM support. PWM example working.
   2019-11-04: Add button driver and GPIO driver support. Buttons and GPIO examples working.
+  2019-12-20: Add i2C driver driver support and i2C tool.
diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/configs/nsh/defconfig b/boards/arm/stm32f0l0g0/nucleo-g070rb/configs/nsh/defconfig
index 2843665..da26cc3 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/configs/nsh/defconfig
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/configs/nsh/defconfig
@@ -34,6 +34,9 @@ CONFIG_EXAMPLES_GPIO=y
 CONFIG_EXAMPLES_HELLO=y
 CONFIG_EXAMPLES_PWM=y
 CONFIG_EXAMPLES_TIMER=y
+CONFIG_I2C=y
+CONFIG_I2CTOOL_MAXADDR=0xff
+CONFIG_I2CTOOL_MINADDR=0x00
 CONFIG_INPUT=y
 CONFIG_INTELHEX_BINARY=y
 CONFIG_MAX_TASKS=8
@@ -60,6 +63,7 @@ CONFIG_START_DAY=19
 CONFIG_START_MONTH=5
 CONFIG_START_YEAR=2013
 CONFIG_STDIO_DISABLE_BUFFERING=y
+CONFIG_STM32F0L0G0_I2C1=y
 CONFIG_STM32F0L0G0_PWM_MULTICHAN=y
 CONFIG_STM32F0L0G0_PWR=y
 CONFIG_STM32F0L0G0_TIM14=y
@@ -100,6 +104,7 @@ CONFIG_STM32F0L0G0_TIM3_CHANNEL4=y
 CONFIG_STM32F0L0G0_TIM3_PWM=y
 CONFIG_STM32F0L0G0_TIM6=y
 CONFIG_STM32F0L0G0_USART2=y
+CONFIG_SYSTEM_I2CTOOL=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c
index 53c640c..e3a4263 100644
--- a/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/src/stm32_bringup.c
@@ -3,6 +3,10 @@
  *
  *   Copyright (C) 2019 Gregory Nutt. All rights reserved.
  *   Author: Daniel Pereira Volpato <dp...@certi.org.br>
+ *           Guillherme da Silva Amaral <gv...@certi.org.br>
+ *
+ *   Based on: boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
+ *   Author: Gregory Nutt <gn...@nuttx.org>
  *
  *   Based on: boards/arm/stm32f0l0g0/nucleo-g071rb/src/stm32_bringup.c
  *   Author: Mateusz Szafoni <ra...@railab.me>
@@ -50,6 +54,7 @@
 #include <nuttx/leds/userled.h>
 
 #include "nucleo-g070rb.h"
+#include "stm32_i2c.h"
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -70,6 +75,62 @@
 #endif
 
 /****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_i2c_register
+ *
+ * Description:
+ *   Register one I2C drivers for the I2C tool.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
+static void stm32_i2c_register(int bus)
+{
+  struct i2c_master_s *i2c;
+  int ret;
+
+  i2c = stm32_i2cbus_initialize(bus);
+  if (i2c == NULL)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
+    }
+  else
+    {
+      ret = i2c_register(i2c, bus);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
+                 bus, ret);
+          stm32_i2cbus_uninitialize(i2c);
+        }
+    }
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_i2ctool
+ *
+ * Description:
+ *   Register I2C drivers for the I2C tool.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
+static void stm32_i2ctool(void)
+{
+#ifdef CONFIG_STM32F0L0G0_I2C1
+  stm32_i2c_register(1);
+#endif
+#ifdef CONFIG_STM32F0L0G0_I2C2
+  stm32_i2c_register(2);
+#endif
+}
+#endif
+
+/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -102,6 +163,10 @@ int stm32_bringup(void)
     }
 #endif
 
+#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
+  stm32_i2ctool();
+#endif
+
 #ifdef CONFIG_BUTTONS
   /* Register the BUTTON driver */