Example #1
0
/**
 * @brief Configures the board hardware and chip peripherals for the demo's functionality
 * @return Nothing
 */
static void SetupHardware(void)
{
	Board_Init();
	Board_Buttons_Init();
	Board_Joystick_Init();
	USB_Init(Mouse_HID_Interface.Config.PortNumber, USB_MODE_Device);
#if defined(USB_DEVICE_ROM_DRIVER)
	UsbdHid_Init();
#endif
}
Example #2
0
/* Configures the board hardware and chip peripherals for the demo's
   functionality */
static void SetupHardware(void)
{
	SystemCoreClockUpdate();
	Board_Init();
	Board_Buttons_Init();
	Board_Joystick_Init();
	USB_Init(Generic_HID_Interface.Config.PortNumber, USB_MODE_Device);
#if defined(USB_DEVICE_ROM_DRIVER)
	UsbdHid_Init();
#endif
}
Example #3
0
/* Set up and initialize all required blocks and functions related to the
   board hardware */
void Board_Init(void)
{
	/* Sets up DEBUG UART */
	DEBUGINIT();

	/* Initializes GPIO */
	Chip_GPIO_Init(LPC_GPIO_PORT);
	Board_GPIOs_Init();

	/* Initialize LEDs */
	Board_LED_Init();

	/* Initialize uarts */
	Board_UART_Init(LPC_USART0); //RS 485
	Board_UART_Init(LPC_USART3); // rs232

	/* Initialize buttons */
	Board_Buttons_Init();

	/* Initialize DAC */
	Board_DAC_Init();

	/* Initialize Timers */
	Board_TIMER_Init();

	/* Initialize ADCs */
	Board_ADC_Init();

	/* Initialize Keyboard disabled */
	Board_KEYBOARD_disable();

	/* Initilize EEPROM */
	Board_EEPROM_init();

	/* Initialize SPI pins */
	Board_SSP_Init();

	/* Initialize RTC module */
	//Board_RTC_Init();

	/* Initialize I2C0 module */
	Board_I2C_Master_Init();

	Chip_ENET_RMIIEnable(LPC_ETHERNET);
}
Example #4
0
/* HID mouse interface init routine */
ErrorCode_t Mouse_Init(USBD_HANDLE_T hUsb,
					   USB_INTERFACE_DESCRIPTOR *pIntfDesc,
					   uint32_t *mem_base,
					   uint32_t *mem_size)
{
	USBD_HID_INIT_PARAM_T hid_param;
	USB_HID_REPORT_T reports_data[1];
	ErrorCode_t ret = LPC_OK;

	/* Do a quick check of if the interface descriptor passed is the right one. */
	if ((pIntfDesc == 0) || (pIntfDesc->bInterfaceClass != USB_DEVICE_CLASS_HUMAN_INTERFACE)) {
		return ERR_FAILED;
	}

	/* init joystick control */
	Board_Buttons_Init();
	Board_Joystick_Init();

	/* Init HID params */
	memset((void *) &hid_param, 0, sizeof(USBD_HID_INIT_PARAM_T));
	hid_param.max_reports = 1;
	hid_param.mem_base = *mem_base;
	hid_param.mem_size = *mem_size;
	hid_param.intf_desc = (uint8_t *) pIntfDesc;
	/* user defined functions */
	hid_param.HID_GetReport = Mouse_GetReport;
	hid_param.HID_SetReport = Mouse_SetReport;
	hid_param.HID_EpIn_Hdlr  = Mouse_EpIN_Hdlr;
	/* Init reports_data */
	reports_data[0].len = Mouse_ReportDescSize;
	reports_data[0].idle_time = 0;
	reports_data[0].desc = (uint8_t *) &Mouse_ReportDescriptor[0];
	hid_param.report_data  = reports_data;

	ret = USBD_API->hid->init(hUsb, &hid_param);

	/* update memory variables */
	*mem_base = hid_param.mem_base;
	*mem_size = hid_param.mem_size;
	/* store stack handle for later use. */
	g_mouse.hUsb = hUsb;
	g_mouse.tx_busy = 0;

	return ret;
}
Example #5
0
File: board.c Project: epernia/HVM
/* Set up and initialize all required blocks and functions related to the
   board hardware */
void Board_Init(void)
{
	/* Sets up DEBUG UART */
	DEBUGINIT();

	/* Initializes GPIO */
	Chip_GPIO_Init(LPC_GPIO_PORT);

	/* Setup GPIOs for USB demos */
	Chip_SCU_PinMuxSet(0x2, 6, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4));			/* P2_6 USB1_PWR_EN, USB1 VBus function */
	Chip_SCU_PinMuxSet(0x2, 5, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2));	/* P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION */
	Chip_SCU_PinMuxSet(0x1, 7, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4));			/* P1_7 USB0_PWR_EN, USB0 VBus function Xplorer */
	Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 6);							/* GPIO5[6] = USB1_PWR_EN */
	Chip_GPIO_SetPinState(LPC_GPIO_PORT, 5, 6, true);							/* GPIO5[6] output high */

	/* Initialize LEDs */
	Board_LED_Init();
	Board_Buttons_Init();
#if defined(USE_RMII)
	Chip_ENET_RMIIEnable(LPC_ETHERNET);
#else
	Chip_ENET_MIIEnable(LPC_ETHERNET);
#endif
}
int main(void) {
	uint8_t ret = 0;
    //int32_t loopback_ret;

#if defined (__USE_LPCOPEN)
#if !defined(NO_BOARD_LIB)
    // Read clock settings and update SystemCoreClock variable
    SystemCoreClockUpdate();
    // Set up and initialize all required blocks and
    // functions related to the board hardware
    Board_Init();
    // Set the LED to the state of "On"
    Board_LED_Set(0, true);
    //Board_LED_Set(1, true);
    //Board_LED_Set(2, true);
#endif
#endif

	SPI_Init();
	W5500_Init();
	Net_Conf(gWIZNETINFO);

#ifdef _MAIN_DEBUG_
	uint8_t tmpstr[6] = {0,};

	ctlwizchip(CW_GET_ID,(void*)tmpstr);
/*
    printf("\r\n=======================================\r\n");
	printf(" WIZnet %s EVB Demos v%d.%.2d\r\n", tmpstr, VER_H, VER_L);
	printf("=======================================\r\n");
	printf(">> W5500 based FTP Client Example\r\n");
	printf("=======================================\r\n");
*/
	Display_Net_Conf(); // Print out the network information to serial terminal
#endif

	/* Enable and setup SysTick Timer at a periodic rate */
	SysTick_Config(SystemCoreClock / TICKRATE_HZ1);

	/* Initialize buttons on the W5500 EVB board */
	Board_Buttons_Init();

	g_sdcard_done = 0;

#if defined(F_APP_FTPC)
	ftpc_init(gWIZNETINFO.ip);
#endif

	ret = flash_mount();
	if(ret > 0)
	{
		display_SDcard_Info(ret);
	}

	while(1) {
	   	/* Button: SW1 */
		if(Check_Buttons_Pressed() == BUTTONS_BUTTON1)
		{
			printf("\r\n########## SW1 was pressed.\r\n");
			printf("########## Data flash flag was cleared.\r\n");
			printf("########## Please reset a target.\r\n");
			release_factory_flag();
		}

#if defined(F_APP_FTPC)
		ftpc_run(gFTPBUF);
#endif

		/* Loopback Test: TCP Server and UDP */
		// Test for Ethernet data transfer validation
		{
			//loopback_tcps(SOCK_TCPS, gDATABUF, PORT_TCPS);
			//loopback_udps(SOCK_UDPS, gDATABUF, PORT_UDPS);
			//loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport);

			//if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code
		}
	}

    return 0 ;
}