summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2012-05-08 20:45:07 +0000
committerChristian Pointner <equinox@mur.at>2012-05-08 20:45:07 +0000
commitf4c1f296ae5ba31ede8a6fff6d1f7b9848d8e10d (patch)
tree42d10cc3bca1062a8e64e5bee8e6aa65c036b930 /software
parentgit-svn-id: https://svn.spreadspace.org/mur.sat@403 7de4ea59-55d0-425e-a1af-a... (diff)
added simple spi test
git-svn-id: https://svn.spreadspace.org/mur.sat@404 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/hhd70dongle/hhd70dongle.c3
-rw-r--r--software/hhd70dongle/spi.c27
2 files changed, 28 insertions, 2 deletions
diff --git a/software/hhd70dongle/hhd70dongle.c b/software/hhd70dongle/hhd70dongle.c
index 09205d1..3d72b57 100644
--- a/software/hhd70dongle/hhd70dongle.c
+++ b/software/hhd70dongle/hhd70dongle.c
@@ -46,5 +46,8 @@ int main(void)
for(;;) {
_delay_ms(250);
led_toggle();
+ char buf[10];
+ int len=sizeof(buf);
+ spi_read(0,buf,&len);
}
}
diff --git a/software/hhd70dongle/spi.c b/software/hhd70dongle/spi.c
index 0732716..0ffa1b9 100644
--- a/software/hhd70dongle/spi.c
+++ b/software/hhd70dongle/spi.c
@@ -29,19 +29,42 @@
* along with mur.sat. If not, see <http://www.gnu.org/licenses/>.
*
*/
+#include "avr/io.h"
+
#include "spi.h"
+#define SPI_DDR DDRB
+#define SPI_PORT PORTB
+#define SPI_PIN PINB
+#define CS 0
+#define SCK 1
+#define MOSI 2
+#define MISO 3
+#define GDO2 4
+#define GDO0 5
+#define RE 6
+#define TE 7
+
void spi_init(void)
{
-
+ SPI_PORT = 0;
+ SPI_DDR = (1<<MOSI)|(1<<SCK)|(1<<CS);
+ SPCR = (1<<SPE)|(1<<MSTR);
+// SPSR = (1<<SPI2X); (4MHz vs. 8MHz)
}
void spi_write(char address, char* data, int len)
{
-
}
void spi_read(char address, char* data, int* len)
{
+ PORTB |= (1<<CS);
+
+ while(SPI_PIN & (1<<MISO)); /* wait for CC1101 to get ready... */
+
+ SPDR = 0x80;
+ while(!(SPSR & (1<<SPIF)));
+ PORTB &= ~(1<<CS);
}