michi-jung commented on code in PR #12186: URL: https://github.com/apache/nuttx/pull/12186#discussion_r1573316338
########## boards/arm/rp2040/common/src/rp2040_w5500.c: ########## @@ -0,0 +1,209 @@ +/**************************************************************************** + * boards/arm/rp2040/common/src/rp2040_w5500.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 <stdint.h> +#include <stdio.h> +#include <assert.h> +#include <debug.h> + +#include <nuttx/spi/spi.h> +#include <nuttx/net/w5500.h> + +#include "rp2040_spi.h" +#include "rp2040_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Sanity Check *************************************************************/ + +#if (CONFIG_RP2040_W5500_SPI_CH == 0) && !defined(CONFIG_RP2040_SPI0) +# error "W5500 configured to use SPI0, but SPI0 is not enabled" +#endif + +#if (CONFIG_RP2040_W5500_SPI_CH == 1) && !defined(CONFIG_RP2040_SPI1) +# error "W5500 configured to use SPI1, but SPI1 is not enabled" +#endif + +/* SPI Assumptions **********************************************************/ + +#define W5500_DEVNO 0 /* Only one W5500 */ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct rp2040_lower_s +{ + const struct w5500_lower_s lower; /* Low-level MCU interface */ + xcpt_t handler; /* W5500 interrupt handler */ + void *arg; /* Argument that accompanies IRQ */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int up_attach(const struct w5500_lower_s *lower, xcpt_t handler, + void *arg); +static void up_enable(const struct w5500_lower_s *lower, bool enable); +static void up_reset(const struct w5500_lower_s *lower, bool reset); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct rp2040_lower_s g_enclower = +{ + .lower = + { + .frequency = (CONFIG_RP2040_W5500_SPI_FREQ * 1000), + .spidevid = 0, + .mode = SPIDEV_MODE0, + .attach = up_attach, Review Comment: Good idea. Done. -- 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]
