Skip to content

Commit 689e0be

Browse files
committed
Extend SPI capabilities
Add setting if block transfer allows different sizes of rx/tx buffers.
1 parent f77f4ea commit 689e0be

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hal/mbed_compat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ MBED_WEAK void spi_get_capabilities(PinName ssel, bool slave, spi_capabilities_t
5555
cap->hw_cs_handle = false; // irrelevant in slave mode
5656
cap->slave_delay_between_symbols_ns = 2500; // 2.5 us
5757
cap->clk_modes = 0x0f; // all clock modes
58+
cap->tx_rx_buffers_equal_length = true; // rx buffer size must be equal tx buffer size
5859
#if DEVICE_SPI_ASYNCH
5960
cap->async_mode = true;
6061
#else
@@ -68,6 +69,7 @@ MBED_WEAK void spi_get_capabilities(PinName ssel, bool slave, spi_capabilities_t
6869
cap->hw_cs_handle = false; // to be determined later based on ssel
6970
cap->slave_delay_between_symbols_ns = 0; // irrelevant in master mode
7071
cap->clk_modes = 0x0f; // all clock modes
72+
cap->tx_rx_buffers_equal_length = true; // rx buffer size must be equal tx buffer size
7173
#if DEVICE_SPI_ASYNCH
7274
cap->async_mode = true;
7375
#else

hal/spi_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ typedef struct {
8484
bool support_slave_mode; /**< If true, the device can handle SPI slave mode using hardware management on the specified ssel pin. */
8585
bool hw_cs_handle; /**< If true, in SPI master mode Chip Select can be handled by hardware. */
8686
bool async_mode; /**< If true, in async mode is supported. */
87-
87+
bool tx_rx_buffers_equal_length; /**< If true, rx and tx buffers must have the same length. */
8888
} spi_capabilities_t;
8989

9090
#ifdef __cplusplus
@@ -96,11 +96,11 @@ extern "C" {
9696
*
9797
* # Defined behavior
9898
* * ::spi_init initializes the spi_t control structure
99-
* * ::spi_init configures the pins used by SPI
99+
* * ::spi_init configures the pins used by SPI - Verified by ::fpga_spi_test_init_free, ::fpga_spi_test_common_no_ss and ::fpga_spi_test_common
100100
* * ::spi_get_capabilities() fills the given `spi_capabilities_t` instance
101101
* * ::spi_get_capabilities() should consider the `ssel` pin when evaluation the `support_slave_mode` and `hw_cs_handle` capability
102102
* * ::spi_get_capabilities(): if the given `ssel` pin cannot be managed by hardware, `support_slave_mode` and `hw_cs_handle` should be false
103-
* * At least a symbol width of 8bit must be supported
103+
* * At least a symbol width of 8bit must be supported - Verified by ::fpga_spi_test_common_no_ss and ::fpga_spi_test_common
104104
* * The supported frequency range must include the range [0.2..2] MHz
105105
* * ::spi_free returns the pins owned by the SPI object to their reset state
106106
* * ::spi_format sets the number of bits per frame

0 commit comments

Comments
 (0)