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 2021/06/03 11:40:44 UTC

[GitHub] [incubator-nuttx] acassis commented on a change in pull request #3838: basic port to RV32M1 RI5CY

acassis commented on a change in pull request #3838:
URL: https://github.com/apache/incubator-nuttx/pull/3838#discussion_r644720157



##########
File path: boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.c
##########
@@ -0,0 +1,151 @@
+/****************************************************************************
+ * boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.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 <nuttx/board.h>
+#include <nuttx/arch.h>
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <errno.h>
+
+#include "rv32m1_gpio.h"
+#include "rv32m1.h"
+#include "rv32m1-vega.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const uint32_t g_buttons[] =
+{
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_FLOAT |GPIO_PORTA|GPIO_PIN0,  /* SW2 */
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN8,  /* SW3 */
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN9,  /* SW4 */
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN12, /* SW5 */
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_button_initialize
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+uint32_t board_button_initialize(void)
+{
+  size_t i ;
+  size_t nbtn = sizeof(g_buttons) / sizeof(g_buttons[0]);
+
+  for(i = 0; i < nbtn; ++i)
+    {
+      rv32m1_gpio_config(g_buttons[i]);
+    }
+
+  return nbtn;
+}
+
+/****************************************************************************
+ * Name: board_buttons
+ *
+ * Description:
+ *   After board_button_initialize() has been called, board_buttons() may be
+ *   called to collect the state of all buttons.  board_buttons() returns an
+ *   8-bit bit set with each bit associated with a button.  See the
+ *   BUTTON_*_BIT  definitions in board.h for the meaning of each bit.
+ *
+ ****************************************************************************/
+
+uint32_t board_buttons(void)
+{
+  uint8_t ret = 0;

Review comment:
       Should be "uint32_t ret = 0;"

##########
File path: arch/risc-v/src/rv32m1/hardware/rv32m1_gpio.h
##########
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * arch/risc-v/src/rv32m1/hardware/rv321m_gpio.h

Review comment:
       you missed the "1" here rv321m_gpio.h -> rv321m1_gpio.h

##########
File path: boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.c
##########
@@ -0,0 +1,151 @@
+/****************************************************************************
+ * boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.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 <nuttx/board.h>
+#include <nuttx/arch.h>
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <errno.h>
+
+#include "rv32m1_gpio.h"
+#include "rv32m1.h"
+#include "rv32m1-vega.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const uint32_t g_buttons[] =
+{
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_FLOAT |GPIO_PORTA|GPIO_PIN0,  /* SW2 */
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN8,  /* SW3 */
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN9,  /* SW4 */
+  GPIO_INPUT|GPIO_INT_EDGE|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN12, /* SW5 */

Review comment:
       Please define the buttons names and just put them here, please don't define it directly here inside the array.

##########
File path: arch/risc-v/include/rv32m1/rv32m1ri5cy_irq.h
##########
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * arch/risc-v/include/rv32m1/rv32m1ri5cy_irq.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_INCLUDE_RV32M1_RV32M1RI5CY_IRQ_H
+#define __ARCH_RISCV_INCLUDE_RV32M1_RV32M1RI5CY_IRQ_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Map RISC-V exception code to NuttX IRQ */
+
+/* IRQ 0-15 : (exception:interrupt=0) */
+
+#define RV32M1_IRQ_IAMISALIGNED  (0) /* Instruction Address Misaligned */
+#define RV32M1_IRQ_IAFAULT       (1) /* Instruction Address Fault */
+#define RV32M1_IRQ_IINSTRUCTION  (2) /* Illegal Instruction */
+#define RV32M1_IRQ_BPOINT        (3) /* Break Point */
+#define RV32M1_IRQ_LAMISALIGNED  (4) /* Load Address Misaligned */
+#define RV32M1_IRQ_LAFAULT       (5) /* Load Access Fault */
+#define RV32M1_IRQ_SAMISALIGNED  (6) /* Store/AMO Address Misaligned */
+#define RV32M1_IRQ_SAFAULT       (7) /* Store/AMO Access Fault */
+#define RV32M1_IRQ_ECALLU        (8) /* Environment Call from U-mode */
+                                    /* 9-10: Reserved */
+
+#define RV32M1_IRQ_ECALLM       (11) /* Environment Call from M-mode */
+                                    /* 12-15: Reserved */

Review comment:
       Why don't you use the definition from arch/risc-v/include/rv32im/mcause.h ? It seams to be standard for RISC-V




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org