Exemple #1
0
/*----------------------------------------------------------------------------
 Initialises the VCOM port.
 Call this function before using VCOM_putchar or VCOM_getchar
 *---------------------------------------------------------------------------*/
void VCOM_Init(void) {
#if PORT_NUM
  CDC_Init (1);
#else
  CDC_Init (0);
#endif
}
Exemple #2
0
void USB_Device_CDC()
{
        int  numBytesToRead, numBytesRead, numAvailByte;
        static char serBuf [USB_CDC_BUFSIZE];
        static unsigned char b[1];
        b[0] = 'h';
	#if PORT_NUM
        CDC_Init (1);
	#else
	  	CDC_Init (0);
	#endif

	  	Timer_Init();
	  	LED_Init();
        USB_Init();
        USB_Connect(TRUE);                        // USB Connect
        while (!USB_Configuration) ;              // wait until USB is configured

        uint8_t buffer[10];
        uint32_t idx, len;

        while(1)
        {
        	len = 0;
        	while(len == 0)
        	{
        		len = UARTReceive((LPC_UART_TypeDef *)LPC_UART0, buffer, sizeof(buffer));
        	}
        	idx = 0;
			while (idx < len)
			{
				UARTSend((LPC_UART_TypeDef *)LPC_UART0, &buffer[idx], 1);
				idx++;
			}
			USB_WriteEP (CDC_DEP_IN, buffer, len);

  /*              CDC_OutBufAvailChar (&numAvailByte);
                if (numAvailByte > 0)
                {
                	numBytesToRead = numAvailByte > 32 ? 32 : numAvailByte;
                    numBytesRead = CDC_RdOutBuf (&serBuf[0], &numBytesToRead);
                    USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead);
                }*/
          /*      else
                {
                	Timer_Delay(100);
                	USB_WriteEP (CDC_DEP_IN, b, 1);
                }*/
        }
}
Exemple #3
0
void systemInit() {
    cpuInit(); // Configure the CPU
    systickInit(CFG_SYSTICK_DELAY_IN_MS); // Start systick timer
    gpioInit(); // Enable GPIO
    pmuInit(); // Configure power management
    step_timer_init();

    // Initialise USB CDC
#ifdef CFG_USBCDC
    lastTick = systickGetTicks(); // Used to control output/printf timing
    CDC_Init(); // Initialise VCOM
    USB_Init(); // USB Initialization
    USB_Connect(TRUE); // USB Connect
    // Wait until USB is configured or timeout occurs
    uint32_t usbTimeout = 0;
    while (usbTimeout < CFG_USBCDC_INITTIMEOUT / 10) {
        if (USB_Configuration)
            break;
        systickDelay(10); // Wait 10ms
        usbTimeout++;
    }
#endif

    // Printf can now be used with UART or USBCDC

}
Exemple #4
0
void main_cdc(void)
{
    int dx = 0;
    //lastTick = systickGetTicks();   // Used to control output/printf timing
    
    lcdPrintln("Init USB"); lcdRefresh(); 
    
    CDC_Init();                     // Initialise VCOM
    USB_Init();                     // USB Initialization
    USB_Connect(TRUE);              // USB Connect
    // Wait until USB is configured or timeout occurs
    uint32_t usbTimeout = 0; 
        while ( usbTimeout < CFG_USBCDC_INITTIMEOUT / 10 )
    {
      if (USB_Configuration) break;
      delayms(10);             // Wait 10ms
      usbTimeout++;
    }
    lcdPrintln("Done"); lcdRefresh(); 
    
    uint8_t buf[2] = {0,0};
    int l;
    while(1){
        CDC_OutBufAvailChar(&l);
        if( l ){
            l = 1;
            CDC_RdOutBuf (buf, &l);
            puts(buf);
            dx=DoString(dx,0,buf);
            lcdDisplay();
        }
        //puts("hello world\r\n");
        //delayms(1);
    }
}
Exemple #5
0
void
slip_arch_init(unsigned long ubr)
{	
   
	(void)ubr;

#if (SLIP_COMM == SLIP_USB)
#if BRTOS_CPU == COLDFIRE_V1	
    (void)CDC_Init(); /* Initialize the USB CDC Application */
#elif  BRTOS_CPU == ARM_Cortex_M0 
	USB_Init();	
	(void)cdc_Init(); /* Initialize the USB CDC Application */
#endif
#endif

#if (SLIP_COMM == SLIP_UART)
#if BRTOS_CPU == COLDFIRE_V1
	// Passado tamanho 0 de fila para não gerar fila do sistema
	// Passado prioridade 0 para não criar mutex
	uart_init(UART_NUMBER, 115200, 0, 0);
#elif  BRTOS_CPU == ARM_Cortex_M0
	// Passado tamanho 0 de fila para não gerar fila do sistema
	Init_UART0(115200, 0);
#endif
#endif
}
Exemple #6
0
/**************************************************************************//**
 * @brief main - the entrypoint after reset.
 *****************************************************************************/
int main( void )
{
  BSP_Init(BSP_INIT_DEFAULT);   /* Initialize DK board register access */

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  CMU_ClockSelectSet( cmuClock_HF, cmuSelect_HFXO );
  CMU_OscillatorEnable(cmuOsc_LFXO, true, false);

  if ( !MSDDMEDIA_Init() )      /* Initialize the media layer of the MSD. */
  {
    EFM_ASSERT( false );
    for( ;; ){}
  }

  VUD_Init();                   /* Initialize the vendor unique device. */
  CDC_Init();                   /* Initialize the communication class device. */
  MSDD_Init(gpioPortE, 1);      /* Initialize the Mass Storage Device.  */

  USBD_Init(&initstruct);       /* Start USB. */

  /*
   * When using a debugger it is practical to uncomment the following three
   * lines to force host to re-enumerate the device.
   */
  /* USBD_Disconnect(); */
  /* USBTIMER_DelayMs( 1000 ); */
  /* USBD_Connect(); */

  for (;;)
  {
    MSDD_Handler();             /* Serve the MSD device. */
  }
}
Exemple #7
0
void usb_init(void)
{
      //printf("\n********** USB XCVR Module Testing **********\n");
      USB_REG_SET_ENABLE;
      CDC_Init();
      // Pull up enable
      FLAG_SET(USB_CONTROL_DPPULLUPNONOTG_SHIFT,USB0_CONTROL);
}
Exemple #8
0
void SerialCDC::setup(PinName tx, PinName rx, const char *name)
{
	_tx = tx;
	_rx = rx;
	_available = false;
	USBIOClkConfig();
	CDC_Init ();					// CDC Initialization
	USB_Init(); 					// USB Initialization
	USB_Connect(1);   				// USB Connect
	while (!USB_Configuration)
		continue;					// wait until USB is configured
}
Exemple #9
0
void Terminal_Task(void)
{
	/* task setup */
	(void) CDC_Init(); /* Initialize the USB CDC Application */

	usb_terminal_init(cdc_putch);
	
#if TERM_UART1
	#define UART1_BUFSIZE	128
	#if UART1_MUTEX	
		uart_init(1,9600,UART1_BUFSIZE,TERM1_PINS,TRUE,UART1_MUTEX_PRIO);
	#else
		uart_init(1,9600,UART1_BUFSIZE,TERM1_PINS,FALSE,0);
	#endif
#endif		
	
#if TERM_UART2
	#define UART2_BUFSIZE	128
	#if UART2_MUTEX		
		uart_init(2,9600,UART2_BUFSIZE,TERM2_PINS,TRUE,UART2_MUTEX_PRIO);
	#else
		uart_init(2,9600,UART2_BUFSIZE,TERM2_PINS,FALSE,0);
	#endif	

#endif	

	(void) usb_terminal_add_cmd((command_t*) &usb_ver_cmd);
	(void) usb_terminal_add_cmd((command_t*) &usb_top_cmd);
	(void) usb_terminal_add_cmd((command_t*) &usb_rst_cmd);
	(void) usb_terminal_add_cmd((command_t*) &usb_temp_cmd);
	(void) usb_terminal_add_cmd((command_t*) &setget_time_cmd);
	(void) usb_terminal_add_cmd((command_t*) &cat_cmd);
	(void) usb_terminal_add_cmd((command_t*) &ls_cmd);
	(void) usb_terminal_add_cmd((command_t*) &cd_cmd);
	(void) usb_terminal_add_cmd((command_t*) &mount_cmd);
	(void) usb_terminal_add_cmd((command_t*) &sr_cmd);
	(void) usb_terminal_add_cmd((command_t*) &rm_cmd);
	(void) usb_terminal_add_cmd((command_t*) &rn_cmd);
	(void) usb_terminal_add_cmd((command_t*) &cr_cmd);
	(void) usb_terminal_add_cmd((command_t*) &mkdir_cmd);
	(void) usb_terminal_add_cmd((command_t*) &cp_cmd);
	(void) usb_terminal_add_cmd((command_t*) &wt_cmd);
	(void) usb_terminal_add_cmd((command_t*) &echo_cmd);
	(void) usb_terminal_add_cmd((command_t*) &echo_stdout_cmd);
	(void) usb_terminal_add_cmd((command_t*) &esp_cmd);	

	while (1)
	{
		/* Call the application task */
		usb_terminal_process();
	}
}
Exemple #10
0
void
init_usbserial (void)
{
#ifdef  ENABLE_BLUETOOTH
    bluetooth_suppress = TRUE;
#endif /*ENABLE_BLUETOOTH */
    fifo_out_count = fifo_in_count = 0;
    CDC_DepInEmpty = TRUE;

    CDC_Init ();
    /* USB Initialization */
    USB_Init ();
    /* Connect to USB port */
    USB_Connect (TRUE);
}
Exemple #11
0
void init ()
{
	cpuInit ();
	systickInit (1);
	gpioInit ();
	pmuInit ();

	CDC_Init ();
	USB_Init ();
	USB_Connect (TRUE);

	gpioSetDir (3, 0, 1);
	gpioSetValue (3, 0, 1);
	while (!USB_Configuration) {
		systickDelay (10);
	}
	gpioSetValue (3, 0, 0); 
}
Exemple #12
0
void
init_usbserial (void)
{
  fifo_out_count = fifo_in_count = 0;
  CDC_DepInEmpty = TRUE;

  CDC_Init ();
  /* USB Initialization */
  USB_Init ();
  /* Connect to USB port */
  USB_Connect (TRUE);
  /* wait until USB is initialized */
  while (!USB_Configuration)
  {
      pmu_wait_ms (90);
      GPIOSetValue (LED_PORT, LED_BIT, LED_ON);
      pmu_wait_ms (10);
      GPIOSetValue (LED_PORT, LED_BIT, LED_OFF);
  }
}
void __usb_init_cdc()
{
	//BSP_Init(BSP_INIT_DEFAULT);   /* Initialize DK board register access */

	//CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);

	/* Initialize the communication class device. */
	CDC_Init();

	/* Initialize and start USB device stack. */
	USBD_Init(&usbInitStruct);

	/*
	* When using a debugger it is practical to uncomment the following three
	* lines to force host to re-enumerate the device.
	*/
	//USBD_Disconnect();
	//USBTIMER_DelayMs(1000);
	//USBD_Connect();
}
Exemple #14
0
int main(void)
{
	/* Enable CT32B1 Timer, IOCON, and USB */
	LPC_SYSCON->SYSAHBCLKCTRL |= (EN_CT32B1 | EN_USB_REG | EN_IOCON);

	/* Initialize GPIO */
	GPIOInit();
	/* Set LED port pin to output */
	GPIOSetDir(LED_PORT, LED_BIT, 1);
	GPIOSetValue(LED_PORT, LED_BIT, 0);

	/* CDC Initialization */
	CDC_Init();
	/* USB Initialization */
	USB_Init();
	/* Connect to USB port */
	USB_Connect(1);

	/* Update System Core Clock Value */
	SystemCoreClockUpdate();

	/* NVIC is installed inside UARTInit file. */
	UARTInit(115200, 0);

	/* the following text is printed on the serial port as vTasksRunning
	 * is not yet set to TRUE in serial_task - which will redirect
	 * debug output to the CDC ACM USB serial device.
	 */
	debug_printf("Hello World!\n");

	/* Create CDC ACM task */
	xTaskCreate(serial_task, (const signed char*) "Serial", TASK_SERIAL_STACK_SIZE, NULL, TASK_SERIAL_PRIORITY, NULL);

	/* Start the tasks running. */
	vTaskStartScheduler();

	return 0;
}
Exemple #15
0
/*----------------------------------------------------------------------------
 Initializes the VCOM port.
 Call this function before using VCOM_putchar or VCOM_getchar
 *---------------------------------------------------------------------------*/
void
VCOM_Init (void)
{

  CDC_Init ();
}
Exemple #16
0
void USB_ISR(void)
{

    if(FLAG_CHK(USB_ISTAT_USBRST_SHIFT,USB0_ISTAT))
    {
        // Clear Reset Flag
        //USB0_ISTAT = USB_ISTAT_USBRST_MASK;

        // Handle RESET Interrupt
        USB_Reset_Handler();

        // Clearing this bit allows the SIE to continue token processing
        //   and clear suspend condition
        //CTL_TXSUSPEND_TOKENBUSY = 0;
        //FLAG_CLR(USB_CTL_TXSUSPENDTOKENBUSY_SHIFT,USB0_CTL);
        // No need to process other interrupts
        return;
    }


    if(FLAG_CHK(USB_ISTAT_SOFTOK_SHIFT,USB0_ISTAT))
    {
        USB0_ISTAT = USB_ISTAT_SOFTOK_MASK;
    }



    if(FLAG_CHK(USB_ISTAT_STALL_SHIFT,USB0_ISTAT))
        //if(INT_STAT_STALL && INT_ENB_STALL_EN )
    {
        USB_Stall_Handler();
    }


    if(FLAG_CHK(USB_ISTAT_TOKDNE_SHIFT,USB0_ISTAT))
    {

        FLAG_SET(USB_CTL_ODDRST_SHIFT,USB0_CTL);
        USB_Handler();
        FLAG_SET(USB_ISTAT_TOKDNE_SHIFT,USB0_ISTAT);
    }


    if(FLAG_CHK(USB_ISTAT_SLEEP_SHIFT,USB0_ISTAT))
        //if(INT_STAT_SLEEP && INT_ENB_SLEEP_EN_MASK)
    {
        // Clear RESUME Interrupt if Pending
        //INT_STAT = INT_STAT_RESUME_MASK;
        //u8ISRCounter++;
        //FLAG_SET(USB_ISTAT_RESUME_SHIFT,USB0_ISTAT);

        // Clear SLEEP Interrupt
        FLAG_SET(USB_ISTAT_SLEEP_SHIFT,USB0_ISTAT);
        //INT_STAT = INT_STAT_SLEEP_MASK;
        //FLAG_SET(USB0_INTEN_RESUME_SHIFT,USB0_ISTAT);
        //INT_ENB_RESUME_EN = 1;

    }

    if(FLAG_CHK(USB_ISTAT_ERROR_SHIFT,USB0_ISTAT))
        //if(INT_STAT_ERROR && INT_ENB_ERROR_EN )
    {
        FLAG_CHK(USB_ISTAT_ERROR_SHIFT,USB0_ISTAT);
        printf("\nUSB Error\n");

        CDC_Init();
        //INT_STAT_ERROR=1;

    }
}
Exemple #17
0
void main_kerosin(void) {

	uint8_t enterCnt = 0;
	uint8_t buffer[64];
	
//	cpuInit();                                // Configure the CPU
	systickInit(CFG_SYSTICK_DELAY_IN_MS);     // Start systick timer
	gpioInit();                               // Enable GPIO
	pmuInit();                                // Configure power management
	adcInit();                                // Config adc pins to save power
	lcdInit();
		
    DoString(10,5,"USB plug");

	// Initialise USB CDC
#ifdef CFG_USBCDC
    DoString(10, 15, "USBCDC");
    lastTick = systickGetTicks();   // Used to control output/printf timing
    CDC_Init();                     // Initialise VCOM
    USB_Init();                     // USB Initialization
    USB_Connect(TRUE);              // USB Connect
    // Wait until USB is configured or timeout occurs
    uint32_t usbTimeout = 0; 
    while ( usbTimeout < CFG_USBCDC_INITTIMEOUT / 10 )
    {
		if (USB_Configuration) break;
		systickDelay(10);             // Wait 10ms
		usbTimeout++;
    }
#endif
	  // Printf can now be used with UART or USBCDC
	
	puts("Hello World");

	
	DoString(10, 25, "Enter:");
	lcdDisplay();

	
	int readData;
    while (1) {
				
		switch (getInput()) {
			case BTN_ENTER:
				enterCnt++;
				puts("ENTER\t");
				buffer[0] = '0' + enterCnt;
				buffer[1] = 0;
				puts(buffer);
				puts("\r\n");
				DoInt(50, 25, (int) (enterCnt));
				lcdDisplay();				
				break;
			case BTN_LEFT:
				readData = CDC_GetInputBuffer(buffer, sizeof(buffer));
				
				DoString(5, 40, buffer);
				DoString(1, 50, "Received: ");
				DoInt(57, 50, readData);
				lcdDisplay();
				break;
			default:
				break;
		}		
	}
}
void CDC_Engine(void)
{
    //uint16 u8RecData;
	
	/** re-init CDC class if a VBUS HIGH event was detected */
	if (FLAG_CHK(VBUS_HIGH_EVENT,gu8ISR_Flags))
	{
          FLAG_SET(USB_CTL_USBENSOFEN_MASK,USB0_CTL);
          u8CDCState = WAITING_FOR_ENUMERATION;
          enum_msg = TRUE;
          CDC_Init();
          FLAG_CLR(VBUS_HIGH_EVENT,gu8ISR_Flags);
	}

    /* control Stage */
    switch(u8CDCState)
    {
        case WAITING_FOR_ENUMERATION:
            /* Wait for USB Enumeration */
            while(gu8USB_State!=uENUMERATED)
            {
                (void)u8CDCState;
            };
            
            if (enum_msg)
            {
               printf ("\nUSB Enumerated, check your COM ports ");
               enum_msg = FALSE;
            }
      
            u8CDCState=0;
            break;

        case SET_LINE_CODING:
            if(FLAG_CHK(EP0,gu8USB_Flags))
            {
                FLAG_CLR(EP0,gu8USB_Flags);
                (void)EP_OUT_Transfer(EP0,(uint8*)&LineCoding);
                EP_IN_Transfer(EP0,0,0);       
                //vfnSCI1Init();
            }
            break;

        case SET_CONTROL_LINE_STATE:
            EP_IN_Transfer(EP0,0,0);       
            break;
       
    }

    /* Data stage */
/*
    if(FLAG_CHK(EP_OUT,gu8USB_Flags))
        {
            u8RecData=USB_EP_OUT_SizeCheck(EP_OUT);         // Check how many bytes from the PC
            usbEP_Reset(EP_OUT);
            usbSIE_CONTROL(EP_OUT);
            FLAG_CLR(EP_OUT,gu8USB_Flags);
            EP_IN_Transfer(EP2,CDC_OUTPointer,2);
            u8RecData=0;
        }
*/
}
// ---------------------------------------------------------------------------
HRESULT CPU_USB_Initialize(int core)
{
    if (core >= MAX_USB_CORE || USB_ENABLED(core)) return S_FALSE;

    USB_CONTROLLER_STATE *State = CPU_USB_GetState(core);
    const USB_ENDPOINT_DESCRIPTOR  *pEpDesc;
    const USB_INTERFACE_DESCRIPTOR *pIfDesc;
    int epNum, ret;
    UINT32 queueId = 0;

    GLOBAL_LOCK(irq);

    // Initialize physical layer
    if (!USB_ENABLED(1 - core))  // No other USB controllers enabled?
    {
        LPC_CGU->PLL[CGU_USB_PLL].PLL_CTRL &= ~1; // Enable USB PLL
        while (!(LPC_CGU->PLL[CGU_USB_PLL].PLL_STAT & 1)); // Wait for USB PLL to lock
    }
    LPC_CGU->BASE_CLK[USB_CLK[core]] &= ~1;  // Enable USBx base clock
    LPC_CREG->CREG0 &= ~(1 << 5); // Enable USB0 PHY
    if (core == 1) // Special init for USB1
    {
        // Enable USB1_DP and USB1_DN on chip FS phy
        LPC_SCU->SFSUSB = 0x12; // USB device mode (0x16 for host mode)
        LPC_USB1->PORTSC1_D |= (1 << 24);
    }

    // Set USB state
    USB_STATE(core) = State;
    USB_FLAGS(core) = 0;
    ep_out_count[core] = 0;
    ep_in_count[core] = 0;

    State->EndpointStatus = USB_EPSTATUS(core);
    State->EndpointCount = USB_MAX_EP_NUM;
    State->PacketSize = MAX_EP0_SIZE;

    // Initialize USB stack
    ret = USB_InitStack(core);
    if (ret != RET_OK) return S_FALSE; // Exit if not succesful

    // Set defaults for unused endpoints
    for (epNum = 1; epNum < State->EndpointCount; epNum++)
    {
        State->IsTxQueue[epNum] = FALSE;
        State->MaxPacketSize[epNum] = MAX_EP_SIZE;
    }

    // Get endpoint configuration
    while (USB_NextEndpoint(State, pEpDesc, pIfDesc))
    {
        // Figure out which endpoint we are initializing
        epNum = pEpDesc->bEndpointAddress & 0x7F;

        // Check interface and endpoint numbers against hardware capability
        if (epNum >= State->EndpointCount || pIfDesc->bInterfaceNumber > 3)
            return S_FALSE;

        if (pEpDesc->bEndpointAddress & 0x80) State->IsTxQueue[epNum] = TRUE;

        // Set the maximum size of the endpoint hardware FIFO
        int endpointSize = pEpDesc->wMaxPacketSize;
        // Exit if the endpoint maximum size in the configuration list is bogus
        // or greater than USB_MAX_DATA_PACKET_SIZE (default=64)
        if ((endpointSize != 8 && endpointSize != 16 && endpointSize != 32 && endpointSize != 64
                && endpointSize != 128 && endpointSize != 256 && endpointSize != 512)
				|| endpointSize > USB_MAX_DATA_PACKET_SIZE)
            return S_FALSE;
        State->MaxPacketSize[epNum] = endpointSize;

        // Assign queues
        QueueBuffers[queueId].Initialize();           // Clear queue before use
        State->Queues[epNum] = &QueueBuffers[queueId];  // Attach queue to endpoint
        queueId++;

        // Isochronous endpoints are currently not supported
        if ((pEpDesc->bmAttributes & 3) == USB_ENDPOINT_ATTRIBUTE_ISOCHRONOUS) return FALSE;
    }

    // Configure CDC driver
    ret = CDC_Init(core);
    if (ret != RET_OK) return S_FALSE; // Exit if not succesful

    // Connect and enable interrupts
    CPU_USB_ProtectPins(core, FALSE);
    CPU_INTC_ActivateInterrupt(USB_IRQ[core], USB_ISR[core], 0);
    USB_ENABLED(core) = TRUE;
    State->DeviceState = USB_DEVICE_STATE_CONFIGURED; // Config done by ROM stack
    USB_StateCallback(State);

    return S_OK;
}
Exemple #20
0
int main(void) {
	SystemCoreClockUpdate();

	// Read IAP before any interrupts are enabled
	UPER_PART_NUMBER		= IAP_GetPartNumber();
	UPER_BOOT_CODE_VERSION	= IAP_GetBootCodeVersion();
	IAP_GetSerialNumber(GUID);

	// Init the rest of the system
	Time_init();

	while (CDC_Init(&stream, GUID) != LPC_OK); // Load SFPPacketStream

	LPC_SYSCON->SYSAHBCLKCTRL |= BIT6 | BIT16 | BIT19; // Enable clock for GPIO, IOConfig and Pin Interrupts

#ifndef DEBUG
	// Disabled for debugging (JTAG)
	lpc_config_gpioInit();
#endif

	// PIO0_4 and PIO0_5 forced to I2C
	LPC_IOCON->PIO0_4 |= 1;	// I2C SCL
	LPC_IOCON->PIO0_5 |= 1;	// I2C SDA

	/* SFP initialization, configuration and launch */
	SFPServer *server = SFPServer_new(&stream);

	SFPServer_setDataTimeout(server, 30000); // 300k is about a second (30k ~100ms)

	/* GPIO/Pin functions */
	SFPServer_addFunctionHandler(server, UPER_FNAME_SETPRIMARY,	 UPER_FID_SETPRIMARY,	lpc_config_setPrimary);
	SFPServer_addFunctionHandler(server, UPER_FNAME_SETSECONDARY, UPER_FID_SETSECONDARY,	lpc_config_setSecondary);

	SFPServer_addFunctionHandler(server, UPER_FNAME_PINMODE,      UPER_FID_PINMODE,		lpc_pinMode);
	SFPServer_addFunctionHandler(server, UPER_FNAME_DIGITALWRITE, UPER_FID_DIGITALWRITE,	lpc_digitalWrite);
	SFPServer_addFunctionHandler(server, UPER_FNAME_DIGITALREAD,  UPER_FID_DIGITALREAD,	lpc_digitalRead);

	SFPServer_addFunctionHandler(server, UPER_FNAME_ATTACHINTERRUPT, UPER_FID_ATTACHINTERRUPT, lpc_attachInterrupt);
	SFPServer_addFunctionHandler(server, UPER_FNAME_DETACHINTERRUPT, UPER_FID_DETACHINTERRUPT, lpc_detachInterrupt);

	SFPServer_addFunctionHandler(server, UPER_FNAME_PULSEIN, UPER_FID_PULSEIN, lpc_pulseIn);

	/* ADC functions */
	SFPServer_addFunctionHandler(server, UPER_FNAME_ANALOGREAD, UPER_FID_ANALOGREAD, lpc_analogRead);

	/* SPI functions */
	SFPServer_addFunctionHandler(server, UPER_FNAME_SPI0BEGIN, UPER_FID_SPI0BEGIN, lpc_spi0_begin);
	SFPServer_addFunctionHandler(server, UPER_FNAME_SPI0TRANS, UPER_FID_SPI0TRANS, lpc_spi0_trans);
	SFPServer_addFunctionHandler(server, UPER_FNAME_SPI0END,   UPER_FID_SPI0END, lpc_spi0_end);

	SFPServer_addFunctionHandler(server, UPER_FNAME_SPI1BEGIN, UPER_FID_SPI1BEGIN, lpc_spi1_begin);
	SFPServer_addFunctionHandler(server, UPER_FNAME_SPI1TRANS, UPER_FID_SPI1TRANS, lpc_spi1_trans);
	SFPServer_addFunctionHandler(server, UPER_FNAME_SPI1END,   UPER_FID_SPI1END, lpc_spi1_end);

	/* I2C functions */
	SFPServer_addFunctionHandler(server, UPER_FNAME_I2CBEGIN, UPER_FID_I2CBEGIN, lpc_i2c_begin);
	SFPServer_addFunctionHandler(server, UPER_FNAME_I2CTRANS, UPER_FID_I2CTRANS, lpc_i2c_trans);
	SFPServer_addFunctionHandler(server, UPER_FNAME_I2CEND,   UPER_FID_I2CEND, lpc_i2c_end);

	/* PWM functions */
	SFPServer_addFunctionHandler(server, UPER_FNAME_PWM0BEGIN, UPER_FID_PWM0BEGIN, lpc_pwm0_begin);
	SFPServer_addFunctionHandler(server, UPER_FNAME_PWM0SET,   UPER_FID_PWM0SET, lpc_pwm0_set);
	SFPServer_addFunctionHandler(server, UPER_FNAME_PWM0END,   UPER_FID_PWM0END, lpc_pwm0_end);

	SFPServer_addFunctionHandler(server, UPER_FNAME_PWM1BEGIN, UPER_FID_PWM1BEGIN, lpc_pwm1_begin);
	SFPServer_addFunctionHandler(server, UPER_FNAME_PWM1SET,   UPER_FID_PWM1SET, lpc_pwm1_set);
	SFPServer_addFunctionHandler(server, UPER_FNAME_PWM1END,   UPER_FID_PWM1END, lpc_pwm1_end);


	/* Other functions */
	SFPServer_addFunctionHandler(server, UPER_FNAME_RESTART,       UPER_FID_RESTART, lpc_system_restart);
	SFPServer_addFunctionHandler(server, UPER_FNAME_GETDEVICEINFO,  UPER_FID_GETDEVICEINFO, lpc_system_getDeviceInfo);


	SFPServer_loop(server);

	SFPServer_delete(server);

	while (1);
}