Skip to content

Commit

Permalink
drivers/mfrc522: add new driver
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikVE committed Jan 20, 2022
1 parent 038b414 commit f599994
Show file tree
Hide file tree
Showing 8 changed files with 4,455 additions and 0 deletions.
856 changes: 856 additions & 0 deletions drivers/include/mfrc522.h

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions drivers/mfrc522/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2022 Freie Universität Berlin
#
# 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.
#

config MODULE_MFRC522
bool "MFRC522 RFID controller"
depends on HAS_PERIPH_GPIO
depends on HAS_PERIPH_SPI
depends on TEST_KCONFIG
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_SPI
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER_MSEC
help
Device driver for the NXP MFRC522 RFID controller
1 change: 1 addition & 0 deletions drivers/mfrc522/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBASE)/Makefile.base
5 changes: 5 additions & 0 deletions drivers/mfrc522/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FEATURES_REQUIRED += periph_gpio
FEATURES_REQUIRED += periph_spi

USEMODULE += ztimer_usec
USEMODULE += ztimer_msec
2 changes: 2 additions & 0 deletions drivers/mfrc522/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USEMODULE_INCLUDES_mfrc522 := $(LAST_MAKEFILEDIR)/include
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_mfrc522)
85 changes: 85 additions & 0 deletions drivers/mfrc522/include/mfrc522_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2021 Freie Universität Berlin
*
* 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_actuators
* @brief Default configuration for the MFRC522 controller
*
* @{
*
* @author Hendrik van Essen <hendrik.ve@fu-berlin.de>
* @file
*/
#ifndef MFRC522_PARAMS_H
#define MFRC522_PARAMS_H

#include <stdbool.h>

#include "periph/spi.h"

#include "mfrc522_regs.h"

#ifdef __cplusplus
extern "C"
{
#endif

/**
* @name Default configuration parameters for MFRC522 driver
* @{
*/
#ifndef MFRC522_PARAM_SPI_DEV
#define MFRC522_PARAM_SPI_DEV SPI_DEV(0) /**< Default SPI device */
#endif
#ifndef MFRC522_PARAM_SPI_CLK
#define MFRC522_PARAM_SPI_CLK SPI_CLK_5MHZ /**< Default SPI speed */
#endif
#ifndef MFRC522_PARAM_SCK_PIN
#define MFRC522_PARAM_SCK_PIN GPIO_PIN(0, 18) /**< Default SCK pin */
#endif
#ifndef MFRC522_PARAM_MISO_PIN
#define MFRC522_PARAM_MISO_PIN GPIO_PIN(0, 19) /**< Default MISO pin */
#endif
#ifndef MFRC522_PARAM_MOSI_PIN
#define MFRC522_PARAM_MOSI_PIN GPIO_PIN(0, 23) /**< Default MOSI pin */
#endif
#ifndef MFRC522_PARAM_CS_PIN
#define MFRC522_PARAM_CS_PIN GPIO_PIN(0, 5) /**< Default CS pin */
#endif
#ifndef MFRC522_PARAM_RST_PIN
#define MFRC522_PARAM_RST_PIN GPIO_PIN(0, 17) /**< Default RST pin */
#endif

#ifndef MFRC522_PARAMS
#define MFRC522_PARAMS \
{ \
.spi_dev = MFRC522_PARAM_SPI_DEV, \
.spi_clk = MFRC522_PARAM_SPI_CLK, \
.sck_pin = MFRC522_PARAM_SCK_PIN, \
.miso_pin = MFRC522_PARAM_MISO_PIN, \
.mosi_pin = MFRC522_PARAM_MOSI_PIN, \
.cs_pin = MFRC522_PARAM_CS_PIN, \
.rst_pin = MFRC522_PARAM_RST_PIN, \
} /**< Struct with default configuration parameters */
#endif /* MFRC522_PARAMS */
/**@}*/

/**
* @brief Allocate some memory to store the actual configuration
*/
static const mfrc522_params_t mfrc522_params[] =
{
MFRC522_PARAMS
};

#ifdef __cplusplus
}
#endif

#endif /* MFRC522_PARAMS_H */
/** @} */
Loading

0 comments on commit f599994

Please sign in to comment.