diff options
Diffstat (limited to 'software/hhd70dongle/spi.c')
-rw-r--r-- | software/hhd70dongle/spi.c | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/software/hhd70dongle/spi.c b/software/hhd70dongle/spi.c deleted file mode 100644 index ec0397b..0000000 --- a/software/hhd70dongle/spi.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * mur.sat - * - * Somewhen in the year 2012, mur.at will have a nano satellite launched - * into a low earth orbit (310 km above the surface of our planet). The - * satellite itself is a TubeSat personal satellite kit, developed and - * launched by interorbital systems. mur.sat is a joint venture of mur.at, - * ESC im Labor and realraum. - * - * Please visit the project hompage at sat.mur.at for further information. - * - * - * Copyright (C) 2012 Bernhard Tittelbach <xro@realraum.at> - * - * This file is part of mur.sat. - * - * mur.sat is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * mur.sat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with mur.sat. If not, see <http://www.gnu.org/licenses/>. - * - */ -#include "avr/io.h" - -#include "spi.h" - -void spi_init(void) -{ - //configure Direction of SS / PB0 , MOSI and SCLK as Output to drive CS of CC1101 - SPI_PORT = (1<<CS); - SPI_DDR = (1<<MOSI)|(1<<SCK)|(1<<CS)|(1<<RE)|(1<<TE); - SPCR = (1<<SPE)|(1<<MSTR); // | (0<<DORD) //select MSB first: DORD == 0 - // SPSR = (0<<SPI2X) // f_osc/4 - // SPSR = (1<<SPI2X) // f_osc/2 - // SPSR = (1<<SPI2X); (4MHz vs. 8MHz) -} - -void spi_cs_enable(void) -{ - //pull low - SPI_PORT &= ~(1<<CS); -} - -void spi_cs_disable(void) -{ - //pull high - SPI_PORT |= (1<<CS); -} - -#include "usb_rawhid.h" -#include "util.h" - -void spi_c1101_wait_chip_rdy(void) -{ - //c1101 will set MISO to low if ready - while (SPI_PINB_REG & (1<<MISO)); - //~ unsigned int c; - //~ for (c=0; c < 0xFFFFFFFF && (SPI_PINB_REG & (1<<MISO)); c++); - //~ uint8_t debug_buff[6]; - //~ usb_rawhid_send((uint8_t*)"spi waited for:",255); - //~ debug_sprint_int16hex(debug_buff, c); - //~ usb_rawhid_send(debug_buff,255); -} - -void spi_write_byte(char byte) -{ - SPDR = byte; //Load byte to Data register - while(!(SPSR & (1<<SPIF))); // Wait for transmission complete -} - -char spi_exchange_byte(char byte) -{ - spi_write_byte(byte); - return SPDR; -} - -char spi_read_byte(void) -{ - //transmit something so SCLK runs for 8 bits, so that slave can transfer 1 byte - return spi_exchange_byte(0); -} - -void hhd70_pa_enable(void) -{ - SPI_PORT |= ~(1<<TE); -} - -void hhd70_pa_disable(void) -{ - SPI_PORT &= ~(1<<TE); -} - -void hhd70_lna_enable(void) -{ - SPI_PORT |= ~(1<<RE); -} - -void hhd70_lna_disable(void) -{ - SPI_PORT &= ~(1<<RE); -} - -int8_t hhd70_rx_data_available(void) -{ - return SPI_PINB_REG & (1 << GDO2); -}
\ No newline at end of file |