comparison 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
comparison
equal deleted inserted replaced
7:9404b9869c27 8:58d76cf522ff
1 #include <stdint.h>
2 #include "spi.h"
3 #include "stm32f10x.h"
4
5 uint8_t
6 SPI_WriteByte(uint8_t out) {
7 uint8_t in = 0;
8
9 /* Wait until the transmit buffer is empty */
10 while (SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE) == RESET)
11 ;
12
13 /* Send the byte */
14 SPI_I2S_SendData(SPI1, out);
15
16 /* Wait until a data is received */
17 while (SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE) == RESET)
18 ;
19
20 /* Get the received data */
21 in = SPI_I2S_ReceiveData(SPI1);
22
23 /* Return the shifted data */
24 return (in);
25 }
26