I'm trying to use my AT90USB162 (Minimus USB board) as a CDC for sending a constant string to an hyperterminal connected to a comport. So I got the demo code Demos/Device/ClassDriver/VirtualSerial and made some changes:
In makefile:
MCU = at90usb162
BOARD = MINIMUS
F_CPU = 16000000
In VirtualSerial.h:
- Removed all entries related to Joystick.h, since AT90USB162 does not have it
- Created the header of functon SendSpecificString() (in exchange of the old CheckJoystickMovement(), which was related to the Joystick.h)
In VirtualSerial.c:
From SetupHardware(): removed call to Joystick_Init(), so the new code is (without comments).
void SetupHardware(void)
{
MCUSR &= ~(1 << WDRF);
wdt_disable();
clock_prescale_set(clock_div_1);
LEDs_Init();
USB_Init();
}
Removed the void CheckJoystickMovement(void) and created the void SendSpecificString(void), based on the first, but without the joystick stuffs:
void SendSpecificString(void)
{
char* ReportString = "data packet";
static bool ActionSent = false;
if ((ReportString != NULL) && (ActionSent == false))
{
ActionSent = true;
fputs(ReportString, &USBSerialStream);
}
}
And finally in main(): exchanged the CheckJoystickMovement() call to the void SendSpecificString() call.
int main(void)
{
SetupHardware();
CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
sei();
for (;;)
{
SendSpecificString();
CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
USB_USBTask();
}
}
So, code builds and I burn into AT90USB162 and enable it. The comport (#6 in my case) appears and I can connect to it from hyperterminal (I'm using HypoTerminal most of the times, but same result occurs with Microsoft Hyperterminal). When I connect to the comport, the terminal does not get stuck as expected, however I expected also that the string ReportString = "data packet" would appear continuously in hyperterminal, but actually nothing appears. Then, what would have I missed?
Thank you.
I just discovered that the problem was not with the fputs or the CDC_Device_SendString calls. The condition loop was not necessary, in this case is enough to make
That's it.