You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/28 21:58:47 UTC
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7458: Files for nucleo-h743zi2 and pysimCoder
pkarashchenko commented on code in PR #7458:
URL: https://github.com/apache/incubator-nuttx/pull/7458#discussion_r1008522420
##########
arch/arm/src/stm32h7/stm32_adc.c:
##########
@@ -1854,8 +1856,8 @@ static int adc_interrupt(struct adc_dev_s *dev, uint32_t adcisr)
value = adc_getreg(priv, STM32_ADC_DR_OFFSET);
value &= ADC_DR_MASK;
- awarn("WARNING: Analog Watchdog, Value (0x%03x) out of range!\n",
- value);
+ awarn("WARNING: Analog Watchdog, Value (0x%03" PRIx32 ") \
+ out of range!\n", value);
Review Comment:
```suggestion
awarn("WARNING: Analog Watchdog, Value (0x%03" PRIx32 ") "
"out of range!\n", value);
```
##########
boards/arm/stm32h7/nucleo-h743zi2/src/nucleo-h743zi2.h:
##########
@@ -101,6 +101,39 @@
GPIO_PUSHPULL|GPIO_PORTG|GPIO_PIN7)
#endif
+/* GPIO pins used by the GPIO Subsystem */
+
+#define BOARD_NGPIOIN 4 /* Amount of GPIO Input pins */
+#define BOARD_NGPIOOUT 8 /* Amount of GPIO Output pins */
+#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */
+
+/* Example, used free Ports on the board */
+
+#define GPIO_IN1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTE | GPIO_PIN7)
+#define GPIO_IN2 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTE | GPIO_PIN12)
+#define GPIO_IN3 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTE | GPIO_PIN14)
+#define GPIO_IN4 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTE | GPIO_PIN15)
+
+#define GPIO_OUT1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN4)
+#define GPIO_OUT2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN5)
+#define GPIO_OUT3 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN6)
+#define GPIO_OUT4 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTA| GPIO_PIN5)
+#define GPIO_OUT5 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTF | GPIO_PIN3)
+#define GPIO_INT1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTE | GPIO_PIN3)
+
+/* PWM */
+
+#if defined(CONFIG_STM32H7_TIM1_PWM)
+# define NUCLEOH743ZI2_PWMTIMER 1
+#else
+# define NUCLEOH743ZI2_PWMTIMER 3
Review Comment:
```suggestion
# define NUCLEOH743ZI2_PWMTIMER 1
#else
# define NUCLEOH743ZI2_PWMTIMER 3
```
##########
boards/arm/stm32h7/nucleo-h743zi2/src/nucleo-h743zi2.h:
##########
@@ -148,4 +205,20 @@ void weak_function stm32_usbinitialize(void);
int stm32_usbhost_initialize(void);
#endif
+/****************************************************************************
+ * Name: stm32_pwm_setup
+ *
+ * Description:
+ * Initialize PWM and register the PWM device.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_PWM
+int stm32_pwm_setup(void);
+#endif
+
+#ifdef CONFIG_SENSORS_QENCODER
+int stm32_qencoder_initialize(const char *devpath, int timer);
Review Comment:
Please add function description
##########
arch/arm/src/stm32h7/stm32_qencoder.c:
##########
@@ -987,7 +987,8 @@ static int stm32_shutdown(struct qe_lowerhalf_s *lower)
putreg32(regval, regaddr);
leave_critical_section(flags);
- sninfo("regaddr: %08x resetbit: %08x\n", regaddr, resetbit);
+ sninfo("regaddr: %08" PRIx32 " resetbit: %08" PRIx32 "\n", \
+ regaddr, resetbit);
Review Comment:
```suggestion
sninfo("regaddr: %08" PRIx32 " resetbit: %08" PRIx32 "\n",
regaddr, resetbit);
```
##########
arch/arm/src/stm32h7/stm32_adc.c:
##########
@@ -1478,17 +1478,19 @@ static int adc_setup(struct adc_dev_s *dev)
leave_critical_section(flags);
- ainfo("ISR: 0x%08x CR: 0x%08x CFGR: 0x%08x CFGR2: 0x%08x\n",
+ ainfo("ISR: 0x%08" PRIx32 " CR: 0x%08" PRIx32 " \
+ CFGR: 0x%08" PRIx32 " CFGR2: 0x%08" PRIx32 "\n",
adc_getreg(priv, STM32_ADC_ISR_OFFSET),
adc_getreg(priv, STM32_ADC_CR_OFFSET),
adc_getreg(priv, STM32_ADC_CFGR_OFFSET),
adc_getreg(priv, STM32_ADC_CFGR2_OFFSET));
- ainfo("SQR1: 0x%08x SQR2: 0x%08x SQR3: 0x%08x SQR4: 0x%08x\n",
+ ainfo("SQR1: 0x%08" PRIx32 " SQR2: 0x%08" PRIx32 " \
+ SQR3: 0x%08" PRIx32 " SQR4: 0x%08" PRIx32 "\n",
Review Comment:
```suggestion
ainfo("SQR1: 0x%08" PRIx32 " SQR2: 0x%08" PRIx32 " "
"SQR3: 0x%08" PRIx32 " SQR4: 0x%08" PRIx32 "\n",
```
##########
boards/arm/stm32h7/nucleo-h743zi2/src/stm32_pwm.c:
##########
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * boards/arm/stm32h7/nucleo-h743zi2/src/stm32_pwm.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/timers/pwm.h>
+#include <arch/board/board.h>
+
+#include "chip.h"
+#include "arm_internal.h"
+#include "stm32_pwm.h"
+#include "nucleo-h743zi2.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#define HAVE_PWM 1
+
+#ifndef CONFIG_PWM
+# undef HAVE_PWM
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_pwm_setup
+ *
+ * Description:
+ * Initialize PWM and register the PWM device.
+ *
+ ****************************************************************************/
+
+int stm32_pwm_setup(void)
+{
+#ifdef HAVE_PWM
+ static bool initialized = false;
+ struct pwm_lowerhalf_s *pwm;
+ int ret;
+
+ /* Have we already initialized? */
+
+ if (!initialized)
+ {
+ /* Get an instance of the PWM interface */
+
+ pwm = stm32_pwminitialize(NUCLEOH743ZI2_PWMTIMER);
+ if (!pwm)
Review Comment:
```suggestion
if (pwm == NULL)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org