diff spi.c @ 8:58d76cf522ff

Split out code into separate files.
author Daniel O'Connor <darius@dons.net.au>
date Sat, 04 Feb 2012 13:29:31 +1030
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spi.c	Sat Feb 04 13:29:31 2012 +1030
@@ -0,0 +1,26 @@
+#include <stdint.h>
+#include "spi.h"
+#include "stm32f10x.h"
+
+uint8_t
+SPI_WriteByte(uint8_t out) {
+    uint8_t in = 0; 
+
+    /* Wait until the transmit buffer is empty */
+    while (SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE) == RESET)
+	;
+    
+    /* Send the byte  */
+    SPI_I2S_SendData(SPI1, out); 
+
+    /* Wait until a data is received */
+    while (SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) == RESET)
+	;
+    
+    /* Get the received data */
+    in = SPI_I2S_ReceiveData(SPI1); 
+
+    /* Return the shifted data */
+    return (in);
+}
+