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 <nuttx/config.h>
   
   #include <debug.h>
   #include <stddef.h>
   #include <unistd.h>
   
   #include <nuttx/fs/fs.h>
   
   #include <arch/board/board.h>
   
   #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 <nuttx/leds/userled.h>
   #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: commits-unsubscr...@nuttx.apache.org

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

Reply via email to