summaryrefslogtreecommitdiff
path: root/software/idm-test
diff options
context:
space:
mode:
Diffstat (limited to 'software/idm-test')
-rw-r--r--software/idm-test/Makefile10
-rw-r--r--software/idm-test/idm-test.c85
2 files changed, 58 insertions, 37 deletions
diff --git a/software/idm-test/Makefile b/software/idm-test/Makefile
index 25dc1ad..f4090a1 100644
--- a/software/idm-test/Makefile
+++ b/software/idm-test/Makefile
@@ -24,9 +24,11 @@ NAME := idm-test
BOARD_TYPE := teensy2
OBJ := $(NAME).o
LIBS := util led lufa-descriptor-usbserial
+
EXTERNAL_LIBS := lufa
+SPREADAVR_PATH := ../../contrib/avr-utils
-LUFA_PATH := ../../contrib/LUFA-120219
+LUFA_PATH := $(SPREADAVR_PATH)/contrib/lufa-LUFA-140928
LUFA_OPTS = -D USB_DEVICE_ONLY
LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
LUFA_OPTS += -D ORDERED_EP_CONFIG
@@ -36,9 +38,9 @@ LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT
-LUFA_OPTS += -D USB_MANUFACTURER="L\"mur.sat\"" -D USB_MANUFACTURER_LEN=7
-LUFA_OPTS += -D USB_PRODUCT="L\"idm-test\"" -D USB_PRODUCT_LEN=8
+LUFA_OPTS += -D USB_MANUFACTURER="L\"mur.sat\""
+LUFA_OPTS += -D USB_PRODUCT="L\"idm-test\""
LUFA_COMPONENTS := USB USBCLASS
-include ../avr.include.mk
+include $(SPREADAVR_PATH)/include.mk
diff --git a/software/idm-test/idm-test.c b/software/idm-test/idm-test.c
index 85e101f..033cf34 100644
--- a/software/idm-test/idm-test.c
+++ b/software/idm-test/idm-test.c
@@ -1,23 +1,33 @@
/*
- * spreadspace avr utils
*
+ * mur.sat
*
- * Copyright (C) 2012 Christian Pointner <equinox@spreadspace.org>
+ * Somewhen in the year 20xx, 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.
*
- * This file is part of spreadspace avr utils.
+ * Please visit the project hompage at sat.mur.at for further information.
*
- * spreadspace avr utils is free software: you can redistribute it and/or modify
+ *
+ * Copyright (C) 2013-2015 Christian Pointner <equinox@mur.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.
*
- * spreadspace avr utils is distributed in the hope that it will be useful,
+ * 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 spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+ * along with mur.sat. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
@@ -31,7 +41,7 @@
/*
LUFA Library
- Copyright (C) Dean Camera, 2012.
+ Copyright (C) Dean Camera, 2014.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
@@ -53,19 +63,25 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
{
.Config =
{
- .ControlInterfaceNumber = 0,
-
- .DataINEndpointNumber = CDC_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
- .DataINEndpointDoubleBank = false,
-
- .DataOUTEndpointNumber = CDC_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
- .DataOUTEndpointDoubleBank = false,
-
- .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
- .NotificationEndpointDoubleBank = false,
+ .ControlInterfaceNumber = INTERFACE_ID_CDC_CCI,
+ .DataINEndpoint =
+ {
+ .Address = CDC_TX_EPADDR,
+ .Size = CDC_TXRX_EPSIZE,
+ .Banks = 1,
+ },
+ .DataOUTEndpoint =
+ {
+ .Address = CDC_RX_EPADDR,
+ .Size = CDC_TXRX_EPSIZE,
+ .Banks = 1,
+ },
+ .NotificationEndpoint =
+ {
+ .Address = CDC_NOTIFICATION_EPADDR,
+ .Size = CDC_NOTIFICATION_EPSIZE,
+ .Banks = 1,
+ },
},
};
@@ -104,9 +120,7 @@ void SetupHardware(void)
led_init();
USB_Init();
- TCCR0B = (1 << CS02);
-
- SPI_Init(SPI_SPEED_FCPU_DIV_8 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST |
+ SPI_Init(SPI_SPEED_FCPU_DIV_8 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST |
SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING);
SPI_CS_DDR |= (1<<CS);
SPI_CS_PORT |= (1<<CS);
@@ -163,9 +177,9 @@ void IDM_ReadData(void)
_delay_us(70);
int_state = (INT_PIN & (1<<INT));
}
-
+
RingBuffer_Insert(&SPItoUSB_Buffer, 128);
-
+
_delay_us(30);
SPI_CS_PORT |= (1<<CS);
_delay_us(50);
@@ -197,14 +211,19 @@ int main(void)
IDM_ReadData();
uint16_t BufferCount = RingBuffer_GetCount(&SPItoUSB_Buffer);
- if ((TIFR0 & (1 << TOV0)) || (BufferCount > (uint8_t)(sizeof(SPItoUSB_Buffer_Data) * .75))) {
- TIFR0 |= (1 << TOV0);
- while (BufferCount--) {
- if(CDC_Device_SendByte(&VirtualSerial_CDC_Interface,
- RingBuffer_Peek(&SPItoUSB_Buffer)) != ENDPOINT_READYWAIT_NoError)
- break;
-
- RingBuffer_Remove(&SPItoUSB_Buffer);
+ if (BufferCount) {
+ Endpoint_SelectEndpoint(VirtualSerial_CDC_Interface.Config.DataINEndpoint.Address);
+ if (Endpoint_IsINReady()) {
+ uint8_t BytesToSend = MIN(BufferCount, (CDC_TXRX_EPSIZE - 1));
+
+ while (BytesToSend--) {
+ if (CDC_Device_SendByte(&VirtualSerial_CDC_Interface,
+ RingBuffer_Peek(&SPItoUSB_Buffer)) != ENDPOINT_READYWAIT_NoError) {
+ break;
+ }
+
+ RingBuffer_Remove(&SPItoUSB_Buffer);
+ }
}
}