//*****************************************************************************
//
// This is the generic callback from host stack.
//
// pvData is actually a pointer to a tEventInfo structure.
//
// This function will be called to inform the application when a USB event has
// occurred that is outside those related to the keyboard device.  At this
// point this is used to detect unsupported devices being inserted and removed.
// It is also used to inform the application when a power fault has occurred.
// This function is required when the g_USBGenericEventDriver is included in
// the host controller driver array that is passed in to the
// USBHCDRegisterDrivers() function.
//
//*****************************************************************************
void
USBHCDEvents(void *pvData)
{
    tEventInfo *pEventInfo;

    //
    // Cast this pointer to its actual type.
    //
    pEventInfo = (tEventInfo *)pvData;

    switch(pEventInfo->ui32Event)
    {
        case USB_EVENT_UNKNOWN_CONNECTED:
        case USB_EVENT_CONNECTED:
        {
            //
            // Save the device instance data.
            //
            g_sStatus.ui32Instance = pEventInfo->ui32Instance;
            g_sStatus.bConnected = true;

            //
            // Update the port status for the new device.
            //
            UIUpdateStatus();

            break;
        }
        //
        // A device has been unplugged.
        //
        case USB_EVENT_DISCONNECTED:
        {
            //
            // Device is no longer connected.
            //
            g_sStatus.bConnected = false;

            //
            // Update the port status for the new device.
            //
            UIUpdateStatus();

            break;
        }
        default:
        {
            break;
        }
    }
}
Exemplo n.º 2
0
//****************************************************************************
//
// Application calls this once to initialize the UI.
//
//****************************************************************************
void
UIInit(void)
{
    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&g_sContext, "usb-dev-chid");

    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);
    WidgetPaint((tWidget *)&g_sBackground);

    //
    // Initially not connected.
    //
    g_eState = UI_NOT_CONNECTED;

    //
    // Not initialized.
    //
    UIUpdateStatus(UI_STATUS_UPDATE);

}
Exemplo n.º 3
0
//*****************************************************************************
//
// Initialize the application interface.
//
//*****************************************************************************
void
UIInit(uint32_t ui32SysClock)
{
    //
    // Initialize the display driver.
    //
    Kentec320x240x16_SSD2119Init(ui32SysClock);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&g_sContext, "usb-host-mouse");

    //
    // Set the font for the application.
    //
    GrContextFontSet(&g_sContext, g_psFontFixed6x8);

    //
    // Default to device type not yet updated.
    //
    g_bTypeUpdated = false;

    //
    // Initial update of the screen.
    //
    UIUpdateStatus();
}
Exemplo n.º 4
0
//****************************************************************************
//
// Called by the mode toggle button in the g_sToggle variable.
//
//****************************************************************************
static void
ToggleMode(tWidget *psWidget)
{
    if(g_eState == UI_CONNECTED)
    {
        UIUpdateStatus(g_sUIState.ui32Indicators ^ UI_STATUS_KEYBOARD);
    }
}
Exemplo n.º 5
0
//*****************************************************************************
//
// Initialize the application interface.
//
//*****************************************************************************
void
UIInit(uint32_t ui32SysClock)
{
    //
    // Initialize the display driver.
    //
    Kentec320x240x16_SSD2119Init(ui32SysClock);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&g_sContext, "usb-host-keyboard");

    //
    // Set the font for the application.
    //
    GrContextFontSet(&g_sContext, g_psFontFixed6x8);

    //
    // Calculate the number of characters that will fit on a line.
    // Make sure to leave a small border for the text box.
    //
    g_ui32CharsPerLine = (GrContextDpyWidthGet(&g_sContext) - 16) /
                         GrFontMaxWidthGet(g_psFontFixed6x8);

    //
    // Calculate the number of lines per usable text screen.  This requires
    // taking off space for the top and bottom banners and adding a small bit
    // for a border.
    //
    g_ui32LinesPerScreen = (GrContextDpyHeightGet(&g_sContext) -
                            (2*(DISPLAY_BANNER_HEIGHT + 1)) -
                            BUTTON_HEIGHT) / GrFontHeightGet(g_psFontFixed6x8);

    //
    // Set up the text scrolling variables.
    //
    g_ui32CurrentLine = 0;
    g_ui32EntryLine = 0;

    //
    // Draw the initial prompt on the screen.
    //
    DrawPrompt();

    //
    // Initial update of the screen.
    //
    UIUpdateStatus();
}
Exemplo n.º 6
0
void
UIMode(tUIState eState)
{
    if(g_eState != UI_CONNECTED)
    {
        if(eState == UI_CONNECTED)
        {
            UIUpdateStatus(g_sUIState.ui32Indicators | UI_STATUS_UPDATE);
        }
    }
    else if(g_eState == UI_CONNECTED)
    {
        if(eState == UI_NOT_CONNECTED)
        {
            UIUpdateStatus(g_sUIState.ui32Indicators & ~UI_STATUS_UPDATE);
        }
    }

    g_eState = eState;
    UIUpdateStatus(g_sUIState.ui32Indicators);
}
//*****************************************************************************
//
// The main routine for handling the USB keyboard.
//
//*****************************************************************************
void
KeyboardMain(void)
{
    switch(g_iKeyboardState)
    {
        //
        // This state is entered when they keyboard is first detected.
        //
        case eStateKeyboardInit:
        {
            //
            // Initialized the newly connected keyboard.
            //
            USBHKeyboardInit(g_psKeyboard);

            //
            // Proceed to the keyboard connected state.
            //
            g_iKeyboardState = eStateKeyboardConnected;

            //
            // Set the current state of the modifiers.
            //
            USBHKeyboardModifierSet(g_psKeyboard, g_sStatus.ui32Modifiers);

            break;
        }
        case eStateKeyboardUpdate:
        {
            //
            // If the application detected a change that required an
            // update to be sent to the keyboard to change the modifier
            // state then call it and return to the connected state.
            //
            g_iKeyboardState = eStateKeyboardConnected;

            USBHKeyboardModifierSet(g_psKeyboard, g_sStatus.ui32Modifiers);

            //
            // Update the modifier status.
            //
            UIUpdateStatus();

            break;
        }
        case eStateKeyboardConnected:
        default:
        {
            break;
        }
    }
}