Skip to content

Commit 300a35f

Browse files
authored
src/corelibs/spi: Added delay in master test case. (#73)
* src/corelibs/spi: Added delay in master test case. Signed-off-by: MDin <Dinesh.M-EE@infineon.com> * src/corelibs/spi: Review comments work. Signed-off-by: MDin <Dinesh.M-EE@infineon.com> * src/corelibs/spi: Review comments work. Signed-off-by: MDin <Dinesh.M-EE@infineon.com> --------- Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
1 parent a35be8f commit 300a35f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/corelibs/spi/test_spi_connected2_masterpingpong.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
// project includes
2020
#include <SPI.h>
21-
21+
#ifndef SPI_TRANSFER_DELAY
22+
#define SPI_TRANSFER_DELAY 500
23+
#else
2224
const uint8_t MAX_BUFFER_SIZE = 20;
2325
const uint8_t MAX_TEST_ITERATION = 10;
2426

@@ -77,14 +79,18 @@ TEST_IFX(spi_connected2_masterpingpong, test_ping_pong_transfer_byte) {
7779
digitalWrite(TEST_PIN_SYNC_IO, HIGH);
7880

7981
digitalWrite(TEST_PIN_SPI_SSEL, LOW);
82+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
8083
testReceiveByte = spi_master->transfer(testTransmitByte); // first byte received is dummy and ignored
84+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
8185
digitalWrite(TEST_PIN_SPI_SSEL, HIGH);
8286

8387
for (uint8_t i = 1; i < MAX_TEST_ITERATION; i++) {
8488
testTransmitByte++;
8589

8690
digitalWrite(TEST_PIN_SPI_SSEL, LOW);
91+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
8792
testReceiveByte = spi_master->transfer(testTransmitByte);
93+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
8894
digitalWrite(TEST_PIN_SPI_SSEL, HIGH);
8995

9096
TEST_ASSERT_EQUAL_UINT8_MESSAGE(expectedReceiveByte, testReceiveByte, "SPI Master PingPong transfer byte failed");
@@ -118,7 +124,9 @@ TEST_IFX(spi_connected2_masterpingpong, test_ping_pong_transfer_word) {
118124
digitalWrite(TEST_PIN_SYNC_IO, HIGH);
119125

120126
digitalWrite(TEST_PIN_SPI_SSEL, LOW);
127+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
121128
testReceiveWord = spi_master->transfer16(testTransmitWord); // first byte received is dummy and ignored
129+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
122130
digitalWrite(TEST_PIN_SPI_SSEL, HIGH);
123131

124132

@@ -127,7 +135,9 @@ TEST_IFX(spi_connected2_masterpingpong, test_ping_pong_transfer_word) {
127135
result = testReceiveWord << 8;
128136

129137
digitalWrite(TEST_PIN_SPI_SSEL, LOW);
138+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
130139
testReceiveWord = spi_master->transfer16(testTransmitWord);
140+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
131141
digitalWrite(TEST_PIN_SPI_SSEL, HIGH);
132142

133143
result = result | testReceiveWord >> 8; // combine the two bytes to form a 16-bit word
@@ -161,7 +171,9 @@ TEST_IFX(spi_connected2_masterpingpong, test_ping_pong_transfer_buffer) {
161171
digitalWrite(TEST_PIN_SYNC_IO, HIGH);
162172

163173
digitalWrite(TEST_PIN_SPI_SSEL, LOW);
174+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
164175
spi_master->transfer(testTransmitBuff, MAX_BUFFER_SIZE+1);
176+
delayMicroseconds(SPI_TRANSFER_DELAY_US);
165177
digitalWrite(TEST_PIN_SPI_SSEL, HIGH);
166178

167179
digitalWrite(TEST_PIN_SYNC_IO, LOW);

0 commit comments

Comments
 (0)