AnsweredAssumed Answered

Embedded wizard application in combination with HID device

Question asked by mail@jimfranssen.nl on Jul 29, 2020
Latest reply on Aug 4, 2020 by Myke Predko

Hallo,

 

I am using the NXP LPCXpresso54628. I have created a graphical interface in embedded wizard that runs on the LPCXpresso54628. Simultaneously I want the device to act as a USB HID device.

 

This is what I have done so far:

 

1) I have compiled the lpcxpresso54628_dev_hid_generic_bm example and got the USB HID device working on the USB FS connector. This is a BM project.

 

2) I compiled the Embedded wizard GUI and have the GUI program running on the LPCXpresso. This is also a BM project.

 

3) I merged all the source files from both projects into a new project.

 

4) When I run the following main program the HID device works in this merged project

 

int main( void )
{

/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
BOARD_InitPins();
BOARD_BootClockFROHF96M();
BOARD_InitDebugConsole();

POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB Phy */
CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
/* enable usb0 host clock */
CLOCK_EnableClock(kCLOCK_Usbhsl0);
/*According to reference mannual, device mode setting has to be set by access usb host register */
*((uint32_t *)(USBFSH_BASE + 0x5C)) |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
/* disable usb0 host clock */
CLOCK_DisableClock(kCLOCK_Usbhsl0);


USB_DeviceApplicationInit();

while (1U)
{

}

return 0;


}

 

5) When I run the following code the GUI program works in the merged project

 

int main( void )
{

/* initialize system */
EwBspSystemInit();

/* initialize Embedded Wizard application */
if ( EwInit() == 0 )
{
return 0;
}

/* process the Embedded Wizard main loop */
while( EwProcess())
{

}

/* de-initialize Embedded Wizard application */
EwDone();

/* terminate the system */
EwBspSystemDone();

return 0;


}

 

I want to have both programs running at the same time, so that I have a GUI on the screen and simultaneously have a USB HID device. When I merge the two main function both applications stop to work. A closer look into 

EwBspSystemInit(); which contains:

 

/*******************************************************************************
* FUNCTION:
* EwBspSystemInit
*
* DESCRIPTION:
* The function EwBspSystemInit initializes the system components.
* (CPU clock, memory, qspi, ...)
*
* ARGUMENTS:
* None
*
* RETURN VALUE:
* None
*
*******************************************************************************/
void EwBspSystemInit( void )
{
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);

/* attach 12 MHz clock to FLEXCOMM2 (I2C master for touch controller) */
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
CLOCK_EnableClock(kCLOCK_Gpio2);

BOARD_InitPins();

BOARD_BootClockPLL180M();

/* attach 12 MHz clock to SPI3 */
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM9);

BOARD_InitDebugConsole();
BOARD_InitSDRAM();

#if EW_USE_EXTERNAL_FLASH == 1
{
spifi_config_t config = {0};
uint32_t sourceClockFreq;

/* Set SPIFI clock source */
CLOCK_AttachClk(kMAIN_CLK_to_SPIFI_CLK);
sourceClockFreq = CLOCK_GetSpifiClkFreq();

/* Set the clock divider */
CLOCK_SetClkDiv(kCLOCK_DivSpifiClk, sourceClockFreq / EXAMPLE_SPI_BAUDRATE - 1U, false);

/* Initialize SPIFI */
SPIFI_GetDefaultConfig(&config);
SPIFI_Init(EXAMPLE_SPIFI, &config);

/* Reset to memory command mode */
SPIFI_ResetCommand(EXAMPLE_SPIFI);
SPIFI_SetMemoryCommand(EXAMPLE_SPIFI, &command[READ]);

 

}
#endif
}

 

shows that here the BOARD_BootClockPLL180M(); is loaded and in the USB HID program the BOARD_BootClockFROHF96M(); is loaded. How do I proceed in merging the two programs ?

 

Many thanks in advance,

 

Jim

Outcomes