[Armadeus-commitlog] armadeus branch, master, updated. armadeus-5.3-521-g51412ca
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2014-12-17 18:20:27
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 51412cac06a55681b05be6ffa7ae2db930e0fb9d (commit)
via f53e7ff8f53288d8ee033b6bd3a7d411a38b5c45 (commit)
via d6129abfe6131515a3471af2f543644575eef64f (commit)
via b9b4ed3c8a8f314f9821d203e2f0d0f66db6c4e8 (commit)
via bdc1c6d0d65667a3e2b98fa3939b2b6ce71118c5 (commit)
from 73f1aed88f2493a1b0385364afa81fc5c2578cb0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 51412cac06a55681b05be6ffa7ae2db930e0fb9d
Author: Julien Boibessot <jul...@ar...>
Date: Wed Dec 17 19:08:57 2014 +0100
[AS_DEVICES] as_spi_msg: add comment to explain internals
commit f53e7ff8f53288d8ee033b6bd3a7d411a38b5c45
Author: Julien Boibessot <jul...@ar...>
Date: Wed Dec 17 19:05:02 2014 +0100
[AS_DEVICES] AsSpi: get rid of buggy error detection and remove cut'n pasted stuff
commit d6129abfe6131515a3471af2f543644575eef64f
Author: Julien Boibessot <jul...@ar...>
Date: Wed Dec 17 19:01:49 2014 +0100
[AS_DEVICES] AsSpi: public methods should be defined explicitly with recent GCC
commit b9b4ed3c8a8f314f9821d203e2f0d0f66db6c4e8
Author: Julien Boibessot <jul...@ar...>
Date: Wed Dec 17 18:26:51 2014 +0100
[AS_DEVICES] as_spi: print error on stderr when spidev device is not valid
commit bdc1c6d0d65667a3e2b98fa3939b2b6ce71118c5
Author: Julien Boibessot <jul...@ar...>
Date: Wed Dec 17 18:23:35 2014 +0100
[LINUX] APF9328: 2.6.29: Use PA4 (CSI_D0) as spidev CS (instead of PB18, conflicting with FPGA)
-----------------------------------------------------------------------
Summary of changes:
patches/linux/2.6.29/021-armadeus-apf9328.patch | 24 +++---
target/packages/as_devices/c/as_spi.c | 4 +-
target/packages/as_devices/cpp/as_spi.cpp | 113 ++++++-----------------
target/packages/as_devices/cpp/as_spi.hpp | 1 +
4 files changed, 45 insertions(+), 97 deletions(-)
diff --git a/patches/linux/2.6.29/021-armadeus-apf9328.patch b/patches/linux/2.6.29/021-armadeus-apf9328.patch
index 70aadd7..4cd17b9 100644
--- a/patches/linux/2.6.29/021-armadeus-apf9328.patch
+++ b/patches/linux/2.6.29/021-armadeus-apf9328.patch
@@ -4,7 +4,7 @@ DON'T EDIT IT OR YOUR MODIFICATIONS WILL BE LOST
Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29.6/arch/arm/mach-imx/apf9328.c 2011-06-15 12:16:40.000000000 +0200
++++ linux-2.6.29.6/arch/arm/mach-imx/apf9328.c 2014-12-17 18:10:02.048877453 +0100
@@ -0,0 +1,602 @@
+/*
+ * linux/arch/arm/mach-imx/apf9328.c
@@ -611,7 +611,7 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328.c
Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328_lcd_config.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29.6/arch/arm/mach-imx/apf9328_lcd_config.h 2011-06-15 11:57:47.000000000 +0200
++++ linux-2.6.29.6/arch/arm/mach-imx/apf9328_lcd_config.h 2014-12-17 18:10:02.048877453 +0100
@@ -0,0 +1,301 @@
+/*
+ *
@@ -917,7 +917,7 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328_lcd_config.h
Index: linux-2.6.29.6/arch/arm/mach-imx/include/mach/apf9328.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29.6/arch/arm/mach-imx/include/mach/apf9328.h 2011-06-15 14:09:58.000000000 +0200
++++ linux-2.6.29.6/arch/arm/mach-imx/include/mach/apf9328.h 2014-12-17 18:10:02.048877453 +0100
@@ -0,0 +1,59 @@
+/*
+ * linux/include/asm-arm/arch-imx/apf9328.h
@@ -981,7 +981,7 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/include/mach/apf9328.h
Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c 2011-06-15 11:57:47.000000000 +0200
++++ linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c 2014-12-17 18:19:49.904896128 +0100
@@ -0,0 +1,338 @@
+/*
+ * linux/arch/arm/mach-imx/apf9328-dev.c
@@ -1199,7 +1199,7 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c
+ * APF9328 CONFIG SPIDEV
+ */
+#ifdef CONFIG_SPI_SPIDEV
-+#define SPIDEV_CS_GPIOB 18
++#define SPIDEV_CS_GPIOA 4 /* CSI_D0 !! */
+
+static int spidev_init_gpio(void)
+{
@@ -1208,9 +1208,9 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c
+ imx_gpio_mode(PC16_PF_SPI1_MISO);
+ imx_gpio_mode(PC17_PF_SPI1_MOSI);
+
-+ /* PortB 18 is used as chip select (in GPIO mode) */
-+ DR(1) |= 1 << SPIDEV_CS_GPIOB; /* Initializes it High */
-+ imx_gpio_mode(GPIO_PORTB | SPIDEV_CS_GPIOB | GPIO_OUT | GPIO_GIUS | GPIO_DR);
++ /* PortA 4 (CSI_D0) is used as chip select (in GPIO mode) */
++ DR(0) |= 1 << SPIDEV_CS_GPIOA; /* Initializes it High */
++ imx_gpio_mode(GPIO_PORTA | SPIDEV_CS_GPIOA | GPIO_OUT | GPIO_GIUS | GPIO_DR);
+
+ return 0;
+}
@@ -1218,11 +1218,11 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c
+/* Chip select command for spidev */
+static void spidev_cs(u32 command)
+{
-+ /* PortB 18 is used as chip select */
++ /* PortA 4 (CSI_D0) is used as chip select */
+ if (command == SPI_CS_DEASSERT)
-+ DR(1) |= 1<< SPIDEV_CS_GPIOB;
++ DR(0) |= 1<< SPIDEV_CS_GPIOA;
+ else
-+ DR(1) &= ~(1<< SPIDEV_CS_GPIOB);
++ DR(0) &= ~(1<< SPIDEV_CS_GPIOA);
+}
+
+static struct spi_imx_chip spidev_hw = {
@@ -1268,7 +1268,7 @@ Index: linux-2.6.29.6/arch/arm/mach-imx/apf9328-dev.c
+ .max_speed_hz = 8000000, /* 8MHz */
+ .bus_num = 1, /* SPI1 */
+ .mode = SPI_MODE_0,
-+ .chip_select = 1,
++ .chip_select = 1,
+ .platform_data = &apf9328_spidev_config,
+},
+#endif /* CONFIG_SPI_SPIDEV */
diff --git a/target/packages/as_devices/c/as_spi.c b/target/packages/as_devices/c/as_spi.c
index 268a15c..b141ed2 100644
--- a/target/packages/as_devices/c/as_spi.c
+++ b/target/packages/as_devices/c/as_spi.c
@@ -48,7 +48,7 @@ int as_spi_open(const unsigned char *aSpidev_name)
fd = open((char *)aSpidev_name, O_RDWR);
if (fd < 0) {
- ERROR("spi open.");
+ fprintf(stderr, "%s: can't open %s\n", __func__, aSpidev_name);
return -1;
}
@@ -183,6 +183,8 @@ unsigned long long as_spi_msg(int aFd,
len = sizeof(buf) - 1;
}
+ /* This way of doing (bits -> bytes) allows greater flexibility
+ in SPI messages format (dixit Fabm) */
for (i = len; i > 0; i--) {
buf[i - 1] = msg & 0x01;
msg = msg >> 1;
diff --git a/target/packages/as_devices/cpp/as_spi.cpp b/target/packages/as_devices/cpp/as_spi.cpp
index 31404d8..1a31236 100644
--- a/target/packages/as_devices/cpp/as_spi.cpp
+++ b/target/packages/as_devices/cpp/as_spi.cpp
@@ -20,9 +20,17 @@
**
*/
-#include "as_spi.hpp"
#include <iostream>
+#include "as_spi.hpp"
+
+#define CHECK_INIT \
+ if (mFd <= 0)\
+ {\
+ std::cerr << "AsSpi class not instantianted successfully" << std::endl;\
+ return -1;\
+ }
+
AsSpi::AsSpi(const unsigned char *aSpidev_name)
{
mFd = as_spi_open(aSpidev_name);
@@ -30,129 +38,66 @@ AsSpi::AsSpi(const unsigned char *aSpidev_name)
AsSpi::~AsSpi()
{
- if (mFd != 0)
+ if (mFd > 0)
{
as_spi_close(mFd);
}
else
{
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
+ std::cerr << "AsSpi class not instantianted successfully" << std::endl;
}
}
int AsSpi::setLsb(unsigned char aLsb)
{
- if (mFd != 0)
- {
- return as_spi_set_lsb(mFd, aLsb);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_set_lsb(mFd, aLsb);
}
int AsSpi::getLsb() const
{
- if (mFd != 0)
- {
- return as_spi_get_lsb(mFd);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_get_lsb(mFd);
}
int AsSpi::setMode(unsigned char aMode)
{
- if (mFd != 0)
- {
- return as_spi_set_mode(mFd, aMode);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_set_mode(mFd, aMode);
}
int AsSpi::getMode() const
{
- if (mFd != 0)
- {
- return as_spi_get_mode(mFd);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_get_mode(mFd);
}
int AsSpi::setSpeed(unsigned char aSpeed)
{
- if (mFd != 0)
- {
- return as_spi_set_speed(mFd, aSpeed);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_set_speed(mFd, aSpeed);
}
int AsSpi::getSpeed() const
{
- if (mFd != 0)
- {
- return as_spi_get_speed(mFd);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_get_speed(mFd);
}
int AsSpi::getBitsPerWord() const
{
- if (mFd != 0)
- {
- return as_spi_get_bits_per_word(mFd);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_get_bits_per_word(mFd);
}
int AsSpi::setBitsPerWord(unsigned char aBits)
{
- if (mFd != 0)
- {
- return as_spi_set_bits_per_word(mFd, aBits);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_set_bits_per_word(mFd, aBits);
}
unsigned long long AsSpi::msg(unsigned long long aMsg, size_t aLen, unsigned long aSpeed)
{
- if (mFd != 0)
- {
- return as_spi_msg(mFd, aMsg, aLen, aSpeed);
- }
- else
- {
- std::cerr<<"AsSpi file descriptor not initialized"<<std::endl;
- return -1;
- }
+ CHECK_INIT
+ return as_spi_msg(mFd, aMsg, aLen, aSpeed);
}
diff --git a/target/packages/as_devices/cpp/as_spi.hpp b/target/packages/as_devices/cpp/as_spi.hpp
index ca53145..3014d64 100644
--- a/target/packages/as_devices/cpp/as_spi.hpp
+++ b/target/packages/as_devices/cpp/as_spi.hpp
@@ -40,6 +40,7 @@
*/
class AsSpi
{
+public:
/** @brief Constructor: Open a SPI bus.
*
* @param aSpidev_name path name
hooks/post-receive
--
armadeus
|