projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix demos based on the device mode HID class driver, as well as the driver itself...
[pub/USBasp.git]
/
Projects
/
Benito
/
Benito.c
diff --git
a/Projects/Benito/Benito.c
b/Projects/Benito/Benito.c
index
712016b
..
26c5664
100644
(file)
--- a/
Projects/Benito/Benito.c
+++ b/
Projects/Benito/Benito.c
@@
-45,6
+45,9
@@
volatile uint8_t TxPulseMSRemaining = 0;
/** Counter for the number of milliseconds remaining for the RX activity LED pulse being generated. */
\r
volatile uint8_t RxPulseMSRemaining = 0;
\r
\r
/** Counter for the number of milliseconds remaining for the RX activity LED pulse being generated. */
\r
volatile uint8_t RxPulseMSRemaining = 0;
\r
\r
+/** Counter for the number of milliseconds remaining for the enumeration LED ping-pong being generated. */
\r
+volatile uint8_t PingPongMSRemaining = 0;
\r
+
\r
/** LUFA CDC Class driver interface configuration and state information. This structure is
\r
* passed to all CDC Class driver functions, so that multiple instances of the same class
\r
* within a device can be differentiated from one another.
\r
/** LUFA CDC Class driver interface configuration and state information. This structure is
\r
* passed to all CDC Class driver functions, so that multiple instances of the same class
\r
* within a device can be differentiated from one another.
\r
@@
-64,11
+67,6
@@
USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
\r
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
\r
},
\r
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
\r
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
\r
},
\r
-
\r
- .State =
\r
- {
\r
- // Leave all state values to their defaults
\r
- }
\r
};
\r
\r
/** Main program entry point. This routine contains the overall program flow, including initial
\r
};
\r
\r
/** Main program entry point. This routine contains the overall program flow, including initial
\r
@@
-78,12
+76,10
@@
int main(void)
{
\r
SetupHardware();
\r
\r
{
\r
SetupHardware();
\r
\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
\r
-
\r
for (;;)
\r
{
\r
/* Echo bytes from the host to the target via the hardware USART */
\r
for (;;)
\r
{
\r
/* Echo bytes from the host to the target via the hardware USART */
\r
- if (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface))
\r
+ if (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface)
> 0
)
\r
{
\r
Serial_TxByte(CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface));
\r
\r
{
\r
Serial_TxByte(CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface));
\r
\r
@@
-103,13
+99,20
@@
int main(void)
/* Check if the millisecond timer has elapsed */
\r
if (TIFR0 & (1 << OCF0A))
\r
{
\r
/* Check if the millisecond timer has elapsed */
\r
if (TIFR0 & (1 << OCF0A))
\r
{
\r
+ /* Check if the LEDs should be ping-ponging (during enumeration) */
\r
+ if (PingPongMSRemaining && !(--PingPongMSRemaining))
\r
+ {
\r
+ LEDs_ToggleLEDs(LEDMASK_BUSY);
\r
+ PingPongMSRemaining = PING_PONG_LED_PULSE_MS;
\r
+ }
\r
+
\r
/* Check if the reset pulse period has elapsed, if so tristate the target reset line */
\r
if (ResetPulseMSRemaining && !(--ResetPulseMSRemaining))
\r
{
\r
/* Check if the reset pulse period has elapsed, if so tristate the target reset line */
\r
if (ResetPulseMSRemaining && !(--ResetPulseMSRemaining))
\r
{
\r
-
AVR_RESET_LINE_PORT &= ~AVR_RESET_LINE_MASK
;
\r
- AVR_RESET_LINE_DDR
&= ~AVR_RESET_LINE_MASK;
\r
+
LEDs_TurnOffLEDs(LEDMASK_BUSY)
;
\r
+ AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK;
\r
}
\r
}
\r
-
\r
+
\r
/* Turn off TX LED(s) once the TX pulse period has elapsed */
\r
if (TxPulseMSRemaining && !(--TxPulseMSRemaining))
\r
LEDs_TurnOffLEDs(LEDMASK_TX);
\r
/* Turn off TX LED(s) once the TX pulse period has elapsed */
\r
if (TxPulseMSRemaining && !(--TxPulseMSRemaining))
\r
LEDs_TurnOffLEDs(LEDMASK_TX);
\r
@@
-154,22
+157,25
@@
void SetupHardware(void)
/** Event handler for the library USB Connection event. */
\r
void EVENT_USB_Connect(void)
\r
{
\r
/** Event handler for the library USB Connection event. */
\r
void EVENT_USB_Connect(void)
\r
{
\r
- LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
\r
+ PingPongMSRemaining = PING_PONG_LED_PULSE_MS;
\r
+ LEDs_SetAllLEDs(LEDMASK_TX);
\r
}
\r
\r
/** Event handler for the library USB Disconnection event. */
\r
void EVENT_USB_Disconnect(void)
\r
{
\r
}
\r
\r
/** Event handler for the library USB Disconnection event. */
\r
void EVENT_USB_Disconnect(void)
\r
{
\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
\r
+ PingPongMSRemaining = 0;
\r
+ LEDs_TurnOffLEDs(LEDMASK_BUSY);
\r
}
\r
\r
/** Event handler for the library USB Configuration Changed event. */
\r
void EVENT_USB_ConfigurationChanged(void)
\r
{
\r
}
\r
\r
/** Event handler for the library USB Configuration Changed event. */
\r
void EVENT_USB_ConfigurationChanged(void)
\r
{
\r
- LEDs_SetAllLEDs(LEDMASK_USB_READY);
\r
+ PingPongMSRemaining = 0;
\r
+ LEDs_TurnOffLEDs(LEDMASK_BUSY);
\r
\r
if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface)))
\r
\r
if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface)))
\r
- LEDs_
SetAllLEDs(LEDMASK_USB
_ERROR);
\r
+ LEDs_
TurnOnLEDs(LEDMASK
_ERROR);
\r
}
\r
\r
/** Event handler for the library USB Unhandled Control Packet event. */
\r
}
\r
\r
/** Event handler for the library USB Unhandled Control Packet event. */
\r
@@
-212,7
+218,7
@@
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCI
break;
\r
}
\r
\r
break;
\r
}
\r
\r
- UCSR1A = (1 << U2X1);
\r
+ UCSR1A = (1 << U2X1);
\r
UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
\r
UCSR1C = ConfigMask;
\r
UBRR1 = SERIAL_2X_UBBRVAL((uint16_t)CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);
\r
UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
\r
UCSR1C = ConfigMask;
\r
UBRR1 = SERIAL_2X_UBBRVAL((uint16_t)CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);
\r
@@
-227,9
+233,9
@@
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const C
/* Check if the DTR line has been asserted - if so, start the target AVR's reset pulse */
\r
if (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR)
\r
{
\r
/* Check if the DTR line has been asserted - if so, start the target AVR's reset pulse */
\r
if (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR)
\r
{
\r
-
AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK
;
\r
- AVR_RESET_LINE_PORT &= ~AVR_RESET_LINE_MASK;
\r
-
\r
+
LEDs_TurnOnLEDs(LEDMASK_BUSY)
;
\r
+
\r
+ AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK;
\r
ResetPulseMSRemaining = AVR_RESET_PULSE_MS;
\r
}
\r
}
\r
ResetPulseMSRemaining = AVR_RESET_PULSE_MS;
\r
}
\r
}
\r