Skip to content

Commit 0ada13f

Browse files
committed
chore(SPI): remove non arduino transfer api with 2 buffer
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 43ec3cb commit 0ada13f

File tree

4 files changed

+16
-55
lines changed

4 files changed

+16
-55
lines changed

libraries/SPI/src/SPI.cpp

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ void SPIClass::setClockDivider(uint8_t _divider)
165165
*/
166166
byte SPIClass::transfer(uint8_t data)
167167
{
168-
uint8_t rx_buffer = 0;
169-
spi_transfer(&_spi, &data, &rx_buffer, sizeof(uint8_t), SPI_TRANSFER_TIMEOUT, _spiSettings.noReceive);
170-
return rx_buffer;
168+
spi_transfer(&_spi, &data, sizeof(uint8_t), SPI_TRANSFER_TIMEOUT, _spiSettings.noReceive);
169+
return data;
171170
}
172171

173172
/**
@@ -178,22 +177,21 @@ byte SPIClass::transfer(uint8_t data)
178177
*/
179178
uint16_t SPIClass::transfer16(uint16_t data)
180179
{
181-
uint16_t rx_buffer = 0;
182180
uint16_t tmp;
183181

184182
if (_spiSettings.bOrder) {
185183
tmp = ((data & 0xff00) >> 8) | ((data & 0xff) << 8);
186184
data = tmp;
187185
}
188-
spi_transfer(&_spi, (uint8_t *)&data, (uint8_t *)&rx_buffer, sizeof(uint16_t),
186+
spi_transfer(&_spi, (uint8_t *)&data, sizeof(uint16_t),
189187
SPI_TRANSFER_TIMEOUT, _spiSettings.noReceive);
190188

191189
if (_spiSettings.bOrder) {
192-
tmp = ((rx_buffer & 0xff00) >> 8) | ((rx_buffer & 0xff) << 8);
193-
rx_buffer = tmp;
190+
tmp = ((data & 0xff00) >> 8) | ((data & 0xff) << 8);
191+
data = tmp;
194192
}
195193

196-
return rx_buffer;
194+
return data;
197195
}
198196

199197
/**
@@ -205,24 +203,8 @@ uint16_t SPIClass::transfer16(uint16_t data)
205203
*/
206204
void SPIClass::transfer(void *_buf, size_t _count)
207205
{
208-
if ((_count != 0) && (_buf != NULL)) {
209-
spi_transfer(&_spi, ((uint8_t *)_buf), ((uint8_t *)_buf), _count,
210-
SPI_TRANSFER_TIMEOUT, _spiSettings.noReceive);
211-
}
212-
}
213-
214-
/**
215-
* @brief Transfer several bytes. One buffer contains the data to send and
216-
* another one will contains the data received. begin() or
217-
* beginTransaction() must be called at least once before.
218-
* @param _bufout: pointer to the bytes to send.
219-
* @param _bufin: pointer to the bytes received.
220-
* @param _count: number of bytes to send/receive.
221-
*/
222-
void SPIClass::transfer(void *_bufout, void *_bufin, size_t _count)
223-
{
224-
if ((_count != 0) && (_bufout != NULL) && (_bufin != NULL)) {
225-
spi_transfer(&_spi, ((uint8_t *)_bufout), ((uint8_t *)_bufin), _count,
206+
if ((count != 0) && (buf != NULL)) {
207+
spi_transfer(&_spi, ((uint8_t *)buf), count,
226208
SPI_TRANSFER_TIMEOUT, _spiSettings.noReceive);
227209
}
228210
}
@@ -281,11 +263,6 @@ void SUBGHZSPIClass::transfer(void *_buf, size_t _count)
281263
SPIClass::transfer(_buf, _count);
282264
}
283265

284-
void SUBGHZSPIClass::transfer(void *_bufout, void *_bufin, size_t _count)
285-
{
286-
SPIClass::transfer(_bufout, _bufin, _count);
287-
}
288-
289266
void SUBGHZSPIClass::enableDebugPins(uint32_t mosi, uint32_t miso, uint32_t sclk, uint32_t ssel)
290267
{
291268
/* Configure SPI GPIO pins */

libraries/SPI/src/SPI.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ class SPIClass {
140140
virtual byte transfer(uint8_t _data);
141141
virtual uint16_t transfer16(uint16_t _data);
142142
virtual void transfer(void *_buf, size_t _count);
143-
virtual void transfer(void *_bufout, void *_bufin, size_t _count);
144143

145144
/* These methods are deprecated and kept for compatibility.
146145
* Use SPISettings with SPI.beginTransaction() to configure SPI parameters.
@@ -184,7 +183,6 @@ class SUBGHZSPIClass : public SPIClass {
184183
byte transfer(uint8_t _data);
185184
uint16_t transfer16(uint16_t _data);
186185
void transfer(void *_buf, size_t _count);
187-
void transfer(void *_bufout, void *_bufin, size_t _count);
188186
void enableDebugPins(uint32_t mosi = DEBUG_SUBGHZSPI_MOSI, uint32_t miso = DEBUG_SUBGHZSPI_MISO, uint32_t sclk = DEBUG_SUBGHZSPI_SCLK, uint32_t ssel = DEBUG_SUBGHZSPI_SS);
189187

190188
using SPIClass::beginTransaction;

libraries/SPI/src/utility/spi_com.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -496,38 +496,25 @@ void spi_deinit(spi_t *obj)
496496
#endif
497497
}
498498

499-
/**
500-
* @brief This function is implemented by user to send data over SPI interface
501-
* @param obj : pointer to spi_t structure
502-
* @param Data : data to be sent
503-
* @param len : length in bytes of the data to be sent
504-
* @param Timeout: Timeout duration in tick
505-
* @retval status of the send operation (0) in case of error
506-
*/
507-
spi_status_e spi_send(spi_t *obj, uint8_t *Data, uint16_t len, uint32_t Timeout)
508-
{
509-
return spi_transfer(obj, Data, Data, len, Timeout, 1 /* SPI_TRANSMITONLY */);
510-
}
511-
512499
/**
513500
* @brief This function is implemented by user to send/receive data over
514501
* SPI interface
515502
* @param obj : pointer to spi_t structure
516-
* @param tx_buffer : tx data to send before reception
517-
* @param rx_buffer : data to receive
503+
* @param buffer : tx data to send before reception
518504
* @param len : length in byte of the data to send and receive
519505
* @param Timeout: Timeout duration in tick
520506
* @param skipReceive: skip receiving data after transmit or not
521507
* @retval status of the send operation (0) in case of error
522508
*/
523-
spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer,
524-
uint16_t len, uint32_t Timeout, bool skipReceive)
509+
spi_status_e spi_transfer(spi_t *obj, uint8_t *buffer, uint16_t len,
510+
uint32_t Timeout, bool skipReceive)
525511
{
526512
spi_status_e ret = SPI_OK;
527513
uint32_t tickstart, size = len;
528514
SPI_TypeDef *_SPI = obj->handle.Instance;
515+
uint8_t *tx_buffer = buffer;
529516

530-
if ((obj == NULL) || (len == 0) || (Timeout == 0U)) {
517+
if ((len == 0) || (Timeout == 0U)) {
531518
return Timeout > 0U ? SPI_ERROR : SPI_TIMEOUT;
532519
}
533520
tickstart = HAL_GetTick();
@@ -553,7 +540,7 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer,
553540
#else
554541
while (!LL_SPI_IsActiveFlag_RXNE(_SPI));
555542
#endif
556-
*rx_buffer++ = LL_SPI_ReceiveData8(_SPI);
543+
*buffer++ = LL_SPI_ReceiveData8(_SPI);
557544
}
558545
if ((Timeout != HAL_MAX_DELAY) && (HAL_GetTick() - tickstart >= Timeout)) {
559546
ret = SPI_TIMEOUT;

libraries/SPI/src/utility/spi_com.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ typedef enum {
102102
/* Exported functions ------------------------------------------------------- */
103103
void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb);
104104
void spi_deinit(spi_t *obj);
105-
spi_status_e spi_send(spi_t *obj, uint8_t *Data, uint16_t len, uint32_t Timeout);
106-
spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer,
107-
uint8_t *rx_buffer, uint16_t len, uint32_t Timeout, bool skipReceive);
105+
spi_status_e spi_transfer(spi_t *obj, uint8_t *buffer, uint16_t len,
106+
uint32_t Timeout, bool skipReceive);
108107
uint32_t spi_getClkFreq(spi_t *obj);
109108

110109
#ifdef __cplusplus

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy