[rtems commit] bsp/atsam: Hide details of SPI driver

Sebastian Huber sebh at rtems.org
Wed Dec 14 12:10:18 UTC 2016


Module:    rtems
Branch:    master
Commit:    3afa95bae047536165e99cb43232baf5cdaf49e4
Changeset: http://git.rtems.org/rtems/commit/?id=3afa95bae047536165e99cb43232baf5cdaf49e4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Dec 14 07:25:49 2016 +0100

bsp/atsam: Hide details of SPI driver

---

 c/src/lib/libbsp/arm/atsam/include/atsam-spi.h | 36 ++++----------------------
 c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c | 19 ++++++++++++++
 2 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/c/src/lib/libbsp/arm/atsam/include/atsam-spi.h b/c/src/lib/libbsp/arm/atsam/include/atsam-spi.h
index e8fba58..3d02c51 100644
--- a/c/src/lib/libbsp/arm/atsam/include/atsam-spi.h
+++ b/c/src/lib/libbsp/arm/atsam/include/atsam-spi.h
@@ -16,43 +16,17 @@
 #define LIBBSP_ARM_ATSAM_ATSAM_SPI_H
 
 #include <libchip/chip.h>
-#include <libchip/include/pio.h>
-
-#include <bsp.h>
-#include <dev/spi/spi.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#define DEFAULT_SPI0_CS 0
-#define DEFAULT_SPI_CLOCK 500000
-
-#define REGISTER_COMMAND_LENGTH 2
-
-typedef struct {
-	spi_bus base;
-	Spi *regs;
-	rtems_vector_number irq;
-	uint32_t board_id;
-	uint32_t msg_todo;
-	const spi_ioc_transfer *msgs;
-	rtems_id task_id;
-	sXdmad Dma;
-	Spid SpiDma;
-	uint32_t dma_tx_channel;
-	uint32_t dma_rx_channel;
-	bool rx_transfer_done;
-	bool tx_transfer_done;
-	bool chip_select_active;
-} atsam_spi_bus;
-
 int spi_bus_register_atsam(
-	const char *bus_path,
-	Spi *register_base,
-	rtems_vector_number irq,
-	const Pin *pins,
-	size_t pin_count
+  const char *bus_path,
+  Spi *register_base,
+  rtems_vector_number irq,
+  const Pin *pins,
+  size_t pin_count
 );
 
 #ifdef __cplusplus
diff --git a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
index 00f5d33..468e4ec 100644
--- a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
+++ b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
@@ -32,8 +32,27 @@
 
 #include <rtems/irq-extension.h>
 
+#include <dev/spi/spi.h>
+
 #define MAX_SPI_FREQUENCY 50000000
 
+typedef struct {
+  spi_bus base;
+  Spi *regs;
+  rtems_vector_number irq;
+  uint32_t board_id;
+  uint32_t msg_todo;
+  const spi_ioc_transfer *msgs;
+  rtems_id task_id;
+  sXdmad Dma;
+  Spid SpiDma;
+  uint32_t dma_tx_channel;
+  uint32_t dma_rx_channel;
+  bool rx_transfer_done;
+  bool tx_transfer_done;
+  bool chip_select_active;
+} atsam_spi_bus;
+
 static void atsam_interrupt_handler(void *arg)
 {
   atsam_spi_bus *bus = (atsam_spi_bus *)arg;




More information about the vc mailing list