[rtems commit] bsp/atsam: Align SPI API with PIO_Configure()
Sebastian Huber
sebh at rtems.org
Wed Dec 14 12:10:18 UTC 2016
Module: rtems
Branch: master
Commit: 1505eca59c8fbf0127debd955d443fe90d267abc
Changeset: http://git.rtems.org/rtems/commit/?id=1505eca59c8fbf0127debd955d443fe90d267abc
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Dec 14 07:18:11 2016 +0100
bsp/atsam: Align SPI API with PIO_Configure()
---
c/src/lib/libbsp/arm/atsam/include/atsam-spi.h | 4 +-
c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c | 12 +++---
c/src/lib/libbsp/arm/atsam/spi/atsam_spi_init.c | 55 ++++++++++++++++---------
3 files changed, 44 insertions(+), 27 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 968a947..e8fba58 100644
--- a/c/src/lib/libbsp/arm/atsam/include/atsam-spi.h
+++ b/c/src/lib/libbsp/arm/atsam/include/atsam-spi.h
@@ -51,8 +51,8 @@ int spi_bus_register_atsam(
const char *bus_path,
Spi *register_base,
rtems_vector_number irq,
- size_t pin_amount,
- const Pin *pins
+ 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 82feebd..00f5d33 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
@@ -495,11 +495,11 @@ static int atsam_spi_setup(spi_bus *base)
static void atsam_spi_init(
atsam_spi_bus *bus,
- size_t pin_amount,
- const Pin *pins
+ const Pin *pins,
+ size_t pin_count
)
{
- PIO_Configure(pins, pin_amount);
+ PIO_Configure(pins, pin_count);
ENABLE_PERIPHERAL(bus->board_id);
XDMAD_Initialize(&bus->Dma, 0);
bus->base.mode = 0;
@@ -516,8 +516,8 @@ int spi_bus_register_atsam(
const char *bus_path,
Spi *register_base,
rtems_vector_number irq,
- size_t pin_amount,
- const Pin *pins
+ const Pin *pins,
+ size_t pin_count
)
{
atsam_spi_bus *bus;
@@ -533,7 +533,7 @@ int spi_bus_register_atsam(
bus->board_id = board_id;
bus->irq = ID_XDMAC;
- atsam_spi_init(bus, pin_amount, pins);
+ atsam_spi_init(bus, pins, pin_count);
sc = rtems_interrupt_handler_install(
bus->irq,
diff --git a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_init.c b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_init.c
index fd8b64c..71e8658 100644
--- a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_init.c
+++ b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_init.c
@@ -55,29 +55,46 @@
int atsam_register_spi_0(void)
{
- static const Pin pins[] = {PIN_SPI0_MISO, PIN_SPI0_MOSI, PIN_SPI0_NPCS0,
- PIN_SPI0_NPCS1_1, PIN_SPI0_NPCS1_2, PIN_SPI0_NPCS2, PIN_SPI0_NPCS3,
- PIN_SPI0_CLOCK};
+ static const Pin pins[] = {
+ PIN_SPI0_MISO,
+ PIN_SPI0_MOSI,
+ PIN_SPI0_NPCS0,
+ PIN_SPI0_NPCS1_1,
+ PIN_SPI0_NPCS1_2,
+ PIN_SPI0_NPCS2,
+ PIN_SPI0_NPCS3,
+ PIN_SPI0_CLOCK
+ };
- return spi_bus_register_atsam(
- ATSAM_SPI_0_BUS_PATH,
- SPI0,
- ID_SPI0,
- 8,
- pins);
+ return spi_bus_register_atsam(
+ ATSAM_SPI_0_BUS_PATH,
+ SPI0,
+ ID_SPI0,
+ pins,
+ RTEMS_ARRAY_SIZE(pins)
+ );
}
int atsam_register_spi_1(void)
{
- static const Pin pins[] = {PIN_SPI1_MISO, PIN_SPI1_MOSI, PIN_SPI1_NPCS0,
- PIN_SPI1_NPCS1_1, PIN_SPI1_NPCS1_2, PIN_SPI1_NPCS2_1,
- PIN_SPI1_NPCS2_2, PIN_SPI1_NPCS3_1, PIN_SPI1_NPCS3_2,
- PIN_SPI1_CLOCK};
+ static const Pin pins[] = {
+ PIN_SPI1_MISO,
+ PIN_SPI1_MOSI,
+ PIN_SPI1_NPCS0,
+ PIN_SPI1_NPCS1_1,
+ PIN_SPI1_NPCS1_2,
+ PIN_SPI1_NPCS2_1,
+ PIN_SPI1_NPCS2_2,
+ PIN_SPI1_NPCS3_1,
+ PIN_SPI1_NPCS3_2,
+ PIN_SPI1_CLOCK
+ };
- return spi_bus_register_atsam(
- ATSAM_SPI_1_BUS_PATH,
- SPI1,
- ID_SPI1,
- 10,
- pins);
+ return spi_bus_register_atsam(
+ ATSAM_SPI_1_BUS_PATH,
+ SPI1,
+ ID_SPI1,
+ pins,
+ RTEMS_ARRAY_SIZE(pins)
+ );
}
More information about the vc
mailing list