From 4379bf266586bb723bc6eb668dd5d5bc7e9ff56f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 30 Jun 2015 05:25:51 +0200 Subject: upgraded to new lufa version of avr-utils --- software/idm-test/idm-test.c | 85 +++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 33 deletions(-) (limited to 'software/idm-test/idm-test.c') 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 + * 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 + * + * 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 . + * along with mur.sat. If not, see . + * */ @@ -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< (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); + } } } -- cgit v1.2.3