Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Hobbyking_Cheetah_Compact Hobbyking_Cheetah_Compact_DRV8323_14bit Hobbyking_Cheetah_Compact_DRV8323_V51_201907 HKC_MiniCheetah ... more
Fork of mbed-dev by
Diff: targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c
- Revision:
- 167:e84263d55307
- Parent:
- 165:e614a9f1c9e2
- Child:
- 169:e3b6fe271b81
diff -r c97ed07ec1a8 -r e84263d55307 targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c
--- a/targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c Thu Jun 08 15:02:37 2017 +0100
+++ b/targets/TARGET_NORDIC/TARGET_NRF5/spi_api.c Wed Jun 21 17:46:44 2017 +0100
@@ -141,11 +141,13 @@
if (p_event->type == NRF_DRV_SPI_EVENT_DONE) {
p_spi_info->flag.busy = false;
+#if DEVICE_SPI_ASYNCH
if (p_spi_info->handler) {
void (*handler)(void) = (void (*)(void))p_spi_info->handler;
p_spi_info->handler = 0;
handler();
}
+#endif
}
}
#define MASTER_EVENT_HANDLER(idx) \
@@ -485,6 +487,20 @@
return p_spi_info->rx_buf;
}
+int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length) {
+ int total = (tx_length > rx_length) ? tx_length : rx_length;
+
+ for (int i = 0; i < total; i++) {
+ char out = (i < tx_length) ? tx_buffer[i] : 0xff;
+ char in = spi_master_write(obj, out);
+ if (i < rx_length) {
+ rx_buffer[i] = in;
+ }
+ }
+
+ return total;
+}
+
int spi_slave_receive(spi_t *obj)
{
spi_info_t *p_spi_info = SPI_INFO(obj);
