Change spi_write_byte to spi_byte

the SPI module reads and writes at the same time. If you don't want to
write a value, then write all zeros or whatever the device you are
communicating with wants.
This commit is contained in:
Byron Lathi
2022-03-10 12:14:07 -06:00
parent 236a75eef8
commit 35973473d3
3 changed files with 38 additions and 8 deletions

View File

@@ -1,10 +1,26 @@
#include <stdio.h>
#include <stdint.h>
#include <spi.h>
char retval;
int main(void)
{
printf("Starting spi_write_byte test...\n");
spi_write_byte(0xa5);
printf("Done!\n");
printf("Setting SPI location to 0x02\n");
*(uint8_t*)0x7ff0 = 2;
if (!(*(uint8_t*)0x7ff0 == 2)) {
printf("Expected 0x02 at 0x7ff0\n");
return 1;
}
printf("Done!\n\n");
printf("Starting spi_byte test...\n");
retval = spi_byte(0xa5);
if (retval != 0) {
printf("Expected 0 return value from spi_byte\n");
return 1;
}
printf("Done! %x\n", retval);
return 0;
}