Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


linguini1 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2852895106

   > Thank you @linguini1 :-) I have ordered this Xiao RP2040 board so I can 
help testing too :-)
   
   You could probably re-use this example on another RP2040 board just using a 
different LED if you want to avoid buying a new board!


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


cederom commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2852851358

   Thank you @linguini1 :-) I have ordered this Xiao RP2040 board so I can help 
testing too :-)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


linguini1 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2851975135

   @keever50 @cederom 
   
   I see that this change has already been merged, however I did take the time 
to write a test case that I tested on the XIAO RP2040 board I have on hand:
   
   ```c
   /
* boards/arm/rp2040/seeed-xiao-rp2040/src/rp2040_bringup.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 
   
   #include 
   #include 
   #include 
   
   #include 
   
   #include 
   
   #include "arm_internal.h"
   #include "chip.h"
   #include "rp2040_gpio.h"
   
   #include "rp2040_pico.h"
   
   #ifdef CONFIG_ARCH_BOARD_COMMON
   #include "rp2040_common_bringup.h"
   #endif /* CONFIG_ARCH_BOARD_COMMON */
   
   #ifdef CONFIG_USERLED
   #  include 
   #endif
   
   /
* Public Functions

/
   
   static int led_irq(int irq, FAR void *context, FAR void *arg)
   {
 static bool value = false;
 // int value = rp2040_gpio_get(29);
 rp2040_gpio_put(GPIO_LED1, value);
 rp2040_gpio_put(GPIO_LED2, value);
 rp2040_gpio_put(GPIO_LED3, value);
 rp2040_gpio_clear_interrupt(29, true, true);
 value = !value;
 return 0;
   }
   
   /
* Name: rp2040_bringup

/
   
   int rp2040_bringup(void)
   {
   #ifdef CONFIG_ARCH_BOARD_COMMON
   
 int ret = rp2040_common_bringup();
 if (ret < 0)
   {
 return ret;
   }
   
   #endif /* CONFIG_ARCH_BOARD_COMMON */
   
 /* --- Place any board specific bringup code here --- */
   
   #ifdef CONFIG_USERLED
 /* Register the LED driver */
   
 ret = userled_lower_initialize("/dev/userleds");
 if (ret < 0)
   {
 syslog(LOG_ERR, \
 "ERROR: userled_lower_initialize() failed: %d\n", ret);
   }
   #endif
   
 /* Configure interrupt that turns on/off LED */
   
 rp2040_gpio_init(GPIO_LED1);
 rp2040_gpio_init(GPIO_LED2);
 rp2040_gpio_init(GPIO_LED3);
 rp2040_gpio_setdir(GPIO_LED1, true);
 rp2040_gpio_setdir(GPIO_LED2, true);
 rp2040_gpio_setdir(GPIO_LED3, true);
 rp2040_gpio_put(GPIO_LED1, false);
 rp2040_gpio_put(GPIO_LED2, false);
 rp2040_gpio_put(GPIO_LED3, false);
   
 rp2040_gpio_init(29);
 rp2040_gpio_set_pulls(29, true, false); /* Pull-up */
 rp2040_gpio_disable_irq(29);
 rp2040_gpio_irq_attach(
 29, RP2040_GPIO_INTR_EDGE_LOW | RP2040_GPIO_INTR_EDGE_HIGH, led_irq,
 NULL);
 rp2040_gpio_enable_irq(29);
   
 return OK;
   }
   ```
   
   This is a modified version of the `rp2040_bringup.c` file for that board. I 
connected a button between GPIO29 (pin 3) and ground on the XIAO and pressed it 
to toggle the RGB led off and on. This code works for me and tests both rising 
and falling edges.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


xiaoxiang781216 merged PR #16281:
URL: https://github.com/apache/nuttx/pull/16281


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


linguini1 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2851381677

   > @linguini1 maybe we need more documentation on how to use the new 
functionality and/or the implementation update so its easier to use? I know 
@keever50 is mostly using the RP2040 so we should value and treat his feedback 
as representative in this matter :-)
   
   Sorry for the late response; had a busy week. Thank you for the testing 
@keever50, it's very much appreciated. @cederom, it appears that Kevin wasn't 
able to get interrupts working either with or without my changes, which might 
be just an issue with the test case. I wasn't able to spot anything wrong with 
his sample code but I plan on creating a sample for the interrupts so that it 
can be tested by others better.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


cederom commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2850979424

   Thank you @keever50 for your time and testing! @linguini1 maybe we need more 
documentation on how to use the new functionality and/or the implementation 
update so its easier to use? I know @keever50 is mostly using the RP2040 so we 
should value and treat  his feedback as representative in this matter :-)
   
   Anyone familiar with the RP2040 please share your feedback! :-)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-05 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2850739222

   @cederom I'm unable to make GPIO interrupts work on nuttx master and this 
PR. If we still want to test this, it might be good to have someone else test 
this.
   
   To be specific, I try to test this without the driver for userspace. I'm 
trying to attach interrupts on board initialization.
   This is required for some device drivers. But I am unable to get it to work 
even after trying examples.
   Maybe I'm missing something.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-02 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2847198409

   > > is it possible that the GPIO driver is a requirement and the RP2040 GPIO 
interrupts are depended on that? Because I dont get dependency warnings
   > 
   > No, the GPIO functions (rp2040_*) are not dependent on the gpio driver, 
that is just a wrapper for application code. Did you say you're also not able 
to set up interrupts on main?
   
   thats correct. On main I am unable to make it work. Are you able to make it 
work during board initialization?
   
   Because some device drivers require pin interrupts to be attached, which is 
done during board init, which is why I am doing it this way instead through an 
application.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-02 Thread via GitHub


linguini1 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2847171477

   > is it possible that the GPIO driver is a requirement and the RP2040 GPIO 
interrupts are depended on that? Because I dont get dependency warnings
   
   No, the GPIO functions (rp2040_*) are not dependent on the gpio driver, that 
is just a wrapper for application code. Did you say you're also not able to set 
up interrupts on main?


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-02 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2846851420

   is it possible that the GPIO driver is a requirement and the RP2040 GPIO 
interrupts are depended on that? Because I dont get dependency warnings


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-05-01 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2845653392

   @linguini1 I am not sure what i am doing wrong. It is also not working on 
master for me.
   I tried expanding my code, but this also does not work.
   I followed some button examples, which dont work for me.
   My debugger shows the interrupts are never triggered.
   
   I am however not using the GPIO driver. I want a "bare metal" approach, but 
I'm guessing something goes wrong there?
   Perhaps this looks similar to the Pico SDK, but behaves completely 
differently.
   
   ```C
   int custom_irq(int irq, FAR void *context, FAR void *arg)
   {
 syslog(LOG_DEBUG, "HELLO!");
 rp2040_gpio_put(BOARD_GPIO_LED_PIN, false);
 return 0;
   }
   
   void rp2040_boardearlyinitialize(void)
   {
 #ifdef CONFIG_ARCH_BOARD_COMMON
 rp2040_common_earlyinitialize();
 #endif
   
 /* --- Place any board specific early initialization here --- */
   
 /* Set board LED pin */
   
 rp2040_gpio_init(BOARD_GPIO_LED_PIN);
 rp2040_gpio_setdir(BOARD_GPIO_LED_PIN, true);
 rp2040_gpio_put(BOARD_GPIO_LED_PIN, true);
   
 /* Test interrupt */
   
 volatile int ret;
 rp2040_gpio_disable_irq(3);
 rp2040_gpio_init(3);
 rp2040_gpio_setdir(3, false);
 rp2040_gpio_set_pulls(3, 1, 0);
 ret = rp2040_gpio_irq_attach(3,
  RP2040_GPIO_INTR_EDGE_LOW,
  custom_irq,
  NULL);
 rp2040_gpio_enable_irq(3);
   
   
   }
   ```
   result:
   ret = 0
   function does not get triggered (also not the breakpoint).
   
   Are all the interrupts being reset after board initialization somewhere?
   
   I need help to figure this out
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-30 Thread via GitHub


linguini1 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2842016830

   > @linguini1 I'm not able to get this to trigger an interrupt. Is this code 
correct? Is it possible that you can give me a testing code / snippet to run 
that also worked for you? This way we can make sure nothing breaks.
   
   Sorry for the late response, here is the full snippet I used for enabling 
the interrupts; it was done as part of the standard RP2040 GPIO driver.
   
   ```c
   /* Attaching interrupts */
   
   static int gpint_attach(struct gpio_dev_s *dev,
   pin_interrupt_t callback)
   {
 struct rp2040gpint_dev_s *rp2040gpint =
   (struct rp2040gpint_dev_s *)dev;
 int irq = g_gpiointinputs[rp2040gpint->rp2040gpio.id];
 int ret;
   
 gpioinfo("Attaching the callback\n");
   
 /* Make sure the interrupt is disabled */
   
 rp2040_gpio_disable_irq(irq);
 ret = rp2040_gpio_irq_attach(irq,
  RP2040_GPIO_INTR_EDGE_LOW |
  RP2040_GPIO_INTR_EDGE_HIGH,
  rp2040gpio_interrupt,
  &g_gpint[rp2040gpint->rp2040gpio.id]);
 if (ret < 0)
   {
 syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret);
 return ret;
   }
   
 gpioinfo("Attach %p\n", callback);
 rp2040gpint->callback = callback;
 return OK;
   }
   
   /* Inside rp2040_dev_gpio_init() */
   
 for (i = 0; i < BOARD_NGPIOINT; i++)
   {
 /* Setup and register the GPIO pin */
   
 g_gpint[i].rp2040gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
 g_gpint[i].rp2040gpio.gpio.gp_ops = &gpint_ops;
 g_gpint[i].rp2040gpio.id  = i;
 gpio_pin_register(&g_gpint[i].rp2040gpio.gpio, g_gpiointinputs[i]);
   
 /* Configure the pins that will be used as interrupt input */
   
 rp2040_gpio_init(g_gpiointinputs[i]);
   
 /* pull-up = false : pull-down = true */
   
 rp2040_gpio_set_pulls(g_gpiointinputs[i], false, true);
   
 pincount++;
   }
   ```
   
   I tested using the `gpio` example which uses `sigwait`.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-29 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2840225926

   Okay gave it another shot, it was my USB port that decided it was tired 
today.
   I apologize for the removal of the previous message, it wasn't accurate 
anymore.
   
   @linguini1 
   I'm not able to get this to trigger an interrupt. Is this code correct?
   Is it possible that you can give me a testing code / snippet to run that 
also worked for you?
   This way we can make sure nothing breaks.
   
   ```C
   int rp2040gpio_interrupt(int irq, FAR void *context, FAR void *arg)
   {
 syslog(LOG_DEBUG, "HELLO!");
 rp2040_gpio_put(BOARD_GPIO_LED_PIN, false);
 return 0;
   }
   
   void rp2040_boardinitialize(void)
   {
 #ifdef CONFIG_ARCH_BOARD_COMMON
 rp2040_common_initialize();
 #endif
   
 /* --- Place any board specific initialization here --- */
   
 rp2040_gpio_init(2);
 rp2040_gpio_setdir(2, false);
 int ret = rp2040_gpio_irq_attach(2,
  RP2040_GPIO_INTR_EDGE_HIGH |
  RP2040_GPIO_INTR_EDGE_LOW,
  rp2040gpio_interrupt,
  NULL);
 rp2040_gpio_enable_irq(2);
   }
   ```
   
   I expected the LED to turn off and a message to appear after an interrupt on 
pin 2.
   This did not happen and it appears the ``rp2040gpio_interrupt`` is not 
triggered.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-29 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2839960570

   i have some delay trying to test the board. Just fried a raspberry pi pico 
after years. Its power supply gave up.
   Ill have to test this on an RP2040 on a different board today.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-29 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2839609284

   @linguini1 
   
   I tried to test the interrupts using this code that I quickly setup
   
![image](https://github.com/user-attachments/assets/0027c35f-f10a-4c0f-94c4-5cfb614d46b1)
   
   However, I'm getting weird behavior that might not be from your code 
directly.
   I have set rp2040_gpio_setdir to out:false, but when i am pulling down that 
pin, it shorts out the microcontroller.
   Which probably means the pin is driven HIGH on output enabled.
   
   Without this initialization, the interrupt does not trigger. So it probably 
requires it.
   
   Do you have any testing code that worked for you?


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-29 Thread via GitHub


keever50 commented on code in PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#discussion_r2065876471


##
arch/arm/src/rp2040/rp2040_gpio.h:
##
@@ -66,10 +66,10 @@
 
 /* GPIO interrupt modes */
 
-#define RP2040_GPIO_INTR_LEVEL_LOW  0
-#define RP2040_GPIO_INTR_LEVEL_HIGH 1
-#define RP2040_GPIO_INTR_EDGE_LOW   2
-#define RP2040_GPIO_INTR_EDGE_HIGH  3
+#define RP2040_GPIO_INTR_LEVEL_LOW  (0x1)

Review Comment:
   The preview shows only one line but meant to comment a little bit more down 
woops



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-29 Thread via GitHub


keever50 commented on code in PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#discussion_r2065869939


##
arch/arm/src/rp2040/rp2040_gpio.h:
##
@@ -66,10 +66,10 @@
 
 /* GPIO interrupt modes */
 
-#define RP2040_GPIO_INTR_LEVEL_LOW  0
-#define RP2040_GPIO_INTR_LEVEL_HIGH 1
-#define RP2040_GPIO_INTR_EDGE_LOW   2
-#define RP2040_GPIO_INTR_EDGE_HIGH  3
+#define RP2040_GPIO_INTR_LEVEL_LOW  (0x1)

Review Comment:
   Nice!
   I do have a suggestion. I believe it is common to use 1<<0, 1<<1, 1<<2... 
etc for bit **positions** instead hexadecimals. It is not going to matter that 
much here, but it does make accidentally making errors less common and it 
increases readability :thinking: But this is fine too
   
   Example:
   
![image](https://github.com/user-attachments/assets/341f5c98-76b5-4b33-8676-c925993405eb)
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-29 Thread via GitHub


keever50 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2837900490

   > @keever50 could you please review and test on your hw? :-)
   
   Yes! Later today :D


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-28 Thread via GitHub


cederom commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2837153842

   @keever50 could you please review and test on your hw? :-)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] RP2040: Allow simultaneous selection of multiple interrupt modes [nuttx]

2025-04-28 Thread via GitHub


nuttxpr commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2837093274

   [**\[Experimental Bot, please feedback 
here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
   
   
   
   Yes, this PR meets the NuttX requirements.  The summary clearly explains the 
change and its purpose.  The impact section adequately addresses the potential 
effects, including the important point of backward compatibility. The testing 
section provides sufficient detail on the test setup, procedure, and results, 
including relevant log output demonstrating the functionality.  The use of code 
examples to illustrate the change is also helpful.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]