1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #17747 from leandrolanzieri/drivers/encx24j600/default_params

drivers/encx24j600: define default parameters
This commit is contained in:
benpicco 2022-03-05 10:29:48 +01:00 committed by GitHub
commit f31fdfd12d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 27 deletions

View File

@ -14887,3 +14887,7 @@ pkg/lvgl7/include/lvgl_riot_conf\.h:[0-9]+: warning: Member LV_TICK_CUSTOM \(mac
pkg/lvgl7/include/lvgl_riot_conf\.h:[0-9]+: warning: Member LV_TICK_CUSTOM_INCLUDE \(macro definition\) of file lvgl_riot_conf\.h is not documented\.
pkg/lvgl7/include/lvgl_riot_conf\.h:[0-9]+: warning: Member LV_TICK_CUSTOM_SYS_TIME_EXPR \(macro definition\) of file lvgl_riot_conf\.h is not documented\.
pkg/lvgl7/include/lvgl_riot_conf\.h:[0-9]+: warning: Member lv_coord_t \(typedef\) of file lvgl_riot_conf\.h is not documented\.
drivers/encx24j600/include/encx24j600_params\.h:[0-9]+: warning: Member ENCX24J600_PARAM_SPI \(macro definition\) of file encx24j600_params\.h is not documented\.
drivers/encx24j600/include/encx24j600_params\.h:[0-9]+: warning: Member ENCX24J600_PARAM_CS \(macro definition\) of file encx24j600_params\.h is not documented\.
drivers/encx24j600/include/encx24j600_params\.h:[0-9]+: warning: Member ENCX24J600_PARAM_INT \(macro definition\) of file encx24j600_params\.h is not documented\.
drivers/encx24j600/include/encx24j600_params\.h:[0-9]+: warning: Member ENCX24J600_PARAMS \(macro definition\) of file encx24j600_params\.h is not documented\.

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2022 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup drivers_encx24j600
* @{
*
* @file
* @brief Default configuration for the ENCX24J600 Ethernet driver
*
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
*/
#ifndef ENCX24J600_PARAMS_H
#define ENCX24J600_PARAMS_H
#include "encx24j600.h"
#include "board.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Set default configuration parameters for the ENCX24J600 driver
* @{
*/
#ifndef ENCX24J600_PARAM_SPI
#define ENCX24J600_PARAM_SPI (SPI_DEV(0))
#endif
#ifndef ENCX24J600_PARAM_CS
#define ENCX24J600_PARAM_CS (GPIO_PIN(0, 0))
#endif
#ifndef ENCX24J600_PARAM_INT
#define ENCX24J600_PARAM_INT (GPIO_PIN(0, 1))
#endif
#ifndef ENCX24J600_PARAMS
#define ENCX24J600_PARAMS { .spi = ENCX24J600_PARAM_SPI, \
.cs_pin = ENCX24J600_PARAM_CS, \
.int_pin = ENCX24J600_PARAM_INT }
#endif
/** @} */
/**
* @brief ENCX24J600 configuration
*/
static const encx24j600_params_t encx24j600_params[] = {
ENCX24J600_PARAMS
};
#ifdef __cplusplus
}
#endif
#endif /* ENCX24J600_PARAMS_H */
/** @} */

View File

@ -20,11 +20,9 @@
#include "log.h"
#include "debug.h"
#include "encx24j600.h"
#include "encx24j600_params.h"
#include "net/gnrc/netif/ethernet.h"
static encx24j600_t encx24j600;
static gnrc_netif_t _netif;
/**
* @brief Define stack parameters for the MAC layer thread
* @{
@ -34,25 +32,38 @@ static gnrc_netif_t _netif;
#define ENCX24J600_MAC_PRIO (GNRC_NETIF_PRIO)
#endif
/**
* @brief Find out how many of these devices are present
*/
#define ENCX24J600_NUM ARRAY_SIZE(encx24j600_params)
/**
* @brief Allocate device descriptors.
*/
static encx24j600_t encx24j600[ENCX24J600_NUM];
/**
* @brief Allocate GNRC interfaces.
*/
static gnrc_netif_t _netif[ENCX24J600_NUM];
/**
* @brief Stacks for the MAC layer threads
*/
static char _netdev_eth_stack[ENCX24J600_MAC_STACKSIZE];
static char _netdev_eth_stack[ENCX24J600_NUM][ENCX24J600_MAC_STACKSIZE];
void auto_init_encx24j600(void)
{
LOG_DEBUG("[auto_init_netif] initializing encx24j600 #0\n");
for (unsigned i = 0; i < ENCX24J600_NUM; i++) {
LOG_DEBUG("[auto_init_netif] initializing encx24j600 #%u\n", i);
/* setup netdev device */
encx24j600_params_t p;
p.spi = ENCX24J600_SPI;
p.cs_pin = ENCX24J600_CS;
p.int_pin = ENCX24J600_INT;
encx24j600_setup(&encx24j600, &p);
/* setup netdev device */
encx24j600_setup(&encx24j600[i], &encx24j600_params[i]);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(&_netif, _netdev_eth_stack, ENCX24J600_MAC_STACKSIZE,
ENCX24J600_MAC_PRIO, "encx24j600",
&encx24j600.netdev);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], ENCX24J600_MAC_STACKSIZE,
ENCX24J600_MAC_PRIO, "encx24j600",
&encx24j600[i].netdev);
}
}
/** @} */

View File

@ -15,20 +15,13 @@ ifneq (,$(filter nucleo-f334r8,$(BOARD)))
ENC_SPI ?= SPI_DEV\(0\)
ENC_CS ?= GPIO_PIN\(PORT_C,10\)
ENC_INT ?= GPIO_PIN\(PORT_D,2\)
# export SPI and pins
CFLAGS += -DENCX24J600_SPI=$(ENC_SPI)
CFLAGS += -DENCX24J600_CS=$(ENC_CS)
CFLAGS += -DENCX24J600_INT=$(ENC_INT)
endif
# fallback: set SPI bus and pins to default values
ENC_SPI ?= SPI_DEV\(0\)
ENC_CS ?= GPIO_PIN\(0,0\)
ENC_INT ?= GPIO_PIN\(0,1\)
# export SPI and pins
CFLAGS += -DENCX24J600_SPI=$(ENC_SPI)
CFLAGS += -DENCX24J600_CS=$(ENC_CS)
CFLAGS += -DENCX24J600_INT=$(ENC_INT)
# make sure we read the local encx24j600 params file
CFLAGS += -I$(CURDIR)
include $(RIOTBASE)/Makefile.include
# lower pktbuf size