forked from nfc-tools/libnfc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The driver seems to work well. I tested it on Linux with i.mx233-based board using hardware SPI. I tried to modify the build files as well, but it's probably a little messy. I'm not sure whether it will work on other *nix OSes, so it's probably better to limit the driver to Linux only using build system.
- Loading branch information
1 parent
a0ebd8b
commit d9fd915
Showing
9 changed files
with
1,141 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*- | ||
* Public platform independent Near Field Communication (NFC) library | ||
* | ||
* Copyright (C) 2013 Evgeny Boger | ||
* Copyright (C) 2009, 2010 Roel Verdult | ||
* Copyright (C) 2009, 2010 Romuald Conty | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
/** | ||
* @file spi.c | ||
* @brief SPI driver wrapper | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
# include "config.h" | ||
#endif // HAVE_CONFIG_H | ||
|
||
#include "spi.h" | ||
|
||
#include <nfc/nfc.h> | ||
#include "nfc-internal.h" | ||
|
||
// Test if we are dealing with unix operating systems | ||
#ifndef _WIN32 | ||
// The POSIX SPI port implementation | ||
# include "spi_posix.c" | ||
#else | ||
// The windows SPI port implementation | ||
# error "Not implemented" | ||
#endif /* _WIN32 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*- | ||
* Public platform independent Near Field Communication (NFC) library | ||
* | ||
* Copyright (C) 2013 Evgeny Boger | ||
* Copyright (C) 2009, 2010 Roel Verdult | ||
* Copyright (C) 2010, 2011 Romain Tarti?re | ||
* Copyright (C) 2009, 2010, 2011 Romuald Conty | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
/** | ||
* @file spi.h | ||
* @brief SPI driver header | ||
*/ | ||
|
||
#ifndef __NFC_BUS_SPI_H__ | ||
# define __NFC_BUS_SPI_H__ | ||
|
||
# include <sys/time.h> | ||
|
||
# include <stdio.h> | ||
# include <string.h> | ||
# include <stdlib.h> | ||
|
||
# include <linux/spi/spidev.h> | ||
|
||
# include <nfc/nfc-types.h> | ||
|
||
// Define shortcut to types to make code more readable | ||
typedef void *spi_port; | ||
# define INVALID_SPI_PORT (void*)(~1) | ||
# define CLAIMED_SPI_PORT (void*)(~2) | ||
|
||
spi_port spi_open(const char *pcPortName); | ||
void spi_close(const spi_port sp); | ||
|
||
void spi_set_speed(spi_port sp, const uint32_t uiPortSpeed); | ||
void spi_set_mode(spi_port sp, const uint32_t uiPortMode); | ||
uint32_t spi_get_speed(const spi_port sp); | ||
|
||
int spi_receive(spi_port sp, uint8_t *pbtRx, const size_t szRx, bool lsb_first); | ||
int spi_send(spi_port sp, const uint8_t *pbtTx, const size_t szTx, bool lsb_first); | ||
int spi_send_receive(spi_port sp, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, bool lsb_first); | ||
|
||
char **spi_list_ports(void); | ||
|
||
#endif // __NFC_BUS_SPI_H__ |
Oops, something went wrong.